diff --git a/.classpath b/.classpath index 9a97ae24b..26c77551c 100644 --- a/.classpath +++ b/.classpath @@ -36,6 +36,7 @@ + diff --git a/build.xml b/build.xml index 673099616..dfc6a8e25 100644 --- a/build.xml +++ b/build.xml @@ -471,8 +471,15 @@ - + + + + + + + @@ -905,7 +912,7 @@ bundle-plugin-msnaccregwizz,bundle-plugin-sipaccregwizz, bundle-plugin-yahooaccregwizz,bundle-plugin-aimaccregwizz, bundle-commons-codec,bundle-httputil,bundle-plugin-spellcheck, - bundle-version,bundle-version-impl,bundle-shutdown-timeout, + bundle-version-impl,bundle-shutdown-timeout, bundle-growlnotification,bundle-swingnotification,bundle-galagonotification, bundle-sparkle, bundle-plugin-branding, bundle-systemactivitynotifications, @@ -935,7 +942,7 @@ bundle-provdisc,bundle-provdisc-dhcp,bundle-provdisc-mdns, bundle-provisioning,bundle-addrbook,bundle-plugin-ldap, bundle-plugin-contactsourceconfig,bundle-plugin-certconfig, - bundle-globalshortcut,bundle-plugin-msofficecomm"/> + bundle-globalshortcut,bundle-plugin-msofficecomm,bundle-libjitsi"/> @@ -1073,8 +1080,6 @@ destfile="${bundles.dest}/configuration.jar" manifest="${src}/net/java/sip/communicator/impl/configuration/configuration.manifest.mf" > - @@ -1120,24 +1125,33 @@ + + + + + + + + + + - - - - @@ -1700,16 +1714,6 @@ javax.swing.event, javax.swing.border"/> - - - - - - - - @@ -2666,8 +2670,6 @@ javax.swing.event, javax.swing.border"/> - diff --git a/lib/felix.client.run.properties b/lib/felix.client.run.properties index 8f63d7b9c..1dc204200 100644 --- a/lib/felix.client.run.properties +++ b/lib/felix.client.run.properties @@ -31,6 +31,9 @@ felix.auto.start.10= \ # file:lib/bundle/servicebinder.jar \ # file:lib/bundle/tablelayout.jar +felix.auto.start.15= \ + reference:file:sc-bundles/libjitsi.jar + felix.auto.start.20= \ reference:file:sc-bundles/util.jar \ reference:file:lib/bundle/log4j.jar \ @@ -69,7 +72,6 @@ felix.auto.start.42= \ felix.auto.start.45= \ reference:file:sc-bundles/ui-service.jar \ reference:file:sc-bundles/argdelegation-service.jar \ - reference:file:sc-bundles/version.jar \ reference:file:sc-bundles/version-impl.jar \ reference:file:sc-bundles/branding.jar \ reference:file:sc-bundles/provdisc-dhcp.jar \ diff --git a/lib/felix.unit.test.properties b/lib/felix.unit.test.properties index 0a454475d..2637869ae 100644 --- a/lib/felix.unit.test.properties +++ b/lib/felix.unit.test.properties @@ -51,6 +51,9 @@ felix.auto.start.10= \ # file:lib/bundle/bundlerepository.jar \ # file:lib/bundle/servicebinder.jar \ +felix.auto.start.15= \ + reference:file:sc-bundles/libjitsi.jar + felix.auto.start.20= \ reference:file:sc-bundles/util.jar \ reference:file:lib/bundle/log4j.jar \ @@ -74,7 +77,6 @@ felix.auto.start.40= \ reference:file:sc-bundles/resourcemanager.jar \ reference:file:sc-bundles/defaultresources.jar \ reference:file:sc-bundles/jfontchooserlib.jar \ - reference:file:sc-bundles/version.jar \ reference:file:sc-bundles/version-impl.jar \ reference:file:sc-bundles/keybindings.jar \ reference:file:sc-bundles/netaddr.jar \ diff --git a/lib/installer-exclude/libjitsi.jar b/lib/installer-exclude/libjitsi.jar new file mode 100644 index 000000000..de260e288 Binary files /dev/null and b/lib/installer-exclude/libjitsi.jar differ diff --git a/lib/native/linux-64/libjnpulseaudio.so b/lib/native/linux-64/libjnpulseaudio.so index f8a3a2893..3845ff51e 100755 Binary files a/lib/native/linux-64/libjnpulseaudio.so and b/lib/native/linux-64/libjnpulseaudio.so differ diff --git a/lib/native/linux-64/libjnvideo4linux2.so b/lib/native/linux-64/libjnvideo4linux2.so index 05aa25bfb..ddbb292f5 100755 Binary files a/lib/native/linux-64/libjnvideo4linux2.so and b/lib/native/linux-64/libjnvideo4linux2.so differ diff --git a/lib/native/linux/libjnpulseaudio.so b/lib/native/linux/libjnpulseaudio.so index 1cbecacfb..e36eff9e0 100755 Binary files a/lib/native/linux/libjnpulseaudio.so and b/lib/native/linux/libjnpulseaudio.so differ diff --git a/lib/native/linux/libjnvideo4linux2.so b/lib/native/linux/libjnvideo4linux2.so index fdc257c00..01de3f422 100755 Binary files a/lib/native/linux/libjnvideo4linux2.so and b/lib/native/linux/libjnvideo4linux2.so differ diff --git a/src/net/java/sip/communicator/impl/argdelegation/ArgDelegationActivator.java b/src/net/java/sip/communicator/impl/argdelegation/ArgDelegationActivator.java index 398ca4174..0670937c1 100644 --- a/src/net/java/sip/communicator/impl/argdelegation/ArgDelegationActivator.java +++ b/src/net/java/sip/communicator/impl/argdelegation/ArgDelegationActivator.java @@ -6,16 +6,17 @@ */ package net.java.sip.communicator.impl.argdelegation; +import java.lang.reflect.*; + import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.launchutils.*; +import org.jitsi.util.*; import org.osgi.framework.*; import com.apple.eawt.*; -import java.lang.reflect.*; - /** * Activates the ArgDelegationService and registers a URI delegation * peer with the util package arg manager so that we would be notified when the diff --git a/src/net/java/sip/communicator/impl/argdelegation/argdelegation.manifest.mf b/src/net/java/sip/communicator/impl/argdelegation/argdelegation.manifest.mf index 31e3155c9..bc6ee145c 100644 --- a/src/net/java/sip/communicator/impl/argdelegation/argdelegation.manifest.mf +++ b/src/net/java/sip/communicator/impl/argdelegation/argdelegation.manifest.mf @@ -8,7 +8,8 @@ Import-Package: org.osgi.framework, com.apple.eawt, net.java.sip.communicator.util, net.java.sip.communicator.util.launchutils, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, + org.jitsi.util, net.java.sip.communicator.service.argdelegation, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, diff --git a/src/net/java/sip/communicator/impl/browserlauncher/BrowserLauncherImpl.java b/src/net/java/sip/communicator/impl/browserlauncher/BrowserLauncherImpl.java index af846af22..c4ad992a3 100644 --- a/src/net/java/sip/communicator/impl/browserlauncher/BrowserLauncherImpl.java +++ b/src/net/java/sip/communicator/impl/browserlauncher/BrowserLauncherImpl.java @@ -7,7 +7,9 @@ package net.java.sip.communicator.impl.browserlauncher; import net.java.sip.communicator.service.browserlauncher.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; + +import org.jitsi.util.*; import com.apple.eio.*; diff --git a/src/net/java/sip/communicator/impl/browserlauncher/browserlauncher.manifest.mf b/src/net/java/sip/communicator/impl/browserlauncher/browserlauncher.manifest.mf index 55a9449a2..0b225ba08 100644 --- a/src/net/java/sip/communicator/impl/browserlauncher/browserlauncher.manifest.mf +++ b/src/net/java/sip/communicator/impl/browserlauncher/browserlauncher.manifest.mf @@ -6,6 +6,7 @@ Bundle-Version: 0.0.1 System-Bundle: yes Export-Package: net.java.sip.communicator.service.browserlauncher Import-Package: org.osgi.framework, + org.jitsi.util, net.java.sip.communicator.util, net.java.sip.communicator.service.browserlauncher, com.apple.eio diff --git a/src/net/java/sip/communicator/impl/callhistory/CallHistoryActivator.java b/src/net/java/sip/communicator/impl/callhistory/CallHistoryActivator.java index 7c7cd7a35..c424df5a5 100644 --- a/src/net/java/sip/communicator/impl/callhistory/CallHistoryActivator.java +++ b/src/net/java/sip/communicator/impl/callhistory/CallHistoryActivator.java @@ -8,14 +8,14 @@ import java.util.*; -import org.osgi.framework.*; - +import net.java.sip.communicator.service.callhistory.*; +import net.java.sip.communicator.service.contactsource.*; import net.java.sip.communicator.service.history.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; -import net.java.sip.communicator.service.callhistory.*; -import net.java.sip.communicator.service.contactsource.*; + +import org.jitsi.service.resources.*; +import org.osgi.framework.*; /** * Activates the CallHistoryService. diff --git a/src/net/java/sip/communicator/impl/callhistory/callhistory.manifest.mf b/src/net/java/sip/communicator/impl/callhistory/callhistory.manifest.mf index 6aab8668d..bb33b1bdc 100644 --- a/src/net/java/sip/communicator/impl/callhistory/callhistory.manifest.mf +++ b/src/net/java/sip/communicator/impl/callhistory/callhistory.manifest.mf @@ -5,7 +5,7 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.fileaccess, net.java.sip.communicator.service.history, net.java.sip.communicator.service.history.event, net.java.sip.communicator.service.contactlist, @@ -15,7 +15,7 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.protocol.icqconstants, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.contactsource, - net.java.sip.communicator.service.resources + org.jitsi.service.resources, net.java.sip.communicator.service.resources Export-Package: net.java.sip.communicator.service.callhistory, net.java.sip.communicator.service.callhistory.event Metadata-Location: net.java.sip.communicator.impl.msghistory, diff --git a/src/net/java/sip/communicator/impl/certificate/CertificateServiceImpl.java b/src/net/java/sip/communicator/impl/certificate/CertificateServiceImpl.java index 5068a72cd..5090f2691 100644 --- a/src/net/java/sip/communicator/impl/certificate/CertificateServiceImpl.java +++ b/src/net/java/sip/communicator/impl/certificate/CertificateServiceImpl.java @@ -11,7 +11,7 @@ import java.lang.reflect.*; import java.net.*; import java.security.*; -import java.security.KeyStore.*; +import java.security.KeyStore.Builder; import java.security.cert.*; import java.security.cert.Certificate; import java.util.*; @@ -20,18 +20,19 @@ import javax.security.auth.callback.*; import javax.swing.*; -import org.bouncycastle.asn1.*; -import org.bouncycastle.asn1.x509.*; -import org.bouncycastle.asn1.x509.X509Extension; - import net.java.sip.communicator.service.certificate.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.httputil.*; -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.swing.*; +import org.bouncycastle.asn1.*; +import org.bouncycastle.asn1.x509.*; +import org.bouncycastle.asn1.x509.X509Extension; +import org.jitsi.service.configuration.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.*; + /** * Implementation of the CertificateService. It asks the user to trust a * certificate when the automatic verification fails. diff --git a/src/net/java/sip/communicator/impl/certificate/CertificateVerificationActivator.java b/src/net/java/sip/communicator/impl/certificate/CertificateVerificationActivator.java index 2c5bffaa9..e1a41bc0b 100644 --- a/src/net/java/sip/communicator/impl/certificate/CertificateVerificationActivator.java +++ b/src/net/java/sip/communicator/impl/certificate/CertificateVerificationActivator.java @@ -7,11 +7,11 @@ package net.java.sip.communicator.impl.certificate; import net.java.sip.communicator.service.certificate.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/certificate/VerifyCertificateDialog.java b/src/net/java/sip/communicator/impl/certificate/VerifyCertificateDialog.java index 0e55dfd13..4e855a220 100644 --- a/src/net/java/sip/communicator/impl/certificate/VerifyCertificateDialog.java +++ b/src/net/java/sip/communicator/impl/certificate/VerifyCertificateDialog.java @@ -12,9 +12,10 @@ import javax.swing.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * Dialog that is shown to the user when a certificate verification failed. */ diff --git a/src/net/java/sip/communicator/impl/certificate/certificate.manifest.mf b/src/net/java/sip/communicator/impl/certificate/certificate.manifest.mf index 8699c8d1a..0c77bbe6c 100644 --- a/src/net/java/sip/communicator/impl/certificate/certificate.manifest.mf +++ b/src/net/java/sip/communicator/impl/certificate/certificate.manifest.mf @@ -8,10 +8,11 @@ Export-Package: net.java.sip.communicator.service.certificate Import-Package: org.osgi.framework, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, + org.jitsi.util, net.java.sip.communicator.service.credentialsstorage, net.java.sip.communicator.service.httputil, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, javax.net.ssl, javax.security.auth.callback, javax.security.auth.x500, diff --git a/src/net/java/sip/communicator/impl/configuration/ChangeEventDispatcher.java b/src/net/java/sip/communicator/impl/configuration/ChangeEventDispatcher.java index f6b204f34..530f36678 100644 --- a/src/net/java/sip/communicator/impl/configuration/ChangeEventDispatcher.java +++ b/src/net/java/sip/communicator/impl/configuration/ChangeEventDispatcher.java @@ -9,7 +9,7 @@ import java.util.*; import java.beans.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; /** * This is a utility class that can be used by objects that support constrained diff --git a/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java b/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java index 68b28b36e..86a28d754 100644 --- a/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java +++ b/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java @@ -8,7 +8,7 @@ import org.osgi.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.*; /** diff --git a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java index 206ba7757..982ff230f 100644 --- a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java +++ b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java @@ -11,11 +11,11 @@ import java.util.*; import net.java.sip.communicator.impl.configuration.xml.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.xml.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; import org.osgi.framework.*; /** @@ -556,18 +556,13 @@ void start(BundleContext bc) { logger.error("Failed to load the configuration file", ex); } - catch (XMLException ex) - { - logger.error("Failed to parse the configuration file", ex); - } } /* * Implements ConfigurationService#reloadConfiguration(). */ public void reloadConfiguration() - throws IOException, - XMLException + throws IOException { this.configurationFile = null; @@ -591,7 +586,17 @@ public void reloadConfiguration() } } - store.reloadConfiguration(file); + try + { + store.reloadConfiguration(file); + } + catch (XMLException xmle) + { + IOException ioe = new IOException(); + + ioe.initCause(xmle); + throw ioe; + } } /* diff --git a/src/net/java/sip/communicator/impl/configuration/configuration.manifest.mf b/src/net/java/sip/communicator/impl/configuration/configuration.manifest.mf index 542af3d3d..0e521dc10 100644 --- a/src/net/java/sip/communicator/impl/configuration/configuration.manifest.mf +++ b/src/net/java/sip/communicator/impl/configuration/configuration.manifest.mf @@ -13,5 +13,5 @@ Import-Package: org.osgi.framework, javax.xml.parsers, net.java.sip.communicator.util, net.java.sip.communicator.util.xml, - net.java.sip.communicator.service.fileaccess -Export-Package: net.java.sip.communicator.service.configuration + org.jitsi.service.configuration, + org.jitsi.service.fileaccess diff --git a/src/net/java/sip/communicator/impl/contactlist/ContactlistActivator.java b/src/net/java/sip/communicator/impl/contactlist/ContactlistActivator.java index 4a8b23398..70fefaa5d 100644 --- a/src/net/java/sip/communicator/impl/contactlist/ContactlistActivator.java +++ b/src/net/java/sip/communicator/impl/contactlist/ContactlistActivator.java @@ -7,10 +7,10 @@ package net.java.sip.communicator.impl.contactlist; import net.java.sip.communicator.service.contactlist.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.fileaccess.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java b/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java index 4576725e3..44190983d 100644 --- a/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java +++ b/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java @@ -11,18 +11,18 @@ import javax.xml.parsers.*; -import org.osgi.framework.*; -import org.w3c.dom.*; - -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.contactlist.event.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.xml.*; import net.java.sip.communicator.util.xml.XMLUtils; +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; +import org.osgi.framework.*; +import org.w3c.dom.*; + /** * The class handles read / write operations over the file where a persistent * copy of the meta contact list is stored. diff --git a/src/net/java/sip/communicator/impl/contactlist/MetaContactImpl.java b/src/net/java/sip/communicator/impl/contactlist/MetaContactImpl.java index 6f27d9a09..1397b36e1 100644 --- a/src/net/java/sip/communicator/impl/contactlist/MetaContactImpl.java +++ b/src/net/java/sip/communicator/impl/contactlist/MetaContactImpl.java @@ -11,10 +11,11 @@ import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.contactlist.event.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.fileaccess.*; + /** * A default implementation of the MetaContact interface. * diff --git a/src/net/java/sip/communicator/impl/contactlist/meta.cl.manifest.mf b/src/net/java/sip/communicator/impl/contactlist/meta.cl.manifest.mf index 5d655e4a8..fb997832f 100644 --- a/src/net/java/sip/communicator/impl/contactlist/meta.cl.manifest.mf +++ b/src/net/java/sip/communicator/impl/contactlist/meta.cl.manifest.mf @@ -5,8 +5,8 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.fileaccess, - net.java.sip.communicator.service.configuration, + org.jitsi.service.fileaccess, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.protocol, diff --git a/src/net/java/sip/communicator/impl/credentialsstorage/CredentialsStorageServiceImpl.java b/src/net/java/sip/communicator/impl/credentialsstorage/CredentialsStorageServiceImpl.java index 83abd01f1..6329e97bf 100644 --- a/src/net/java/sip/communicator/impl/credentialsstorage/CredentialsStorageServiceImpl.java +++ b/src/net/java/sip/communicator/impl/credentialsstorage/CredentialsStorageServiceImpl.java @@ -8,7 +8,7 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; diff --git a/src/net/java/sip/communicator/impl/credentialsstorage/credentialsstorage.manifest.mf b/src/net/java/sip/communicator/impl/credentialsstorage/credentialsstorage.manifest.mf index 9d7cb699e..f4b5eb012 100644 --- a/src/net/java/sip/communicator/impl/credentialsstorage/credentialsstorage.manifest.mf +++ b/src/net/java/sip/communicator/impl/credentialsstorage/credentialsstorage.manifest.mf @@ -5,7 +5,7 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.crypto, diff --git a/src/net/java/sip/communicator/impl/fileaccess/FailSafeTransactionImpl.java b/src/net/java/sip/communicator/impl/fileaccess/FailSafeTransactionImpl.java index b612feb91..2b4c895e5 100644 --- a/src/net/java/sip/communicator/impl/fileaccess/FailSafeTransactionImpl.java +++ b/src/net/java/sip/communicator/impl/fileaccess/FailSafeTransactionImpl.java @@ -8,7 +8,8 @@ package net.java.sip.communicator.impl.fileaccess; import java.io.*; -import net.java.sip.communicator.service.fileaccess.*; + +import org.jitsi.service.fileaccess.*; /** * A failsafe transaction class. By failsafe we mean here that the file diff --git a/src/net/java/sip/communicator/impl/fileaccess/FileAccessActivator.java b/src/net/java/sip/communicator/impl/fileaccess/FileAccessActivator.java index 9f832ac1f..8bdaf495d 100644 --- a/src/net/java/sip/communicator/impl/fileaccess/FileAccessActivator.java +++ b/src/net/java/sip/communicator/impl/fileaccess/FileAccessActivator.java @@ -6,10 +6,9 @@ */ package net.java.sip.communicator.impl.fileaccess; +import org.jitsi.service.fileaccess.*; import org.osgi.framework.*; -import net.java.sip.communicator.service.fileaccess.*; - /** * Invoke "Service Binder" to parse the service XML and register all services. * diff --git a/src/net/java/sip/communicator/impl/fileaccess/FileAccessServiceImpl.java b/src/net/java/sip/communicator/impl/fileaccess/FileAccessServiceImpl.java index c3d644c70..677e15b00 100644 --- a/src/net/java/sip/communicator/impl/fileaccess/FileAccessServiceImpl.java +++ b/src/net/java/sip/communicator/impl/fileaccess/FileAccessServiceImpl.java @@ -10,9 +10,11 @@ import javax.swing.filechooser.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.fileaccess.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; + +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; +import org.jitsi.util.*; /** * Default FileAccessService implementation. diff --git a/src/net/java/sip/communicator/impl/fileaccess/fileaccess.manifest.mf b/src/net/java/sip/communicator/impl/fileaccess/fileaccess.manifest.mf index df19ee546..ddcc1159e 100644 --- a/src/net/java/sip/communicator/impl/fileaccess/fileaccess.manifest.mf +++ b/src/net/java/sip/communicator/impl/fileaccess/fileaccess.manifest.mf @@ -14,6 +14,6 @@ Import-Package: org.osgi.framework, javax.swing.filechooser, net.java.sip.communicator.util, net.java.sip.communicator.util.xml, - net.java.sip.communicator.service.fileaccess -Export-Package: net.java.sip.communicator.service.fileaccess + org.jitsi.service.fileaccess, + org.jitsi.util Metadata-Location: /net/java/sip/communicator/impl/fileaccess/fileaccess.metadata.xml diff --git a/src/net/java/sip/communicator/impl/galagonotification/GalagoNotificationActivator.java b/src/net/java/sip/communicator/impl/galagonotification/GalagoNotificationActivator.java index 6904a9c3d..01f4d620b 100644 --- a/src/net/java/sip/communicator/impl/galagonotification/GalagoNotificationActivator.java +++ b/src/net/java/sip/communicator/impl/galagonotification/GalagoNotificationActivator.java @@ -10,6 +10,7 @@ import net.java.sip.communicator.service.systray.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/galagonotification/galagonotification.manifest.mf b/src/net/java/sip/communicator/impl/galagonotification/galagonotification.manifest.mf index e1fe3df35..7c68a9475 100644 --- a/src/net/java/sip/communicator/impl/galagonotification/galagonotification.manifest.mf +++ b/src/net/java/sip/communicator/impl/galagonotification/galagonotification.manifest.mf @@ -6,6 +6,6 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: javax.imageio, net.java.sip.communicator.service.systray, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, org.osgi.framework diff --git a/src/net/java/sip/communicator/impl/globalshortcut/GlobalShortcutServiceImpl.java b/src/net/java/sip/communicator/impl/globalshortcut/GlobalShortcutServiceImpl.java index bb183b8d7..b9336b3fd 100644 --- a/src/net/java/sip/communicator/impl/globalshortcut/GlobalShortcutServiceImpl.java +++ b/src/net/java/sip/communicator/impl/globalshortcut/GlobalShortcutServiceImpl.java @@ -6,14 +6,16 @@ */ package net.java.sip.communicator.impl.globalshortcut; -import java.util.*; -import java.util.List; // disambiguation - import java.awt.*; +import java.util.*; +import java.util.List; import net.java.sip.communicator.service.globalshortcut.*; import net.java.sip.communicator.service.keybindings.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; + +import org.jitsi.util.*; +// disambiguation /** * This global shortcut service permits to register listeners for global diff --git a/src/net/java/sip/communicator/impl/globalshortcut/NativeKeyboardHookDelegate.java b/src/net/java/sip/communicator/impl/globalshortcut/NativeKeyboardHookDelegate.java index 04b135c32..522759989 100644 --- a/src/net/java/sip/communicator/impl/globalshortcut/NativeKeyboardHookDelegate.java +++ b/src/net/java/sip/communicator/impl/globalshortcut/NativeKeyboardHookDelegate.java @@ -41,4 +41,4 @@ public interface NativeKeyboardHookDelegate * @param modifiers modifiers received (ALT or CTRL + letter, ...) */ public void receiveKey(int keycode, int modifiers); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/globalshortcut/globalshortcut.manifest.mf b/src/net/java/sip/communicator/impl/globalshortcut/globalshortcut.manifest.mf index 93aec4c75..16bd25ec9 100644 --- a/src/net/java/sip/communicator/impl/globalshortcut/globalshortcut.manifest.mf +++ b/src/net/java/sip/communicator/impl/globalshortcut/globalshortcut.manifest.mf @@ -5,6 +5,7 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, + org.jitsi.util, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.media, net.java.sip.communicator.service.protocol.event, diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java index 243b9f095..0ee56758c 100644 --- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java +++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java @@ -8,15 +8,15 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.contactsource.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.googlecontacts.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java index 0b1c98d49..509ecd9b7 100644 --- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java +++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java @@ -11,7 +11,7 @@ import java.util.*; import java.util.regex.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.googlecontacts.*; import net.java.sip.communicator.impl.googlecontacts.configform.*; diff --git a/src/net/java/sip/communicator/impl/googlecontacts/googlecontacts.manifest.mf b/src/net/java/sip/communicator/impl/googlecontacts/googlecontacts.manifest.mf index 9629bf12d..f5f779364 100644 --- a/src/net/java/sip/communicator/impl/googlecontacts/googlecontacts.manifest.mf +++ b/src/net/java/sip/communicator/impl/googlecontacts/googlecontacts.manifest.mf @@ -5,11 +5,11 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.credentialsstorage, net.java.sip.communicator.service.contactsource, net.java.sip.communicator.service.gui, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.protocol, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, diff --git a/src/net/java/sip/communicator/impl/growlnotification/GrowlNotificationActivator.java b/src/net/java/sip/communicator/impl/growlnotification/GrowlNotificationActivator.java index 69a1638c9..ac32c63be 100644 --- a/src/net/java/sip/communicator/impl/growlnotification/GrowlNotificationActivator.java +++ b/src/net/java/sip/communicator/impl/growlnotification/GrowlNotificationActivator.java @@ -6,14 +6,14 @@ */ package net.java.sip.communicator.impl.growlnotification; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.service.systray.*; +import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; -import net.java.sip.communicator.util.*; - /** * Activates the GrowlNotificationService * diff --git a/src/net/java/sip/communicator/impl/growlnotification/growlnotification.manifest.mf b/src/net/java/sip/communicator/impl/growlnotification/growlnotification.manifest.mf index 27444f404..08734427f 100644 --- a/src/net/java/sip/communicator/impl/growlnotification/growlnotification.manifest.mf +++ b/src/net/java/sip/communicator/impl/growlnotification/growlnotification.manifest.mf @@ -5,10 +5,10 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.protocol, net.java.sip.communicator.util, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.systray, net.java.sip.communicator.service.systray.event, net.java.sip.communicator.util.swing, diff --git a/src/net/java/sip/communicator/impl/gui/GuiActivator.java b/src/net/java/sip/communicator/impl/gui/GuiActivator.java index 66af4a650..302107338 100644 --- a/src/net/java/sip/communicator/impl/gui/GuiActivator.java +++ b/src/net/java/sip/communicator/impl/gui/GuiActivator.java @@ -11,26 +11,26 @@ import net.java.sip.communicator.impl.gui.main.account.*; import net.java.sip.communicator.impl.gui.main.contactlist.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.audionotifier.*; import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.callhistory.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.contactsource.*; import net.java.sip.communicator.service.desktop.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.keybindings.*; import net.java.sip.communicator.service.metahistory.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.replacement.*; import net.java.sip.communicator.service.replacement.smilies.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.service.shutdown.*; import net.java.sip.communicator.service.systray.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.audionotifier.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index c705230a6..45eb91cc3 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -35,12 +35,14 @@ import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.service.shutdown.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.*; import org.osgi.framework.*; import com.sun.jna.examples.*; @@ -1515,4 +1517,4 @@ public void startChat(String[] participants) else throw new IllegalArgumentException("participants"); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/SCScrollPane.java b/src/net/java/sip/communicator/impl/gui/customcontrols/SCScrollPane.java index 3a1ccf089..d56dab53d 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/SCScrollPane.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/SCScrollPane.java @@ -15,10 +15,11 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.util.*; + /** * The SCScrollPane is a JScrollPane with a custom viewport that allows to * set an image as a background. Depending on the diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/Wizard.java b/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/Wizard.java index 2d4c7c1b0..923015831 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/Wizard.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/Wizard.java @@ -16,9 +16,10 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * This class implements a basic wizard dialog, where the programmer can insert * one or more Components to act as panels. These panels can be navigated diff --git a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommCheckBoxUI.java b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommCheckBoxUI.java index 2e208b345..757006fea 100644 --- a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommCheckBoxUI.java +++ b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommCheckBoxUI.java @@ -34,4 +34,4 @@ public void paint(Graphics g, JComponent c) AntialiasingManager.activateAntialiasing(g); super.paint(g, c); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/DialPadFieldUI.java b/src/net/java/sip/communicator/impl/gui/main/DialPadFieldUI.java index a3e2adbb9..c4cf2526b 100644 --- a/src/net/java/sip/communicator/impl/gui/main/DialPadFieldUI.java +++ b/src/net/java/sip/communicator/impl/gui/main/DialPadFieldUI.java @@ -103,4 +103,4 @@ public static ComponentUI createUI(JComponent c) { return new DialPadFieldUI(); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/GeneralDialPadDialog.java b/src/net/java/sip/communicator/impl/gui/main/GeneralDialPadDialog.java index d40260f3e..1a165282a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/GeneralDialPadDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/GeneralDialPadDialog.java @@ -14,11 +14,12 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.main.call.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.plaf.*; +import org.jitsi.util.*; + import com.explodingpixels.macwidgets.*; /** diff --git a/src/net/java/sip/communicator/impl/gui/main/GeneralDialPanel.java b/src/net/java/sip/communicator/impl/gui/main/GeneralDialPanel.java index 1f61649a2..58075ac95 100755 --- a/src/net/java/sip/communicator/impl/gui/main/GeneralDialPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/GeneralDialPanel.java @@ -16,10 +16,11 @@ import net.java.sip.communicator.impl.gui.main.call.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.util.*; + /** * The DialPanel is the panel that contains the buttons to dial a * phone number. diff --git a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java index 6824c943a..e2a6ae195 100644 --- a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java +++ b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java @@ -8,7 +8,7 @@ import java.awt.*; import java.awt.event.*; -import java.beans.PropertyChangeEvent; +import java.beans.*; import java.util.*; import java.util.List; @@ -23,20 +23,22 @@ import net.java.sip.communicator.impl.gui.main.menus.*; import net.java.sip.communicator.impl.gui.main.presence.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.contacteventhandler.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.protocol.OperationSetMessageWaiting.*; +import net.java.sip.communicator.service.protocol.OperationSetMessageWaiting.MessageType; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.event.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.*; import org.osgi.framework.*; import com.explodingpixels.macwidgets.*; @@ -2009,4 +2011,4 @@ public void loadSkin() GuiActivator.getResources() .getColor("service.gui.MAIN_WINDOW_BACKGROUND"))); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java b/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java index 78026b4da..314ee9830 100644 --- a/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java +++ b/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java @@ -7,18 +7,17 @@ import java.io.*; import java.util.*; -import java.util.List; import javax.imageio.*; import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.wizard.*; import net.java.sip.communicator.impl.gui.main.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.configuration.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationPanel.java b/src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationPanel.java index 5b7ed35b2..90246d6fb 100644 --- a/src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationPanel.java @@ -14,11 +14,12 @@ import javax.swing.event.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.configuration.*; + /** * The AccountsConfigurationPanel is the panel containing the accounts * list and according buttons shown in the options form. diff --git a/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java b/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java index 0f62bae33..1c6514a2d 100644 --- a/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java @@ -18,10 +18,10 @@ import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/gui/main/call/AbstractCallToggleButton.java b/src/net/java/sip/communicator/impl/gui/main/call/AbstractCallToggleButton.java index 13d217dda..7958d68db 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/AbstractCallToggleButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/AbstractCallToggleButton.java @@ -300,4 +300,4 @@ public void setIconImageID(ImageID iconImageID) * action has been performed and that it should execute its very logic. */ public abstract void buttonPressed(); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallButton.java b/src/net/java/sip/communicator/impl/gui/main/call/CallButton.java index b2c1b7d3c..69c86d52e 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallButton.java @@ -149,4 +149,4 @@ private void updateTooltip() else setToolTipText(defaultTooltip); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallHistoryButton.java b/src/net/java/sip/communicator/impl/gui/main/call/CallHistoryButton.java index 9e0b67950..476ad524f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallHistoryButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallHistoryButton.java @@ -223,4 +223,4 @@ public void loadSkin() setHistoryView(); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java b/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java index baea81ff6..49ef171ee 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java @@ -12,16 +12,18 @@ import javax.swing.*; -import com.explodingpixels.macwidgets.*; - import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; + import org.ice4j.ice.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.*; + +import com.explodingpixels.macwidgets.*; /** * The frame displaying the statistical information for a call. @@ -495,8 +497,8 @@ private void appendStreamEncryptionMethod( } String rtpType; - SrtpControl srtpControl = callPeerMediaHandler - .getEncryptionMethod(mediaType); + SrtpControl srtpControl + = callPeerMediaHandler.getEncryptionMethod(mediaType); // If the stream is secured. if(srtpControl != null) { diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java index 4d7ae57df..b20dc5d51 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java @@ -19,14 +19,15 @@ import net.java.sip.communicator.impl.gui.main.contactlist.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.contactlist.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.transparent.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.device.*; + /** * The CallManager is the one that handles calls. It contains also * the "Call" and "Hang up" buttons panel. Here are handles incoming and @@ -1170,7 +1171,7 @@ public void run() qualityControl.setPreferredRemoteSendMaxPreset( qualityPreset); } - catch(OperationFailedException e) + catch(org.jitsi.service.protocol.OperationFailedException e) { logger.info("Unable to change video quality.", e); diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java index 84ed128d5..751bba184 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java @@ -16,23 +16,25 @@ import javax.swing.border.*; import javax.swing.event.*; -import org.osgi.framework.*; - import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.main.call.conference.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.border.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.util.*; +import org.osgi.framework.*; + /** * The dialog created for a given call. * diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallPeerAdapter.java b/src/net/java/sip/communicator/impl/gui/main/call/CallPeerAdapter.java index e61759da8..23c39b3ff 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallPeerAdapter.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallPeerAdapter.java @@ -11,6 +11,8 @@ import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; +import org.jitsi.service.protocol.event.*; + /** * The CallPeerAdapter is an adapter that implements all common * CallPeer related listeners in order to facilitate the task of diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallStatusPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallStatusPanel.java index 3099702f9..e50f7ef81 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallStatusPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallStatusPanel.java @@ -53,4 +53,4 @@ public void paintComponent(Graphics g) g.dispose(); } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallTransferHandler.java b/src/net/java/sip/communicator/impl/gui/main/call/CallTransferHandler.java index 86dbfb777..beaf53667 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallTransferHandler.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallTransferHandler.java @@ -219,4 +219,4 @@ else if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) } return false; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/call/DTMFHandler.java b/src/net/java/sip/communicator/impl/gui/main/call/DTMFHandler.java index 62594fbe3..126c6e505 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/DTMFHandler.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/DTMFHandler.java @@ -13,12 +13,13 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; - -import net.java.sip.communicator.service.audionotifier.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.audionotifier.*; +import org.jitsi.service.protocol.*; + /** * Handles DTMF sending and playing sound notifications for that. * diff --git a/src/net/java/sip/communicator/impl/gui/main/call/DesktopSharingFrame.java b/src/net/java/sip/communicator/impl/gui/main/call/DesktopSharingFrame.java index 693c6cf2e..41de8abbd 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/DesktopSharingFrame.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/DesktopSharingFrame.java @@ -15,13 +15,15 @@ import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.transparent.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.util.*; + /** * * @author Yana Stamcheva diff --git a/src/net/java/sip/communicator/impl/gui/main/call/InputVolumeControlButton.java b/src/net/java/sip/communicator/impl/gui/main/call/InputVolumeControlButton.java index 5dc9996ae..f318667ac 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/InputVolumeControlButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/InputVolumeControlButton.java @@ -16,11 +16,12 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.event.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.event.*; + /** * Represents an UI means to mute the audio stream sent in an associated * Call. diff --git a/src/net/java/sip/communicator/impl/gui/main/call/LocalVideoButton.java b/src/net/java/sip/communicator/impl/gui/main/call/LocalVideoButton.java index 54b4961b9..d945a43ed 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/LocalVideoButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/LocalVideoButton.java @@ -8,11 +8,12 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.device.*; + /** * The local video button is the button used to start/stop video in a * conversation. diff --git a/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPanel.java index 8a4796b0e..13bdaf4bc 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPanel.java @@ -12,13 +12,16 @@ import javax.swing.*; -import com.explodingpixels.macwidgets.*; - import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.swing.*; +import org.jitsi.util.*; + +import com.explodingpixels.macwidgets.*; + /** * The CallPanel is the panel containing call information. It's created * and added to the main tabbed pane when user makes or receives calls. It shows diff --git a/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPeerPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPeerPanel.java index a1bfc7ca6..86ed4494e 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPeerPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPeerPanel.java @@ -17,7 +17,6 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.main.contactlist.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.media.*; @@ -25,6 +24,11 @@ import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import net.java.sip.communicator.util.swing.TransparentPanel; + +import org.jitsi.service.neomedia.*; +import org.jitsi.service.protocol.event.*; +import org.jitsi.util.swing.*; /** * The OneToOneCallPeerPanel is the panel containing data for a call diff --git a/src/net/java/sip/communicator/impl/gui/main/call/OutputVolumeControlButton.java b/src/net/java/sip/communicator/impl/gui/main/call/OutputVolumeControlButton.java index 7dfdde5f1..78a157d50 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/OutputVolumeControlButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/OutputVolumeControlButton.java @@ -13,10 +13,11 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.neomedia.*; + /** * The VolumeControlButton is the button shown in the call window, * which allows to adjust the playback volume of your call. diff --git a/src/net/java/sip/communicator/impl/gui/main/call/ParanoiaTimerSecurityPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/ParanoiaTimerSecurityPanel.java index 13c7de2e0..f950a7fb1 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/ParanoiaTimerSecurityPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/ParanoiaTimerSecurityPanel.java @@ -6,17 +6,19 @@ */ package net.java.sip.communicator.impl.gui.main.call; +import java.awt.*; +import java.text.*; +import java.util.*; +import java.util.Timer; + +import javax.swing.*; + import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; -import javax.swing.*; -import java.awt.*; -import java.text.*; -import java.util.*; -import java.util.Timer; +import org.jitsi.service.neomedia.*; /** * @author Damian Minkov diff --git a/src/net/java/sip/communicator/impl/gui/main/call/PreCallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/PreCallDialog.java index fa31bb6e1..c3cc565d7 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/PreCallDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/PreCallDialog.java @@ -12,11 +12,12 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.util.*; + import com.explodingpixels.macwidgets.*; /** diff --git a/src/net/java/sip/communicator/impl/gui/main/call/RecordButton.java b/src/net/java/sip/communicator/impl/gui/main/call/RecordButton.java index 607231719..12289ced4 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/RecordButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/RecordButton.java @@ -11,13 +11,15 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.*; + /** * The button that starts/stops the call recording. * diff --git a/src/net/java/sip/communicator/impl/gui/main/call/ResizeVideoButton.java b/src/net/java/sip/communicator/impl/gui/main/call/ResizeVideoButton.java index 9b581c1b0..e7cae169c 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/ResizeVideoButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/ResizeVideoButton.java @@ -13,9 +13,10 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; +import org.jitsi.service.neomedia.*; + /** * The button responsible to resize video for the associated participant. * diff --git a/src/net/java/sip/communicator/impl/gui/main/call/SecurityPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/SecurityPanel.java index 202c15078..22e940027 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/SecurityPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/SecurityPanel.java @@ -6,12 +6,13 @@ */ package net.java.sip.communicator.impl.gui.main.call; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.neomedia.*; + /** * Base class for security panels that show encryption specific UI controls. * diff --git a/src/net/java/sip/communicator/impl/gui/main/call/SelectScreenDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/SelectScreenDialog.java index 961fdd335..e08eb0ca9 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/SelectScreenDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/SelectScreenDialog.java @@ -14,11 +14,14 @@ import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import net.java.sip.communicator.util.swing.TransparentPanel; + +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.service.neomedia.format.*; +import org.jitsi.util.swing.*; /** * A dialog dedicated to desktop streaming/sharing. Shows the possible screens diff --git a/src/net/java/sip/communicator/impl/gui/main/call/UIVideoHandler.java b/src/net/java/sip/communicator/impl/gui/main/call/UIVideoHandler.java index 3bd9caac5..37863a9ef 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/UIVideoHandler.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/UIVideoHandler.java @@ -16,12 +16,15 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.main.call.conference.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.event.*; import net.java.sip.communicator.util.swing.*; +import net.java.sip.communicator.util.swing.TransparentPanel; + +import org.jitsi.service.neomedia.*; +import org.jitsi.util.event.*; +import org.jitsi.util.swing.*; /** * The UIVideoHandler is meant to handle all video related events. diff --git a/src/net/java/sip/communicator/impl/gui/main/call/VolumeControlSlider.java b/src/net/java/sip/communicator/impl/gui/main/call/VolumeControlSlider.java index 08b74320a..9f8d2f271 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/VolumeControlSlider.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/VolumeControlSlider.java @@ -11,10 +11,11 @@ import javax.swing.*; import javax.swing.event.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.event.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.event.*; + /** * The volume control slider component. * diff --git a/src/net/java/sip/communicator/impl/gui/main/call/ZrtpSecurityPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/ZrtpSecurityPanel.java index 31b7ab5ff..8c56ae9c6 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/ZrtpSecurityPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/ZrtpSecurityPanel.java @@ -14,16 +14,18 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.media.*; -import net.java.sip.communicator.util.event.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.protocol.event.*; +import org.jitsi.util.event.*; + /** * The panel containing details about ZRTP call security. * diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/BasicConferenceParticipantPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/BasicConferenceParticipantPanel.java index 2f0f3d2fa..1b13b99f4 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/conference/BasicConferenceParticipantPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/BasicConferenceParticipantPanel.java @@ -13,13 +13,14 @@ import net.java.sip.communicator.impl.gui.main.call.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.neomedia.*; + /** * The basic panel used to render any conference participant. Meant to be * extended for CallPeers and ConferenceMembers. diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceFocusPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceFocusPanel.java index c50b83c94..e67a97fff 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceFocusPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceFocusPanel.java @@ -18,6 +18,8 @@ import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.protocol.event.*; + /** * * diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java index 593b8766d..0dc53c4da 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java @@ -482,4 +482,4 @@ public String toString() return contact; } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferencePeerPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferencePeerPanel.java index c091ac04e..c23021962 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferencePeerPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferencePeerPanel.java @@ -13,16 +13,19 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.main.call.*; -import net.java.sip.communicator.impl.gui.main.call.CallPeerAdapter; // disambiguation +import net.java.sip.communicator.impl.gui.main.call.CallPeerAdapter; import net.java.sip.communicator.impl.gui.main.presence.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.protocol.event.*; +// disambiguation + /** * The ConferencePeerPanel renders a single ConferencePeer, * which is not a conference focus. diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/ProtocolProviderSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/ProtocolProviderSelectorBox.java index 7d21f3f36..2e7c57452 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/conference/ProtocolProviderSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/ProtocolProviderSelectorBox.java @@ -253,4 +253,4 @@ public void paintComponent(Graphics g) this); } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/VideoConferenceCallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/VideoConferenceCallPanel.java index f44bc8b39..03a78b75d 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/conference/VideoConferenceCallPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/VideoConferenceCallPanel.java @@ -10,7 +10,8 @@ import net.java.sip.communicator.impl.gui.main.call.CallPeerAdapter; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.swing.*; + +import org.jitsi.util.swing.*; /** * The UI for video conference calls. This panel contains all conference peers diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java index 7aa4dca00..e25a9afb1 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java @@ -14,11 +14,12 @@ import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * The ChatConversationComponent is a component that can be added to * the conversation area of the chat window in order to display any special diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java index 97c65b48a..70a8ab90f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java @@ -9,8 +9,7 @@ import java.awt.*; import java.awt.Container; import java.awt.event.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; +import java.beans.*; import java.io.*; import java.util.*; import java.util.List; @@ -30,11 +29,13 @@ import net.java.sip.communicator.service.metahistory.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.SwingWorker; +import org.jitsi.util.*; + /** * The ChatPanel is the panel, where users can write and send messages, * view received messages. A ChatPanel is created for a contact or for a group @@ -2636,4 +2637,4 @@ public void removeChatLinkClickedListener(ChatLinkClickedListener listener) { conversationPanel.removeChatLinkClickedListener(listener); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java index e06118265..75fc85147 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java @@ -23,9 +23,11 @@ import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.keybindings.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.util.*; import org.osgi.framework.*; import com.explodingpixels.macwidgets.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java index 7962e872f..5f122c297 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java @@ -20,7 +20,9 @@ import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; + +import org.jitsi.util.*; /** * Manages chat windows and panels. diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java index 7829c825f..1c3149968 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java @@ -21,7 +21,7 @@ import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.chat.menus.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ContactPhotoPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ContactPhotoPanel.java index 8f95667a3..54c8ac634 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ContactPhotoPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ContactPhotoPanel.java @@ -188,4 +188,4 @@ public String getToolTipText(MouseEvent event) { return chatSession.getChatName(); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/FontChooser.java b/src/net/java/sip/communicator/impl/gui/main/chat/FontChooser.java index c0f287621..4945aed0b 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/FontChooser.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/FontChooser.java @@ -14,9 +14,10 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * The FontChooserDialog is a dialog for font selection * diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatContactRoleIcon.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatContactRoleIcon.java index 1468b5e3c..80b3a8c85 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatContactRoleIcon.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatContactRoleIcon.java @@ -50,4 +50,4 @@ public static Icon getRoleIcon(ChatRoomMemberRole role) } return i; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomSubjectPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomSubjectPanel.java index 724b932b1..75e46abba 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomSubjectPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomSubjectPanel.java @@ -15,11 +15,12 @@ import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * The panel containing the subject of the chat room and the configuration * button. diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java index 39eb97261..64e08b74d 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java @@ -20,12 +20,12 @@ import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; -// Java 1.6 has javax.swing.SwingWorker so we have to disambiguate. -import org.jdesktop.swingworker.SwingWorker; +import org.jdesktop.swingworker.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; +// Java 1.6 has javax.swing.SwingWorker so we have to disambiguate. /** * The ConferenceChatManager is the one that manages both chat room and diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/AdHocChatRoomList.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/AdHocChatRoomList.java index 2df98ef7d..e936e4338 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/AdHocChatRoomList.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/AdHocChatRoomList.java @@ -10,10 +10,10 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.main.chat.conference.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.configuration.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomList.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomList.java index edec4b746..74c006f1a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomList.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomList.java @@ -11,7 +11,7 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.main.chat.conference.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java index 576a49002..d5be43c4f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java @@ -21,6 +21,8 @@ import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * The ChatRoomsListRightButtonMenu is the menu, opened when user clicks * with the right mouse button on the chat rooms list panel. It's the one that diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizard.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizard.java index 1b8c66226..3d29b72ff 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizard.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizard.java @@ -75,4 +75,4 @@ public void wizardFinished(WizardEvent e) newChatRoom.getChatRoomProvider()); } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizardPage2.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizardPage2.java index d39b6f271..4f23b02a9 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizardPage2.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizardPage2.java @@ -160,4 +160,4 @@ public void removeUpdate(DocumentEvent e) public void changedUpdate(DocumentEvent e) {} } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java b/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java index 77ceba8f5..054b5c0be 100644 --- a/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java +++ b/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java @@ -13,9 +13,10 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.swing.*; +import org.jitsi.util.*; import org.osgi.framework.*; import com.explodingpixels.macwidgets.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java index d38df5e47..f92eb915e 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java @@ -1548,4 +1548,4 @@ public void run() } } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListUtils.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListUtils.java index 817d71008..18a630e7c 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListUtils.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListUtils.java @@ -98,4 +98,4 @@ else if (errorCode } }.start(); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupNode.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupNode.java index d988c3e79..11753db19 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupNode.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupNode.java @@ -456,4 +456,4 @@ private void refreshSelection(int lastSelectedIndex, int newSelectedIndex) sipCommTreeUI.selectionChanged(oldSelectionPath, newSelectionPath); } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFieldUI.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFieldUI.java index 06a680380..bf85c9e20 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFieldUI.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFieldUI.java @@ -351,4 +351,4 @@ public static ComponentUI createUI(JComponent c) { return new SearchFieldUI(); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/UIContactDetail.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/UIContactDetail.java index 26670893f..c50e0c263 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/UIContactDetail.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/UIContactDetail.java @@ -201,4 +201,4 @@ public void setPrefix(String prefix) * null if the detail doesn't support presence */ public abstract PresenceStatus getPresenceStatus(); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/UnknownContactPanel.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/UnknownContactPanel.java index 6549cb0c9..38ce960c8 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/UnknownContactPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/UnknownContactPanel.java @@ -259,4 +259,4 @@ public void setVisible(boolean isVisible) super.setVisible(isVisible); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/MetaUIContact.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/MetaUIContact.java index dc834e1f9..e6735cb3c 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/MetaUIContact.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/MetaUIContact.java @@ -608,4 +608,4 @@ public JPopupMenu getRightButtonMenu() { return new MetaContactRightButtonMenu(metaContact); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/notifsource/NotificationContact.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/notifsource/NotificationContact.java index d64c382e3..ae728ecc0 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/notifsource/NotificationContact.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/notifsource/NotificationContact.java @@ -17,7 +17,8 @@ import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.OperationSetMessageWaiting.MessageType; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.service.resources.*; + +import org.jitsi.service.resources.*; /** * The NotificationContact represents a notification entry shown in diff --git a/src/net/java/sip/communicator/impl/gui/main/login/DefaultSecurityAuthority.java b/src/net/java/sip/communicator/impl/gui/main/login/DefaultSecurityAuthority.java index 96caa5463..e2c975366 100644 --- a/src/net/java/sip/communicator/impl/gui/main/login/DefaultSecurityAuthority.java +++ b/src/net/java/sip/communicator/impl/gui/main/login/DefaultSecurityAuthority.java @@ -147,4 +147,4 @@ public boolean isUserNameEditable() { return isUserNameEditable; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/AutoAnswerMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/AutoAnswerMenu.java index cfcaf17b8..e3bd95f93 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/AutoAnswerMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/AutoAnswerMenu.java @@ -10,17 +10,18 @@ import java.awt.event.*; import java.awt.image.*; +import javax.swing.*; +import javax.swing.border.*; + import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; -import org.osgi.framework.*; -import javax.swing.*; -import javax.swing.border.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; /** * The auto answer menu dynamically adds/removes menu items for enabled/disabled diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java index 1c8aa6d35..ddf214562 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java @@ -20,11 +20,12 @@ import net.java.sip.communicator.impl.gui.main.contactlist.addgroup.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * The FileMenu is a menu in the main application menu bar that * contains "New account". diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java index 4a3c0ae55..6cf1680bc 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java @@ -9,13 +9,13 @@ import java.awt.event.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.gui.Container; -import net.java.sip.communicator.service.resources.*; +import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * The HelpMenu is a menu in the main application menu bar. * diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/MainMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/MainMenu.java index e5f840c34..47b8e07c9 100755 --- a/src/net/java/sip/communicator/impl/gui/main/menus/MainMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/MainMenu.java @@ -10,7 +10,8 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.main.*; -import net.java.sip.communicator.service.resources.*; + +import org.jitsi.service.resources.*; /** * The main menu bar. This is the menu bar that appears on top of the main diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/GlobalStatusSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/presence/GlobalStatusSelectorBox.java index e831a30f8..5bfde2490 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/GlobalStatusSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/GlobalStatusSelectorBox.java @@ -18,7 +18,7 @@ import net.java.sip.communicator.impl.gui.lookandfeel.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.service.systray.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/StatusSelectorMenu.java b/src/net/java/sip/communicator/impl/gui/main/presence/StatusSelectorMenu.java index 8b0df4cce..4cc7968a1 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/StatusSelectorMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/StatusSelectorMenu.java @@ -13,7 +13,7 @@ import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/avatar/imagepicker/WebcamDialog.java b/src/net/java/sip/communicator/impl/gui/main/presence/avatar/imagepicker/WebcamDialog.java index 4429d9f1d..db16279d8 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/avatar/imagepicker/WebcamDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/avatar/imagepicker/WebcamDialog.java @@ -13,10 +13,13 @@ import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.service.audionotifier.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import net.java.sip.communicator.util.swing.TransparentPanel; + +import org.jitsi.service.audionotifier.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.util.swing.*; /** * A dialog showing the webcam and allowing the user to grap a snapshot diff --git a/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf b/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf index 4b8512a24..2673e6ab1 100644 --- a/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf +++ b/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf @@ -4,17 +4,30 @@ Bundle-Description: An implementation of the UI service. Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes -Import-Package: org.osgi.framework, - net.java.sip.communicator.service.audionotifier, +Import-Package: com.apple.eawt, + com.sun.jna.examples, + javax.accessibility, + javax.imageio, + javax.swing, + javax.swing.border, + javax.swing.event, + javax.swing.filechooser, + javax.swing.plaf, + javax.swing.plaf.basic, + javax.swing.plaf.metal, + javax.swing.table, + javax.swing.text, + javax.swing.text.html, + javax.swing.tree, + javax.swing.undo, net.java.sip.communicator.service.browserlauncher, net.java.sip.communicator.service.callhistory, net.java.sip.communicator.service.callhistory.event, - net.java.sip.communicator.service.configuration, net.java.sip.communicator.service.contacteventhandler, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, + net.java.sip.communicator.service.contactsource, net.java.sip.communicator.service.desktop, - net.java.sip.communicator.service.fileaccess, net.java.sip.communicator.service.filehistory, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, @@ -26,39 +39,29 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.icqconstants, net.java.sip.communicator.service.protocol.media, + net.java.sip.communicator.service.replacement, + net.java.sip.communicator.service.replacement.smilies, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.shutdown, net.java.sip.communicator.service.systray, - net.java.sip.communicator.service.neomedia, - net.java.sip.communicator.service.neomedia.event, - net.java.sip.communicator.service.neomedia.device, - net.java.sip.communicator.service.neomedia.format, - net.java.sip.communicator.service.contactsource, - net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.replacement.smilies, net.java.sip.communicator.util, net.java.sip.communicator.util.event, net.java.sip.communicator.util.skin, - net.java.sip.communicator.util.swing.transparent, net.java.sip.communicator.util.swing, net.java.sip.communicator.util.swing.border, net.java.sip.communicator.util.swing.event, net.java.sip.communicator.util.swing.plaf, - javax.accessibility, - javax.imageio, - javax.swing, - javax.swing.border, - javax.swing.event, - javax.swing.filechooser, - javax.swing.plaf, - javax.swing.plaf.basic, - javax.swing.plaf.metal, - javax.swing.table, - javax.swing.text, - javax.swing.text.html, - javax.swing.tree, - javax.swing.undo, - com.sun.jna.examples, + net.java.sip.communicator.util.swing.transparent, org.jdesktop.jdic.desktop, - say.swing, - com.apple.eawt + org.jitsi.service.audionotifier, + org.jitsi.service.configuration, + org.jitsi.service.fileaccess, + org.jitsi.service.neomedia, + org.jitsi.service.neomedia.event, + org.jitsi.service.neomedia.device, + org.jitsi.service.neomedia.format, + org.jitsi.service.resources, + org.jitsi.util, + org.jitsi.util.swing, + org.osgi.framework, + say.swing diff --git a/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java b/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java index 3ec0530ed..73c078bb5 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java @@ -11,7 +11,7 @@ import java.util.List; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; import org.osgi.framework.*; diff --git a/src/net/java/sip/communicator/impl/gui/utils/SoundProperties.java b/src/net/java/sip/communicator/impl/gui/utils/SoundProperties.java index 76d0aaf84..a4933f5ea 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/SoundProperties.java +++ b/src/net/java/sip/communicator/impl/gui/utils/SoundProperties.java @@ -7,7 +7,8 @@ package net.java.sip.communicator.impl.gui.utils; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.service.resources.*; + +import org.jitsi.service.resources.*; /** * Manages the access to the properties file containing all sounds paths. diff --git a/src/net/java/sip/communicator/impl/hid/HIDServiceImpl.java b/src/net/java/sip/communicator/impl/hid/HIDServiceImpl.java index 82a887102..3e5c48712 100644 --- a/src/net/java/sip/communicator/impl/hid/HIDServiceImpl.java +++ b/src/net/java/sip/communicator/impl/hid/HIDServiceImpl.java @@ -10,7 +10,9 @@ import java.awt.event.*; import net.java.sip.communicator.service.hid.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; + +import org.jitsi.util.*; /** * Implementation of the HID service to provide way of regenerate key press diff --git a/src/net/java/sip/communicator/impl/hid/hid.manifest.mf b/src/net/java/sip/communicator/impl/hid/hid.manifest.mf index 504fb2dcc..a4db319f9 100644 --- a/src/net/java/sip/communicator/impl/hid/hid.manifest.mf +++ b/src/net/java/sip/communicator/impl/hid/hid.manifest.mf @@ -5,5 +5,6 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, + org.jitsi.util, net.java.sip.communicator.util -Export-Package: net.java.sip.communicator.service.hid \ No newline at end of file +Export-Package: net.java.sip.communicator.service.hid diff --git a/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java b/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java index 48214eb85..e4139d91c 100644 --- a/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java +++ b/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java @@ -11,16 +11,16 @@ import javax.xml.parsers.*; -import org.osgi.framework.*; -import org.w3c.dom.*; -import org.xml.sax.*; - -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.history.*; import net.java.sip.communicator.service.history.records.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; +import org.osgi.framework.*; +import org.w3c.dom.*; +import org.xml.sax.*; + /** * @author Alexander Pelov * @author Damian Minkov diff --git a/src/net/java/sip/communicator/impl/history/history.manifest.mf b/src/net/java/sip/communicator/impl/history/history.manifest.mf index bc08a6d90..249408945 100644 --- a/src/net/java/sip/communicator/impl/history/history.manifest.mf +++ b/src/net/java/sip/communicator/impl/history/history.manifest.mf @@ -5,8 +5,8 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.configuration, + org.jitsi.service.fileaccess, net.java.sip.communicator.service.history, net.java.sip.communicator.service.history.records, org.w3c.dom, diff --git a/src/net/java/sip/communicator/impl/keybindings/KeybindingsActivator.java b/src/net/java/sip/communicator/impl/keybindings/KeybindingsActivator.java index aad960a16..f8ca35755 100644 --- a/src/net/java/sip/communicator/impl/keybindings/KeybindingsActivator.java +++ b/src/net/java/sip/communicator/impl/keybindings/KeybindingsActivator.java @@ -6,11 +6,11 @@ */ package net.java.sip.communicator.impl.keybindings; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.keybindings.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/keybindings/KeybindingsServiceImpl.java b/src/net/java/sip/communicator/impl/keybindings/KeybindingsServiceImpl.java index 35efb39ff..d294166f2 100644 --- a/src/net/java/sip/communicator/impl/keybindings/KeybindingsServiceImpl.java +++ b/src/net/java/sip/communicator/impl/keybindings/KeybindingsServiceImpl.java @@ -10,17 +10,18 @@ import java.io.*; import java.text.*; import java.util.*; -import java.util.List; //disambiguation +import java.util.List; import javax.swing.*; -import org.osgi.framework.*; - -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.keybindings.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; +import org.osgi.framework.*; +//disambiguation + /** * Service that concerns keybinding mappings used by various parts of the UI. * Persistence is handled as follows when started: diff --git a/src/net/java/sip/communicator/impl/keybindings/keybindings.manifest.mf b/src/net/java/sip/communicator/impl/keybindings/keybindings.manifest.mf index 278a3c998..716b666ee 100644 --- a/src/net/java/sip/communicator/impl/keybindings/keybindings.manifest.mf +++ b/src/net/java/sip/communicator/impl/keybindings/keybindings.manifest.mf @@ -6,9 +6,9 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.util, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.fileaccess, net.java.sip.communicator.service.gui, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, javax.swing Export-Package: net.java.sip.communicator.service.keybindings diff --git a/src/net/java/sip/communicator/impl/ldap/LdapActivator.java b/src/net/java/sip/communicator/impl/ldap/LdapActivator.java index 23f691e36..d47f3e1bd 100644 --- a/src/net/java/sip/communicator/impl/ldap/LdapActivator.java +++ b/src/net/java/sip/communicator/impl/ldap/LdapActivator.java @@ -6,16 +6,15 @@ */ package net.java.sip.communicator.impl.ldap; -import java.util.HashMap; -import java.util.Map; +import java.util.*; -import org.osgi.framework.*; - -import net.java.sip.communicator.util.*; -import net.java.sip.communicator.service.contactsource.ContactSourceService; +import net.java.sip.communicator.service.contactsource.*; import net.java.sip.communicator.service.ldap.*; -import net.java.sip.communicator.service.protocol.PhoneNumberI18nService; -import net.java.sip.communicator.service.resources.ResourceManagementService; +import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.util.*; + +import org.jitsi.service.resources.*; +import org.osgi.framework.*; /** * Activates the LdapService diff --git a/src/net/java/sip/communicator/impl/ldap/LdapDirectorySetImpl.java b/src/net/java/sip/communicator/impl/ldap/LdapDirectorySetImpl.java index 2631fc2ed..734921986 100644 --- a/src/net/java/sip/communicator/impl/ldap/LdapDirectorySetImpl.java +++ b/src/net/java/sip/communicator/impl/ldap/LdapDirectorySetImpl.java @@ -9,7 +9,7 @@ import java.util.*; import net.java.sip.communicator.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.ldap.*; import net.java.sip.communicator.service.ldap.event.*; diff --git a/src/net/java/sip/communicator/impl/ldap/LdapDirectorySettingsImpl.java b/src/net/java/sip/communicator/impl/ldap/LdapDirectorySettingsImpl.java index b30093d4c..940772a38 100644 --- a/src/net/java/sip/communicator/impl/ldap/LdapDirectorySettingsImpl.java +++ b/src/net/java/sip/communicator/impl/ldap/LdapDirectorySettingsImpl.java @@ -8,7 +8,7 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.ldap.*; diff --git a/src/net/java/sip/communicator/impl/ldap/LdapServiceImpl.java b/src/net/java/sip/communicator/impl/ldap/LdapServiceImpl.java index 9791f4e42..da18a0783 100644 --- a/src/net/java/sip/communicator/impl/ldap/LdapServiceImpl.java +++ b/src/net/java/sip/communicator/impl/ldap/LdapServiceImpl.java @@ -11,7 +11,7 @@ import org.osgi.framework.*; import net.java.sip.communicator.service.certificate.CertificateService; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.contactsource.ContactSourceService; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.ldap.*; diff --git a/src/net/java/sip/communicator/impl/ldap/ldap.manifest.mf b/src/net/java/sip/communicator/impl/ldap/ldap.manifest.mf index 248ca893b..4bd450d3e 100644 --- a/src/net/java/sip/communicator/impl/ldap/ldap.manifest.mf +++ b/src/net/java/sip/communicator/impl/ldap/ldap.manifest.mf @@ -12,14 +12,14 @@ Import-Package: org.osgi.framework, javax.net.ssl, net.java.sip.communicator.util, net.java.sip.communicator.service.certificate, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.credentialsstorage, net.java.sip.communicator.service.ldap, net.java.sip.communicator.service.ldap.event, net.java.sip.communicator.service.contactsource, net.java.sip.communicator.service.protocol, net.java.sip.communicator.util.swing, - net.java.sip.communicator.service.resources + org.jitsi.service.resources, net.java.sip.communicator.service.resources Export-Package: net.java.sip.communicator.service.ldap, net.java.sip.communicator.service.ldap.event Metadata-Location: /net/java/sip/communicator/impl/ldap/ldap.metadata.xml diff --git a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java index 563cf4646..3eb3c5bf5 100644 --- a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java +++ b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java @@ -6,14 +6,11 @@ */ package net.java.sip.communicator.impl.msghistory; +import java.beans.*; import java.io.*; import java.util.*; -import java.beans.*; - -import org.osgi.framework.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.history.*; import net.java.sip.communicator.service.history.event.*; @@ -25,6 +22,9 @@ import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; + /** * The Message History Service stores messages exchanged through the various * protocols diff --git a/src/net/java/sip/communicator/impl/msghistory/msghistory.manifest.mf b/src/net/java/sip/communicator/impl/msghistory/msghistory.manifest.mf index e2733eefe..e6379edba 100644 --- a/src/net/java/sip/communicator/impl/msghistory/msghistory.manifest.mf +++ b/src/net/java/sip/communicator/impl/msghistory/msghistory.manifest.mf @@ -5,9 +5,9 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + org.jitsi.service.fileaccess, net.java.sip.communicator.service.history, net.java.sip.communicator.service.history.event, net.java.sip.communicator.service.msghistory, diff --git a/src/net/java/sip/communicator/impl/neomedia/AbstractRTPConnector.java b/src/net/java/sip/communicator/impl/neomedia/AbstractRTPConnector.java deleted file mode 100755 index 931e9ca19..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/AbstractRTPConnector.java +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.net.*; - -import javax.media.rtp.*; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * Provides a base/default implementation of RTPConnector which has - * factory methods for its control and data input and output streams and has an - * associated StreamConnector. - * - * @author Bing SU (nova.su@gmail.com) - * @author Lyubomir Marinov - */ -public abstract class AbstractRTPConnector - implements RTPConnector -{ - /** - * The pair of datagram sockets for RTP and RTCP traffic that this instance - * uses in the form of a StreamConnector. - */ - protected final StreamConnector connector; - - /** - * RTCP packet input stream used by RTPManager. - */ - private RTPConnectorInputStream controlInputStream; - - /** - * RTCP packet output stream used by RTPManager. - */ - private RTPConnectorOutputStream controlOutputStream; - - /** - * RTP packet input stream used by RTPManager. - */ - private RTPConnectorInputStream dataInputStream; - - /** - * RTP packet output stream used by RTPManager. - */ - private RTPConnectorOutputStream dataOutputStream; - - /** - * Initializes a new AbstractRTPConnector which is to use a given - * pair of datagram sockets for RTP and RTCP traffic specified in the form - * of a StreamConnector. - * - * @param connector the pair of datagram sockets for RTP and RTCP traffic - * the new instance is to use - */ - public AbstractRTPConnector(StreamConnector connector) - { - if (connector == null) - throw new NullPointerException("connector"); - - this.connector = connector; - } - - /** - * Add a stream target. A stream target is the destination address which - * this RTP session will send its data to. For a single session, we can add - * multiple SessionAddresses, and for each address, one copy of data will be - * sent to. - * - * @param target Destination target address - * @throws IOException if there was a socket-related error while adding the - * specified target - */ - public void addTarget(SessionAddress target) - throws IOException - { - InetAddress controlAddress = target.getControlAddress(); - - if (controlAddress != null) - { - getControlOutputStream() - .addTarget( - controlAddress, - target.getControlPort()); - } - - getDataOutputStream() - .addTarget( - target.getDataAddress(), - target.getDataPort()); - } - - /** - * Closes all sockets, stream, and the StreamConnector that this - * RTPConnector is using. - */ - public void close() - { - if (dataOutputStream != null) - { - dataOutputStream.close(); - dataOutputStream = null; - } - if (controlOutputStream != null) - { - controlOutputStream.close(); - controlOutputStream = null; - } - if (dataInputStream != null) - { - dataInputStream.close(); - dataInputStream = null; - } - if (controlInputStream != null) - { - controlInputStream.close(); - controlInputStream = null; - } - - connector.close(); - } - - /** - * Creates the RTCP packet input stream to be used by RTPManager. - * - * @return a new RTCP packet input stream to be used by RTPManager - * @throws IOException if an error occurs during the creation of the RTCP - * packet input stream - */ - protected abstract RTPConnectorInputStream createControlInputStream() - throws IOException; - - /** - * Creates the RTCP packet output stream to be used by RTPManager. - * - * @return a new RTCP packet output stream to be used by RTPManager - * @throws IOException if an error occurs during the creation of the RTCP - * packet output stream - */ - protected abstract RTPConnectorOutputStream createControlOutputStream() - throws IOException; - - /** - * Creates the RTP packet input stream to be used by RTPManager. - * - * @return a new RTP packet input stream to be used by RTPManager - * @throws IOException if an error occurs during the creation of the RTP - * packet input stream - */ - protected abstract RTPConnectorInputStream createDataInputStream() - throws IOException; - - /** - * Creates the RTP packet output stream to be used by RTPManager. - * - * @return a new RTP packet output stream to be used by RTPManager - * @throws IOException if an error occurs during the creation of the RTP - * packet output stream - */ - protected abstract RTPConnectorOutputStream createDataOutputStream() - throws IOException; - - /** - * Gets the StreamConnector which represents the pair of datagram - * sockets for RTP and RTCP traffic used by this instance. - * - * @return the StreamConnector which represents the pair of - * datagram sockets for RTP and RTCP traffic used by this instance - */ - public final StreamConnector getConnector() - { - return connector; - } - - /** - * Returns the input stream that is handling incoming RTCP packets. - * - * @return the input stream that is handling incoming RTCP packets. - * - * @throws IOException if an error occurs during the creation of the RTCP - * packet input stream - */ - public RTPConnectorInputStream getControlInputStream() - throws IOException - { - return getControlInputStream(true); - } - - /** - * Gets the PushSourceStream which gives access to the RTCP data - * received from the remote targets and optionally creates it if it does not - * exist yet. - * - * @param create true to create the PushSourceStream which - * gives access to the RTCP data received from the remote targets if it does - * not exist yet; otherwise, false - * @return the PushBufferStream which gives access to the RTCP data - * received from the remote targets; null if it does not exist yet - * and create is false - * @throws IOException if creating the PushSourceStream fails - */ - protected RTPConnectorInputStream getControlInputStream(boolean create) - throws IOException - { - if ((controlInputStream == null) && create) - controlInputStream = createControlInputStream(); - return controlInputStream; - } - - /** - * Returns the input stream that is handling outgoing RTCP packets. - * - * @return the input stream that is handling outgoing RTCP packets. - * - * @throws IOException if an error occurs during the creation of the RTCP - * packet output stream - */ - public RTPConnectorOutputStream getControlOutputStream() - throws IOException - { - return getControlOutputStream(true); - } - - /** - * Gets the OutputDataStream which is used to write RTCP data to be - * sent to from the remote targets and optionally creates it if it does not - * exist yet. - * - * @param create true to create the OutputDataStream which - * is to be used to write RTCP data to be sent to the remote targets if it - * does not exist yet; otherwise, false - * @return the OutputDataStream which is used to write RTCP data to - * be sent to the remote targets; null if it does not exist yet and - * create is false - * @throws IOException if creating the OutputDataStream fails - */ - protected RTPConnectorOutputStream getControlOutputStream(boolean create) - throws IOException - { - if ((controlOutputStream == null) && create) - controlOutputStream = createControlOutputStream(); - return controlOutputStream; - } - - /** - * Returns the input stream that is handling incoming RTP packets. - * - * @return the input stream that is handling incoming RTP packets. - * - * @throws IOException if an error occurs during the creation of the RTP - * packet input stream - */ - public RTPConnectorInputStream getDataInputStream() - throws IOException - { - return getDataInputStream(true); - } - - /** - * Gets the PushSourceStream which gives access to the RTP data - * received from the remote targets and optionally creates it if it does not - * exist yet. - * - * @param create true to create the PushSourceStream which - * gives access to the RTP data received from the remote targets if it does - * not exist yet; otherwise, false - * @return the PushBufferStream which gives access to the RTP data - * received from the remote targets; null if it does not exist yet - * and create is false - * @throws IOException if creating the PushSourceStream fails - */ - protected RTPConnectorInputStream getDataInputStream(boolean create) - throws IOException - { - if ((dataInputStream == null) && create) - dataInputStream = createDataInputStream(); - return dataInputStream; - } - - /** - * Returns the input stream that is handling outgoing RTP packets. - * - * @return the input stream that is handling outgoing RTP packets. - * - * @throws IOException if an error occurs during the creation of the RTP - */ - public RTPConnectorOutputStream getDataOutputStream() - throws IOException - { - return getDataOutputStream(true); - } - - /** - * Gets the OutputDataStream which is used to write RTP data to be - * sent to from the remote targets and optionally creates it if it does not - * exist yet. - * - * @param create true to create the OutputDataStream which - * is to be used to write RTP data to be sent to the remote targets if it - * does not exist yet; otherwise, false - * @return the OutputDataStream which is used to write RTP data to - * be sent to the remote targets; null if it does not exist yet and - * create is false - * @throws IOException if creating the OutputDataStream fails - */ - public RTPConnectorOutputStream getDataOutputStream(boolean create) - throws IOException - { - if ((dataOutputStream == null) && create) - dataOutputStream = createDataOutputStream(); - return dataOutputStream; - } - - /** - * Provides a dummy implementation to {@link - * RTPConnector#getReceiveBufferSize()} that always returns -1. - */ - public int getReceiveBufferSize() - { - // Not applicable - return -1; - } - - /** - * Provides a dummy implementation to {@link - * RTPConnector#getRTCPBandwidthFraction()} that always returns -1. - */ - public double getRTCPBandwidthFraction() - { - // Not applicable - return -1; - } - - /** - * Provides a dummy implementation to {@link - * RTPConnector#getRTCPSenderBandwidthFraction()} that always returns - * -1. - */ - public double getRTCPSenderBandwidthFraction() - { - // Not applicable - return -1; - } - - /** - * Provides a dummy implementation to {@link - * RTPConnector#getSendBufferSize()} that always returns -1. - */ - public int getSendBufferSize() - { - // Not applicable - return -1; - } - - /** - * Removes a target from our session. If a target is removed, there will be - * no data sent to that address. - * - * @param target Destination target to be removed - */ - public void removeTarget(SessionAddress target) - { - if (controlOutputStream != null) - controlOutputStream - .removeTarget( - target.getControlAddress(), - target.getControlPort()); - - if (dataOutputStream != null) - dataOutputStream - .removeTarget( - target.getDataAddress(), - target.getDataPort()); - } - - /** - * Remove all stream targets. After this operation is done. There will be - * no targets receiving data, so no data will be sent. - */ - public void removeTargets() - { - if (controlOutputStream != null) - controlOutputStream.removeTargets(); - - if (dataOutputStream != null) - dataOutputStream.removeTargets(); - } - - /** - * Provides a dummy implementation to {@link - * RTPConnector#setReceiveBufferSize(int)}. - * - * @param size ignored. - */ - public void setReceiveBufferSize(int size) - throws IOException - { - // Nothing should be done here :-) - } - - /** - * Provides a dummy implementation to {@link - * RTPConnector#setSendBufferSize(int)}. - * - * @param size ignored. - */ - public void setSendBufferSize(int size) - throws IOException - { - // Nothing should be done here :-) - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/AbstractVolumeControl.java b/src/net/java/sip/communicator/impl/neomedia/AbstractVolumeControl.java deleted file mode 100644 index 3b8a9eeca..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/AbstractVolumeControl.java +++ /dev/null @@ -1,536 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.awt.*; -import java.lang.ref.*; -import java.util.*; -import java.util.List; - -import javax.media.*; - -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.event.*; -import net.java.sip.communicator.util.*; - -/** - * Controls media service volume input or output. If a playback volume level - * is set we change it on all current players, as we synchronize volume - * on all players. Implements interface exposed from media service, also - * implements the interface used in the Renderer part of JMF and merges the two - * functionalities to work as one. - * - * @author Damian Minkov - * @author Lyubomir Marinov - */ -public class AbstractVolumeControl - implements VolumeControl, - GainControl -{ - /** - * The Logger used by the VolumeControlImpl class and - * its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(AbstractVolumeControl.class); - - /** - * The minimum volume level accepted by AbstractVolumeControl. - */ - private static final float MIN_VOLUME_LEVEL = 0.0F; - - /** - * The minimum volume level expressed in percent accepted by - * AbstractVolumeControl. - */ - public static final int MIN_VOLUME_PERCENT = 0; - - /** - * The maximum volume level accepted by AbstractVolumeControl. - */ - private static final float MAX_VOLUME_LEVEL = 1.0F; - - /** - * The maximum volume level expressed in percent accepted by - * AbstractVolumeControl. - */ - public static final int MAX_VOLUME_PERCENT = 200; - - /** - * The default volume level. - */ - private static final float DEFAULT_VOLUME_LEVEL - = MIN_VOLUME_LEVEL - + (MAX_VOLUME_LEVEL - MIN_VOLUME_LEVEL) - / ((MAX_VOLUME_PERCENT - MIN_VOLUME_PERCENT) / 100); - - /** - * The VolumeChangeListeners interested in volume change events - * through the VolumeControl interface. - *

- * Because the instances of AbstractVolumeControl are global at the - * time of this writing and, consequently, they cause the - * VolumeChangeListeners to be leaked, the listeners are referenced - * using WeakReferences. - *

- */ - private final List> - volumeChangeListeners - = new ArrayList>(); - - /** - * Listeners interested in volume change inside FMJ/JMF. - */ - private List gainChangeListeners; - - /** - * The current volume level. - */ - private float volumeLevel = DEFAULT_VOLUME_LEVEL; - - /** - * Current mute state, by default we start unmuted. - */ - private boolean mute = false; - - /** - * Current level in db. - */ - private float db; - - /** - * The initial volume level, when this instance was created. - */ - private final float initialVolumeLevel; - - /** - * The name of the configuration property which specifies the value of the - * volume level of this AbstractVolumeControl. - */ - private final String volumeLevelConfigurationPropertyName; - - /** - * Creates volume control instance and initializes initial level value - * if stored in the configuration service. - * - * @param volumeLevelConfigurationPropertyName the name of the configuration - * property which specifies the value of the volume level of the new - * instance - */ - public AbstractVolumeControl( - String volumeLevelConfigurationPropertyName) - { - this.volumeLevelConfigurationPropertyName - = volumeLevelConfigurationPropertyName; - - // Read the initial volume level from the ConfigurationService. - float initialVolumeLevel = DEFAULT_VOLUME_LEVEL; - - try - { - ConfigurationService cfg - = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - String initialVolumeLevelString - = cfg.getString(this.volumeLevelConfigurationPropertyName); - - if (initialVolumeLevelString != null) - { - initialVolumeLevel - = Float.parseFloat(initialVolumeLevelString); - if(logger.isDebugEnabled()) - { - logger.debug( - "Restored volume: " + initialVolumeLevelString); - } - } - } - } - catch (Throwable t) - { - logger.warn("Error restoring volume", t); - } - - this.initialVolumeLevel = initialVolumeLevel; - this.volumeLevel = this.initialVolumeLevel; - } - - /** - * Applies the gain specified by gainControl to the signal defined - * by the length number of samples given in buffer - * starting at offset. - * - * @param gainControl the GainControl which specifies the gain to - * apply - * @param buffer the samples of the signal to apply the gain to - * @param offset the start of the samples of the signal in buffer - * @param length the number of samples of the signal given in - * buffer - */ - public static void applyGain( - GainControl gainControl, - byte[] buffer, int offset, int length) - { - if (gainControl.getMute()) - Arrays.fill(buffer, offset, offset + length, (byte) 0); - else - { - // Assign a maximum of MAX_VOLUME_PERCENT to the volume scale. - float level = gainControl.getLevel() * (MAX_VOLUME_PERCENT / 100); - - if (level != 1) - { - for (int i = offset, toIndex = offset + length; - i < toIndex; - i += 2) - { - int i1 = i + 1; - short s = (short) ((buffer[i] & 0xff) | (buffer[i1] << 8)); - - /* Clip, don't wrap. */ - int si = s; - - si = (int) (si * level); - if (si > Short.MAX_VALUE) - s = Short.MAX_VALUE; - else if (si < Short.MIN_VALUE) - s = Short.MIN_VALUE; - else - s = (short) si; - - buffer[i] = (byte) s; - buffer[i1] = (byte) (s >> 8); - } - } - } - } - - /** - * Current volume value. - * - * @return the current volume level. - * - * @see net.java.sip.communicator.service.neomedia.VolumeControl - */ - public float getVolume() - { - return volumeLevel; - } - - /** - * Get the current gain set for this - * object as a value between 0.0 and 1.0 - * - * @return The gain in the level scale (0.0-1.0). - * - * @see javax.media.GainControl - */ - public float getLevel() - { - return volumeLevel; - } - - /** - * Returns the minimum allowed volume value. - * - * @return the minimum allowed volume value. - * - * @see net.java.sip.communicator.service.neomedia.VolumeControl - */ - public float getMinValue() - { - return MIN_VOLUME_LEVEL; - } - - /** - * Returns the maximum allowed volume value. - * - * @return the maximum allowed volume value. - * - * @see net.java.sip.communicator.service.neomedia.VolumeControl - */ - public float getMaxValue() - { - return MAX_VOLUME_LEVEL; - } - - /** - * Changes volume level. - * - * @param value the new level to set. - * @return the actual level which was set. - * - * @see net.java.sip.communicator.service.neomedia.VolumeControl - */ - public float setVolume(float value) - { - return this.setVolumeLevel(value); - } - - /** - * Set the gain using a floating point scale - * with values between 0.0 and 1.0. - * 0.0 is silence; 1.0 is the loudest - * useful level that this GainControl supports. - * - * @param level The new gain value specified in the level scale. - * @return The level that was actually set. - * - * @see javax.media.GainControl - */ - public float setLevel(float level) - { - return this.setVolumeLevel(level); - } - - /** - * Internal implementation combining setting level from JMF - * and from outside Media Service. - * - * @param value the new value, changed if different from current - * volume settings. - * @return the value that was changed or just the current one if - * the same. - */ - private float setVolumeLevel(float value) - { - if (value < MIN_VOLUME_LEVEL) - value = MIN_VOLUME_LEVEL; - else if (value > MAX_VOLUME_LEVEL) - value = MAX_VOLUME_LEVEL; - - if (volumeLevel == value) - return value; - - volumeLevel = value; - fireVolumeChange(); - - /* - * Save the current volume level in the ConfigurationService so that we - * can restore it on the next application run. - */ - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - cfg.setProperty( - this.volumeLevelConfigurationPropertyName, - String.valueOf(volumeLevel)); - } - - float f1 = value / initialVolumeLevel; - - db - = (float) - ((Math.log(((double)f1 != 0.0D) ? f1 : 0.0001D) - / Math.log(10D)) - * 20D); - fireGainEvents(); - - return volumeLevel; - } - - /** - * Mutes current sound. - * - * @param mute mutes/unmutes. - */ - public void setMute(boolean mute) - { - if (this.mute != mute) - { - this.mute = mute; - - fireVolumeChange(); - fireGainEvents(); - } - } - - /** - * Get mute state of sound. - * - * @return mute state of sound. - */ - public boolean getMute() - { - return mute; - } - - /** - * Set the gain in decibels. - * Setting the gain to 0.0 (the default) implies that the audio - * signal is neither amplified nor attenuated. - * Positive values amplify the audio signal and negative values attenuate - * the signal. - * - * @param gain The new gain in dB. - * @return The gain that was actually set. - * - * @see javax.media.GainControl - */ - public float setDB(float gain) - { - if(this.db != gain) - { - this.db = gain; - - float f1 = (float)Math.pow(10D, (double)this.db / 20D); - float volumeLevel = f1 * this.initialVolumeLevel; - - setVolumeLevel(volumeLevel); - } - return this.db; - } - - /** - * Get the current gain set for this object in dB. - * @return The gain in dB. - */ - public float getDB() - { - return this.db; - } - - /** - * Register for gain change update events. - * A GainChangeEvent is posted when the state - * of the GainControl changes. - * - * @param listener The object to deliver events to. - */ - public void addGainChangeListener(GainChangeListener listener) - { - if(listener != null) - { - if(gainChangeListeners == null) - gainChangeListeners = new ArrayList(); - gainChangeListeners.add(listener); - } - } - - /** - * Remove interest in gain change update events. - * - * @param listener The object that has been receiving events. - */ - public void removeGainChangeListener(GainChangeListener listener) - { - if(listener != null && gainChangeListeners != null) - gainChangeListeners.remove(listener); - } - - /** - * Adds a VolumeChangeListener to be informed for any change - * in the volume levels. - * - * @param listener volume change listener. - */ - public void addVolumeChangeListener(VolumeChangeListener listener) - { - synchronized (volumeChangeListeners) - { - Iterator> i - = volumeChangeListeners.iterator(); - boolean contains = false; - - while (i.hasNext()) - { - VolumeChangeListener l = i.next().get(); - - if (l == null) - i.remove(); - else if (l.equals(listener)) - contains = true; - } - if(!contains) - volumeChangeListeners.add( - new WeakReference(listener)); - } - } - - /** - * Removes a VolumeChangeListener. - * - * @param listener the volume change listener to be removed. - */ - public void removeVolumeChangeListener(VolumeChangeListener listener) - { - synchronized (volumeChangeListeners) - { - Iterator> i - = volumeChangeListeners.iterator(); - - while (i.hasNext()) - { - VolumeChangeListener l = i.next().get(); - - if ((l == null) || l.equals(listener)) - i.remove(); - } - } - } - - /** - * Fire a change in volume to interested listeners. - */ - private void fireVolumeChange() - { - List ls; - - synchronized (volumeChangeListeners) - { - Iterator> i - = volumeChangeListeners.iterator(); - - ls - = new ArrayList( - volumeChangeListeners.size()); - while (i.hasNext()) - { - VolumeChangeListener l = i.next().get(); - - if (l == null) - i.remove(); - else - ls.add(l); - } - } - - VolumeChangeEvent changeEvent - = new VolumeChangeEvent(this, volumeLevel, mute); - - for(VolumeChangeListener l : ls) - l.volumeChange(changeEvent); - } - - /** - * Fire events informing for our current state. - */ - private void fireGainEvents() - { - if(gainChangeListeners != null) - { - GainChangeEvent gainchangeevent - = new GainChangeEvent(this, mute, db, volumeLevel); - - for(GainChangeListener gainchangelistener : gainChangeListeners) - gainchangelistener.gainChange(gainchangeevent); - } - } - - /** - * Not used. - * @return null - */ - public Component getControlComponent() - { - return null; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/ArrayIOUtils.java b/src/net/java/sip/communicator/impl/neomedia/ArrayIOUtils.java deleted file mode 100644 index 78bef257e..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/ArrayIOUtils.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -/** - * Implements functionality aiding the reading and writing in little endian of - * byte arrays and primitive types such as short. - * - * @author Lyubomir Marinov - */ -public class ArrayIOUtils -{ - - /** - * Reads a short integer from a specific series of bytes starting the - * reading at a specific offset in it. The difference with - * {@link #readShort(byte[], int)} is that the read short integer is an - * int which has been formed by reading two bytes, not a - * short. - * - * @param input the series of bytes to read the short integer from - * @param inputOffset the offset in input at which the reading of - * the short integer is to start - * @return a short integer in the form of int read from the - * specified series of bytes starting at the specified offset in it - */ - public static int readInt16(byte[] input, int inputOffset) - { - return ((input[inputOffset + 1] << 8) | (input[inputOffset] & 0x00FF)); - } - - /** - * Reads a short integer from a specific series of bytes starting the - * reading at a specific offset in it. - * - * @param input the series of bytes to read the short integer from - * @param inputOffset the offset in input at which the reading of - * the short integer is to start - * @return a short integer in the form of short read from the - * specified series of bytes starting at the specified offset in it - */ - public static short readShort(byte[] input, int inputOffset) - { - return - (short) - ((input[inputOffset + 1] << 8) - | (input[inputOffset] & 0x00FF)); - } - - /** - * Converts a short integer to a series of bytes and writes the result into - * a specific output array of bytes starting the writing at a specific - * offset in it. The difference with {@link #writeShort(short, byte[], int)} - * is that the input is an int and just two bytes of it are - * written. - * - * @param input the short integer to be written out as a series of bytes - * specified as an integer i.e. the value to be converted is contained in - * only two of the four bytes made available by the integer - * @param output the output to receive the conversion of the specified short - * integer to a series of bytes - * @param outputOffset the offset in output at which the writing of - * the result of the conversion is to be started - */ - public static void writeInt16(int input, byte[] output, int outputOffset) - { - output[outputOffset] = (byte) (input & 0xFF); - output[outputOffset + 1] = (byte) (input >> 8); - } - - /** - * Converts a short integer to a series of bytes and writes the result into - * a specific output array of bytes starting the writing at a specific - * offset in it. - * - * @param input the short integer to be written out as a series of bytes - * specified as short - * @param output the output to receive the conversion of the specified short - * integer to a series of bytes - * @param outputOffset the offset in output at which the writing of - * the result of the conversion is to be started - */ - public static void writeShort(short input, byte[] output, int outputOffset) - { - writeInt16(input, output, outputOffset); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/AudioMediaStreamImpl.java b/src/net/java/sip/communicator/impl/neomedia/AudioMediaStreamImpl.java deleted file mode 100644 index 1717c978c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/AudioMediaStreamImpl.java +++ /dev/null @@ -1,484 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.util.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.transform.dtmf.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.event.*; -import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.util.*; - -/** - * Extends MediaStreamImpl in order to provide an implementation of - * AudioMediaStream. - * - * @author Lyubomir Marinov - * @author Emil Ivov - */ -public class AudioMediaStreamImpl - extends MediaStreamImpl - implements AudioMediaStream -{ - - /** - * The Logger used by the AudioMediaStreamImpl class and - * its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(AudioMediaStreamImpl.class); - - /** - * The transformer that we use for sending and receiving DTMF packets. - */ - private DtmfTransformEngine dtmfTransfrmEngine ; - - /** - * List of DTMF listeners; - */ - private List dtmfListeners = new ArrayList(); - - /** - * List of RTP format strings which are supported by SIP Communicator in - * addition to the JMF standard formats. - * - * @see #registerCustomCodecFormats(StreamRTPManager) - */ - private static final AudioFormat[] CUSTOM_CODEC_FORMATS - = new AudioFormat[] - { - /* - * these formats are specific, since RTP uses format numbers - * with no parameters. - */ - new AudioFormat( - Constants.ALAW_RTP, - 8000, - 8, - 1, - Format.NOT_SPECIFIED, - AudioFormat.SIGNED), - new AudioFormat( - Constants.G722_RTP, - 8000, - Format.NOT_SPECIFIED /* sampleSizeInBits */, - 1) - }; - - /** - * The listener that gets notified of changes in the audio level of - * remote conference participants. - */ - private CsrcAudioLevelListener csrcAudioLevelListener = null; - - /** - * Initializes a new AudioMediaStreamImpl instance which will use - * the specified MediaDevice for both capture and playback of audio - * exchanged via the specified StreamConnector. - * - * @param connector the StreamConnector the new instance is to use - * for sending and receiving audio - * @param device the MediaDevice the new instance is to use for - * both capture and playback of audio exchanged via the specified - * StreamConnector - * @param srtpControl a control which is already created, used to control - * the srtp operations. - */ - public AudioMediaStreamImpl(StreamConnector connector, - MediaDevice device, - SrtpControl srtpControl) - { - super(connector, device, srtpControl); - - if(logger.isTraceEnabled()) - logger.trace("Created Audio Stream with hashCode " + hashCode()); - } - - /** - * Performs any optional configuration on the BufferControl of the - * specified RTPManager which is to be used as the - * RTPManager of this MediaStreamImpl. - * - * @param rtpManager the RTPManager which is to be used by this - * MediaStreamImpl - * @param bufferControl the BufferControl of rtpManager on - * which any optional configuration is to be performed - */ - @Override - protected void configureRTPManagerBufferControl( - StreamRTPManager rtpManager, - BufferControl bufferControl) - { - /* - * It appears that if we don't do this managers don't play. You can try - * some other buffer size to see if you can get better smoothness. - */ - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - long bufferLength = 100; - - if (cfg != null) - { - String bufferLengthStr - = cfg.getString(PROPERTY_NAME_RECEIVE_BUFFER_LENGTH); - - try - { - if ((bufferLengthStr != null) && (bufferLengthStr.length() > 0)) - bufferLength = Long.parseLong(bufferLengthStr); - } - catch (NumberFormatException nfe) - { - logger.warn( - bufferLengthStr - + " is not a valid receive buffer length/long value", - nfe); - } - } - - bufferLength = bufferControl.setBufferLength(bufferLength); - if (logger.isTraceEnabled()) - logger.trace("Set receiver buffer length to " + bufferLength); - - bufferControl.setEnabledThreshold(true); - bufferControl.setMinimumThreshold(100); - } - - /** - * A stub that allows audio oriented streams to create and keep a reference - * to a DtmfTransformEngine. - * - * @return a DtmfTransformEngine if this is an audio oriented - * stream and null otherwise. - */ - @Override - protected DtmfTransformEngine createDtmfTransformEngine() - { - if(this.dtmfTransfrmEngine == null) - this.dtmfTransfrmEngine = new DtmfTransformEngine(this); - - return this.dtmfTransfrmEngine; - } - - /** - * Adds a DTMFListener to this AudioMediaStream which is - * to receive notifications when the remote party starts sending DTMF tones - * to us. - * - * @param listener the DTMFListener to register for notifications - * about the remote party starting sending of DTM tones to this - * AudioMediaStream - * @see AudioMediaStream#addDTMFListener(DTMFListener) - */ - public void addDTMFListener(DTMFListener listener) - { - if(!dtmfListeners.contains(listener)) - { - dtmfListeners.add(listener); - } - } - - /** - * Sets listener as the SimpleAudioLevelListener - * registered to receive notifications from our device session for changes - * in the levels of the party that's at the other end of this stream. - * - * @param listener the SimpleAudioLevelListener that we'd like to - * register or null if we want to stop stream audio level - * measurements. - */ - public void setStreamAudioLevelListener(SimpleAudioLevelListener listener) - { - getDeviceSession().setStreamAudioLevelListener(listener); - } - - /** - * Registers listener as the CsrcAudioLevelListener that - * will receive notifications for changes in the levels of conference - * participants that the remote party could be mixing. - * - * @param listener the CsrcAudioLevelListener that we'd like to - * register or null if we'd like to stop receiving notifications. - */ - public void setCsrcAudioLevelListener(CsrcAudioLevelListener listener) - { - this.csrcAudioLevelListener = listener; - } - - /** - * Registers {@link #CUSTOM_CODEC_FORMATS} with a specific - * RTPManager. - * - * @param rtpManager the RTPManager to register - * {@link #CUSTOM_CODEC_FORMATS} with - * @see MediaStreamImpl#registerCustomCodecFormats(StreamRTPManager) - */ - @Override - protected void registerCustomCodecFormats(StreamRTPManager rtpManager) - { - super.registerCustomCodecFormats(rtpManager); - - for (AudioFormat format : CUSTOM_CODEC_FORMATS) - { - if (logger.isDebugEnabled()) - logger.debug("registering format " + format + - " with RTP manager"); - - /* - * NOTE (mkoch@rowa.de): com.sun.media.rtp.RtpSessionMgr.addFormat - * leaks memory, since it stores the Format in a static Vector. - * AFAIK there is no easy way around it, but the memory impact - * should not be too bad. - */ - rtpManager.addFormat( format, - MediaUtils.getRTPPayloadType( - format.getEncoding(), format.getSampleRate())); - } - } - - /** - * Removes listener from the list of DTMFListeners - * registered with this AudioMediaStream to receive notifications - * about incoming DTMF tones. - * - * @param listener the DTMFListener to no longer be notified by - * this AudioMediaStream about incoming DTMF tones - * @see AudioMediaStream#removeDTMFListener(DTMFListener) - */ - public void removeDTMFListener(DTMFListener listener) - { - dtmfListeners.remove(listener); - } - - /** - * Starts sending the specified DTMFTone until the - * stopSendingDTMF() method is called (Excepts for INBAND DTMF, - * which stops by itself this is why where there is no need to call the - * stopSendingDTMF). Callers should keep in mind the fact that calling this - * method would most likely interrupt all audio transmission until the - * corresponding stop method is called. Also, calling this method - * successively without invoking the corresponding stop method between the - * calls will simply replace the DTMFTone from the first call with - * that from the second. - * - * @param tone the DTMFTone to start sending. - * @param dtmfMethod The kind of DTMF used (RTP, SIP-INOF or INBAND). - * - * @see AudioMediaStream#startSendingDTMF(DTMFTone, DTMFMethod) - */ - public void startSendingDTMF(DTMFTone tone, DTMFMethod dtmfMethod) - { - switch(dtmfMethod) - { - case RTP_DTMF: - if(dtmfTransfrmEngine != null) - { - DTMFRtpTone t = DTMFRtpTone.mapTone(tone); - if(t != null) - { - dtmfTransfrmEngine.startSending(t); - } - } - break; - case SIP_INFO_DTMF: - // This kind of DTMF is not manged directly by the - // OperationSetDTMFSipImpl. - break; - case INBAND_DTMF: - MediaDeviceSession deviceSession = getDeviceSession(); - - if (deviceSession != null) - { - deviceSession.addDTMF(DTMFInbandTone.mapTone(tone)); - } - break; - } - } - - /** - * Interrupts transmission of a DTMFTone started with the - * startSendingDTMF() method. Has no effect if no tone is currently - * being sent. - * - * @param dtmfMethod The kind of DTMF used (RTP, SIP-INOF or INBAND). - * - * @see AudioMediaStream#stopSendingDTMF(DTMFMethod) - */ - public void stopSendingDTMF(DTMFMethod dtmfMethod) - { - switch(dtmfMethod) - { - case RTP_DTMF: - if(dtmfTransfrmEngine != null) - { - dtmfTransfrmEngine.stopSendingDTMF(); - } - break; - case SIP_INFO_DTMF: - // The SIP-INFO DTMF is not manged directly by the - // OperationSetDTMFSipImpl. - break; - case INBAND_DTMF: - // The INBAND DTMF is send by impluse of constant duration and - // does not need to be stopped explecitely. - break; - } - } - - /** - * In addition to calling - * {@link MediaStreamImpl#addRTPExtension(byte, RTPExtension)} - * this method enables sending of CSRC audio levels. The reason we are - * doing this here rather than in the super class is that CSRC levels only - * make sense for audio streams so we don't want them enabled in any other - * kind. - * - * @param extensionID the ID assigned to rtpExtension for the - * lifetime of this stream. - * @param rtpExtension the RTPExtension that is being added to this stream. - */ - @Override - public void addRTPExtension(byte extensionID, RTPExtension rtpExtension) - { - super.addRTPExtension(extensionID, rtpExtension); - - if (RTPExtension.CSRC_AUDIO_LEVEL_URN.equals( - rtpExtension.getURI().toString())) - { - getCsrcEngine().setCsrcAudioLevelAudioLevelExtensionID( - extensionID, - rtpExtension.getDirection()); - } - } - - /** - * Sets listener as the SimpleAudioLevelListener - * registered to receive notifications from our device session for changes - * in the levels of the audio that this stream is sending out. - * - * @param listener the SimpleAudioLevelListener that we'd like to - * register or null if we want to stop local audio level - * measurements. - */ - public void setLocalUserAudioLevelListener( - SimpleAudioLevelListener listener) - { - getDeviceSession().setLocalUserAudioLevelListener(listener); - } - - /** - * Returns the MediaDeviceSession associated with this stream - * after first casting it to AudioMediaDeviceSession since this is, - * after all, an AudioMediaStreamImpl. - * - * @return the AudioMediaDeviceSession associated with this stream. - */ - @Override - public AudioMediaDeviceSession getDeviceSession() - { - return (AudioMediaDeviceSession)super.getDeviceSession(); - } - - /** - * Returns the last audio level that was measured by the underlying device - * session for the specified ssrc (where ssrc could also - * correspond to our local sync source identifier). - * - * @param ssrc the SSRC ID whose last measured audio level we'd like to - * retrieve. - * - * @return the audio level that was last measured for the specified - * ssrc or -1 if no level has been cached for that ID. - */ - public int getLastMeasuredAudioLevel(long ssrc) - { - AudioMediaDeviceSession devSession = getDeviceSession(); - - if (devSession == null) - return -1; - - if ( ssrc == getLocalSourceID() ) - return devSession.getLastMeasuredLocalUserAudioLevel(); - else - return devSession.getLastMeasuredAudioLevel(ssrc); - } - - /** - * Delivers the audioLevels map to whoever's interested. This - * method is meant for use primarily by the transform engine handling - * incoming RTP packets (currently CsrcTransformEngine). - * - * @param audioLevels a array mapping CSRC IDs to audio levels in - * consecutive elements. - */ - public void fireConferenceAudioLevelEvent(long[] audioLevels) - { - CsrcAudioLevelListener csrcAudioLevelListener - = this.csrcAudioLevelListener; - - if (csrcAudioLevelListener != null) - csrcAudioLevelListener.audioLevelsReceived(audioLevels); - } - - /** - * Delivers the DTMF tones. This - * method is meant for use primarily by the transform engine handling - * incoming RTP packets (currently DtmfTransformEngine). - * - * @param tone the new tone - * @param end is end or start of tone. - */ - public void fireDTMFEvent(DTMFRtpTone tone, boolean end) - { - Iterator iter = dtmfListeners.iterator(); - DTMFToneEvent ev = new DTMFToneEvent(this, tone); - while (iter.hasNext()) - { - DTMFListener listener = iter.next(); - if(end) - listener.dtmfToneReceptionEnded(ev); - else - listener.dtmfToneReceptionStarted(ev); - } - } - - /** - * Releases the resources allocated by this instance in the course of its - * execution and prepares it to be garbage collected. - * - * @see MediaStream#close() - */ - @Override - public void close() - { - super.close(); - - if(dtmfTransfrmEngine != null) - { - dtmfTransfrmEngine = null; - } - } - - /** - * The priority of the audio is 3, which is meant to be higher than - * other threads and higher than the video one. - * @return audio priority. - */ - @Override - protected int getPriority() - { - return 3; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/CallRecordingConfigForm.java b/src/net/java/sip/communicator/impl/neomedia/CallRecordingConfigForm.java index 3e202666e..da76fa1fd 100644 --- a/src/net/java/sip/communicator/impl/neomedia/CallRecordingConfigForm.java +++ b/src/net/java/sip/communicator/impl/neomedia/CallRecordingConfigForm.java @@ -12,12 +12,15 @@ import javax.swing.*; import javax.swing.event.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.swing.*; +import org.jitsi.impl.neomedia.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.*; + /** * The saved calls management and configuration form. * diff --git a/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java b/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java index f5128da0d..1130c82bb 100644 --- a/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java +++ b/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java @@ -16,8 +16,8 @@ import javax.swing.*; import javax.swing.event.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.*; +import org.jitsi.impl.neomedia.device.*; +import org.jitsi.service.neomedia.*; /** * @author Lubomir Marinov diff --git a/src/net/java/sip/communicator/impl/neomedia/EncodingConfigurationTableModel.java b/src/net/java/sip/communicator/impl/neomedia/EncodingConfigurationTableModel.java index cf8a763e2..fc2cf2e35 100644 --- a/src/net/java/sip/communicator/impl/neomedia/EncodingConfigurationTableModel.java +++ b/src/net/java/sip/communicator/impl/neomedia/EncodingConfigurationTableModel.java @@ -10,10 +10,11 @@ import javax.swing.table.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.format.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.format.*; +import org.jitsi.impl.neomedia.*; +import org.jitsi.impl.neomedia.codec.*; +import org.jitsi.impl.neomedia.format.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.format.*; /** * Implements {@link TableModel} for {@link EncodingConfiguration}. diff --git a/src/net/java/sip/communicator/impl/neomedia/MediaConfiguration.java b/src/net/java/sip/communicator/impl/neomedia/MediaConfiguration.java index f8bae0453..06bd30765 100644 --- a/src/net/java/sip/communicator/impl/neomedia/MediaConfiguration.java +++ b/src/net/java/sip/communicator/impl/neomedia/MediaConfiguration.java @@ -16,14 +16,18 @@ import javax.swing.event.*; import javax.swing.table.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.event.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import net.java.sip.communicator.util.swing.TransparentPanel; + +import org.jitsi.impl.neomedia.*; +import org.jitsi.impl.neomedia.device.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.service.neomedia.event.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.swing.*; /** * @author Lyubomir Marinov diff --git a/src/net/java/sip/communicator/impl/neomedia/MediaServiceImpl.java b/src/net/java/sip/communicator/impl/neomedia/MediaServiceImpl.java deleted file mode 100644 index 7bf29cee3..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/MediaServiceImpl.java +++ /dev/null @@ -1,1496 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.awt.*; -import java.awt.event.*; -import java.beans.*; -import java.io.*; -import java.util.*; -import java.util.List; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; -import javax.media.protocol.*; -import javax.swing.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.format.*; -import net.java.sip.communicator.impl.neomedia.transform.sdes.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.event.*; -import net.java.sip.communicator.util.swing.*; - -import org.json.*; - -import com.sun.media.util.*; - -/** - * Implements MediaService for JMF. - * - * @author Lyubomir Marinov - * @author Dmitri Melnikov - */ -public class MediaServiceImpl - extends PropertyChangeNotifier - implements MediaService -{ - /** - * The Logger used by the MediaServiceImpl class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(MediaServiceImpl.class); - - /** - * The name of the boolean ConfigurationService property - * which indicates whether the detection of audio CaptureDevices is - * to be disabled. The default value is false i.e. the audio - * CaptureDevices are detected. - */ - public static final String DISABLE_AUDIO_SUPPORT_PNAME - = "net.java.sip.communicator.service.media.DISABLE_AUDIO_SUPPORT"; - - /** - * The name of the boolean ConfigurationService property - * which indicates whether the detection of video CaptureDevices is - * to be disabled. The default value is false i.e. the video - * CaptureDevices are detected. - */ - public static final String DISABLE_VIDEO_SUPPORT_PNAME - = "net.java.sip.communicator.service.media.DISABLE_VIDEO_SUPPORT"; - - /** - * The prefix of the property names the values of which specify the dynamic - * payload type preferences. - */ - private static final String DYNAMIC_PAYLOAD_TYPE_PREFERENCES_PNAME_PREFIX - = "net.java.sip.communicator.impl.neomedia.dynamicPayloadTypePreferences"; - - /** - * The value of the devices property of MediaServiceImpl - * when no MediaDevices are available. Explicitly defined in order - * to reduce unnecessary allocations. - */ - private static final List EMPTY_DEVICES - = Collections.emptyList(); - - /** - * The name of the System boolean property which specifies whether - * the loading of the JMF/FMJ Registry is to be disabled. - */ - private static final String JMF_REGISTRY_DISABLE_LOAD - = "net.sf.fmj.utility.JmfRegistry.disableLoad"; - - /** - * The indicator which determines whether the loading of the JMF/FMJ - * Registry is disabled. - */ - private static boolean jmfRegistryDisableLoad; - - /** - * The indicator which determined whether - * {@link #postInitializeOnce(MediaServiceImpl)} has been executed in order - * to perform one-time initialization after initializing the first instance - * of MediaServiceImpl. - */ - private static boolean postInitializeOnce; - - /** - * The CaptureDevice user choices such as the default audio and - * video capture devices. - */ - private final DeviceConfiguration deviceConfiguration - = new DeviceConfiguration(); - - /** - * The PropertyChangeListener which listens to - * {@link #deviceConfiguration}. - */ - private final PropertyChangeListener - deviceConfigurationPropertyChangeListener - = new PropertyChangeListener() - { - public void propertyChange(PropertyChangeEvent event) - { - deviceConfigurationPropertyChange(event); - } - }; - - /** - * The list of audio MediaDevices reported by this instance when - * its {@link MediaService#getDevices(MediaType, MediaUseCase)} method is - * called with an argument {@link MediaType#AUDIO}. - */ - private final List audioDevices - = new ArrayList(); - - /** - * The format-related user choices such as the enabled and disabled codecs - * and the order of their preference. - */ - private final EncodingConfiguration encodingConfiguration - = new EncodingConfiguration(); - - /** - * The MediaFormatFactory through which MediaFormat - * instances may be created for the purposes of working with the - * MediaStreams created by this MediaService. - */ - private MediaFormatFactory formatFactory; - - /** - * The one and only MediaDevice instance with - * MediaDirection not allowing sending and MediaType equal - * to AUDIO. - */ - private MediaDevice nonSendAudioDevice; - - /** - * The one and only MediaDevice instance with - * MediaDirection not allowing sending and MediaType equal - * to VIDEO. - */ - private MediaDevice nonSendVideoDevice; - - /** - * The list of video MediaDevices reported by this instance when - * its {@link MediaService#getDevices(MediaType, MediaUseCase)} method is - * called with an argument {@link MediaType#VIDEO}. - */ - private final List videoDevices - = new ArrayList(); - - /** - * A {@link Map} that binds indicates whatever preferences this - * media service implementation may have for the RTP payload type numbers - * that get dynamically assigned to {@link MediaFormat}s with no static - * payload type. The method is useful for formats such as "telephone-event" - * for example that is statically assigned the 101 payload type by some - * legacy systems. Signalling protocol implementations such as SIP and XMPP - * should make sure that, whenever this is possible, they assign to formats - * the dynamic payload type returned in this {@link Map}. - */ - private static Map dynamicPayloadTypePreferences; - - /** - * The volume control of the media service playback. - */ - private static VolumeControl outputVolumeControl; - - /** - * The volume control of the media service capture. - */ - private static VolumeControl inputVolumeControl; - - /** - * Listeners interested in Recorder events without the need to - * have access to their instances. - */ - private final List recorderListeners = - new ArrayList(); - - static - { - setupFMJ(); - } - - /** - * Initializes a new MediaServiceImpl instance. - */ - public MediaServiceImpl() - { - /* - * XXX The deviceConfiguration is initialized and referenced by this - * instance so adding deviceConfigurationPropertyChangeListener does not - * need a matching removal. - */ - deviceConfiguration.addPropertyChangeListener( - deviceConfigurationPropertyChangeListener); - - /* - * Perform one-time initialization after initializing the first instance - * of MediaServiceImpl. - */ - synchronized (MediaServiceImpl.class) - { - if (!postInitializeOnce) - { - postInitializeOnce = true; - postInitializeOnce(this); - } - } - } - - /** - * Create a MediaStream which will use a specific - * MediaDevice for capture and playback of media. The new instance - * will not have a StreamConnector at the time of its construction - * and a StreamConnector will be specified later on in order to - * enable the new instance to send and receive media. - * - * @param device the MediaDevice to be used by the new instance for - * capture and playback of media - * @return a newly-created MediaStream which will use the specified - * device for capture and playback of media - * @see MediaService#createMediaStream(MediaDevice) - */ - public MediaStream createMediaStream(MediaDevice device) - { - return createMediaStream(null, device); - } - - /** - * Creates a new MediaStream instance which will use the specified - * MediaDevice for both capture and playback of media exchanged - * via the specified StreamConnector. - * - * @param connector the StreamConnector that the new - * MediaStream instance is to use for sending and receiving media - * @param device the MediaDevice that the new MediaStream - * instance is to use for both capture and playback of media exchanged via - * the specified connector - * @return a new MediaStream instance - * @see MediaService#createMediaStream(StreamConnector, MediaDevice) - */ - public MediaStream createMediaStream( - StreamConnector connector, - MediaDevice device) - { - return createMediaStream(connector, device, null); - } - - /** - * Creates a new MediaStream instance which will use the specified - * MediaDevice for both capture and playback of media exchanged - * via the specified StreamConnector. - * - * @param connector the StreamConnector that the new - * MediaStream instance is to use for sending and receiving media - * @param device the MediaDevice that the new MediaStream - * instance is to use for both capture and playback of media exchanged via - * the specified connector - * @param srtpControl a control which is already created, used to control - * the srtp operations. - * - * @return a new MediaStream instance - * @see MediaService#createMediaStream(StreamConnector, MediaDevice) - */ - public MediaStream createMediaStream( - StreamConnector connector, - MediaDevice device, - SrtpControl srtpControl) - { - switch (device.getMediaType()) - { - case AUDIO: - return new AudioMediaStreamImpl(connector, device, srtpControl); - case VIDEO: - return new VideoMediaStreamImpl(connector, device, srtpControl); - default: - return null; - } - } - - /** - * Creates a new MediaDevice which uses a specific - * MediaDevice to capture and play back media and performs mixing - * of the captured media and the media played back by any other users of the - * returned MediaDevice. For the AUDIO MediaType, - * the returned device is commonly referred to as an audio mixer. The - * MediaType of the returned MediaDevice is the same as - * the MediaType of the specified device. - * - * @param device the MediaDevice which is to be used by the - * returned MediaDevice to actually capture and play back media - * @return a new MediaDevice instance which uses device to - * capture and play back media and performs mixing of the captured media and - * the media played back by any other users of the returned - * MediaDevice instance - * @see MediaService#createMixer(MediaDevice) - */ - public MediaDevice createMixer(MediaDevice device) - { - switch (device.getMediaType()) - { - case AUDIO: - return new AudioMixerMediaDevice((AudioMediaDeviceImpl) device); - case VIDEO: - return new VideoTranslatorMediaDevice((MediaDeviceImpl) device); - default: - /* - * TODO If we do not support mixing, should we return null or rather - * a MediaDevice with INACTIVE MediaDirection? - */ - return null; - } - } - - /** - * Gets the default MediaDevice for the specified - * MediaType. - * - * @param mediaType a MediaType value indicating the type of media - * to be handled by the MediaDevice to be obtained - * @param useCase the MediaUseCase to obtain the - * MediaDevice list for - * @return the default MediaDevice for the specified - * mediaType if such a MediaDevice exists; otherwise, - * null - * @see MediaService#getDefaultDevice(MediaType, MediaUseCase) - */ - public MediaDevice getDefaultDevice( - MediaType mediaType, - MediaUseCase useCase) - { - CaptureDeviceInfo captureDeviceInfo; - - switch (mediaType) - { - case AUDIO: - captureDeviceInfo - = getDeviceConfiguration().getAudioCaptureDevice(); - break; - case VIDEO: - captureDeviceInfo - = getDeviceConfiguration().getVideoCaptureDevice(useCase); - break; - default: - captureDeviceInfo = null; - break; - } - - MediaDevice defaultDevice = null; - - if (captureDeviceInfo != null) - { - for (MediaDevice device : getDevices(mediaType, useCase)) - { - if ((device instanceof MediaDeviceImpl) - && captureDeviceInfo.equals( - ((MediaDeviceImpl) device) - .getCaptureDeviceInfo())) - { - defaultDevice = device; - break; - } - } - } - if (defaultDevice == null) - { - switch (mediaType) - { - case AUDIO: - defaultDevice = getNonSendAudioDevice(); - break; - case VIDEO: - defaultDevice = getNonSendVideoDevice(); - break; - default: - /* - * There is no MediaDevice with direction which does not allow - * sending and mediaType other than AUDIO and VIDEO. - */ - break; - } - } - - /* - * Don't use the device in case the user has disabled all codecs for - * that kind of media. - */ - if ((defaultDevice != null) - && (defaultDevice.getSupportedFormats().isEmpty())) - { - defaultDevice = null; - } - return defaultDevice; - } - - /** - * Gets the CaptureDevice user choices such as the default audio - * and video capture devices. - * - * @return the CaptureDevice user choices such as the default audio - * and video capture devices. - */ - public DeviceConfiguration getDeviceConfiguration() - { - return deviceConfiguration; - } - - /** - * Gets a list of the MediaDevices known to this - * MediaService and handling the specified MediaType. - * - * @param mediaType the MediaType to obtain the - * MediaDevice list for - * @param useCase the MediaUseCase to obtain the - * MediaDevice list for - * @return a new List of MediaDevices known to this - * MediaService and handling the specified MediaType. The - * returned List is a copy of the internal storage and, - * consequently, modifications to it do not affect this instance. Despite - * the fact that a new List instance is returned by each call to - * this method, the MediaDevice instances are the same if they are - * still known to this MediaService to be available. - * @see MediaService#getDevices(MediaType, MediaUseCase) - */ - public List getDevices( - MediaType mediaType, - MediaUseCase useCase) - { - List cdis; - List privateDevices; - - if (MediaType.VIDEO.equals(mediaType)) - { - /* - * In case a video capture device has been added to or removed from - * system (i.e. webcam, monitor, etc.), rescan the video capture - * devices. - */ - DeviceSystem.initializeDeviceSystems(MediaType.VIDEO); - } - - switch (mediaType) - { - case AUDIO: - cdis = getDeviceConfiguration().getAvailableAudioCaptureDevices(); - privateDevices = audioDevices; - break; - case VIDEO: - cdis - = getDeviceConfiguration().getAvailableVideoCaptureDevices( - useCase); - privateDevices = videoDevices; - break; - default: - /* - * MediaService does not understand MediaTypes other than AUDIO and - * VIDEO. - */ - return EMPTY_DEVICES; - } - - List publicDevices; - - synchronized (privateDevices) - { - if ((cdis == null) - || (cdis.size() <= 0)) - privateDevices.clear(); - else - { - Iterator deviceIter - = privateDevices.iterator(); - - while (deviceIter.hasNext()) - { - Iterator cdiIter = cdis.iterator(); - CaptureDeviceInfo captureDeviceInfo - = deviceIter.next().getCaptureDeviceInfo(); - boolean deviceIsFound = false; - - while (cdiIter.hasNext()) - { - if (captureDeviceInfo.equals(cdiIter.next())) - { - deviceIsFound = true; - cdiIter.remove(); - break; - } - } - if (!deviceIsFound) - deviceIter.remove(); - } - - for (CaptureDeviceInfo cdi : cdis) - { - if (cdi == null) - continue; - - MediaDeviceImpl device; - - switch (mediaType) - { - case AUDIO: - device = new AudioMediaDeviceImpl(cdi); - break; - case VIDEO: - device - = new MediaDeviceImpl(cdi, mediaType); - break; - default: - device = null; - break; - } - if (device != null) - privateDevices.add(device); - } - } - - publicDevices = new ArrayList(privateDevices); - } - - /* - * If there are no MediaDevice instances of the specified mediaType, - * make sure that there is at least one MediaDevice which does not allow - * sending. - */ - if (publicDevices.isEmpty()) - { - MediaDevice nonSendDevice; - - switch (mediaType) - { - case AUDIO: - nonSendDevice = getNonSendAudioDevice(); - break; - case VIDEO: - nonSendDevice = getNonSendVideoDevice(); - break; - default: - /* - * There is no MediaDevice with direction not allowing sending - * and mediaType other than AUDIO and VIDEO. - */ - nonSendDevice = null; - break; - } - if (nonSendDevice != null) - publicDevices.add(nonSendDevice); - } - - return publicDevices; - } - - /** - * Gets the format-related user choices such as the enabled and disabled - * codecs and the order of their preference. - * - * @return the format-related user choices such as the enabled and disabled - * codecs and the order of their preference - */ - public EncodingConfiguration getEncodingConfiguration() - { - return encodingConfiguration; - } - - /** - * Gets the MediaFormatFactory through which MediaFormat - * instances may be created for the purposes of working with the - * MediaStreams created by this MediaService. - * - * @return the MediaFormatFactory through which - * MediaFormat instances may be created for the purposes of working - * with the MediaStreams created by this MediaService - * @see MediaService#getFormatFactory() - */ - public MediaFormatFactory getFormatFactory() - { - if (formatFactory == null) - formatFactory = new MediaFormatFactoryImpl(); - return formatFactory; - } - - /** - * Gets the one and only MediaDevice instance with - * MediaDirection not allowing sending and MediaType equal - * to AUDIO. - * - * @return the one and only MediaDevice instance with - * MediaDirection not allowing sending and MediaType equal - * to AUDIO - */ - private MediaDevice getNonSendAudioDevice() - { - if (nonSendAudioDevice == null) - nonSendAudioDevice = new AudioMediaDeviceImpl(); - return nonSendAudioDevice; - } - - /** - * Gets the one and only MediaDevice instance with - * MediaDirection not allowing sending and MediaType equal - * to VIDEO. - * - * @return the one and only MediaDevice instance with - * MediaDirection not allowing sending and MediaType equal - * to VIDEO - */ - private MediaDevice getNonSendVideoDevice() - { - if (nonSendVideoDevice == null) - nonSendVideoDevice = new MediaDeviceImpl(MediaType.VIDEO); - return nonSendVideoDevice; - } - - /** - * Initializes a new ZrtpControl instance which is to control all - * ZRTP options. - * - * @return a new ZrtpControl instance which is to control all ZRTP - * options - */ - public ZrtpControl createZrtpControl() - { - return new ZrtpControlImpl(); - } - - /** - * Initializes a new SDesControl instance which is to control all - * SDes options. - * - * @return a new SDesControl instance which is to control all SDes - * options - */ - public SDesControl createSDesControl() - { - return new SDesControlImpl(); - } - - /** - * Gets the VolumeControl which controls the volume level of audio - * output/playback. - * - * @return the VolumeControl which controls the volume level of - * audio output/playback - * @see MediaService#getOutputVolumeControl() - */ - public VolumeControl getOutputVolumeControl() - { - if (outputVolumeControl == null) - { - outputVolumeControl - = new AbstractVolumeControl( - VolumeControl.PLAYBACK_VOLUME_LEVEL_PROPERTY_NAME); - } - return outputVolumeControl; - } - - /** - * Gets the VolumeControl which controls the volume level of audio - * input/capture. - * - * @return the VolumeControl which controls the volume level of - * audio input/capture - * @see MediaService#getInputVolumeControl() - */ - public VolumeControl getInputVolumeControl() - { - if (inputVolumeControl == null) - { - inputVolumeControl - = new AbstractVolumeControl( - VolumeControl.CAPTURE_VOLUME_LEVEL_PROPERTY_NAME); - } - return inputVolumeControl; - } - - /** - * Get available screens. - * - * @return screens - */ - public List getAvailableScreenDevices() - { - ScreenDevice screens[] = ScreenDeviceImpl.getAvailableScreenDevices(); - List screenList; - - if ((screens != null) && (screens.length != 0)) - screenList = new ArrayList(Arrays.asList(screens)); - else - screenList = Collections.emptyList(); - return screenList; - } - - /** - * Get default screen device. - * - * @return default screen device - */ - public ScreenDevice getDefaultScreenDevice() - { - List screens = getAvailableScreenDevices(); - int width = 0; - int height = 0; - ScreenDevice best = null; - - for (ScreenDevice screen : screens) - { - java.awt.Dimension res = screen.getSize(); - - if ((res != null) && ((width < res.width) || (height < res.height))) - { - width = res.width; - height = res.height; - best = screen; - } - } - return best; - } - - /** - * Creates a new Recorder instance that can be used to record a - * call which captures and plays back media using a specific - * MediaDevice. - * - * @param device the MediaDevice which is used for media capture - * and playback by the call to be recorded - * @return a new Recorder instance that can be used to record a - * call which captures and plays back media using the specified - * MediaDevice - * @see MediaService#createRecorder(MediaDevice) - */ - public Recorder createRecorder(MediaDevice device) - { - if (device instanceof AudioMixerMediaDevice) - return new RecorderImpl((AudioMixerMediaDevice) device); - else - return null; - } - - /** - * Returns a {@link Map} that binds indicates whatever preferences this - * media service implementation may have for the RTP payload type numbers - * that get dynamically assigned to {@link MediaFormat}s with no static - * payload type. The method is useful for formats such as "telephone-event" - * for example that is statically assigned the 101 payload type by some - * legacy systems. Signaling protocol implementations such as SIP and XMPP - * should make sure that, whenever this is possible, they assign to formats - * the dynamic payload type returned in this {@link Map}. - * - * @return a {@link Map} binding some formats to a preferred dynamic RTP - * payload type number. - */ - public Map getDynamicPayloadTypePreferences() - { - if(dynamicPayloadTypePreferences == null) - { - dynamicPayloadTypePreferences = new HashMap(); - - /* - * Set the dynamicPayloadTypePreferences to their default values. If - * the user chooses to override them through the - * ConfigurationService, they will be overwritten later on. - */ - MediaFormat telephoneEvent - = MediaUtils.getMediaFormat("telephone-event", 8000); - if (telephoneEvent != null) - dynamicPayloadTypePreferences.put(telephoneEvent, (byte) 101); - - MediaFormat h264 - = MediaUtils.getMediaFormat( - "H264", - VideoMediaFormatImpl.DEFAULT_CLOCK_RATE); - if (h264 != null) - dynamicPayloadTypePreferences.put(h264, (byte) 99); - - /* - * Try to load dynamicPayloadTypePreferences from the - * ConfigurationService. - */ - ConfigurationService cfg - = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - String prefix = DYNAMIC_PAYLOAD_TYPE_PREFERENCES_PNAME_PREFIX; - List propertyNames - = cfg.getPropertyNamesByPrefix(prefix, true); - - for (String propertyName : propertyNames) - { - /* - * The dynamic payload type is the name of the property name - * and the format which prefers it is the property value. - */ - byte dynamicPayloadTypePreference = 0; - Throwable exception = null; - - try - { - dynamicPayloadTypePreference - = Byte.parseByte( - propertyName.substring( - prefix.length() + 1)); - } - catch (IndexOutOfBoundsException ioobe) - { - exception = ioobe; - } - catch (NumberFormatException nfe) - { - exception = nfe; - } - if (exception != null) - { - logger.warn( - "Ignoring dynamic payload type preference" - + " which could not be parsed: " - + propertyName, - exception); - continue; - } - - String source = cfg.getString(propertyName); - - if ((source != null) && (source.length() != 0)) - { - try - { - JSONObject json = new JSONObject(source); - String encoding - = json.getString( - MediaFormatImpl.ENCODING_PNAME); - int clockRate - = json.getInt(MediaFormatImpl.CLOCK_RATE_PNAME); - Map fmtps - = new HashMap(); - - if (json.has( - MediaFormatImpl.FORMAT_PARAMETERS_PNAME)) - { - JSONObject jsonFmtps - = json.getJSONObject( - MediaFormatImpl - .FORMAT_PARAMETERS_PNAME); - Iterator jsonFmtpsIter = jsonFmtps.keys(); - - while (jsonFmtpsIter.hasNext()) - { - String key - = jsonFmtpsIter.next().toString(); - String value = jsonFmtps.getString(key); - - fmtps.put(key, value); - } - } - - MediaFormat mediaFormat - = MediaUtils.getMediaFormat( - encoding, clockRate, - fmtps); - - if (mediaFormat != null) - { - dynamicPayloadTypePreferences.put( - mediaFormat, - dynamicPayloadTypePreference); - } - } - catch (JSONException jsone) - { - logger.warn( - "Ignoring dynamic payload type preference" - + " which could not be parsed: " - + source, - jsone); - } - } - } - } - } - return dynamicPayloadTypePreferences; - } - - /** - * Creates a preview component for the specified device(video device) used - * to show video preview from that device. - * - * @param device the video device - * @param preferredWidth the width we prefer for the component - * @param preferredHeight the height we prefer for the component - * @return the preview component. - */ - public Object getVideoPreviewComponent( - MediaDevice device, - int preferredWidth, int preferredHeight) - { - ResourceManagementService resources = NeomediaActivator.getResources(); - String noPreviewText - = (resources == null) - ? "" - : resources.getI18NString("impl.media.configform.NO_PREVIEW"); - JLabel noPreview = new JLabel(noPreviewText); - - noPreview.setHorizontalAlignment(SwingConstants.CENTER); - noPreview.setVerticalAlignment(SwingConstants.CENTER); - - final JComponent videoContainer = new VideoContainer(noPreview, false); - - if ((preferredWidth > 0) && (preferredHeight > 0)) - videoContainer.setPreferredSize( - new Dimension(preferredWidth, preferredHeight)); - - try - { - CaptureDeviceInfo captureDeviceInfo; - - if ((device != null) && - ((captureDeviceInfo - = ((MediaDeviceImpl)device) - .getCaptureDeviceInfo()) - != null)) - { - DataSource dataSource - = Manager.createDataSource(captureDeviceInfo.getLocator()); - - /* - * Don't let the size be uselessly small just because the - * videoContainer has too small a preferred size. - */ - if ((preferredWidth < 128) || (preferredHeight < 96)) - { - preferredWidth = 128; - preferredHeight = 96; - } - VideoMediaStreamImpl.selectVideoSize( - dataSource, - preferredWidth, preferredHeight); - - // A Player is documented to be created on a connected - // DataSource. - dataSource.connect(); - - Processor player = Manager.createProcessor(dataSource); - final MediaLocator locator = dataSource.getLocator(); - - player.addControllerListener(new ControllerListener() - { - public void controllerUpdate(ControllerEvent event) - { - controllerUpdateForPreview( - event, - videoContainer, - locator); - } - }); - player.configure(); - } - } - catch (Throwable t) - { - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - logger.error("Failed to create video preview", t); - } - - return videoContainer; - } - - /** - * Listens and shows the video in the video container when needed. - * @param event the event when player has ready visual component. - * @param videoContainer the container. - * @param locator input DataSource locator - */ - private static void controllerUpdateForPreview( - ControllerEvent event, - JComponent videoContainer, - MediaLocator locator) - { - if (event instanceof ConfigureCompleteEvent) - { - Processor player = (Processor) event.getSourceController(); - - /* - * Use SwScaler for the scaling since it produces an image with - * better quality and add the "flip" effect to the video. - */ - TrackControl[] trackControls = player.getTrackControls(); - - if ((trackControls != null) && (trackControls.length != 0)) - try - { - for (TrackControl trackControl : trackControls) - { - Codec codecs[] = null; - SwScaler scaler = new SwScaler(); - - // do not flip desktop - if (DeviceSystem.LOCATOR_PROTOCOL_IMGSTREAMING.equals( - locator.getProtocol())) - codecs = new Codec[] { scaler }; - else - codecs = new Codec[] { new HFlip(), scaler }; - - trackControl.setCodecChain(codecs); - break; - } - } - catch (UnsupportedPlugInException upiex) - { - logger.warn( - "Failed to add SwScaler/VideoFlipEffect to " + - "codec chain", upiex); - } - - // Turn the Processor into a Player. - try - { - player.setContentDescriptor(null); - } - catch (NotConfiguredError nce) - { - logger.error( - "Failed to set ContentDescriptor of Processor", - nce); - } - - player.realize(); - } - else if (event instanceof RealizeCompleteEvent) - { - Player player = (Player) event.getSourceController(); - Component video = player.getVisualComponent(); - - showPreview(videoContainer, video, player); - } - } - - /** - * Shows the preview panel. - * @param previewContainer the container - * @param preview the preview component. - * @param player the player. - */ - private static void showPreview( - final JComponent previewContainer, - final Component preview, - final Player player) - { - if (!SwingUtilities.isEventDispatchThread()) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - showPreview(previewContainer, preview, player); - } - }); - return; - } - - previewContainer.removeAll(); - - if (preview != null) - { - HierarchyListener hierarchyListener = new HierarchyListener() - { - private Window window; - - private WindowListener windowListener; - - public void dispose() - { - if (windowListener != null) - { - if (window != null) - { - window.removeWindowListener(windowListener); - window = null; - } - windowListener = null; - } - preview.removeHierarchyListener(this); - - disposePlayer(player); - - /* - * We've just disposed the player which created the preview - * component so the preview component is of no use - * regardless of whether the Media configuration form will - * be redisplayed or not. And since the preview component - * appears to be a huge object even after its player is - * disposed, make sure to not reference it. - */ - previewContainer.remove(preview); - } - - public void hierarchyChanged(HierarchyEvent event) - { - if ((event.getChangeFlags() - & HierarchyEvent.DISPLAYABILITY_CHANGED) - == 0) - return; - - if (!preview.isDisplayable()) - { - dispose(); - return; - } - else - player.start(); - - if (windowListener == null) - { - window = SwingUtilities.windowForComponent(preview); - if (window != null) - { - windowListener = new WindowAdapter() - { - @Override - public void windowClosing(WindowEvent event) - { - dispose(); - } - }; - window.addWindowListener(windowListener); - } - } - } - }; - preview.addHierarchyListener(hierarchyListener); - - previewContainer.add(preview); - - previewContainer.revalidate(); - previewContainer.repaint(); - } - else - disposePlayer(player); - } - - /** - * Dispose the player used for the preview. - * @param player the player. - */ - private static void disposePlayer(Player player) - { - player.stop(); - player.deallocate(); - player.close(); - } - - /** - * Get a MediaDevice for a part of desktop streaming/sharing. - * - * @param width width of the part - * @param height height of the part - * @param x origin of the x coordinate (relative to the full desktop) - * @param y origin of the y coordinate (relative to the full desktop) - * @return MediaDevice representing the part of desktop or null - * if problem - */ - public MediaDevice getMediaDeviceForPartialDesktopStreaming( - int width, int height, int x, int y) - { - MediaDevice device = null; - String name = "Partial desktop streaming"; - Dimension size = null; - int multiple = 0; - int tmpX = (x < 0)? 0: x; - int tmpY = (y < 0)? 0: y; - Point p = new Point(tmpX, tmpY); - ScreenDevice dev = getScreenForPoint(p); - int display = -1; - - if(dev != null) - display = dev.getIndex(); - else - return null; - - /* on Mac OS X, width have to be a multiple of 16 */ - if(OSUtils.IS_MAC) - { - multiple = Math.round(width / 16f); - width = multiple * 16; - } - else - { - /* JMF filter graph seems to not like odd width */ - multiple = Math.round(width / 2f); - width = multiple * 2; - } - - /* JMF filter graph seems to not like odd height */ - multiple = Math.round(height / 2f); - height = multiple * 2; - - size = new Dimension(width, height); - - Format formats[] = new Format[] - { - new AVFrameFormat( - size, - Format.NOT_SPECIFIED, - FFmpeg.PIX_FMT_ARGB, - Format.NOT_SPECIFIED), - new RGBFormat( - size, // size - Format.NOT_SPECIFIED, // maxDataLength - Format.byteArray, // dataType - Format.NOT_SPECIFIED, // frameRate - 32, // bitsPerPixel - 2 /* red */, - 3 /* green */, - 4 /* blue */) - }; - - Rectangle bounds = ((ScreenDeviceImpl)dev).getBounds(); - x -= bounds.x; - y -= bounds.y; - - CaptureDeviceInfo devInfo - = new CaptureDeviceInfo( - name + " " + display, - new MediaLocator( - DeviceSystem.LOCATOR_PROTOCOL_IMGSTREAMING - + ":" - + display - + "," - + x - + "," - + y), - formats); - - device = new MediaDeviceImpl(devInfo, MediaType.VIDEO); - return device; - } - - /** - * If the MediaDevice corresponds to partial desktop streaming - * device. - * - * @param mediaDevice MediaDevice - * @return true if MediaDevice is a partial desktop streaming - * device, false otherwise - */ - public boolean isPartialStreaming(MediaDevice mediaDevice) - { - MediaDeviceImpl dev = (MediaDeviceImpl)mediaDevice; - CaptureDeviceInfo devInfo = dev.getCaptureDeviceInfo(); - - return - (devInfo != null) - && devInfo.getName().startsWith("Partial desktop streaming"); - } - - /** - * Find the screen device that contains specified point. - * - * @param p point coordinates - * @return screen device that contains point - */ - public ScreenDevice getScreenForPoint(Point p) - { - for(ScreenDevice dev : getAvailableScreenDevices()) - if(dev.containsPoint(p)) - return dev; - return null; - } - - /** - * Gets the origin of a specific desktop streaming device. - * - * @param mediaDevice the desktop streaming device to get the origin on - * @return the origin of the specified desktop streaming device - */ - public Point getOriginForDesktopStreamingDevice(MediaDevice mediaDevice) - { - MediaDeviceImpl dev = (MediaDeviceImpl)mediaDevice; - CaptureDeviceInfo devInfo = dev.getCaptureDeviceInfo(); - if(devInfo == null) - return null; - MediaLocator locator = devInfo.getLocator(); - - if(!DeviceSystem.LOCATOR_PROTOCOL_IMGSTREAMING.equals( - locator.getProtocol())) - return null; - - String remainder = locator.getRemainder(); - String split[] = remainder.split(","); - int index - = Integer.parseInt( - ((split != null) && (split.length > 1)) - ? split[0] - : remainder); - - List devs = getAvailableScreenDevices(); - - if (devs.size() - 1 >= index) - { - Rectangle r = ((ScreenDeviceImpl) devs.get(index)).getBounds(); - - return new Point(r.x, r.y); - } - - return null; - } - - /** - * Those interested in Recorder events add listener through MediaService. - * This way they don't need to have access to the Recorder instance. - * Adds a new Recorder.Listener to the list of listeners - * interested in notifications from a Recorder. - * - * @param listener the new Recorder.Listener to be added to the - * list of listeners interested in notifications from Recorders. - */ - public void addRecorderListener(Recorder.Listener listener) - { - synchronized(recorderListeners) - { - if(!recorderListeners.contains(listener)) - recorderListeners.add(listener); - } - } - - /** - * Removes an existing Recorder.Listener from the list of listeners - * interested in notifications from Recorders. - * - * @param listener the existing Listener to be removed from the - * list of listeners interested in notifications from Recorders - */ - public void removeRecorderListener(Recorder.Listener listener) - { - synchronized(recorderListeners) - { - recorderListeners.remove(listener); - } - } - - /** - * Gives access to currently registered Recorder.Listeners. - * @return currently registered Recorder.Listeners. - */ - public Iterator getRecorderListeners() - { - return recorderListeners.iterator(); - } - - /** - * Notifies this instance that the value of a property of - * {@link #deviceConfiguration} has changed. - * - * @param event a PropertyChangeEvent which specifies the name of - * the property which had its value changed and the old and the new values - * of that property - */ - private void deviceConfigurationPropertyChange(PropertyChangeEvent event) - { - String propertyName = event.getPropertyName(); - - if (DeviceConfiguration.AUDIO_CAPTURE_DEVICE.equals(propertyName) - || DeviceConfiguration.VIDEO_CAPTURE_DEVICE.equals( - propertyName)) - { - /* - * We do not know the old value of the property at the time of this - * writing. We cannot report the new value either because we do not - * know the MediaType and the MediaUseCase. - */ - firePropertyChange(DEFAULT_DEVICE, null, null); - } - } - - /** - * Initializes a new RTPTranslator which is to forward RTP and RTCP - * traffic between multiple MediaStreams. - * - * @return a new RTPTranslator which is to forward RTP and RTCP - * traffic between multiple MediaStreams - * @see MediaService#createRTPTranslator() - */ - public RTPTranslator createRTPTranslator() - { - return new RTPTranslatorImpl(); - } - - /** - * Gets the indicator which determines whether the loading of the JMF/FMJ - * Registry has been disabled. - * - * @return true if the loading of the JMF/FMJ Registry has - * been disabled; otherwise, false - */ - public static boolean isJmfRegistryDisableLoad() - { - return jmfRegistryDisableLoad; - } - - /** - * Performs one-time initialization after initializing the first instance of - * MediaServiceImpl. - * - * @param mediaServiceImpl the MediaServiceImpl instance which has - * caused the need to perform the one-time initialization - */ - private static void postInitializeOnce(MediaServiceImpl mediaServiceImpl) - { - new ZrtpFortunaEntropyGatherer( - mediaServiceImpl.getDeviceConfiguration()) - .setEntropy(); - } - - /** - * Sets up FMJ for execution. For example, sets properties which instruct - * FMJ whether it is to create a log, where the log is to be created. - */ - private static void setupFMJ() - { - /* - * Since FMJ is part of neomedia, FMJ's log should be enabled when - * neomedia's log is enabled. - */ - Registry.set("allowLogging", logger.isDebugEnabled()); - - /* - * Disable the loading of .fmj.registry because Kertesz Laszlo has - * reported that audio input devices duplicate after restarting Jitsi. - * Besides, Jitsi does not really need .fmj.registry on startup. - */ - if (System.getProperty(JMF_REGISTRY_DISABLE_LOAD) == null) - System.setProperty(JMF_REGISTRY_DISABLE_LOAD, "true"); - jmfRegistryDisableLoad - = "true".equalsIgnoreCase(System.getProperty( - JMF_REGISTRY_DISABLE_LOAD)); - - String scHomeDirLocation - = System.getProperty( - ConfigurationService.PNAME_SC_HOME_DIR_LOCATION); - - if (scHomeDirLocation != null) - { - String scHomeDirName - = System.getProperty( - ConfigurationService.PNAME_SC_HOME_DIR_NAME); - - if (scHomeDirName != null) - { - File scHomeDir = new File(scHomeDirLocation, scHomeDirName); - - /* Write FMJ's log in Jitsi's log directory. */ - Registry.set( - "secure.logDir", - new File(scHomeDir, "log").getPath()); - - /* Write FMJ's registry in Jitsi's user data directory. */ - String jmfRegistryFilename - = "net.sf.fmj.utility.JmfRegistry.filename"; - - if (System.getProperty(jmfRegistryFilename) == null) - { - System.setProperty( - jmfRegistryFilename, - new File(scHomeDir, ".fmj.registry").getAbsolutePath()); - } - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/MediaStreamImpl.java b/src/net/java/sip/communicator/impl/neomedia/MediaStreamImpl.java deleted file mode 100644 index e48941cfa..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/MediaStreamImpl.java +++ /dev/null @@ -1,2476 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.net.*; -import java.util.*; -import java.beans.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; -import javax.media.protocol.*; -import javax.media.rtp.*; -import javax.media.rtp.event.*; -import javax.media.rtp.rtcp.*; - -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.format.*; -import net.java.sip.communicator.impl.neomedia.transform.*; -import net.java.sip.communicator.impl.neomedia.transform.csrc.*; -import net.java.sip.communicator.impl.neomedia.transform.dtmf.*; -import net.java.sip.communicator.impl.neomedia.transform.rtcp.*; -import net.java.sip.communicator.impl.neomedia.transform.zrtp.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; -import net.java.sip.communicator.util.*; - -/** - * Implements MediaStream using JMF. - * - * @author Lyubomir Marinov - * @author Emil Ivov - * @author Sebastien Vincent - */ -public class MediaStreamImpl - extends AbstractMediaStream - implements ReceiveStreamListener, - SendStreamListener, - SessionListener, - RemoteListener -{ - /** - * The Logger used by the MediaStreamImpl class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(MediaStreamImpl.class); - - /** - * The name of the property indicating the length of our receive buffer. - */ - protected static final String PROPERTY_NAME_RECEIVE_BUFFER_LENGTH - = "net.java.sip.communicator.impl.neomedia.RECEIVE_BUFFER_LENGTH"; - - /** - * The session with the MediaDevice this instance uses for both - * capture and playback of media. - */ - private MediaDeviceSession deviceSession; - - /** - * The PropertyChangeListener which listens to - * {@link #deviceSession} and changes in the values of its - * {@link MediaDeviceSession#OUTPUT_DATA_SOURCE} property. - */ - private final PropertyChangeListener deviceSessionPropertyChangeListener - = new PropertyChangeListener() - { - public void propertyChange(PropertyChangeEvent event) - { - String propertyName = event.getPropertyName(); - - if (MediaDeviceSession.OUTPUT_DATA_SOURCE.equals(propertyName)) - deviceSessionOutputDataSourceChanged(); - else if (MediaDeviceSession.SSRC_LIST.equals(propertyName)) - deviceSessionSsrcListChanged(event); - } - }; - - /** - * The MediaDirection in which this MediaStream is allowed - * to stream media. - */ - private MediaDirection direction; - - /** - * The Map of associations in this MediaStream and the - * RTPManager it utilizes of (dynamic) RTP payload types to - * MediaFormats. - */ - private final Map dynamicRTPPayloadTypes - = new HashMap(); - - /** - * The ReceiveStreams this instance plays back on its associated - * MediaDevice. - */ - private final List receiveStreams - = new LinkedList(); - - /** - * The RTPConnector through which this instance sends and receives - * RTP and RTCP traffic. The instance is a TransformConnector in - * order to also enable packet transformations. - */ - private AbstractRTPConnector rtpConnector; - - /** - * The one and only MediaStreamTarget this instance has added as a - * target in {@link #rtpConnector}. - */ - private MediaStreamTarget rtpConnectorTarget; - - /** - * The RTPManager which utilizes {@link #rtpConnector} and sends - * and receives RTP and RTCP traffic on behalf of this MediaStream. - */ - private StreamRTPManager rtpManager; - - /** - * The RTPTranslator, if any, which forwards RTP and RTCP traffic - * between this and other MediaStreams. - */ - private RTPTranslator rtpTranslator; - - /** - * The indicator which determines whether {@link #createSendStreams()} has - * been executed for {@link #rtpManager}. If true, the - * SendStreams have to be recreated when the MediaDevice, - * respectively the MediaDeviceSession, of this instance is - * changed. - */ - private boolean sendStreamsAreCreated = false; - - /** - * The indicator which determines whether {@link #start()} has been called - * on this MediaStream without {@link #stop()} or {@link #close()}. - */ - private boolean started = false; - - /** - * The MediaDirection in which this instance is started. For - * example, {@link MediaDirection#SENDRECV} if this instances is both - * sending and receiving data (e.g. RTP and RTCP) or - * {@link MediaDirection#SENDONLY} if this instance is only sending data. - */ - private MediaDirection startedDirection; - - /** - * The SSRC identifiers of the party that we are exchanging media with. - */ - private final Vector remoteSourceIDs = new Vector(1, 1); - - /** - * Our own SSRC identifier. - */ - private long localSourceID = -1; - - /** - * The list of CSRC IDs contributing to the media that this - * MediaStream is sending to its remote party. - */ - private long[] localContributingSourceIDList = null; - - /** - * The indicator which determines whether this MediaStream is set - * to transmit "silence" instead of the actual media fed from its - * MediaDevice. - */ - private boolean mute = false; - - /** - * The map of currently active RTPExtensions and the IDs that they - * have been assigned for the lifetime of this MediaStream. - */ - private final Map activeRTPExtensions - = new Hashtable(); - - /** - * The engine that we are using in order to add CSRC lists in conference - * calls, send CSRC sound levels, and handle incoming levels and CSRC lists. - */ - private CsrcTransformEngine csrcEngine; - - /** - * The SrtpControl which controls the SRTP functionality of this - * MediaStream. - */ - private final SrtpControl srtpControl; - - /** - * Number of received sender reports. Used for logging and debugging only. - */ - private long numberOfReceivedSenderReports = 0; - - /** - * The minimum inter arrival jitter value the other party has reported. - */ - private long maxRemoteInterArrivalJitter = 0; - - /** - * The maximum inter arrival jitter value the other party has reported. - */ - private long minRemoteInterArrivalJitter = -1; - - /** - * Engine chain reading sent RTCP sender reports and stores/prints - * statistics. - */ - private StatisticsEngine statisticsEngine = null; - - /** - * The MediaStreamStatsImpl object used to compute the statistics about - * this MediaStreamImpl. - */ - private MediaStreamStatsImpl mediaStreamStatsImpl; - - /** - * Initializes a new MediaStreamImpl instance which will use the - * specified MediaDevice for both capture and playback of media. - * The new instance will not have an associated StreamConnector and - * it must be set later for the new instance to be able to exchange media - * with a remote peer. - * - * @param device the MediaDevice the new instance is to use for - * both capture and playback of media - * @param srtpControl an existing control instance to control the SRTP - * operations - */ - public MediaStreamImpl(MediaDevice device, SrtpControl srtpControl) - { - this(null, device, srtpControl); - } - - /** - * Initializes a new MediaStreamImpl instance which will use the - * specified MediaDevice for both capture and playback of media - * exchanged via the specified StreamConnector. - * - * @param connector the StreamConnector the new instance is to use - * for sending and receiving media or null if the - * StreamConnector of the new instance is to not be set at - * initialization time but specified later on - * @param device the MediaDevice the new instance is to use for - * both capture and playback of media exchanged via the specified - * StreamConnector - * @param srtpControl an existing control instance to control the ZRTP - * operations or null if a new control instance is to be created by - * the new MediaStreamImpl - */ - public MediaStreamImpl( - StreamConnector connector, - MediaDevice device, - SrtpControl srtpControl) - { - /* - * XXX Set the device early in order to make sure that it is of the - * right type because we do not support just about any MediaDevice yet. - */ - setDevice(device); - - // TODO Add option to disable ZRTP, e.g. by implementing a NullControl. - // If you change the default behavior (initiates a ZrtpControlImpl if - // the srtpControl attribute is null), please accordingly modify the - // CallPeerMediaHandler.initStream function. - this.srtpControl - = (srtpControl == null) - ? NeomediaActivator.getMediaServiceImpl() - .createZrtpControl() - : srtpControl; - - if (connector != null) - setConnector(connector); - - this.mediaStreamStatsImpl = new MediaStreamStatsImpl(this); - - } - - /** - * Performs any optional configuration on a specific - * RTPConnectorOuputStream of an RTPManager to be used by - * this MediaStreamImpl. Allows extenders to override. - * - * @param dataOutputStream the RTPConnectorOutputStream to be used - * by an RTPManager of this MediaStreamImpl and to be - * configured - */ - protected void configureDataOutputStream( - RTPConnectorOutputStream dataOutputStream) - { - dataOutputStream.setPriority(getPriority()); - } - - /** - * Performs any optional configuration on a specific - * RTPConnectorInputStream of an RTPManager to be used by - * this MediaStreamImpl. Allows extenders to override. - * - * @param dataInputStream the RTPConnectorInputStream to be used - * by an RTPManager of this MediaStreamImpl and to be - * configured - */ - protected void configureDataInputStream( - RTPConnectorInputStream dataInputStream) - { - dataInputStream.setPriority(getPriority()); - } - - /** - * Performs any optional configuration on the BufferControl of the - * specified RTPManager which is to be used as the - * RTPManager of this MediaStreamImpl. Allows extenders to - * override. - * - * @param rtpManager the RTPManager which is to be used by this - * MediaStreamImpl - * @param bufferControl the BufferControl of rtpManager on - * which any optional configuration is to be performed - */ - protected void configureRTPManagerBufferControl( - StreamRTPManager rtpManager, - BufferControl bufferControl) - { - } - - /** - * Creates a chain of transform engines for use with this stream. Note - * that this is the only place where the TransformEngineChain is - * and should be manipulated to avoid problems with the order of the - * transformers. - * - * @return the TransformEngineChain that this stream should be - * using. - */ - private TransformEngineChain createTransformEngineChain() - { - ArrayList engineChain - = new ArrayList(4); - - // CSRCs and audio levels - if (csrcEngine == null) - csrcEngine = new CsrcTransformEngine(this); - engineChain.add(csrcEngine); - - // DTMF - DtmfTransformEngine dtmfEngine = createDtmfTransformEngine(); - - if (dtmfEngine != null) - engineChain.add(dtmfEngine); - - // RTCP Statistics - if (statisticsEngine == null) - statisticsEngine = new StatisticsEngine(this); - engineChain.add(statisticsEngine); - - // SRTP - engineChain.add(srtpControl.getTransformEngine()); - - return - new TransformEngineChain( - engineChain.toArray( - new TransformEngine[engineChain.size()])); - } - - /** - * A stub that allows audio oriented streams to create and keep a reference - * to a DtmfTransformEngine. - * - * @return a DtmfTransformEngine if this is an audio oriented - * stream and null otherwise. - */ - protected DtmfTransformEngine createDtmfTransformEngine() - { - return null; - } - - /** - * Adds a new association in this MediaStream of the specified RTP - * payload type with the specified MediaFormat in order to allow it - * to report rtpPayloadType in RTP flows sending and receiving - * media in format. Usually, rtpPayloadType will be in the - * range of dynamic RTP payload types. - * - * @param rtpPayloadType the RTP payload type to be associated in this - * MediaStream with the specified MediaFormat - * @param format the MediaFormat to be associated in this - * MediaStream with rtpPayloadType - * @see MediaStream#addDynamicRTPPayloadType(byte, MediaFormat) - */ - public void addDynamicRTPPayloadType( - byte rtpPayloadType, - MediaFormat format) - { - @SuppressWarnings("unchecked") - MediaFormatImpl mediaFormatImpl - = (MediaFormatImpl) format; - - synchronized (dynamicRTPPayloadTypes) - { - dynamicRTPPayloadTypes.put(Byte.valueOf(rtpPayloadType), format); - - if (rtpManager != null) - rtpManager.addFormat( - mediaFormatImpl.getFormat(), - rtpPayloadType); - } - } - - /** - * Maps or updates the mapping between extensionID and - * rtpExtension. If rtpExtension's MediaDirection - * attribute is set to INACTIVE the mapping is removed from the - * local extensions table and the extension would not be transmitted or - * handled by this stream's RTPConnector. - * - * @param extensionID the ID that is being mapped to rtpExtension - * @param rtpExtension the RTPExtension that we are mapping. - */ - public void addRTPExtension(byte extensionID, RTPExtension rtpExtension) - { - synchronized (activeRTPExtensions) - { - if(rtpExtension.getDirection() == MediaDirection.INACTIVE) - activeRTPExtensions.remove(extensionID); - else - activeRTPExtensions.put(extensionID, rtpExtension); - } - } - - /** - * Returns a map containing all currently active RTPExtensions in - * use by this stream. - * - * @return a map containing all currently active RTPExtensions in - * use by this stream. - */ - public Map getActiveRTPExtensions() - { - synchronized (activeRTPExtensions) - { - return new HashMap(activeRTPExtensions); - } - } - - /** - * Returns the ID currently assigned to a specific RTP extension. - * - * @param rtpExtension the RTP extension to get the currently assigned ID of - * @return the ID currently assigned to the specified RTP extension or - * -1 if no ID has been defined for this extension so far - */ - public byte getActiveRTPExtensionID(RTPExtension rtpExtension) - { - synchronized (activeRTPExtensions) - { - Set> extSet - = this.activeRTPExtensions.entrySet(); - - for (Map.Entry entry : extSet) - { - if (entry.getValue().equals(rtpExtension)) - return entry.getKey(); - } - } - - return -1; - } - - /** - * Returns the engine that is responsible for adding the list of CSRC - * identifiers to outgoing RTP packets during a conference. - * - * @return the engine that is responsible for adding the list of CSRC - * identifiers to outgoing RTP packets during a conference. - */ - protected CsrcTransformEngine getCsrcEngine() - { - return csrcEngine; - } - - /** - * Releases the resources allocated by this instance in the course of its - * execution and prepares it to be garbage collected. - * - * @see MediaStream#close() - */ - public void close() - { - stop(); - closeSendStreams(); - - srtpControl.cleanup(); - - if (csrcEngine != null) - { - csrcEngine.close(); - csrcEngine = null; - } - - if (rtpConnector != null) - rtpConnector.removeTargets(); - rtpConnectorTarget = null; - - if (rtpManager != null) - { - if (logger.isInfoEnabled()) - printFlowStatistics(rtpManager); - - rtpManager.removeReceiveStreamListener(this); - rtpManager.removeSendStreamListener(this); - rtpManager.removeSessionListener(this); - rtpManager.removeRemoteListener(this); - try - { - rtpManager.dispose(); - rtpManager = null; - } - catch (Throwable t) - { - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - - /* - * Analysis of heap dumps and application logs suggests that - * RTPManager#dispose() may throw an exception after a - * NullPointerException has been thrown by SendStream#close() as - * documented in - * #stopSendStreams(Iterable, boolean). It is - * unknown at the time of this writing whether we can do - * anything to prevent the exception here but it is clear that, - * if we let it go through, we will not release at least one - * capture device (i.e. we will at least skip the - * MediaDeviceSession#close() bellow). For example, if the - * exception is thrown for the audio stream in a call, its - * capture device will not be released and any video stream will - * not get its #close() method called at all. - */ - logger.error("Failed to dispose of RTPManager", t); - } - } - - if (deviceSession != null) - deviceSession.close(); - } - - /** - * Closes the SendStreams this instance is sending to its remote - * peer. - */ - private void closeSendStreams() - { - stopSendStreams(true); - } - - /** - * Creates new SendStream instances for the streams of - * {@link #deviceSession} through {@link #rtpManager}. - */ - private void createSendStreams() - { - StreamRTPManager rtpManager = getRTPManager(); - MediaDeviceSession deviceSession = getDeviceSession(); - DataSource dataSource = deviceSession.getOutputDataSource(); - int streamCount; - - if (dataSource instanceof PushBufferDataSource) - { - PushBufferStream[] streams - = ((PushBufferDataSource) dataSource).getStreams(); - - streamCount = (streams == null) ? 0 : streams.length; - } - else if (dataSource instanceof PushDataSource) - { - PushSourceStream[] streams - = ((PushDataSource) dataSource).getStreams(); - - streamCount = (streams == null) ? 0 : streams.length; - } - else if (dataSource instanceof PullBufferDataSource) - { - PullBufferStream[] streams - = ((PullBufferDataSource) dataSource).getStreams(); - - streamCount = (streams == null) ? 0 : streams.length; - } - else if (dataSource instanceof PullDataSource) - { - PullSourceStream[] streams - = ((PullDataSource) dataSource).getStreams(); - - streamCount = (streams == null) ? 0 : streams.length; - } - else - streamCount = (dataSource == null) ? 0 : 1; - - /* - * XXX We came up with a scenario in our testing in which G.722 would - * work fine for the first call since the start of the application and - * then it would fail for subsequent calls, JMF would complain that the - * G.722 RTP format is unknown to the RTPManager. Since - * RTPManager#createSendStream(DataSource, int) is one of the cases in - * which the formats registered with the RTPManager are necessary, - * register them (again) just before we use them. - */ - registerCustomCodecFormats(rtpManager); - - for (int streamIndex = 0; streamIndex < streamCount; streamIndex++) - { - try - { - SendStream sendStream - = rtpManager.createSendStream(dataSource, streamIndex); - - if (logger.isTraceEnabled()) - logger - .trace( - "Created SendStream" - + " with hashCode " - + sendStream.hashCode() - + " for " - + toString(dataSource) - + " and streamIndex " - + streamIndex - + " in RTPManager with hashCode " - + rtpManager.hashCode()); - - long localSSRC = sendStream.getSSRC(); - - if (getLocalSourceID() != localSSRC) - setLocalSourceID(localSSRC); - - /* - * If a ZRTP engine is available, then let it know about the - * SSRC of the new SendStream. Currently, ZRTP supports only one - * SSRC per engine. - */ - TransformEngine engine = srtpControl.getTransformEngine(); - - if ((engine != null) && (engine instanceof ZRTPTransformEngine)) - ((ZRTPTransformEngine)engine).setOwnSSRC(localSSRC); - } - catch (IOException ioe) - { - logger - .error( - "Failed to create send stream for data source " - + dataSource - + " and stream index " - + streamIndex, - ioe); - } - catch (UnsupportedFormatException ufe) - { - logger - .error( - "Failed to create send stream for data source " - + dataSource - + " and stream index " - + streamIndex - + " because of failed format " - + ufe.getFailedFormat(), - ufe); - } - } - sendStreamsAreCreated = true; - - if (logger.isTraceEnabled()) - { - @SuppressWarnings("unchecked") - Vector sendStreams = rtpManager.getSendStreams(); - int sendStreamCount - = (sendStreams == null) ? 0 : sendStreams.size(); - - logger - .trace( - "Total number of SendStreams in RTPManager with hashCode " - + rtpManager.hashCode() - + " is " - + sendStreamCount); - } - } - - /** - * Notifies this MediaStream that the MediaDevice (and - * respectively the MediaDeviceSession with it) which this instance - * uses for capture and playback of media has been changed. Allows extenders - * to override and provide additional processing of oldValue and - * newValue. - * - * @param oldValue the MediaDeviceSession with the - * MediaDevice this instance used work with - * @param newValue the MediaDeviceSession with the - * MediaDevice this instance is to work with - */ - protected void deviceSessionChanged( - MediaDeviceSession oldValue, - MediaDeviceSession newValue) - { - recreateSendStreams(); - } - - /** - * Notifies this instance that the output DataSource of its - * MediaDeviceSession has changed. Recreates the - * SendStreams of this instance as necessary so that it, for - * example, continues streaming after the change if it was streaming before - * the change. - */ - private void deviceSessionOutputDataSourceChanged() - { - recreateSendStreams(); - } - - /** - * Recalculates the list of CSRC identifiers that this MediaStream - * needs to include in RTP packets bound to its interlocutor. The method - * uses the list of SSRC identifiers currently handled by our device - * (possibly a mixer), then removes the SSRC ID of this stream's - * interlocutor. If this turns out to be the only SSRC currently in the list - * we set the list of local CSRC identifiers to null since this is obviously - * a non-conf call and we don't need to be advertising CSRC lists. If that's - * not the case, we also add our own SSRC to the list of IDs and cache the - * entire list. - * - * @param evt the PropetyChangeEvent containing the list of SSRC - * identifiers handled by our device session before and after it changed. - */ - private void deviceSessionSsrcListChanged(PropertyChangeEvent evt) - { - long[] ssrcArray = (long[])evt.getNewValue(); - - // the list is empty - if(ssrcArray == null) - { - this.localContributingSourceIDList = null; - return; - } - - int elementsToRemove = 0; - Vector remoteSourceIDs = this.remoteSourceIDs; - - //in case of a conf call the mixer would return all SSRC IDs that are - //currently contributing including this stream's counterpart. We need - //to remove that last one since that's where we will be sending our - //csrc list - for(long csrc : ssrcArray) - if (remoteSourceIDs.contains(csrc)) - elementsToRemove ++; - - //we don't seem to be in a conf call since the list only contains the - //SSRC id of the party that we are directly interacting with. - if (elementsToRemove >= ssrcArray.length) - { - this.localContributingSourceIDList = null; - return; - } - - //prepare the new array. make it big enough to also add the local - //SSRC id but do not make it bigger than 15 since that's the maximum - //for RTP. - int cc = Math.min(ssrcArray.length - elementsToRemove + 1, 15); - - long[] csrcArray = new long[cc]; - - for (int i = 0,j = 0; - (i < ssrcArray.length) && (j < csrcArray.length - 1); - i++) - { - long ssrc = ssrcArray[i]; - - if (!remoteSourceIDs.contains(ssrc)) - { - csrcArray[j] = ssrc; - j++; - } - } - - csrcArray[csrcArray.length - 1] = getLocalSourceID(); - - this.localContributingSourceIDList = csrcArray; - } - - /** - * Sets the target of this MediaStream to which it is to send and - * from which it is to receive data (e.g. RTP) and control data (e.g. RTCP). - * In contrast to {@link #setTarget(MediaStreamTarget)}, sets the specified - * target on this MediaStreamImpl even if its current - * target is equal to the specified one. - * - * @param target the MediaStreamTarget describing the data - * (e.g. RTP) and the control data (e.g. RTCP) locations to which this - * MediaStream is to send and from which it is to receive - * @see MediaStreamImpl#setTarget(MediaStreamTarget) - */ - private void doSetTarget(MediaStreamTarget target) - { - rtpConnector.removeTargets(); - rtpConnectorTarget = null; - - boolean targetIsSet; - - if (target != null) - { - InetSocketAddress dataAddr = target.getDataAddress(); - InetSocketAddress controlAddr = target.getControlAddress(); - - try - { - rtpConnector - .addTarget( - new SessionAddress( - dataAddr.getAddress(), - dataAddr.getPort(), - controlAddr != null ? controlAddr.getAddress() - : null, - controlAddr != null ? controlAddr.getPort() - : 0)); - targetIsSet = true; - } - catch (IOException ioe) - { - // TODO - targetIsSet = false; - logger.error("Failed to set target " + target, ioe); - } - } - else - targetIsSet = true; - if (targetIsSet) - { - rtpConnectorTarget = target; - - if (logger.isTraceEnabled()) - logger - .trace( - "Set target of " - + getClass().getSimpleName() - + " with hashCode " - + hashCode() - + " to " - + target); - } - } - - /** - * Gets the MediaDevice that this stream uses to play back and - * capture media. - * - * @return the MediaDevice that this stream uses to play back and - * capture media - * @see MediaStream#getDevice() - */ - public AbstractMediaDevice getDevice() - { - return getDeviceSession().getDevice(); - } - - /** - * Gets the MediaDeviceSession which represents the work of this - * MediaStream with its associated MediaDevice. - * - * @return the MediaDeviceSession which represents the work of this - * MediaStream with its associated MediaDevice - */ - public MediaDeviceSession getDeviceSession() - { - return deviceSession; - } - - /** - * Gets the direction in which this MediaStream is allowed to - * stream media. - * - * @return the MediaDirection in which this MediaStream is - * allowed to stream media - * @see MediaStream#getDirection() - */ - public MediaDirection getDirection() - { - if (direction != null) - return direction; - - MediaDeviceSession deviceSession = getDeviceSession(); - - return (deviceSession == null) - ? MediaDirection.INACTIVE - : deviceSession.getDevice().getDirection(); - } - - /** - * Gets the existing associations in this MediaStream of RTP - * payload types to MediaFormats. The returned Map - * only contains associations previously added in this instance with - * {@link #addDynamicRTPPayloadType(byte, MediaFormat)} and not globally or - * well-known associations reported by - * {@link MediaFormat#getRTPPayloadType()}. - * - * @return a Map of RTP payload type expressed as Byte to - * MediaFormat describing the existing (dynamic) associations in - * this instance of RTP payload types to MediaFormats. The - * Map represents a snapshot of the existing associations at the - * time of the getDynamicRTPPayloadTypes() method call and - * modifications to it are not reflected on the internal storage - * @see MediaStream#getDynamicRTPPayloadTypes() - */ - public Map getDynamicRTPPayloadTypes() - { - synchronized (dynamicRTPPayloadTypes) - { - return new HashMap(dynamicRTPPayloadTypes); - } - } - - /** - * Returns the payload type number that has been negotiated for the - * specified encoding or -1 if no payload type has been - * negotiated for it. If multiple formats match the specified - * encoding, then this method would return the first one it - * encounters while iterating through the map. - * - * @param encoding the encoding whose payload type we are trying to obtain. - * - * @return the payload type number that has been negotiated for the - * specified encoding or -1 if no payload type has been - * negotiated for it. - */ - public byte getDynamicRTPPayloadType(String encoding) - { - synchronized (dynamicRTPPayloadTypes) - { - for (Map.Entry entry - : dynamicRTPPayloadTypes.entrySet()) - { - if (entry.getValue().getEncoding().equals(encoding)) - return entry.getKey().byteValue(); - } - return -1; - } - } - - /** - * Gets the MediaFormat that this stream is currently transmitting - * in. - * - * @return the MediaFormat that this stream is currently - * transmitting in - * @see MediaStream#getFormat() - */ - public MediaFormat getFormat() - { - return getDeviceSession().getFormat(); - } - - /** - * Gets the synchronization source (SSRC) identifier of the local peer or - * -1 if it is not yet known. - * - * @return the synchronization source (SSRC) identifier of the local peer - * or -1 if it is not yet known - * @see MediaStream#getLocalSourceID() - */ - public long getLocalSourceID() - { - return this.localSourceID; - } - - /** - * Gets the address that this stream is sending RTCP traffic to. - * - * @return an InetSocketAddress instance indicating the address - * that this stream is sending RTCP traffic to - * @see MediaStream#getRemoteControlAddress() - */ - public InetSocketAddress getRemoteControlAddress() - { - StreamConnector connector = - (rtpConnector != null) ? rtpConnector.getConnector() : null; - - if(connector != null) - { - if(connector.getDataSocket() != null) - { - return (InetSocketAddress)connector.getControlSocket(). - getRemoteSocketAddress(); - } - else if(connector.getDataTCPSocket() != null) - { - return (InetSocketAddress)connector.getControlTCPSocket(). - getRemoteSocketAddress(); - } - } - - return null; - } - - /** - * Gets the address that this stream is sending RTP traffic to. - * - * @return an InetSocketAddress instance indicating the address - * that this stream is sending RTP traffic to - * @see MediaStream#getRemoteDataAddress() - */ - public InetSocketAddress getRemoteDataAddress() - { - StreamConnector connector = - (rtpConnector != null) ? rtpConnector.getConnector() : null; - - if(connector != null) - { - if(connector.getDataSocket() != null) - { - return (InetSocketAddress)connector.getDataSocket(). - getRemoteSocketAddress(); - } - else if(connector.getDataTCPSocket() != null) - { - return (InetSocketAddress)connector.getDataTCPSocket(). - getRemoteSocketAddress(); - } - } - - return null; - } - - /** - * Gets the local address that this stream is sending RTCP traffic from. - * - * @return an InetSocketAddress instance indicating the local - * address that this stream is sending RTCP traffic from. - */ - public InetSocketAddress getLocalControlAddress() - { - StreamConnector connector = - (rtpConnector != null) ? rtpConnector.getConnector() : null; - - if(connector != null) - { - if(connector.getDataSocket() != null) - { - return (InetSocketAddress)connector.getControlSocket(). - getLocalSocketAddress(); - } - else if(connector.getDataTCPSocket() != null) - { - return (InetSocketAddress)connector.getControlTCPSocket(). - getLocalSocketAddress(); - } - } - - return null; - } - - /** - * Gets the local address that this stream is sending RTP traffic from. - * - * @return an InetSocketAddress instance indicating the local - * address that this stream is sending RTP traffic from. - */ - public InetSocketAddress getLocalDataAddress() - { - StreamConnector connector = - (rtpConnector != null) ? rtpConnector.getConnector() : null; - - if(connector != null) - { - if(connector.getDataSocket() != null) - { - return (InetSocketAddress)connector.getDataSocket(). - getLocalSocketAddress(); - } - else if(connector.getDataTCPSocket() != null) - { - return (InetSocketAddress)connector.getDataTCPSocket(). - getLocalSocketAddress(); - } - } - - return null; - } - - /** - * Returns the transport protocol used by the streams. - * - * @return the transport protocol (UDP or TCP) used by the streams. null if - * the stream connector is not instanciated. - */ - public StreamConnector.Protocol getTransportProtocol() - { - StreamConnector connector = - (rtpConnector != null) ? rtpConnector.getConnector() : null; - - if(connector == null) - { - return null; - } - - return connector.getProtocol(); - } - - /** - * Get the synchronization source (SSRC) identifier of the remote peer or - * -1 if it is not yet known. - * - * @return the synchronization source (SSRC) identifier of the remote - * peer or -1 if it is not yet known - * @see MediaStream#getRemoteSourceID() - */ - public long getRemoteSourceID() - { - return remoteSourceIDs.isEmpty() ? -1 : remoteSourceIDs.lastElement(); - } - - /** - * Gets the synchronization source (SSRC) identifiers of the remote peers. - * - * @return the synchronization source (SSRC) identifiers of the remote peers - * @see MediaStream#getRemoteSourceIDs() - */ - public List getRemoteSourceIDs() - { - return Collections.unmodifiableList(remoteSourceIDs); - } - - /** - * Gets the RTPConnector through which this instance sends and - * receives RTP and RTCP traffic. - * - * @return the RTPConnector through which this instance sends and - * receives RTP and RTCP traffic - */ - protected AbstractRTPConnector getRTPConnector() - { - return rtpConnector; - } - - /** - * Gets the RTPManager instance which sends and receives RTP and - * RTCP traffic on behalf of this MediaStream. - * - * @return the RTPManager instance which sends and receives RTP and - * RTCP traffic on behalf of this MediaStream - */ - public StreamRTPManager getRTPManager() - { - if (rtpManager == null) - { - RTPConnector rtpConnector = getRTPConnector(); - - if (rtpConnector == null) - throw new IllegalStateException("rtpConnector"); - - rtpManager = new StreamRTPManager(rtpTranslator); - - registerCustomCodecFormats(rtpManager); - - rtpManager.addReceiveStreamListener(this); - rtpManager.addSendStreamListener(this); - rtpManager.addSessionListener(this); - rtpManager.addRemoteListener(this); - - BufferControl bc - = (BufferControl) - rtpManager.getControl(BufferControl.class.getName()); - if (bc != null) - configureRTPManagerBufferControl(rtpManager, bc); - - rtpManager.initialize(rtpConnector); - - /* - * JMF initializes the local SSRC upon #initialize(RTPConnector) so - * now's the time to ask. - */ - /* - * As JMF keeps the SSRC as a signed int value, convert it to - * unsigned. - */ - setLocalSourceID(rtpManager.getLocalSSRC() & 0xFFFFFFFFL); - } - return rtpManager; - } - - /** - * Gets the SrtpControl which controls the SRTP of this stream. - * - * @return the SrtpControl which controls the SRTP of this stream - */ - public SrtpControl getSrtpControl() - { - return srtpControl; - } - - /** - * Determines whether this MediaStream is set to transmit "silence" - * instead of the media being fed from its MediaDevice. "Silence" - * for video is understood as video data which is not the captured video - * data and may represent, for example, a black image. - * - * @return true if this MediaStream is set to transmit - * "silence" instead of the media fed from its MediaDevice; - * false, otherwise - * @see MediaStream#isMute() - */ - public boolean isMute() - { - MediaDeviceSession deviceSession = getDeviceSession(); - - return (deviceSession == null) ? mute : deviceSession.isMute(); - } - - /** - * Determines whether {@link #start()} has been called on this - * MediaStream without {@link #stop()} or {@link #close()} - * afterwards. - * - * @return true if {@link #start()} has been called on this - * MediaStream without {@link #stop()} or {@link #close()} - * afterwards - * @see MediaStream#isStarted() - */ - public boolean isStarted() - { - return started; - } - - /** - * Recreates the SendStreams of this instance (i.e. of its - * RTPManager) as necessary. For example, if there was no attempt - * to create the SendStreams prior to the call, does nothing. If - * they were created prior to the call, closes them and creates them again. - * If they were not started prior to the call, does not start them after - * recreating them. - */ - private void recreateSendStreams() - { - if (sendStreamsAreCreated) - { - closeSendStreams(); - - if ((getDeviceSession() != null) && (rtpManager != null)) - { - if (MediaDirection.SENDONLY.equals(startedDirection) - || MediaDirection.SENDRECV.equals(startedDirection)) - startSendStreams(); - } - } - } - - /** - * Registers any custom JMF Formats with a specific - * RTPManager. Extenders should override in order to register their - * own customizations and should call back to this super implementation - * during the execution of their override in order to register the - * associations defined in this instance of (dynamic) RTP payload types to - * MediaFormats. - * - * @param rtpManager the RTPManager to register any custom JMF - * Formats with - */ - protected void registerCustomCodecFormats(StreamRTPManager rtpManager) - { - synchronized (dynamicRTPPayloadTypes) - { - for (Map.Entry dynamicRTPPayloadType - : dynamicRTPPayloadTypes.entrySet()) - { - @SuppressWarnings("unchecked") - MediaFormatImpl mediaFormatImpl - = (MediaFormatImpl) - dynamicRTPPayloadType.getValue(); - - rtpManager.addFormat( - mediaFormatImpl.getFormat(), - dynamicRTPPayloadType.getKey()); - } - } - } - - /** - * Notifies this MediaStream implementation that its - * RTPConnector instance has changed from a specific old value to a - * specific new value. Allows extenders to override and perform additional - * processing after this MediaStream has changed its - * RTPConnector instance. - * - * @param oldValue the RTPConnector of this MediaStream - * implementation before it got changed to newValue - * @param newValue the current RTPConnector of this - * MediaStream which replaced oldValue - */ - protected void rtpConnectorChanged( - AbstractRTPConnector oldValue, - AbstractRTPConnector newValue) - { - srtpControl.setConnector(newValue); - - if (newValue != null) - { - /* - * Register the transform engines that we will be using in this - * stream. - */ - if(newValue instanceof RTPTransformUDPConnector) - ((RTPTransformUDPConnector)newValue) - .setEngine(createTransformEngineChain()); - else if(newValue instanceof RTPTransformTCPConnector) - ((RTPTransformTCPConnector)newValue) - .setEngine(createTransformEngineChain()); - - if (rtpConnectorTarget != null) - doSetTarget(rtpConnectorTarget); - } - } - - /** - * Sets the StreamConnector to be used by this instance for sending - * and receiving media. - * - * @param connector the StreamConnector to be used by this instance - * for sending and receiving media - */ - public void setConnector(StreamConnector connector) - { - if (connector == null) - throw new NullPointerException("connector"); - - AbstractRTPConnector oldValue = rtpConnector; - - // Is the StreamConnector really changing? - if ((oldValue != null) && (oldValue.getConnector() == connector)) - return; - - switch (connector.getProtocol()) - { - case UDP: - rtpConnector - = new RTPTransformUDPConnector(connector) - { - @Override - protected TransformUDPOutputStream createDataOutputStream() - throws IOException - { - TransformUDPOutputStream dataOutputStream - = super.createDataOutputStream(); - - if (dataOutputStream != null) - configureDataOutputStream(dataOutputStream); - return dataOutputStream; - } - - @Override - protected TransformUDPInputStream createDataInputStream() - throws IOException - { - TransformUDPInputStream dataInputStream - = super.createDataInputStream(); - - if (dataInputStream != null) - configureDataInputStream(dataInputStream); - return dataInputStream; - } - }; - break; - case TCP: - rtpConnector - = new RTPTransformTCPConnector(connector) - { - @Override - protected TransformTCPOutputStream createDataOutputStream() - throws IOException - { - TransformTCPOutputStream dataOutputStream - = super.createDataOutputStream(); - - if (dataOutputStream != null) - configureDataOutputStream(dataOutputStream); - return dataOutputStream; - } - - @Override - protected TransformTCPInputStream createDataInputStream() - throws IOException - { - TransformTCPInputStream dataInputStream - = super.createDataInputStream(); - - if (dataInputStream != null) - configureDataInputStream(dataInputStream); - return dataInputStream; - } - }; - break; - default: - throw new IllegalArgumentException("connector"); - } - - rtpConnectorChanged(oldValue, rtpConnector); - } - - /** - * Sets the MediaDevice that this stream should use to play back - * and capture media. - *

- * Note: Also resets any previous direction set with - * {@link #setDirection(MediaDirection)} to the direction of the specified - * MediaDevice. - *

- * - * @param device the MediaDevice that this stream should use to - * play back and capture media - * @see MediaStream#setDevice(MediaDevice) - */ - public void setDevice(MediaDevice device) - { - if (device == null) - throw new NullPointerException("device"); - - // Require AbstractMediaDevice for MediaDeviceSession support. - AbstractMediaDevice abstractMediaDevice = (AbstractMediaDevice) device; - - if ((deviceSession == null) || (deviceSession.getDevice() != device)) - { - MediaDeviceSession oldValue = deviceSession; - MediaFormat format; - MediaDirection startedDirection; - - if (deviceSession != null) - { - format = getFormat(); - startedDirection = deviceSession.getStartedDirection(); - - deviceSession.removePropertyChangeListener( - deviceSessionPropertyChangeListener); - - // keep player active - deviceSession.setDisposePlayerOnClose( - !(deviceSession instanceof VideoMediaDeviceSession)); - deviceSession.close(); - deviceSession = null; - } - else - { - format = null; - startedDirection = MediaDirection.INACTIVE; - } - - deviceSession = abstractMediaDevice.createSession(); - - /* - * Copy the playback from the old MediaDeviceSession into the new - * MediaDeviceSession in order to prevent the recreation of the - * playback of the ReceiveStream(s) when just changing the - * MediaDevice of this MediaSteam. - */ - if (oldValue != null) - deviceSession.copyPlayback(oldValue); - - deviceSession.addPropertyChangeListener( - deviceSessionPropertyChangeListener); - - /* - * Setting a new device resets any previously-set direction. - * Otherwise, we risk not being able to set a new device if it is - * mandatory for the new device to fully cover any previously-set - * direction. - */ - direction = null; - - if (deviceSession != null) - { - if (format != null) - deviceSession.setFormat(format); - deviceSession.setMute(mute); - } - deviceSessionChanged(oldValue, deviceSession); - if (deviceSession != null) - { - deviceSession.start(startedDirection); - synchronized (receiveStreams) - { - for (ReceiveStream receiveStream : receiveStreams) - deviceSession.addReceiveStream(receiveStream); - } - } - } - } - - /** - * Sets the direction in which media in this MediaStream is to be - * streamed. If this MediaStream is not currently started, calls to - * {@link #start()} later on will start it only in the specified - * direction. If it is currently started in a direction different - * than the specified, directions other than the specified will be stopped. - * - * @param direction the MediaDirection in which this - * MediaStream is to stream media when it is started - * @see MediaStream#setDirection(MediaDirection) - */ - public void setDirection(MediaDirection direction) - { - if (direction == null) - throw new NullPointerException("direction"); - if(this.direction == direction) - return; - - if(logger.isTraceEnabled()) - logger.trace("Changing direction of stream " + hashCode() - + " from:" + this.direction + " to:" + direction); - - /* - * Make sure that the specified direction is in accord with the - * direction of the MediaDevice of this instance. - */ - MediaDeviceSession deviceSession = getDeviceSession(); - MediaDirection deviceDirection - = (deviceSession == null) - ? MediaDirection.INACTIVE - : deviceSession.getDevice().getDirection(); - - if (!deviceDirection.and(direction).equals(direction)) - throw new IllegalArgumentException("direction"); - - this.direction = direction; - - switch (this.direction) - { - case INACTIVE: - stop(MediaDirection.SENDRECV); - return; - case RECVONLY: - stop(MediaDirection.SENDONLY); - break; - case SENDONLY: - stop(MediaDirection.RECVONLY); - break; - case SENDRECV: - break; - default: - // Don't know what it may be (in the future) so ignore it. - return; - } - if (started) - start(this.direction); - } - - /** - * Sets the MediaFormat that this MediaStream should - * transmit in. - * - * @param format the MediaFormat that this MediaStream - * should transmit in - * @see MediaStream#setFormat(MediaFormat) - */ - public void setFormat(MediaFormat format) - { - MediaDeviceSession deviceSession = getDeviceSession(); - MediaFormatImpl deviceSessionFormat = null; - - if (deviceSession != null) - { - deviceSessionFormat = deviceSession.getFormat(); - if ((deviceSessionFormat != null) - && deviceSessionFormat.equals(format) - && deviceSessionFormat.advancedAttributesAreEqual( - deviceSessionFormat.getAdvancedAttributes(), - format.getAdvancedAttributes())) - return; - } - - if (logger.isTraceEnabled()) - logger.trace( - "Changing format of stream " + hashCode() - + " from: " + deviceSessionFormat - + " to: " + format); - - handleAttributes(format, format.getAdvancedAttributes()); - handleAttributes(format, format.getFormatParameters()); - deviceSession.setFormat(format); - } - - /** - * Handles attributes contained in MediaFormat. - * - * @param format the MediaFormat to handle the attributes of - * @param attrs the attributes Map to handle - */ - protected void handleAttributes( - MediaFormat format, - Map attrs) - { - } - - /** - * Causes this MediaStream to stop transmitting the media being fed - * from this stream's MediaDevice and transmit "silence" instead. - * "Silence" for video is understood as video data which is not the captured - * video data and may represent, for example, a black image. - * - * @param mute true to have this MediaStream transmit - * "silence" instead of the actual media data that it captures from its - * MediaDevice; false to transmit actual media data - * captured from the MediaDevice of this MediaStream - * @see MediaStream#setMute(boolean) - */ - public void setMute(boolean mute) - { - if (this.mute != mute) - { - if(logger.isTraceEnabled()) - logger.trace((mute? "Muting" : "Unmuting") - + " stream with hashcode " + hashCode()); - - this.mute = mute; - - MediaDeviceSession deviceSession = getDeviceSession(); - - if (deviceSession != null) - deviceSession.setMute(this.mute); - } - } - - /** - * Returns the target of this MediaStream to which it is to send - * and from which it is to receive data (e.g. RTP) and control data (e.g. - * RTCP). - * - * @return the MediaStreamTarget describing the data - * (e.g. RTP) and the control data (e.g. RTCP) locations to which this - * MediaStream is to send and from which it is to receive - * @see MediaStream#setTarget(MediaStreamTarget) - */ - public MediaStreamTarget getTarget() - { - return rtpConnectorTarget; - } - - /** - * Sets the target of this MediaStream to which it is to send and - * from which it is to receive data (e.g. RTP) and control data (e.g. RTCP). - * - * @param target the MediaStreamTarget describing the data - * (e.g. RTP) and the control data (e.g. RTCP) locations to which this - * MediaStream is to send and from which it is to receive - * @see MediaStream#setTarget(MediaStreamTarget) - */ - public void setTarget(MediaStreamTarget target) - { - // Short-circuit if setting the same target. - if (target == null) - { - if (rtpConnectorTarget == null) - return; - } - else if (target.equals(rtpConnectorTarget)) - return; - - doSetTarget(target); - } - - /** - * Starts capturing media from this stream's MediaDevice and then - * streaming it through the local StreamConnector toward the - * stream's target address and port. Also puts the MediaStream in a - * listening state which make it play all media received from the - * StreamConnector on the stream's MediaDevice. - * - * @see MediaStream#start() - */ - public void start() - { - start(getDirection()); - started = true; - } - - /** - * Starts the processing of media in this instance in a specific direction. - * - * @param direction a MediaDirection value which represents the - * direction of the processing of media to be started. For example, - * {@link MediaDirection#SENDRECV} to start both capture and playback of - * media in this instance or {@link MediaDirection#SENDONLY} to only start - * the capture of media in this instance - */ - private void start(MediaDirection direction) - { - if (direction == null) - throw new NullPointerException("direction"); - - if (direction.allowsSending() - && ((startedDirection == null) - || !startedDirection.allowsSending())) - { - startSendStreams(); - - getDeviceSession().start(MediaDirection.SENDONLY); - - if (MediaDirection.RECVONLY.equals(startedDirection)) - startedDirection = MediaDirection.SENDRECV; - else if (startedDirection == null) - startedDirection = MediaDirection.SENDONLY; - - logger.info(getFormat().getMediaType().toString() + " codec/freq: " - + getMediaStreamStats().getEncoding() - + "/" + getMediaStreamStats().getEncodingClockRate() + " Hz"); - logger.info(getFormat().getMediaType().toString() - + " remote IP/port: " - + getMediaStreamStats().getRemoteIPAddress() - + "/" + String.valueOf(getMediaStreamStats().getRemotePort())); - } - - if (direction.allowsReceiving() - && ((startedDirection == null) - || !startedDirection.allowsReceiving())) - { - startReceiveStreams(); - - getDeviceSession().start(MediaDirection.RECVONLY); - - if (MediaDirection.SENDONLY.equals(startedDirection)) - startedDirection = MediaDirection.SENDRECV; - else if (startedDirection == null) - startedDirection = MediaDirection.RECVONLY; - } - } - - /** - * Starts the ReceiveStreams that this instance is receiving from - * its remote peer. By design, a MediaStream instance is associated - * with a single ReceiveStream at a time. However, the - * ReceiveStreams are created by RTPManager and it tracks - * multiple ReceiveStreams. In practice, the RTPManager of - * this MediaStreamImpl will have a single ReceiveStream - * in its list. - */ - @SuppressWarnings("unchecked") - private void startReceiveStreams() - { - StreamRTPManager rtpManager = getRTPManager(); - List receiveStreams; - - try - { - receiveStreams = rtpManager.getReceiveStreams(); - } - catch (Exception ex) - { - /* - * It appears that in early call states when there are no streams, a - * NullPointerException could be thrown. Make sure we handle it - * gracefully. - */ - if (logger.isTraceEnabled()) - logger.trace("Failed to retrieve receive streams", ex); - receiveStreams = null; - } - - if (receiveStreams != null) - { - /* - * It turns out that the receiveStreams list of rtpManager can be - * empty. As a workaround, use the receiveStreams of this instance. - */ - if (receiveStreams.isEmpty() && (this.receiveStreams != null)) - receiveStreams = this.receiveStreams; - - for (ReceiveStream receiveStream : receiveStreams) - { - try - { - DataSource receiveStreamDataSource - = receiveStream.getDataSource(); - - /* - * For an unknown reason, the stream DataSource can be null - * at the end of the Call after re-INVITEs have been - * handled. - */ - if (receiveStreamDataSource != null) - receiveStreamDataSource.start(); - } - catch (IOException ioex) - { - logger.warn( - "Failed to start receive stream " + receiveStream, - ioex); - } - } - } - } - - /** - * Starts the SendStreams of the RTPManager of this - * MediaStreamImpl. - */ - private void startSendStreams() - { - /* - * Until it's clear that the SendStreams are required (i.e. we've - * negotiated to send), they will not be created. Otherwise, their - * creation isn't only illogical but also causes the CaptureDevice to - * be used. - */ - if (!sendStreamsAreCreated) - createSendStreams(); - - StreamRTPManager rtpManager = getRTPManager(); - @SuppressWarnings("unchecked") - Iterable sendStreams = rtpManager.getSendStreams(); - - if (sendStreams != null) - { - for (SendStream sendStream : sendStreams) - { - try - { - DataSource sendStreamDataSource - = sendStream.getDataSource(); - - // TODO Are we sure we want to connect here? - sendStreamDataSource.connect(); - sendStream.start(); - sendStreamDataSource.start(); - - if (logger.isTraceEnabled()) - { - logger.trace( - "Started SendStream with hashCode " - + sendStream.hashCode()); - } - } - catch (IOException ioe) - { - logger.warn("Failed to start stream " + sendStream, ioe); - } - } - } - } - - /** - * Stops all streaming and capturing in this MediaStream and closes - * and releases all open/allocated devices/resources. Has no effect if this - * MediaStream is already closed and is simply ignored. - * - * @see MediaStream#stop() - */ - public void stop() - { - stop(MediaDirection.SENDRECV); - started = false; - } - - /** - * Stops the processing of media in this instance in a specific direction. - * - * @param direction a MediaDirection value which represents the - * direction of the processing of media to be stopped. For example, - * {@link MediaDirection#SENDRECV} to stop both capture and playback of - * media in this instance or {@link MediaDirection#SENDONLY} to only stop - * the capture of media in this instance - */ - private void stop(MediaDirection direction) - { - if (direction == null) - throw new NullPointerException("direction"); - - if (rtpManager == null) - return; - - if ((MediaDirection.SENDRECV.equals(direction) - || MediaDirection.SENDONLY.equals(direction)) - && (MediaDirection.SENDRECV.equals(startedDirection) - || MediaDirection.SENDONLY.equals(startedDirection))) - { - stopSendStreams(false); - - if (deviceSession != null) - deviceSession.stop(MediaDirection.SENDONLY); - - if (MediaDirection.SENDRECV.equals(startedDirection)) - startedDirection = MediaDirection.RECVONLY; - else if (MediaDirection.SENDONLY.equals(startedDirection)) - startedDirection = null; - } - - if ((MediaDirection.SENDRECV.equals(direction) - || MediaDirection.RECVONLY.equals(direction)) - && (MediaDirection.SENDRECV.equals(startedDirection) - || MediaDirection.RECVONLY.equals(startedDirection))) - { - stopReceiveStreams(); - - if (deviceSession != null) - deviceSession.stop(MediaDirection.RECVONLY); - - if (MediaDirection.SENDRECV.equals(startedDirection)) - startedDirection = MediaDirection.SENDONLY; - else if (MediaDirection.RECVONLY.equals(startedDirection)) - startedDirection = null; - } - } - - /** - * Stops the ReceiveStreams that this instance is receiving from - * its remote peer. By design, a MediaStream instance is associated - * with a single ReceiveStream at a time. However, the - * ReceiveStreams are created by RTPManager and it tracks - * multiple ReceiveStreams. In practice, the RTPManager of - * this MediaStreamImpl will have a single ReceiveStream - * in its list. - */ - @SuppressWarnings("unchecked") - private void stopReceiveStreams() - { - List receiveStreams; - - try - { - receiveStreams = rtpManager.getReceiveStreams(); - } - catch (Exception ex) - { - /* - * It appears that in early call states when there are no streams, a - * NullPointerException could be thrown. Make sure we handle it - * gracefully. - */ - if (logger.isTraceEnabled()) - logger.trace("Failed to retrieve receive streams", ex); - receiveStreams = null; - } - - if (receiveStreams != null) - { - /* - * It turns out that the receiveStreams list of rtpManager can be - * empty. As a workaround, use the receiveStreams of this instance. - */ - if (receiveStreams.isEmpty() && (this.receiveStreams != null)) - receiveStreams = this.receiveStreams; - - for (ReceiveStream receiveStream : receiveStreams) - { - try - { - if (logger.isTraceEnabled()) - logger.trace( - "Stopping receive stream with hashcode " - + receiveStream.hashCode()); - - DataSource receiveStreamDataSource - = receiveStream.getDataSource(); - - /* - * For an unknown reason, the stream DataSource can be null - * at the end of the Call after re-INVITEs have been - * handled. - */ - if (receiveStreamDataSource != null) - receiveStreamDataSource.stop(); - } - catch (IOException ioex) - { - logger.warn( - "Failed to stop receive stream " + receiveStream, - ioex); - } - } - } - } - - /** - * Stops the SendStreams that this instance is sending to its - * remote peer and optionally closes them. - * - * @param close true to close the SendStreams that this - * instance is sending to its remote peer after stopping them; - * false to only stop them - * @return the SendStreams which were stopped - */ - private Iterable stopSendStreams(boolean close) - { - if (rtpManager == null) - return null; - - @SuppressWarnings("unchecked") - Iterable sendStreams = rtpManager.getSendStreams(); - Iterable stoppedSendStreams - = stopSendStreams(sendStreams, close); - - if (close) - sendStreamsAreCreated = false; - - return stoppedSendStreams; - } - - /** - * Stops specific SendStreams and optionally closes them. - * - * @param sendStreams the SendStreams to be stopped and optionally - * closed - * @param close true to close the specified SendStreams - * after stopping them; false to only stop them - * @return the stopped SendStreams - */ - private Iterable stopSendStreams( - Iterable sendStreams, - boolean close) - { - if (sendStreams == null) - return null; - - for (SendStream sendStream : sendStreams) - try - { - if(logger.isTraceEnabled()) - logger.trace("Stopping send stream with hashcode " - + sendStream.hashCode()); - - sendStream.getDataSource().stop(); - sendStream.stop(); - - if (close) - try - { - sendStream.close(); - } - catch (NullPointerException npe) - { - /* - * Sometimes com.sun.media.rtp.RTCPTransmitter#bye() may - * throw NullPointerException but it does not seem to be - * guaranteed because it does not happen while debugging - * and stopping at a breakpoint on SendStream#close(). - * One of the cases in which it appears upon call - * hang-up is if we do not close the "old" SendStreams - * upon reinvite(s). Though we are now closing such - * SendStreams, ignore the exception here just in case - * because we already ignore IOExceptions. - */ - logger - .error( - "Failed to close stream " + sendStream, - npe); - } - } - catch (IOException ioe) - { - logger.warn("Failed to stop stream " + sendStream, ioe); - } - return sendStreams; - } - - /** - * Returns a human-readable representation of a specific DataSource - * instance in the form of a String value. - * - * @param dataSource the DataSource to return a human-readable - * representation of - * @return a String value which gives a human-readable - * representation of the specified dataSource - */ - public static String toString(DataSource dataSource) - { - StringBuffer str = new StringBuffer(); - - str.append(dataSource.getClass().getSimpleName()); - str.append(" with hashCode "); - str.append(dataSource.hashCode()); - - MediaLocator locator = dataSource.getLocator(); - - if (locator != null) - { - str.append(" and locator "); - str.append(locator); - } - return str.toString(); - } - - /** - * Notifies this ReceiveStreamListener that the RTPManager - * it is registered with has generated an event related to a ReceiveStream. - * - * @param event the ReceiveStreamEvent which specifies the - * ReceiveStream that is the cause of the event and the very type - * of the event - * @see ReceiveStreamListener#update(ReceiveStreamEvent) - */ - public void update(ReceiveStreamEvent event) - { - if (event instanceof NewReceiveStreamEvent) - { - ReceiveStream receiveStream = event.getReceiveStream(); - - if (receiveStream != null) - { - long receiveStreamSSRC = receiveStream.getSSRC(); - - if (logger.isTraceEnabled()) - { - logger.trace( - "Received new ReceiveStream with ssrc " - + receiveStreamSSRC); - } - - addRemoteSourceID(receiveStreamSSRC); - - synchronized (receiveStreams) - { - if (!receiveStreams.contains(receiveStream)) - { - receiveStreams.add(receiveStream); - - MediaDeviceSession deviceSession = getDeviceSession(); - - if (deviceSession != null) - deviceSession.addReceiveStream(receiveStream); - } - } - } - } - else if (event instanceof TimeoutEvent) - { - ReceiveStream receiveStream = event.getReceiveStream(); - - /* - * If we recreate streams, we will already have restarted - * zrtpControl. But when on the other end someone recreates his - * streams, we will receive a ByeEvent (which extends TimeoutEvent) - * and then we must also restart our ZRTP. This happens, for - * example, when we are already in a call and the remote peer - * converts his side of the call into a conference call. - */ - /* - if(!zrtpRestarted) - restartZrtpControl(); - */ - - if (receiveStream != null) - { - synchronized (receiveStreams) - { - if (receiveStreams.contains(receiveStream)) - { - receiveStreams.remove(receiveStream); - - MediaDeviceSession deviceSession = getDeviceSession(); - - if (deviceSession != null) - deviceSession.removeReceiveStream(receiveStream); - } - } - } - } - } - - /** - * Notifies this SendStreamListener that the RTPManager it - * is registered with has generated an event related to a SendStream. - * - * @param event the SendStreamEvent which specifies the - * SendStream that is the cause of the event and the very type of - * the event - * @see SendStreamListener#update(SendStreamEvent) - */ - public void update(SendStreamEvent event) - { - if (event instanceof NewSendStreamEvent) - { - long localSourceID = event.getSendStream().getSSRC(); - - if (getLocalSourceID() != localSourceID) - setLocalSourceID(localSourceID); - } - } - - /** - * Notifies this SessionListener that the RTPManager it is - * registered with has generated an event which pertains to the session as a - * whole and does not belong to a ReceiveStream or a - * SendStream or a remote participant necessarily. - * - * @param event the SessionEvent which specifies the source and the - * very type of the event - * @see SessionListener#update(SessionEvent) - */ - public void update(SessionEvent event) - { - // TODO Auto-generated method stub - } - - /** - * Method called back in the RemoteListener to notify - * listener of all RTP Remote Events.RemoteEvents are one of - * ReceiverReportEvent, SenderReportEvent or RemoteCollisionEvent - * - * @param remoteEvent the event - */ - public void update(RemoteEvent remoteEvent) - { - if(!logger.isInfoEnabled()) - return; - - if(remoteEvent instanceof SenderReportEvent) - { - numberOfReceivedSenderReports++; - - SenderReport report = - ((SenderReportEvent)remoteEvent).getReport(); - - Feedback feedback = null; - long remoteJitter = -1; - - if(report.getFeedbackReports().size() > 0) - { - feedback = (Feedback)report.getFeedbackReports().get(0); - - remoteJitter = feedback.getJitter(); - - if(remoteJitter < minRemoteInterArrivalJitter - ||minRemoteInterArrivalJitter == -1) - minRemoteInterArrivalJitter = remoteJitter; - - if(maxRemoteInterArrivalJitter < remoteJitter) - maxRemoteInterArrivalJitter = remoteJitter; - } - - // As sender reports are received on every 5 seconds - // print every 4th packet, on every 20 seconds - if(numberOfReceivedSenderReports%4 != 1) - return; - - StringBuilder buff - = new StringBuilder(StatisticsEngine.RTP_STAT_PREFIX); - MediaFormat format = getFormat(); - - buff.append("Received a report for ") - .append( - (format == null) - ? "" - : format.getMediaType().toString()) - .append(" stream SSRC:") - .append(getLocalSourceID()) - .append(" [packet count:") - .append(report.getSenderPacketCount()) - .append(", bytes:").append(report.getSenderByteCount()); - - if(feedback != null) - { - buff.append(", interarrival jitter:") - .append(remoteJitter) - .append(", lost packets:").append(feedback.getNumLost()) - .append(", time since previous report:") - .append((int) (feedback.getDLSR() / 65.536)) - .append("ms"); - } - buff.append(" ]"); - logger.info(buff); - } - } - - /** - * Sets the local SSRC identifier and fires the corresponding - * PropertyChangeEvent. - * - * @param localSourceID the SSRC identifier that this stream will be using - * in outgoing RTP packets from now on - */ - protected void setLocalSourceID(long localSourceID) - { - if (this.localSourceID != localSourceID) - { - Long oldValue = this.localSourceID; - - this.localSourceID = localSourceID; - - firePropertyChange(PNAME_LOCAL_SSRC, oldValue, this.localSourceID); - } - } - - /** - * Sets the remote SSRC identifier and fires the corresponding - * PropertyChangeEvent. - * - * @param remoteSourceID the SSRC identifier that this stream will be using - * in outgoing RTP packets from now on. - */ - protected void addRemoteSourceID(long remoteSourceID) - { - Long oldValue = getRemoteSourceID(); - - if(!remoteSourceIDs.contains(remoteSourceID)) - remoteSourceIDs.add(remoteSourceID); - - firePropertyChange(PNAME_REMOTE_SSRC, oldValue, remoteSourceID); - } - - /** - * Returns the list of CSRC identifiers for all parties currently known - * to contribute to the media that this stream is sending toward its remote - * counter part. In other words, the method returns the list of CSRC IDs - * that this stream will include in outgoing RTP packets. This method will - * return an null in case this stream is not part of a mixed - * conference call. - * - * @return a long[] array of CSRC IDs representing parties that are - * currently known to contribute to the media that this stream is sending - * or an null in case this MediaStream is not part of a - * conference call. - */ - public long[] getLocalContributingSourceIDs() - { - return localContributingSourceIDList; - } - - /** - * Returns the List of CSRC identifiers representing the parties - * contributing to the stream that we are receiving from this - * MediaStream's remote party. - * - * @return a List of CSRC identifiers representing the parties - * contributing to the stream that we are receiving from this - * MediaStream's remote party. - */ - public long[] getRemoteContributingSourceIDs() - { - long[] remoteSsrcList = getDeviceSession().getRemoteSSRCList(); - - // TODO implement - - return remoteSsrcList; - } - - /** - * Used to set the priority of the receive/send streams. Underling - * implementations can override this and return different than - * current default value. - * - * @return the priority for the current thread. - */ - protected int getPriority() - { - return Thread.currentThread().getPriority(); - } - - /** - * Prints all statistics available for {@link #rtpManager}. - * - * @param rtpManager the RTPManager to print statistics for - */ - private void printFlowStatistics(StreamRTPManager rtpManager) - { - try - { - if(!logger.isInfoEnabled()) - return; - - //print flow statistics. - GlobalTransmissionStats s = rtpManager.getGlobalTransmissionStats(); - - StringBuilder buff = - new StringBuilder(StatisticsEngine.RTP_STAT_PREFIX); - - buff.append("call stats for outgoing ") - .append(getFormat() != null ? getFormat().getMediaType() : "") - .append(" stream SSRC:") - .append(getLocalSourceID()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("bytes sent: ").append(s.getBytesSent()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("RTP sent: ").append(s.getRTPSent()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("remote reported min interarrival jitter : ") - .append(minRemoteInterArrivalJitter) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("remote reported max interarrival jitter : ") - .append(maxRemoteInterArrivalJitter) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("local collisions: ").append(s.getLocalColls()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("remote collisions: ").append(s.getRemoteColls()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("RTCP sent: ").append(s.getRTCPSent()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("transmit failed: ").append(s.getTransmitFailed()); - - logger.info(buff); - - GlobalReceptionStats rs = rtpManager.getGlobalReceptionStats(); - - buff = new StringBuilder(StatisticsEngine.RTP_STAT_PREFIX); - - buff.append("call stats for incoming ") - .append(getFormat() != null ? getFormat().getMediaType() : "") - .append(" stream SSRC:") - .append(getRemoteSourceID()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("packets received: ").append(rs.getPacketsRecd()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("bytes received: ").append(rs.getBytesRecd()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("packets lost: ").append(statisticsEngine.getLost()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("min interarrival jitter : ") - .append(statisticsEngine.getMinInterArrivalJitter()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("max interarrival jitter : ") - .append(statisticsEngine.getMaxInterArrivalJitter()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("RTCPs received: ").append(rs.getRTCPRecd()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("bad RTCP packets: ").append(rs.getBadRTCPPkts()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("bad RTP packets: ").append(rs.getBadRTPkts()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("local collisions: ").append(rs.getLocalColls()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("malformed BYEs: ").append(rs.getMalformedBye()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("malformed RRs: ").append(rs.getMalformedRR()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("malformed SDESs: ").append(rs.getMalformedSDES()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("malformed SRs: ").append(rs.getMalformedSR()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("packets looped: ").append(rs.getPacketsLooped()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("remote collisions: ").append(rs.getRemoteColls()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("SRRs received: ").append(rs.getSRRecd()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("transmit failed: ").append(rs.getTransmitFailed()) - .append("\n").append(StatisticsEngine.RTP_STAT_PREFIX) - .append("unknown types: ").append(rs.getUnknownTypes()); - - logger.info(buff); - } - catch(Throwable t) - { - logger.error("Error writing statistics", t); - } - } - - /** - * Sets the RTPTranslator which is to forward RTP and RTCP traffic - * between this and other MediaStreams. - * - * @param rtpTranslator the RTPTranslator which is to forward RTP - * and RTCP traffic between this and other MediaStreams - */ - public void setRTPTranslator(RTPTranslator rtpTranslator) - { - if (this.rtpTranslator != rtpTranslator) - { - this.rtpTranslator = rtpTranslator; - } - } - - /** - * Returns a MediaStreamStats object used to get statistics about this - * MediaStream. - * - * @return the MediaStreamStats object used to compute the statistics about - * this MediaStream. - */ - public MediaStreamStats getMediaStreamStats() - { - return this.mediaStreamStatsImpl; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/MediaStreamStatsImpl.java b/src/net/java/sip/communicator/impl/neomedia/MediaStreamStatsImpl.java deleted file mode 100644 index 340ce00d9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/MediaStreamStatsImpl.java +++ /dev/null @@ -1,665 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.awt.*; -import java.net.*; - -import javax.media.format.*; -import javax.media.rtp.*; - -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.*; -import net.sf.fmj.media.rtp.*; - -/** - * Class used to compute stats concerning a MediaStream. - * - * @author Vincent Lucas - */ -public class MediaStreamStatsImpl - implements MediaStreamStats -{ - - /** - * Enumeation of the direction (DOWNLOAD or UPLOAD) used for the stats. - */ - private enum StreamDirection - { - DOWNLOAD, - UPLOAD - } - - /** - * The MediaStream used to copte the stats. - */ - private MediaStreamImpl mediaStreamImpl; - - /** - * The last time these stats have been updated. - */ - private long updateTimeMs; - - /** - * The last number of received/sent packets. - */ - private long[] nbPackets = {0, 0}; - - /** - * The last number of sent packets when the last feedback has been received. - * This counter is used to compute the upload loss rate. - */ - private long uploadFeedbackNbPackets = 0; - - /** - * The last number of download/upload lost packets. - */ - private long[] nbLost = {0, 0}; - - /** - * The last number of received/sent Bytes. - */ - private long[] nbByte = {0, 0}; - - /** - * The last download/upload loss rate computed (in %). - */ - private double[] percentLoss = {0, 0}; - - /** - * The last used bandwidth computed in download/upload (in Kbit/s). - */ - private double[] rateKiloBitPerSec = {0, 0}; - - /** - * The last jitter received/sent in a RTCP feedback (in RTP timestamp - * units). - */ - private double[] jitterRTPTimestampUnits = {0, 0}; - - /** - * Creates a new instance of stats concerning a MediaStream. - * - * @param mediaStreamImpl The MediaStreamImpl used to compute the stats. - */ - public MediaStreamStatsImpl(MediaStreamImpl mediaStreamImpl) - { - this.updateTimeMs = System.currentTimeMillis(); - this.mediaStreamImpl = mediaStreamImpl; - } - - /** - * Computes and updates information for a specific stream. - */ - public void updateStats() - { - // Gets the current time. - long currentTimeMs = System.currentTimeMillis(); - - // UPdates stats for the download stream. - this.updateStreamDirectionStats( - StreamDirection.DOWNLOAD, - currentTimeMs); - // UPdates stats for the upload stream. - this.updateStreamDirectionStats( - StreamDirection.UPLOAD, - currentTimeMs); - - // Saves the last update values. - this.updateTimeMs = currentTimeMs; - } - - /** - * Computes and updates information for a specific stream. - * - * @param streamDirection The stream direction (DOWNLOAD or UPLOAD) of the - * stream from which this function updates the stats. - * @param currentTime The current time in ms. - */ - private void updateStreamDirectionStats( - StreamDirection streamDirection, - long currentTimeMs) - { - int streamDirectionIndex = streamDirection.ordinal(); - - // Gets the current number of packets correctly received since the - // beginning of this stream. - long newNbRecv = this.getNbPDU(streamDirection); - // Gets the number of byte received/sent since the beginning of this - // stream. - long newNbByte = this.getNbBytes(streamDirection); - - // Computes the number of update steps which has not been done since - // last update. - long nbSteps = newNbRecv - this.nbPackets[streamDirectionIndex]; - // Even if the remote peer does not send any packets (i.e. is - // microphone is muted), Jitsi must updates it stats. Thus, Jitsi - // computes a number of steps equivalent as if Jitsi receives a packet - // each 20ms (default value). - if(nbSteps == 0) - { - nbSteps = (currentTimeMs - this.updateTimeMs) / 20; - } - - // The upload percentLoss is only computed when a new RTCP feedback is - // received. This is not the case for the download percentLoss which is - // updated for each new RTP packet received. - // Computes the loss rate for this stream. - if(streamDirection == StreamDirection.DOWNLOAD) - { - // Gets the current number of losses in download since the beginning - // of this stream. - long newNbLost = - this.getDownloadNbPDULost() - this.nbLost[streamDirectionIndex]; - - updateNbLoss(streamDirection, newNbLost, nbSteps + newNbLost); - } - - // Computes the bandwidth used by this stream. - double newRateKiloBitPerSec = - MediaStreamStatsImpl.computeRateKiloBitPerSec( - newNbByte - this.nbByte[streamDirectionIndex], - currentTimeMs - this.updateTimeMs); - this.rateKiloBitPerSec[streamDirectionIndex] = - MediaStreamStatsImpl.computeEWMA( - nbSteps, - this.rateKiloBitPerSec[streamDirectionIndex], - newRateKiloBitPerSec); - - // Saves the last update values. - this.nbPackets[streamDirectionIndex] = newNbRecv; - this.nbByte[streamDirectionIndex] = newNbByte; - } - - /** - * Returns the local IP address of the MediaStream. - * - * @return the local IP address of the stream. - */ - public String getLocalIPAddress() - { - InetSocketAddress mediaStreamLocalDataAddress = - mediaStreamImpl.getLocalDataAddress(); - if(mediaStreamLocalDataAddress == null) - { - return null; - } - return mediaStreamLocalDataAddress.getAddress().getHostAddress(); - } - - /** - * Returns the local port of the MediaStream. - * - * @return the local port of the stream. - */ - public int getLocalPort() - { - InetSocketAddress mediaStreamLocalDataAddress = - mediaStreamImpl.getLocalDataAddress(); - if(mediaStreamLocalDataAddress == null) - { - return -1; - } - return mediaStreamLocalDataAddress.getPort(); - } - - /** - * Returns the remote IP address of the MediaStream. - * - * @return the remote IP address of the stream. - */ - public String getRemoteIPAddress() - { - MediaStreamTarget mediaStreamTarget = mediaStreamImpl.getTarget(); - // Stops if the endpoint is disconnected. - if(mediaStreamTarget == null) - { - return null; - } - // Gets this stream IP address endpoint. - return mediaStreamTarget.getDataAddress().getAddress().getHostAddress(); - } - - /** - * Returns the remote port of the MediaStream. - * - * @return the remote port of the stream. - */ - public int getRemotePort() - { - MediaStreamTarget mediaStreamTarget = mediaStreamImpl.getTarget(); - // Stops if the endpoint is disconnected. - if(mediaStreamTarget == null) - { - return -1; - } - // Gets this stream port endpoint. - return mediaStreamTarget.getDataAddress().getPort(); - } - - /** - * Returns the MediaStream enconding. - * - * @return the encoding used by the stream. - */ - public String getEncoding() - { - // Gets this stream encoding. - return mediaStreamImpl.getFormat().getEncoding(); - } - - /** - * Returns the MediaStream enconding rate (in Hz).. - * - * @return the encoding rate used by the stream. - */ - public String getEncodingClockRate() - { - // Gets this stream encoding clock rate. - return mediaStreamImpl.getFormat().getRealUsedClockRateString(); - } - - /** - * Returns the upload video format if this stream uploads a video, or null - * if not. - * - * @return the upload video format if this stream uploads a video, or null - * if not. - */ - private VideoFormat getUploadVideoFormat() - { - MediaDeviceSession mediaDeviceSession - = mediaStreamImpl.getDeviceSession(); - - return - (mediaDeviceSession instanceof VideoMediaDeviceSession) - ? ((VideoMediaDeviceSession) mediaDeviceSession) - .getSentVideoFormat() - : null; - } - - /** - * Returns the download video format if this stream downloads a video, or - * null if not. - * - * @return the download video format if this stream downloads a video, or - * null if not. - */ - private VideoFormat getDownloadVideoFormat() - { - MediaDeviceSession mediaDeviceSession - = mediaStreamImpl.getDeviceSession(); - - return - (mediaDeviceSession instanceof VideoMediaDeviceSession) - ? ((VideoMediaDeviceSession) mediaDeviceSession) - .getReceivedVideoFormat() - : null; - } - - /** - * Returns the upload video size if this stream uploads a video, or null if - * not. - * - * @return the upload video size if this stream uploads a video, or null if - * not. - */ - public Dimension getUploadVideoSize() - { - Dimension videoSize = null; - VideoFormat format = this.getUploadVideoFormat(); - if(format != null) - { - videoSize = format.getSize(); - } - return videoSize; - } - - /** - * Returns the download video size if this stream downloads a video, or - * null if not. - * - * @return the download video size if this stream downloads a video, or null - * if not. - */ - public Dimension getDownloadVideoSize() - { - Dimension videoSize = null; - VideoFormat format = this.getDownloadVideoFormat(); - if(format != null) - { - videoSize = format.getSize(); - } - return videoSize; - } - - /** - * Returns the percent loss of the download stream. - * - * @return the last loss rate computed (in %). - */ - public double getDownloadPercentLoss() - { - return this.percentLoss[StreamDirection.DOWNLOAD.ordinal()]; - } - - /** - * Returns the percent loss of the upload stream. - * - * @return the last loss rate computed (in %). - */ - public double getUploadPercentLoss() - { - return this.percentLoss[StreamDirection.UPLOAD.ordinal()]; - } - - /** - * Returns the bandwidth used by this download stream. - * - * @return the last used download bandwidth computed (in Kbit/s). - */ - public double getDownloadRateKiloBitPerSec() - { - return this.rateKiloBitPerSec[StreamDirection.DOWNLOAD.ordinal()]; - } - - /** - * Returns the bandwidth used by this download stream. - * - * @return the last used upload bandwidth computed (in Kbit/s). - */ - public double getUploadRateKiloBitPerSec() - { - return this.rateKiloBitPerSec[StreamDirection.UPLOAD.ordinal()]; - } - - /** - * Returns the jitter average of this download stream. - * - * @return the last jitter average computed (in ms). - */ - public double getDownloadJitterMs() - { - return this.getJitterMs(StreamDirection.DOWNLOAD); - } - - /** - * Returns the jitter average of this upload stream. - * - * @return the last jitter average computed (in ms). - */ - public double getUploadJitterMs() - { - return this.getJitterMs(StreamDirection.UPLOAD); - } - - /** - * Returns the jitter average of this upload/download stream. - * - * @param streamDirection The stream direction (DOWNLOAD or UPLOAD) of the - * stream from which this function retrieve the jitter. - * - * @return the last jitter average computed (in ms). - */ - private double getJitterMs(StreamDirection streamDirection) - { - double mediaFormatClockRate = - this.mediaStreamImpl.getFormat().getClockRate(); - - // RFC3550 says that concerning the RTP timestamp unit (cf. section 5.1 - // RTP Fixed Header Fields, subsection timestamp: 32 bits): - // As an example, for fixed-rate audio the timestamp clock would likely - // increment by one for each sampling period. - // - // Thus we take the jitter (in RTP timestamp units), converts it to - // seconds (deivision by the codec clock rate) and finally converts it - // in Ms (* 1000). - return (this.jitterRTPTimestampUnits[streamDirection.ordinal()] - / mediaFormatClockRate) * 1000.0; - } - - /** - * Updates the jitter stream stats with the new feedback sent. - * - * @param feedback The last RTCP feedback sent by the MediaStream. - * @param streamDirection The stream direction (DOWNLOAD or UPLOAD) of the - * stream from which this function retrieve the jitter. - */ - private void updateJitterRTPTimestampUnits( - RTCPFeedback feedback, - StreamDirection streamDirection) - { - // Updates the download jitter in RTP timestamp units. - // There is no need to compute a jitter average, since (cf. RFC3550, - // section 6.4.1 SR: Sender Report RTCP Packet, subsection interarrival - // jitter: 32 bits) the value contained in the RTCP sender report packet - // contains a mean deviation of the jitter. - this.jitterRTPTimestampUnits[streamDirection.ordinal()] = - feedback.getJitter(); - } - - /** - * Updates this stream stats with the new feedback sent. - * - * @param feedback The last RTCP feedback sent by the MediaStream. - */ - public void updateNewSentFeedback(RTCPFeedback feedback) - { - updateJitterRTPTimestampUnits(feedback, StreamDirection.DOWNLOAD); - - // No need to update the download loss has we have a more accurate value - // in the global reception stats, which are updated for each new packet - // received. - } - - /** - * Updates this stream stats with the new feedback received. - * - * @param feedback The last RTCP feedback received by the MediaStream. - */ - public void updateNewReceivedFeedback(RTCPFeedback feedback) - { - StreamDirection streamDirection = StreamDirection.UPLOAD; - - updateJitterRTPTimestampUnits(feedback, streamDirection); - - // Updates the loss rate with the RTCP sender report feedback, since - // this is the only information source available for the upalod stream. - long uploadNewNbRecv = feedback.getXtndSeqNum(); - long newNbLost = - feedback.getNumLost() - this.nbLost[streamDirection.ordinal()]; - long nbSteps = uploadNewNbRecv - this.uploadFeedbackNbPackets; - - updateNbLoss(streamDirection, newNbLost, nbSteps); - - // Updates the upload loss counters. - this.uploadFeedbackNbPackets = uploadNewNbRecv; - } - - /** - * Updates the number of loss for a given stream. - * - * @param streamDirection The stream direction (DOWNLOAD or UPLOAD) of the - * stream from which this function updates the stats. - * @param newNbLost The last update of the number of lost. - * @param nbSteps The number of elasped steps since the last number of loss - * update. - */ - private void updateNbLoss( - StreamDirection streamDirection, - long newNbLost, - long nbSteps) - { - int streamDirectionIndex = streamDirection.ordinal(); - - double newPercentLoss = MediaStreamStatsImpl.computePercentLoss( - nbSteps, - newNbLost); - this.percentLoss[streamDirectionIndex] = - MediaStreamStatsImpl.computeEWMA( - nbSteps, - this.percentLoss[streamDirectionIndex], - newPercentLoss); - - // Saves the last update number download lost value. - this.nbLost[streamDirectionIndex] += newNbLost; - } - - /** - * Computes the loss rate. - * - * @param nbLostAndRecv The number of lost and received packets. - * @param nbLost The number of lost packets. - * - * @return The loss rate in percent. - */ - private static double computePercentLoss(long nbLostAndRecv, long nbLost) - { - if(nbLostAndRecv == 0) - { - return 0; - } - return ((double) 100 * nbLost) / ((double)(nbLostAndRecv)); - } - - /** - * Computes the bandwidth usage in Kilo bits per secondes. - * - * @param nbByteRecv The number of Byte received. - * @param callNbTimeMsSpent The time spent since the mediaStreamImpl is - * connected to the endpoint. - * - * @return the bandwidth rate computed in Kilo bits per secondes. - */ - private static double computeRateKiloBitPerSec( - long nbByteRecv, - long callNbTimeMsSpent) - { - if(nbByteRecv == 0) - { - return 0; - } - return (nbByteRecv * 8.0 / 1000.0) / (callNbTimeMsSpent / 1000.0); - } - - /** - * Computes an Exponentially Weighted Moving Average (EWMA). Thus, the most - * recent history has a more preponderant importance in the average - * computed. - * - * @param nbStepSinceLastUpdate The number of step which has not been - * computed since last update. In our case the number of packets received - * since the last computation. - * @param lastValue The value computed during the last update. - * @param newValue The value newly computed. - * - * @return The EWMA average computed. - */ - private static double computeEWMA( - long nbStepSinceLastUpdate, - double lastValue, - double newValue) - { - // For each new packet received the EWMA moves by a 0.1 coefficient. - double EWMACoeff = 0.01 * nbStepSinceLastUpdate; - // EWMA must be <= 1. - if(EWMACoeff > 1) - { - EWMACoeff = 1.0; - } - return lastValue * (1.0 - EWMACoeff) + newValue * EWMACoeff; - - } - - /** - * Returns the number of Protocol Data Units (PDU) sent/received since the - * beginning of the session. - * - * @param streamDirection The stream direction (DOWNLOAD or UPLOAD) of the - * stream from which this function retrieve the number of sent/received - * packets. - * - * @return the number of packets sent/received for this stream. - */ - private long getNbPDU(StreamDirection streamDirection) - { - long nbPDU = 0; - StreamRTPManager rtpManager = this.mediaStreamImpl.getRTPManager(); - - if(rtpManager != null) - { - switch(streamDirection) - { - case UPLOAD: - nbPDU = - rtpManager.getGlobalTransmissionStats().getRTPSent(); - break; - case DOWNLOAD: - GlobalReceptionStats globalReceptionStats = - rtpManager.getGlobalReceptionStats(); - nbPDU = - globalReceptionStats.getPacketsRecd() - - globalReceptionStats.getRTCPRecd(); - break; - } - } - return nbPDU; - } - - /** - * Returns the number of Protocol Data Units (PDU) lost in download since - * the beginning of the session. - * - * @return the number of packets lost for this stream. - */ - private long getDownloadNbPDULost() - { - int nbLost = 0; - java.util.List listReceiveStream = - this.mediaStreamImpl.getDeviceSession().getReceiveStreams(); - - for(int i = 0; i < listReceiveStream.size(); ++i) - { - ReceiveStream receiveStream = listReceiveStream.get(i); - nbLost += receiveStream.getSourceReceptionStats().getPDUlost(); - } - - return nbLost; - } - - /** - * Returns the number of sent/received bytes since the beginning of the - * session. - * - * @param streamDirection The stream direction (DOWNLOAD or UPLOAD) of the - * stream from which this function retrieve the number of sent/received - * bytes. - * - * @return the number of sent/received bytes for this stream. - */ - private long getNbBytes(StreamDirection streamDirection) - { - long nbBytes = 0; - StreamRTPManager rtpManager = this.mediaStreamImpl.getRTPManager(); - - if(rtpManager != null) - { - switch(streamDirection) - { - case DOWNLOAD: - nbBytes = - rtpManager.getGlobalReceptionStats().getBytesRecd(); - break; - case UPLOAD: - nbBytes = - rtpManager.getGlobalTransmissionStats().getBytesSent(); - break; - } - } - return nbBytes; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/MediaUtils.java b/src/net/java/sip/communicator/impl/neomedia/MediaUtils.java deleted file mode 100644 index 91b4d29c8..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/MediaUtils.java +++ /dev/null @@ -1,826 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.util.*; - -import javax.media.*; -import javax.media.format.*; -import javax.sdp.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.h264.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.format.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; -import net.java.sip.communicator.util.*; - -/** - * Implements static utility methods used by media classes. - * - * @author Emil Ivov - * @author Lyubomir Marinov - */ -public class MediaUtils -{ - /** - * The constant which stands for an empty array of MediaFormats. - * Explicitly defined in order to reduce unnecessary allocations. - */ - public static final MediaFormat[] EMPTY_MEDIA_FORMATS = new MediaFormat[0]; - - /** - * The maximum number of channels for audio that is available through - * MediaUtils. - */ - public static final int MAX_AUDIO_CHANNELS; - - /** - * The maximum sample rate for audio that is available through - * MediaUtils. - */ - public static final double MAX_AUDIO_SAMPLE_RATE; - - /** - * The maximum sample size in bits for audio that is available through - * MediaUtils. - */ - public static final int MAX_AUDIO_SAMPLE_SIZE_IN_BITS; - - /** - * The Map of JMF-specific encodings to well-known encodings as - * defined in RFC 3551. - */ - private static final Map jmfEncodingToEncodings - = new HashMap(); - - /** - * The MediaFormats which do not have RTP payload types assigned by - * RFC 3551 and are thus referred to as having dynamic RTP payload types. - */ - private static final List rtpPayloadTypelessMediaFormats - = new ArrayList(); - - /** - * The Map of RTP payload types (expressed as Strings) to - * MediaFormats. - */ - private static final Map - rtpPayloadTypeStrToMediaFormats - = new HashMap(); - - static - { - addMediaFormats( - (byte) SdpConstants.PCMU, - "PCMU", - MediaType.AUDIO, - AudioFormat.ULAW_RTP, - 8000); - - /* - * Some codecs depend on JMF native libraries which are only available - * on 32-bit Linux and 32-bit Windows. - */ - if(OSUtils.IS_LINUX32 || OSUtils.IS_WINDOWS32) - { - Map g723FormatParams - = new HashMap(); - g723FormatParams.put("annexa", "no"); - g723FormatParams.put("bitrate", "6.3"); - addMediaFormats( - (byte) SdpConstants.G723, - "G723", - MediaType.AUDIO, - AudioFormat.G723_RTP, - g723FormatParams, - null, - 8000); - } - - addMediaFormats( - (byte) SdpConstants.GSM, - "GSM", - MediaType.AUDIO, - AudioFormat.GSM_RTP, - 8000); - addMediaFormats( - (byte) SdpConstants.DVI4_8000, - "DVI4", - MediaType.AUDIO, - AudioFormat.DVI_RTP, - 8000); - addMediaFormats( - (byte) SdpConstants.DVI4_16000, - "DVI4", - MediaType.AUDIO, - AudioFormat.DVI_RTP, - 16000); - addMediaFormats( - (byte) SdpConstants.PCMA, - "PCMA", - MediaType.AUDIO, - Constants.ALAW_RTP, - 8000); - addMediaFormats( - MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN, - "iLBC", - MediaType.AUDIO, - Constants.ILBC_RTP, - 8000); - addMediaFormats( - MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN, - "speex", - MediaType.AUDIO, - Constants.SPEEX_RTP, - 8000, 16000, 32000); - addMediaFormats( - (byte) SdpConstants.G722, - "G722", - MediaType.AUDIO, - Constants.G722_RTP, - 8000); - if (EncodingConfiguration.G729) - { - addMediaFormats( - (byte) SdpConstants.G729, - "G729", - MediaType.AUDIO, - AudioFormat.G729_RTP, - 8000); - } - addMediaFormats( - MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN, - "SILK", - MediaType.AUDIO, - Constants.SILK_RTP, - 8000, 12000, 16000, 24000); - addMediaFormats( - MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN, - "telephone-event", - MediaType.AUDIO, - Constants.TELEPHONE_EVENT, - 8000); - - /* - * We don't really support these. - * - addMediaFormats( - (byte) SdpConstants.JPEG, - "JPEG", - MediaType.VIDEO, - VideoFormat.JPEG_RTP); - addMediaFormats( - (byte) SdpConstants.H263, - "H263", - MediaType.VIDEO, - VideoFormat.H263_RTP); - addMediaFormats( - (byte) SdpConstants.H261, - "H261", - MediaType.VIDEO, - VideoFormat.H261_RTP); - */ - - /* H264 */ - Map h264FormatParams - = new HashMap(); - String packetizationMode = "packetization-mode"; - Map h264AdvancedAttributes - = new HashMap(); - - /* - * Disable PLI since we use the periodic intra-refresh feature of - * FFmpeg/x264. - */ - //h264AdvancedAttributes.put("rtcp-fb", "nack pli"); - - /* - * XXX The initialization of MediaServiceImpl is very complex so it is - * wise to not reference it at the early stage of its initialization. - */ - ScreenDevice screen = ScreenDeviceImpl.getDefaultScreenDevice(); - java.awt.Dimension res = (screen == null) ? null : screen.getSize(); - - h264AdvancedAttributes.put("imageattr", createImageAttr(null, res)); - - // packetization-mode=1 - h264FormatParams.put(packetizationMode, "1"); - - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - - if ((cfg == null) - || cfg - .getString( - "net.java.sip.communicator.impl.neomedia" - + ".codec.video.h264.defaultProfile", - JNIEncoder.MAIN_PROFILE) - .equals(JNIEncoder.MAIN_PROFILE)) - { - // main profile, common features, HD capable level 3.1 - h264FormatParams.put("profile-level-id", "4DE01f"); - } - else - { - // baseline profile, common features, HD capable level 3.1 - h264FormatParams.put("profile-level-id", "42E01f"); - } - - addMediaFormats( - MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN, - "H264", - MediaType.VIDEO, - Constants.H264_RTP, - h264FormatParams, - h264AdvancedAttributes); - /* - * XXX Android's current video CaptureDevice is based on MediaRecorder - * and provides support for packetization-mode=1 only. - */ - if (!OSUtils.IS_ANDROID) - { - // packetization-mode=0 - /* - * XXX At the time of this writing, - * EncodingConfiguration#compareEncodingPreferences(MediaFormat, - * MediaFormat) is incomplete and considers two MediaFormats to be equal - * if they have an equal number of format parameters (given that the - * encodings and clock rates are equal, of course). Either fix the - * method in question or don't add a format parameter for packetization - * mode 0 (which is equivalent to having packetization-mode explicitly - * defined as 0 anyway, according to the respective RFC). - */ - h264FormatParams.remove(packetizationMode); - addMediaFormats( - MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN, - "H264", - MediaType.VIDEO, - Constants.H264_RTP, - h264FormatParams, - h264AdvancedAttributes); - } - - /* H263+ */ - Map h263FormatParams - = new HashMap(); - Map h263AdvancedAttributes - = new LinkedHashMap(); - - /* - * The maximum resolution we can receive is the size of our screen - * device. - */ - if (res != null) - h263FormatParams.put("CUSTOM", res.width + "," + res.height + ",2"); - h263FormatParams.put("VGA", "2"); - h263FormatParams.put("CIF", "1"); - h263FormatParams.put("QCIF", "1"); - - addMediaFormats( - MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN, - "H263-1998", - MediaType.VIDEO, - Constants.H263P_RTP, - h263FormatParams, - h263AdvancedAttributes); - - // Calculate the values of the MAX_AUDIO_* static fields of MediaUtils. - List audioMediaFormats - = new ArrayList( - rtpPayloadTypeStrToMediaFormats.size() - + rtpPayloadTypelessMediaFormats.size()); - - for (MediaFormat[] mediaFormats - : rtpPayloadTypeStrToMediaFormats.values()) - for (MediaFormat mediaFormat : mediaFormats) - if (MediaType.AUDIO.equals(mediaFormat.getMediaType())) - audioMediaFormats.add(mediaFormat); - for (MediaFormat mediaFormat : rtpPayloadTypelessMediaFormats) - if (MediaType.AUDIO.equals(mediaFormat.getMediaType())) - audioMediaFormats.add(mediaFormat); - - int maxAudioChannels = Format.NOT_SPECIFIED; - double maxAudioSampleRate = Format.NOT_SPECIFIED; - int maxAudioSampleSizeInBits = Format.NOT_SPECIFIED; - - for (MediaFormat mediaFormat : audioMediaFormats) - { - AudioMediaFormatImpl audioMediaFormat - = (AudioMediaFormatImpl) mediaFormat; - int channels = audioMediaFormat.getChannels(); - double sampleRate = audioMediaFormat.getClockRate(); - int sampleSizeInBits - = audioMediaFormat.getFormat().getSampleSizeInBits(); - - if (maxAudioChannels < channels) - maxAudioChannels = channels; - if (maxAudioSampleRate < sampleRate) - maxAudioSampleRate = sampleRate; - if (maxAudioSampleSizeInBits < sampleSizeInBits) - maxAudioSampleSizeInBits = sampleSizeInBits; - } - - MAX_AUDIO_CHANNELS = maxAudioChannels; - MAX_AUDIO_SAMPLE_RATE = maxAudioSampleRate; - MAX_AUDIO_SAMPLE_SIZE_IN_BITS = maxAudioSampleSizeInBits; - } - - /** - * Adds a new mapping of a specific RTP payload type to a list of - * MediaFormats of a specific MediaType, with a specific - * JMF encoding and, optionally, with specific clock rates. - * - * @param rtpPayloadType the RTP payload type to be associated with a list - * of MediaFormats - * @param encoding the well-known encoding (name) corresponding to - * rtpPayloadType (in contrast to the JMF-specific encoding - * specified by jmfEncoding) - * @param mediaType the MediaType of the MediaFormats to - * be associated with rtpPayloadType - * @param jmfEncoding the JMF encoding of the MediaFormats to be - * associated with rtpPayloadType - * @param clockRates the optional list of clock rates of the - * MediaFormats to be associated with rtpPayloadType - */ - private static void addMediaFormats( - byte rtpPayloadType, - String encoding, - MediaType mediaType, - String jmfEncoding, - double... clockRates) - { - addMediaFormats( - rtpPayloadType, - encoding, - mediaType, - jmfEncoding, - null, - null, - clockRates); - } - - /** - * Adds a new mapping of a specific RTP payload type to a list of - * MediaFormats of a specific MediaType, with a specific - * JMF encoding and, optionally, with specific clock rates. - * - * @param rtpPayloadType the RTP payload type to be associated with a list - * of MediaFormats - * @param encoding the well-known encoding (name) corresponding to - * rtpPayloadType (in contrast to the JMF-specific encoding - * specified by jmfEncoding) - * @param mediaType the MediaType of the MediaFormats to - * be associated with rtpPayloadType - * @param jmfEncoding the JMF encoding of the MediaFormats to be - * associated with rtpPayloadType - * @param formatParameters the set of format-specific parameters of the - * MediaFormats to be associated with rtpPayloadType - * @param advancedAttributes the set of advanced attributes of the - * MediaFormats to be associated with rtpPayload - * @param clockRates the optional list of clock rates of the - * MediaFormats to be associated with rtpPayloadType - */ - @SuppressWarnings("unchecked") - private static void addMediaFormats( - byte rtpPayloadType, - String encoding, - MediaType mediaType, - String jmfEncoding, - Map formatParameters, - Map advancedAttributes, - double... clockRates) - { - int clockRateCount = clockRates.length; - List mediaFormats - = new ArrayList(clockRateCount); - - if (clockRateCount > 0) - { - for (double clockRate : clockRates) - { - Format format; - - switch (mediaType) - { - case AUDIO: - format = new AudioFormat(jmfEncoding); - break; - case VIDEO: - format - = new ParameterizedVideoFormat( - jmfEncoding, - formatParameters); - break; - default: - throw new IllegalArgumentException("mediaType"); - } - - MediaFormat mediaFormat - = MediaFormatImpl.createInstance( - format, - clockRate, - formatParameters, - advancedAttributes); - - if (mediaFormat != null) - mediaFormats.add(mediaFormat); - } - } - else - { - Format format; - double clockRate; - - switch (mediaType) - { - case AUDIO: - AudioFormat audioFormat = new AudioFormat(jmfEncoding); - - format = audioFormat; - clockRate = audioFormat.getSampleRate(); - break; - case VIDEO: - format - = new ParameterizedVideoFormat( - jmfEncoding, - formatParameters); - clockRate = VideoMediaFormatImpl.DEFAULT_CLOCK_RATE; - break; - default: - throw new IllegalArgumentException("mediaType"); - } - - MediaFormat mediaFormat - = MediaFormatImpl.createInstance( - format, - clockRate, - formatParameters, - advancedAttributes); - - if (mediaFormat != null) - mediaFormats.add(mediaFormat); - } - - if (mediaFormats.size() > 0) - { - if (MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN == rtpPayloadType) - rtpPayloadTypelessMediaFormats.addAll(mediaFormats); - else - rtpPayloadTypeStrToMediaFormats.put( - Byte.toString(rtpPayloadType), - mediaFormats.toArray(EMPTY_MEDIA_FORMATS)); - - jmfEncodingToEncodings.put( - ((MediaFormatImpl) mediaFormats.get(0)) - .getJMFEncoding(), - encoding); - } - } - - /** - * Gets a MediaFormat predefined in MediaUtils which - * represents a specific JMF Format. If there is no such - * representing MediaFormat in MediaUtils, returns - * null. - * - * @param format the JMF Format to get the MediaFormat - * representation for - * @return a MediaFormat predefined in MediaUtils which - * represents format if any; null if there is no such - * representing MediaFormat in MediaUtils - */ - @SuppressWarnings("unchecked") - public static MediaFormat getMediaFormat(Format format) - { - double clockRate; - - if (format instanceof AudioFormat) - clockRate = ((AudioFormat) format).getSampleRate(); - else if (format instanceof VideoFormat) - clockRate = VideoMediaFormatImpl.DEFAULT_CLOCK_RATE; - else - clockRate = Format.NOT_SPECIFIED; - - byte rtpPayloadType = getRTPPayloadType(format.getEncoding(), clockRate); - - if (MediaFormatImpl.RTP_PAYLOAD_TYPE_UNKNOWN != rtpPayloadType) - { - for (MediaFormat mediaFormat : getMediaFormats(rtpPayloadType)) - { - MediaFormatImpl mediaFormatImpl - = (MediaFormatImpl) mediaFormat; - - if (format.matches(mediaFormatImpl.getFormat())) - return mediaFormat; - } - } - return null; - } - - /** - * Gets the MediaFormat known to MediaUtils and having the - * specified well-known encoding (name) and clockRate. - * - * @param encoding the well-known encoding (name) of the - * MediaFormat to get - * @param clockRate the clock rate of the MediaFormat to get - * @return the MediaFormat known to MediaUtils and having - * the specified encoding and clockRate - */ - public static MediaFormat getMediaFormat(String encoding, double clockRate) - { - return getMediaFormat(encoding, clockRate, null); - } - - /** - * Gets the MediaFormat known to MediaUtils and having the - * specified well-known encoding (name), clockRate and - * matching format parameters. - * - * @param encoding the well-known encoding (name) of the - * MediaFormat to get - * @param clockRate the clock rate of the MediaFormat to get - * @param fmtps the format parameters of the MediaFormat to get - * @return the MediaFormat known to MediaUtils and having - * the specified encoding (name), clockRate and matching - * format parameters - */ - public static MediaFormat getMediaFormat( - String encoding, double clockRate, - Map fmtps) - { - for (MediaFormat format : getMediaFormats(encoding)) - if ((format.getClockRate() == clockRate) - && format.formatParametersMatch(fmtps)) - return format; - return null; - } - - /** - * Gets the index of a specific MediaFormat instance within the - * internal storage of MediaUtils. Since the index is in the - * internal storage which may or may not be one and the same for the various - * MediaFormat instances and which may or may not be searched for - * the purposes of determining the index, the index is not to be used as a - * way to determine whether MediaUtils knows the specified - * mediaFormat - * - * @param mediaFormat the MediaFormat to determine the index of - * @return the index of the specified mediaFormat in the internal - * storage of MediaUtils - */ - public static int getMediaFormatIndex(MediaFormat mediaFormat) - { - return rtpPayloadTypelessMediaFormats.indexOf(mediaFormat); - } - - /** - * Gets the MediaFormats predefined in MediaUtils with a - * specific well-known encoding (name) as defined by RFC 3551 "RTP Profile - * for Audio and Video Conferences with Minimal Control". - * - * @param encoding the well-known encoding (name) to get the corresponding - * MediaFormats of - * @return a List of MediaFormats corresponding to the - * specified encoding (name) - */ - @SuppressWarnings("unchecked") - public static List getMediaFormats(String encoding) - { - String jmfEncoding = null; - - for (Map.Entry jmfEncodingToEncoding - : jmfEncodingToEncodings.entrySet()) - if (jmfEncodingToEncoding.getValue().equals(encoding)) - { - jmfEncoding = jmfEncodingToEncoding.getKey(); - break; - } - - List mediaFormats = new ArrayList(); - - if (jmfEncoding != null) - { - for (MediaFormat[] rtpPayloadTypeMediaFormats - : rtpPayloadTypeStrToMediaFormats.values()) - for (MediaFormat rtpPayloadTypeMediaFormat - : rtpPayloadTypeMediaFormats) - if (((MediaFormatImpl) - rtpPayloadTypeMediaFormat) - .getJMFEncoding().equals(jmfEncoding)) - mediaFormats.add(rtpPayloadTypeMediaFormat); - - - if (mediaFormats.size() < 1) - { - for (MediaFormat rtpPayloadTypelessMediaFormat - : rtpPayloadTypelessMediaFormats) - if (((MediaFormatImpl) - rtpPayloadTypelessMediaFormat) - .getJMFEncoding().equals(jmfEncoding)) - mediaFormats.add(rtpPayloadTypelessMediaFormat); - } - } - return mediaFormats; - } - - /** - * Gets the MediaFormats known to MediaUtils and being of - * the specified MediaType. - * - * @param mediaType the MediaType of the MediaFormats to - * get - * @return the MediaFormats known to MediaUtils and being - * of the specified mediaType - */ - public static MediaFormat[] getMediaFormats(MediaType mediaType) - { - List mediaFormats = new ArrayList(); - - for (MediaFormat[] formats : rtpPayloadTypeStrToMediaFormats.values()) - for (MediaFormat format : formats) - if (format.getMediaType().equals(mediaType)) - mediaFormats.add(format); - for (MediaFormat format : rtpPayloadTypelessMediaFormats) - if (format.getMediaType().equals(mediaType)) - mediaFormats.add(format); - return mediaFormats.toArray(EMPTY_MEDIA_FORMATS); - } - - /** - * Gets the MediaFormats (expressed as an array) corresponding to - * a specific RTP payload type. - * - * @param rtpPayloadType the RTP payload type to retrieve the - * corresponding MediaFormats for - * @return an array of MediaFormats corresponding to the specified - * RTP payload type - */ - public static MediaFormat[] getMediaFormats(byte rtpPayloadType) - { - MediaFormat[] mediaFormats - = rtpPayloadTypeStrToMediaFormats.get(Byte.toString(rtpPayloadType)); - - return - (mediaFormats == null) - ? EMPTY_MEDIA_FORMATS - : mediaFormats.clone(); - } - - /** - * Gets the well-known encoding (name) as defined in RFC 3551 "RTP Profile - * for Audio and Video Conferences with Minimal Control" corresponding to a - * given JMF-specific encoding. - * - * @param jmfEncoding the JMF encoding to get the corresponding well-known - * encoding of - * @return the well-known encoding (name) as defined in RFC 3551 "RTP - * Profile for Audio and Video Conferences with Minimal Control" - * corresponding to jmfEncoding if any; otherwise, null - */ - public static String jmfEncodingToEncoding(String jmfEncoding) - { - return jmfEncodingToEncodings.get(jmfEncoding); - } - - /** - * Gets the RTP payload type corresponding to a specific JMF encoding and - * clock rate. - * - * @param jmfEncoding the JMF encoding as returned by - * {@link Format#getEncoding()} or the respective AudioFormat and - * VideoFormat encoding constants to get the corresponding RTP - * payload type of - * @param clockRate the clock rate to be taken into account in the search - * for the RTP payload type if the JMF encoding does not uniquely identify - * it - * @return the RTP payload type corresponding to the specified JMF encoding - * and clock rate if known in RFC 3551 "RTP Profile for Audio and Video - * Conferences with Minimal Control"; otherwise, - * {@link MediaFormat#RTP_PAYLOAD_TYPE_UNKNOWN} - */ - public static byte getRTPPayloadType(String jmfEncoding, double clockRate) - { - if (jmfEncoding == null) - return MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN; - else if (jmfEncoding.equals(AudioFormat.ULAW_RTP)) - return SdpConstants.PCMU; - else if (jmfEncoding.equals(Constants.ALAW_RTP)) - return SdpConstants.PCMA; - else if (jmfEncoding.equals(AudioFormat.GSM_RTP)) - return SdpConstants.GSM; - else if (jmfEncoding.equals(AudioFormat.G723_RTP)) - return SdpConstants.G723; - else if (jmfEncoding.equals(AudioFormat.DVI_RTP) - && (clockRate == 8000)) - return SdpConstants.DVI4_8000; - else if (jmfEncoding.equals(AudioFormat.DVI_RTP) - && (clockRate == 16000)) - return SdpConstants.DVI4_16000; - else if (jmfEncoding.equals(AudioFormat.ALAW)) - return SdpConstants.PCMA; - else if (jmfEncoding.equals(Constants.G722)) - return SdpConstants.G722; - else if (jmfEncoding.equals(Constants.G722_RTP)) - return SdpConstants.G722; - else if (jmfEncoding.equals(AudioFormat.GSM)) - return SdpConstants.GSM; - else if (jmfEncoding.equals(AudioFormat.GSM_RTP)) - return SdpConstants.GSM; - else if (jmfEncoding.equals(AudioFormat.G728_RTP)) - return SdpConstants.G728; - else if (jmfEncoding.equals(AudioFormat.G729_RTP)) - return SdpConstants.G729; - else if (jmfEncoding.equals(VideoFormat.H263_RTP)) - return SdpConstants.H263; - else if (jmfEncoding.equals(VideoFormat.JPEG_RTP)) - return SdpConstants.JPEG; - else if (jmfEncoding.equals(VideoFormat.H261_RTP)) - return SdpConstants.H261; - else - return MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN; - } - - - /** - * Creates value of an imgattr. - * - * http://tools.ietf.org/html/draft-ietf-mmusic-image-attributes-04 - * - * @param sendSize maximum size peer can send - * @param maxRecvSize maximum size peer can display - * @return string that represent imgattr that can be encoded via SIP/SDP or - * XMPP/Jingle - */ - public static String createImageAttr(java.awt.Dimension sendSize, - java.awt.Dimension maxRecvSize) - { - StringBuffer img = new StringBuffer(); - - /* send width */ - if(sendSize != null) - { - /* single value => send [x=width,y=height] */ - /*img.append("send [x="); - img.append((int)sendSize.getWidth()); - img.append(",y="); - img.append((int)sendSize.getHeight()); - img.append("]");*/ - /* send [x=[min-max],y=[min-max]] */ - img.append("send [x=[0-"); - img.append((int)sendSize.getWidth()); - img.append("],y=[0-"); - img.append((int)sendSize.getHeight()); - img.append("]]"); - /* - else - { - // range - img.append(" send [x=["); - img.append((int)minSendSize.getWidth()); - img.append("-"); - img.append((int)maxSendSize.getWidth()); - img.append("],y=["); - img.append((int)minSendSize.getHeight()); - img.append("-"); - img.append((int)maxSendSize.getHeight()); - img.append("]]"); - } - */ - } - else - { - /* can send "all" sizes */ - img.append("send *"); - } - - /* receive size */ - if(maxRecvSize != null) - { - /* basically we can receive any size up to our - * screen display size - */ - - /* recv [x=[min-max],y=[min-max]] */ - img.append(" recv [x=[0-"); - img.append((int)maxRecvSize.getWidth()); - img.append("],y=[0-"); - img.append((int)maxRecvSize.getHeight()); - img.append("]]"); - } - else - { - /* accept all sizes */ - img.append(" recv *"); - } - - return img.toString(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/NeomediaActivator.java b/src/net/java/sip/communicator/impl/neomedia/NeomediaActivator.java index 01a2f0ad6..c25dee583 100644 --- a/src/net/java/sip/communicator/impl/neomedia/NeomediaActivator.java +++ b/src/net/java/sip/communicator/impl/neomedia/NeomediaActivator.java @@ -14,18 +14,20 @@ import javax.swing.*; import net.java.sip.communicator.impl.neomedia.codec.video.h264.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.notify.*; -import net.java.sip.communicator.service.audionotifier.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.packetlogging.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.impl.neomedia.*; +import org.jitsi.impl.neomedia.device.*; +import org.jitsi.service.audionotifier.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; +import org.jitsi.service.libjitsi.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.packetlogging.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** @@ -143,7 +145,7 @@ public void start(BundleContext bundleContext) NeomediaActivator.bundleContext = bundleContext; // MediaService - mediaServiceImpl = new MediaServiceImpl(); + mediaServiceImpl = (MediaServiceImpl) LibJitsi.getMediaService(); bundleContext.registerService( MediaService.class.getName(), @@ -258,8 +260,7 @@ public void propertyChange(PropertyChangeEvent event) // AudioNotifierService AudioNotifierService audioNotifierService - = new AudioNotifierServiceImpl( - mediaServiceImpl.getDeviceConfiguration()); + = LibJitsi.getAudioNotifierService(); audioNotifierService.setMute( (cfg == null) diff --git a/src/net/java/sip/communicator/impl/neomedia/ProcessorUtility.java b/src/net/java/sip/communicator/impl/neomedia/ProcessorUtility.java deleted file mode 100644 index 5a2abd17d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/ProcessorUtility.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import javax.media.*; - -import net.java.sip.communicator.util.*; - -/** - * A utility class that provides utility functions when working with processors. - * - * @author Emil Ivov - * @author Ken Larson - * @author Lubomir Marinov - */ -public class ProcessorUtility - implements ControllerListener -{ - - /** - * The Logger used by the ProcessorUtility class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(ProcessorUtility.class); - - /** - * The Object used for syncing when waiting for a processor to - * enter a specific state. - */ - private final Object stateLock = new Object(); - - /** - * The indicator which determines whether the waiting of this instance on a - * processor for it to enter a specific state has failed. - */ - private boolean failed = false; - - /** - * Initializes a new ProcessorUtility instance. - */ - public ProcessorUtility() - { - } - - /** - * Gets the Object to use for syncing when waiting for a processor - * to enter a specific state. - * - * @return the Object to use for syncing when waiting for a - * processor to enter a specific state - */ - private Object getStateLock() - { - return stateLock; - } - - /** - * Specifies whether the wait operation has failed or completed with - * success. - * - * @param failed true if waiting has failed; false, - * otherwise - */ - private void setFailed(boolean failed) - { - this.failed = failed; - } - - /** - * This method is called when an event is generated by a - * Controller that this listener is registered with. We use - * the event to notify all waiting on our lock and record success or - * failure. - * - * @param ce The event generated. - */ - public void controllerUpdate(ControllerEvent ce) - { - // If there was an error during configure or - // realize, the processor will be closed - if (ce instanceof ControllerClosedEvent) - { - if (ce instanceof ControllerErrorEvent) - logger.warn("ControllerErrorEvent: " + ce); - else - if (logger.isDebugEnabled()) - logger.debug("ControllerClosedEvent: " + ce); - - setFailed(true); - - // All controller events, send a notification - // to the waiting thread in waitForState method. - } - - Object stateLock = getStateLock(); - - synchronized (stateLock) - { - stateLock.notifyAll(); - } - } - - /** - * Waits until processor enters state and returns a boolean - * indicating success or failure of the operation. - * - * @param processor Processor - * @param state one of the Processor.XXXed state vars - * @return true if the state has been reached; false, - * otherwise - */ - public synchronized boolean waitForState(Processor processor, int state) - { - processor.addControllerListener(this); - setFailed(false); - - // Call the required method on the processor - if (state == Processor.Configured) - processor.configure(); - else if (state == Processor.Realized) - processor.realize(); - - // Wait until we get an event that confirms the - // success of the method, or a failure event. - // See StateListener inner class - while ((processor.getState() < state) && !failed) - { - Object stateLock = getStateLock(); - - synchronized (stateLock) - { - try - { - stateLock.wait(); - } - catch (InterruptedException ie) - { - logger - .warn( - "Failed while waiting on Processor " - + processor - + " for state " - + state, - ie); - processor.removeControllerListener(this); - return false; - } - } - } - - processor.removeControllerListener(this); - return !failed; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/RTCPConnectorInputStream.java b/src/net/java/sip/communicator/impl/neomedia/RTCPConnectorInputStream.java deleted file mode 100644 index d25f1eb14..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RTCPConnectorInputStream.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.net.*; -import java.util.*; - -import net.java.sip.communicator.service.neomedia.event.*; - -/** - * @author Bing SU (nova.su@gmail.com) - * @author Lyubomir Marinov - * @author Sebastien Vincent - */ -public class RTCPConnectorInputStream - extends RTPConnectorUDPInputStream -{ - /** - * List of feedback listeners; - */ - private final List rtcpFeedbackListeners - = new ArrayList(); - - /** - * Initializes a new RTCPConnectorInputStream which is to receive - * packet data from a specific UDP socket. - * - * @param socket the UDP socket the new instance is to receive data from - */ - public RTCPConnectorInputStream(DatagramSocket socket) - { - super(socket); - } - - /** - * Add an RTCPFeedbackListener. - * - * @param listener object that will listen to incoming RTCP feedback - * messages. - */ - public void addRTCPFeedbackListener(RTCPFeedbackListener listener) - { - if(!rtcpFeedbackListeners.contains(listener)) - rtcpFeedbackListeners.add(listener); - } - - /** - * Remove an RTCPFeedbackListener. - * - * @param listener object to remove from listening RTCP feedback messages. - */ - public void removeRTCPFeedbackListener(RTCPFeedbackListener listener) - { - rtcpFeedbackListeners.remove(listener); - } - - /** - * Copies the content of the most recently received packet into - * inBuffer. - * - * @param inBuffer the byte[] that we'd like to copy the content - * of the packet to. - * @param offset the position where we are supposed to start writing in - * inBuffer. - * @param length the number of bytes available for writing in - * inBuffer. - * - * @return the number of bytes read - * - * @throws IOException if length is less than the size of the - * packet. - */ - public int read(byte[] inBuffer, int offset, int length) - throws IOException - { - if (ioError) - return -1; - - int pktLength = pkt.getLength(); - - if (length < pktLength) - throw - new IOException("Input buffer not big enough for " + pktLength); - - /* check if RTCP feedback message */ - - /* Feedback message size is minimum 12 bytes: - * Version/Padding/Feedback message type: 1 byte - * Payload type: 1 byte - * Length: 2 bytes - * SSRC of packet sender: 4 bytes - * SSRC of media source: 4 bytes - */ - if(pktLength >= 12) - { - byte data[] = pkt.getBuffer(); - int fmt = 0; - int pt = 0; - - /* get FMT field (last 5 bits of first byte) */ - fmt = (data[0] & 0x1F); - pt |= (data[1] & 0xFF); - - RTCPFeedbackEvent evt = new RTCPFeedbackEvent(this, fmt, pt); - - /* notify feedback listeners */ - for(RTCPFeedbackListener l : rtcpFeedbackListeners) - l.feedbackReceived(evt); - } - - System.arraycopy( - pkt.getBuffer(), pkt.getOffset(), inBuffer, offset, pktLength); - - return pktLength; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/RTCPFeedbackPacket.java b/src/net/java/sip/communicator/impl/neomedia/RTCPFeedbackPacket.java deleted file mode 100644 index 145498bc9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RTCPFeedbackPacket.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import javax.media.rtp.*; - -/** - * Represents an RTCP feedback packet as described in RFC4585. - * - * @author Sebastien Vincent - */ -public class RTCPFeedbackPacket -{ - /** - * Feedback message type. - */ - private int fmt = 0; - - /** - * Payload type. - */ - private int payloadType = 0; - - /** - * SSRC of packet sender. - */ - private long senderSSRC = 0; - - /** - * SSRC of media source. - */ - private long sourceSSRC = 0; - - /** - * Constructor. - * - * @param type feedback message type - * @param payloadType payload type - * @param sender sender SSRC - * @param src source SSRC - */ - public RTCPFeedbackPacket(int type, int payloadType, long sender, long src) - { - this.fmt = type; - this.payloadType = payloadType; - this.senderSSRC = sender; - this.sourceSSRC = src; - } - - /** - * Write RTCP packet to output stream of a DatagramSocket. - * - * @param out OutputDataStream of a DatagramSocket - */ - public void writeTo(OutputDataStream out) - { - byte data[] = new byte[12]; - byte vpfmt = (byte)((2 << 7) | (0 << 6) | (byte)fmt); - - data[0] = vpfmt; - data[1] = (byte)payloadType; - - /* length (in 32-bit words minus one) */ - data[2] = 0; - data[3] = 2; /* common packet is 12 bytes so (12/4) - 1 */ - - /* sender SSRC */ - data[4] = (byte)(senderSSRC >> 24); - data[5] = (byte)((senderSSRC >> 16) & 0xFF); - data[6] = (byte)((senderSSRC >> 8) & 0xFF); - data[7] = (byte)(senderSSRC & 0xFF); - - /* source SSRC */ - data[8] = (byte)(sourceSSRC >> 24); - data[9] = (byte)((sourceSSRC >> 16) & 0xFF); - data[10] = (byte)((sourceSSRC >> 8) & 0xFF); - data[11] = (byte)(sourceSSRC & 0xFF); - - /* effective write */ - out.write(data, 0, 12); - } -} - diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorInputStream.java b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorInputStream.java deleted file mode 100755 index 541a05965..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorInputStream.java +++ /dev/null @@ -1,425 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.net.*; - -import javax.media.protocol.*; - -import org.ice4j.socket.*; - -import net.java.sip.communicator.service.packetlogging.*; -import net.java.sip.communicator.util.*; - -/** - * @author Bing SU (nova.su@gmail.com) - * @author Lyubomir Marinov - */ -public abstract class RTPConnectorInputStream - implements PushSourceStream, - Runnable -{ - /** - * The value of the property controls of - * RTPConnectorInputStream when there are no controls. Explicitly - * defined in order to reduce unnecessary allocations. - */ - private static final Object[] EMPTY_CONTROLS = new Object[0]; - - /** - * The length in bytes of the buffers of RTPConnectorInputStream - * receiving packets from the network. - */ - private static final int PACKET_RECEIVE_BUFFER_LENGTH = 4 * 1024; - - /** - * Packet receive buffer - */ - private final byte[] buffer = new byte[PACKET_RECEIVE_BUFFER_LENGTH]; - - /** - * Whether this stream is closed. Used to control the termination of worker - * thread. - */ - protected boolean closed; - - /** - * Caught an IO exception during read from socket - */ - protected boolean ioError = false; - - /** - * The packet data to be read out of this instance through its - * {@link #read(byte[], int, int)} method. - */ - protected RawPacket pkt; - - /** - * SourceTransferHandler object which is used to read packets. - */ - private SourceTransferHandler transferHandler; - - /** - * The Thread receiving packets. - */ - protected Thread receiverThread = null; - - /** - * The DatagramPacketFilters which allow dropping - * DatagramPackets before they are converted into - * RawPackets. - */ - private DatagramPacketFilter[] datagramPacketFilters; - - /** - * Initializes a new RTPConnectorInputStream which is to receive - * packet data from a specific UDP socket. - */ - public RTPConnectorInputStream() - { - // PacketLoggingService - addDatagramPacketFilter( - new DatagramPacketFilter() - { - /** - * Used for debugging. As we don't log every packet, we must - * count them and decide which to log. - */ - private long numberOfPackets = 0; - - public boolean accept(DatagramPacket p) - { - numberOfPackets++; - if (RTPConnectorOutputStream.logPacket(numberOfPackets)) - { - PacketLoggingService packetLogging - = NeomediaActivator.getPacketLogging(); - - if ((packetLogging != null) - && packetLogging.isLoggingEnabled( - PacketLoggingService.ProtocolName - .RTP)) - doLogPacket(p); - } - - return true; - } - }); - } - - /** - * Close this stream, stops the worker thread. - */ - public synchronized void close() - { - } - - /** - * Creates a new RawPacket from a specific DatagramPacket - * in order to have this instance receive its packet data through its - * {@link #read(byte[], int, int)} method. Allows extenders to intercept the - * packet data and possibly filter and/or modify it. - * - * @param datagramPacket the DatagramPacket containing the packet - * data - * @return a new RawPacket containing the packet data of the - * specified DatagramPacket or possibly its modification; - * null to ignore the packet data of the specified - * DatagramPacket and not make it available to this instance - * through its {@link #read(byte[], int, int)} method - */ - protected RawPacket createRawPacket(DatagramPacket datagramPacket) - { - if (pkt == null) - { - return - new RawPacket( - datagramPacket.getData(), - datagramPacket.getOffset(), - datagramPacket.getLength()); - } - pkt.setBuffer(datagramPacket.getData()); - pkt.setLength(datagramPacket.getLength()); - pkt.setOffset(datagramPacket.getOffset()); - return pkt; - } - - /** - * Provides a dummy implementation to {@link - * RTPConnectorInputStream#endOfStream()} that always returns - * false. - * - * @return false, no matter what. - */ - public boolean endOfStream() - { - return false; - } - - /** - * Provides a dummy implementation to {@link - * RTPConnectorInputStream#getContentDescriptor()} that always returns - * null. - * - * @return null, no matter what. - */ - public ContentDescriptor getContentDescriptor() - { - return null; - } - - /** - * Provides a dummy implementation to {@link - * RTPConnectorInputStream#getContentLength()} that always returns - * LENGTH_UNKNOWN. - * - * @return LENGTH_UNKNOWN, no matter what. - */ - public long getContentLength() - { - return pkt.getLength(); - } - - /** - * Provides a dummy implementation to {@link - * RTPConnectorInputStream#getControl(String)} that always returns - * null. - * - * @param controlType ignored. - * - * @return null, no matter what. - */ - public Object getControl(String controlType) - { - return null; - } - - /** - * Provides a dummy implementation to {@link - * RTPConnectorInputStream#getControls()} that always returns - * EMPTY_CONTROLS. - * - * @return EMPTY_CONTROLS, no matter what. - */ - public Object[] getControls() - { - return EMPTY_CONTROLS; - } - - /** - * Provides a dummy implementation to {@link - * RTPConnectorInputStream#getMinimumTransferSize()} that always returns - * 2 * 1024. - * - * @return 2 * 1024, no matter what. - */ - public int getMinimumTransferSize() - { - return 2 * 1024; // twice the MTU size, just to be safe. - } - - /** - * Copies the content of the most recently received packet into - * buffer. - * - * @param buffer the byte[] that we'd like to copy the content of - * the packet to. - * @param offset the position where we are supposed to start writing in - * buffer. - * @param length the number of bytes available for writing in - * buffer. - * - * @return the number of bytes read - * - * @throws IOException if length is less than the size of the - * packet. - */ - public int read(byte[] buffer, int offset, int length) - throws IOException - { - if (ioError) - return -1; - - int pktLength = pkt.getLength(); - - if (length < pktLength) - throw - new IOException("Input buffer not big enough for " + pktLength); - - System.arraycopy( - pkt.getBuffer(), pkt.getOffset(), buffer, offset, pktLength); - - return pktLength; - } - - /** - * Log the packet. - * - * @param packet packet to log - */ - protected abstract void doLogPacket(DatagramPacket packet); - - /** - * Receive packet. - * - * @param p packet for receiving - * @throws IOException if something goes wrong during receiving - */ - protected abstract void receivePacket(DatagramPacket p) - throws IOException; - - /** - * Listens for incoming datagrams, stores them for reading by the - * read method and notifies the local transferHandler - * that there's data to be read. - */ - public void run() - { - DatagramPacket p - = new DatagramPacket(buffer, 0, PACKET_RECEIVE_BUFFER_LENGTH); - - while (!closed) - { - try - { - if (OSUtils.IS_ANDROID) - { - // http://code.google.com/p/android/issues/detail?id=24765 - p.setLength(PACKET_RECEIVE_BUFFER_LENGTH); - } - - receivePacket(p); - } - catch (IOException e) - { - ioError = true; - break; - } - - /* - * Do the DatagramPacketFilters accept the received DatagramPacket? - */ - DatagramPacketFilter[] datagramPacketFilters - = getDatagramPacketFilters(); - boolean accept; - - if (datagramPacketFilters == null) - accept = true; - else - { - accept = true; - for (int i = 0; i < datagramPacketFilters.length; i++) - { - try - { - if (!datagramPacketFilters[i].accept(p)) - { - accept = false; - break; - } - } - catch (Throwable t) - { - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - } - } - } - - if (accept) - { - pkt = createRawPacket(p); - - /* - * If we got extended, the delivery of the packet may have been - * canceled. - */ - if ((pkt != null) && (transferHandler != null) && !closed) - transferHandler.transferData(this); - } - } - } - - /** - * Sets the transferHandler that this connector should be notifying - * when new data is available for reading. - * - * @param transferHandler the transferHandler that this connector - * should be notifying when new data is available for reading. - */ - public void setTransferHandler(SourceTransferHandler transferHandler) - { - if (!closed) - this.transferHandler = transferHandler; - } - - /** - * Changes current thread priority. - * @param priority the new priority. - */ - public void setPriority(int priority) - { - // currently no priority is set -// if (receiverThread != null) -// receiverThread.setPriority(priority); - } - - /** - * Gets the DatagramPacketFilters which allow dropping - * DatagramPackets before they are converted into - * RawPackets. - * - * @return the DatagramPacketFilters which allow dropping - * DatagramPackets before they are converted into - * RawPackets. - */ - public synchronized DatagramPacketFilter[] getDatagramPacketFilters() - { - return datagramPacketFilters; - } - - /** - * Adds a DatagramPacketFilter which allows dropping - * DatagramPackets before they are converted into - * RawPackets. - * - * @param datagramPacketFilter the DatagramPacketFilter which - * allows dropping DatagramPackets before they are converted into - * RawPackets - */ - public synchronized void addDatagramPacketFilter( - DatagramPacketFilter datagramPacketFilter) - { - if (datagramPacketFilter == null) - throw new NullPointerException("datagramPacketFilter"); - - if (datagramPacketFilters == null) - { - datagramPacketFilters - = new DatagramPacketFilter[] { datagramPacketFilter }; - } - else - { - final int length = datagramPacketFilters.length; - - for (int i = 0; i < length; i++) - if (datagramPacketFilter.equals(datagramPacketFilters[i])) - return; - - DatagramPacketFilter[] newDatagramPacketFilters - = new DatagramPacketFilter[length + 1]; - - System.arraycopy( - datagramPacketFilters, 0, - newDatagramPacketFilters, 0, - length); - newDatagramPacketFilters[length] = datagramPacketFilter; - datagramPacketFilters = newDatagramPacketFilters; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorOutputStream.java b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorOutputStream.java deleted file mode 100755 index aca97ef5c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorOutputStream.java +++ /dev/null @@ -1,559 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import net.java.sip.communicator.service.packetlogging.*; - -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.locks.*; - -import javax.media.rtp.*; - -/** - * @author Bing SU (nova.su@gmail.com) - * @author Lyubomir Marinov - */ -public abstract class RTPConnectorOutputStream - implements OutputDataStream -{ - - /** - * The maximum number of packets to be sent to be kept in the queue of - * MaxPacketsPerMillisPolicy. When the maximum is reached, the next - * attempt to write a new packet in the queue will block until at least one - * packet from the queue is sent. Defined in order to prevent - * OutOfMemoryErrors which, technically, may arise if the capacity - * of the queue is unlimited. - */ - public static final int - MAX_PACKETS_PER_MILLIS_POLICY_PACKET_QUEUE_CAPACITY - = 256; - - /** - * The functionality which allows this OutputDataStream to control - * how many RTP packets it sends through its DatagramSocket per a - * specific number of milliseconds. - */ - private MaxPacketsPerMillisPolicy maxPacketsPerMillisPolicy; - - /** - * Stream targets' IP addresses and ports. - */ - protected final List targets - = new LinkedList(); - - /** - * The pool of RawPacket instances which reduces the number of - * allocations performed by {@link #createRawPacket(byte[], int, int)}. - */ - private final LinkedBlockingQueue rawPacketPool - = new LinkedBlockingQueue(); - - /** - * Used for debugging. As we don't log every packet - * we must count them and decide which to log. - */ - private long numberOfPackets = 0; - - /** - * Initializes a new RTPConnectorOutputStream which is to send - * packet data out through a specific socket. - */ - public RTPConnectorOutputStream() - { - } - - /** - * Add a target to stream targets list - * - * @param remoteAddr target ip address - * @param remotePort target port - */ - public void addTarget(InetAddress remoteAddr, int remotePort) - { - InetSocketAddress target - = new InetSocketAddress(remoteAddr, remotePort); - - if (!targets.contains(target)) - targets.add(target); - } - - /** - * Close this output stream. - */ - public void close() - { - if (maxPacketsPerMillisPolicy != null) - { - maxPacketsPerMillisPolicy.close(); - maxPacketsPerMillisPolicy = null; - } - removeTargets(); - } - - /** - * Creates a new RawPacket from a specific byte[] buffer - * in order to have this instance send its packet data through its - * {@link #write(byte[], int, int)} method. Allows extenders to intercept - * the packet data and possibly filter and/or modify it. - * - * @param buffer the packet data to be sent to the targets of this instance - * @param offset the offset of the packet data in buffer - * @param length the length of the packet data in buffer - * @return a new RawPacket containing the packet data of the - * specified byte[] buffer or possibly its modification; - * null to ignore the packet data of the specified byte[] - * buffer and not send it to the targets of this instance through its - * {@link #write(byte[], int, int)} method - */ - protected RawPacket createRawPacket(byte[] buffer, int offset, int length) - { - RawPacket pkt = rawPacketPool.poll(); - - if ((pkt == null) || (pkt.getBuffer().length < length)) - pkt = new RawPacket(new byte[length], 0, 0); - - System.arraycopy(buffer, offset, pkt.getBuffer(), 0, length); - pkt.setLength(length); - pkt.setOffset(0); - return pkt; - } - - /** - * Remove a target from stream targets list - * - * @param remoteAddr target ip address - * @param remotePort target port - * @return true if the target is in stream target list and can be - * removed; false, otherwise - */ - public boolean removeTarget(InetAddress remoteAddr, int remotePort) - { - for (Iterator targetIter = targets.iterator(); - targetIter.hasNext();) - { - InetSocketAddress target = targetIter.next(); - - if (target.getAddress().equals(remoteAddr) - && (target.getPort() == remotePort)) - { - targetIter.remove(); - return true; - } - } - return false; - } - - /** - * Remove all stream targets from this session. - */ - public void removeTargets() - { - targets.clear(); - } - - /** - * Determines whether a RawPacket which has a specific number in - * the total number of sent RawPackets is to be logged by - * {@link PacketLoggingService}. - * - * @param numOfPacket the number of the RawPacket in the total - * number of sent RawPackets - * @return true if the RawPacket with the specified - * numOfPacket is to be logged by PacketLoggingService; - * otherwise, false - */ - static boolean logPacket(long numOfPacket) - { - return - (numOfPacket == 1) - || (numOfPacket == 300) - || (numOfPacket == 500) - || (numOfPacket == 1000) - || ((numOfPacket % 5000) == 0); - } - - /** - * Sends a specific RawPacket through this - * OutputDataStream to a specific InetSocketAddress. - * - * @param packet the RawPacket to send through this - * OutputDataStream to the specified target - * @param target the InetSocketAddress to which the specified - * packet is to be sent through this OutputDataStream - * @throws IOException if anything goes wrong while sending the specified - * packet through this OutputDataStream to the specified - * target - */ - protected abstract void sendToTarget( - RawPacket packet, - InetSocketAddress target) - throws IOException; - - /** - * Logs a specific RawPacket associated with a specific remote - * address. - * - * @param packet packet to log - * @param target the remote address associated with the packet - */ - protected abstract void doLogPacket( - RawPacket packet, - InetSocketAddress target); - - /** - * Returns whether or not this RTPConnectorOutputStream has a valid - * socket. - * - * @return true if this RTPConnectorOutputStream has a - * valid socket; false, otherwise - */ - protected abstract boolean isSocketValid(); - - /** - * Sends a specific RTP packet through the DatagramSocket of this - * OutputDataSource. - * - * @param packet the RTP packet to be sent through the - * DatagramSocket of this OutputDataSource - * @return true if the specified packet was successfully - * sent; otherwise, false - */ - private boolean send(RawPacket packet) - { - if(!isSocketValid()) - return false; - - numberOfPackets++; - for (InetSocketAddress target : targets) - { - try - { - sendToTarget(packet, target); - - if(logPacket(numberOfPackets)) - { - PacketLoggingService packetLogging - = NeomediaActivator.getPacketLogging(); - - if ((packetLogging != null) - && packetLogging.isLoggingEnabled( - PacketLoggingService.ProtocolName.RTP)) - doLogPacket(packet, target); - } - } - catch (IOException ioe) - { - rawPacketPool.offer(packet); - // TODO error handling - return false; - } - } - rawPacketPool.offer(packet); - return true; - } - - /** - * Sets the maximum number of RTP packets to be sent by this - * OutputDataStream through its DatagramSocket per - * a specific number of milliseconds. - * - * @param maxPackets the maximum number of RTP packets to be sent by this - * OutputDataStream through its DatagramSocket per the - * specified number of milliseconds; -1 if no maximum is to be set - * @param perMillis the number of milliseconds per which maxPackets - * are to be sent by this OutputDataStream through its - * DatagramSocket - */ - public void setMaxPacketsPerMillis(int maxPackets, long perMillis) - { - if (maxPacketsPerMillisPolicy == null) - { - if (maxPackets > 0) - { - if (perMillis < 1) - throw new IllegalArgumentException("perMillis"); - - maxPacketsPerMillisPolicy - = new MaxPacketsPerMillisPolicy(maxPackets, perMillis); - } - } - else - { - maxPacketsPerMillisPolicy - .setMaxPacketsPerMillis(maxPackets, perMillis); - } - } - - /** - * Implements {@link OutputDataStream#write(byte[], int, int)}. - * - * @param buffer the byte[] that we'd like to copy the content - * of the packet to. - * @param offset the position where we are supposed to start writing in - * buffer. - * @param length the number of bytes available for writing in - * inBuffer. - * - * @return the number of bytes read - */ - public int write(byte[] buffer, int offset, int length) - { - RawPacket packet = createRawPacket(buffer, offset, length); - - /* - * If we got extended, the delivery of the packet may have been - * canceled. - */ - if (packet != null) - { - if (maxPacketsPerMillisPolicy == null) - { - if (!send(packet)) - return -1; - } - else - maxPacketsPerMillisPolicy.write(packet); - } - return length; - } - - /** - * Changes current thread priority. - * @param priority the new priority. - */ - public void setPriority(int priority) - { - // currently no priority is set -// if(maxPacketsPerMillisPolicy != null && -// maxPacketsPerMillisPolicy.sendThread != null) -// maxPacketsPerMillisPolicy.sendThread.setPriority(priority); - } - - /** - * Implements the functionality which allows this OutputDataStream - * to control how many RTP packets it sends through its - * DatagramSocket per a specific number of milliseconds. - */ - private class MaxPacketsPerMillisPolicy - { - - /** - * The maximum number of RTP packets to be sent by this - * OutputDataStream through its DatagramSocket per - * {@link #perNanos} nanoseconds. - */ - private int maxPackets = -1; - - /** - * The time stamp in nanoseconds of the start of the current - * perNanos interval. - */ - private long millisStartTime = 0; - - /** - * The list of RTP packets to be sent through the - * DatagramSocket of this OutputDataSource. - */ - private final ArrayBlockingQueue packetQueue - = new ArrayBlockingQueue( - MAX_PACKETS_PER_MILLIS_POLICY_PACKET_QUEUE_CAPACITY); - - /** - * The number of RTP packets already sent during the current - * perNanos interval. - */ - private long packetsSentInMillis = 0; - - /** - * The time interval in nanoseconds during which {@link #maxPackets} - * number of RTP packets are to be sent through the - * DatagramSocket of this OutputDataSource. - */ - private long perNanos = -1; - - /** - * The Thread which is to send the RTP packets in - * {@link #packetQueue} through the DatagramSocket of this - * OutputDataSource. - */ - private Thread sendThread; - - /** - * To signal run or stop condition to send thread. - */ - private boolean sendRun = true; - - /** - * Initializes a new MaxPacketsPerMillisPolicy instance which - * is to control how many RTP packets this OutputDataSource is - * to send through its DatagramSocket per a specific number of - * milliseconds. - * - * @param maxPackets the maximum number of RTP packets to be sent per - * perMillis milliseconds through the DatagramSocket - * of this OutputDataStream - * @param perMillis the number of milliseconds per which a maximum of - * maxPackets RTP packets are to be sent through the - * DatagramSocket of this OutputDataStream - */ - public MaxPacketsPerMillisPolicy(int maxPackets, long perMillis) - { - setMaxPacketsPerMillis(maxPackets, perMillis); - synchronized (this) { - if (sendThread == null) - { - sendThread - = new Thread(getClass().getName()) - { - @Override - public void run() - { - runInSendThread(); - } - }; - sendThread.setDaemon(true); - sendThread.start(); - } - } - } - - /** - * Closes the connector. - */ - synchronized void close() - { - if (!sendRun) - return; - sendRun = false; - // just offer a new packet to wakeup thread in case it waits for - // a packet. - packetQueue.offer(new RawPacket(null, 0, 0)); - } - - /** - * Sends the RTP packets in {@link #packetQueue} in accord with - * {@link #maxPackets} and {@link #perNanos}. - */ - private void runInSendThread() - { - try - { - while (sendRun) - { - RawPacket packet = null; - - while (true) - { - try - { - packet = packetQueue.take(); - break; - } - catch (InterruptedException iex) - { - continue; - } - } - if (!sendRun) - break; - - long time = System.nanoTime(); - long millisRemainingTime = time - millisStartTime; - - if ((perNanos < 1) - || (millisRemainingTime >= perNanos)) - { - millisStartTime = time; - packetsSentInMillis = 0; - } - else if ((maxPackets > 0) - && (packetsSentInMillis >= maxPackets)) - { - while (true) - { - millisRemainingTime = System.nanoTime() - - millisStartTime; - if (millisRemainingTime >= perNanos) - break; - LockSupport.parkNanos(millisRemainingTime); - } - millisStartTime = System.nanoTime(); - packetsSentInMillis = 0; - } - - send(packet); - packetsSentInMillis++; - } - } - finally - { - packetQueue.clear(); - synchronized (packetQueue) - { - if (Thread.currentThread().equals(sendThread)) - sendThread = null; - } - } - } - - /** - * Sets the maximum number of RTP packets to be sent by this - * OutputDataStream through its DatagramSocket per - * a specific number of milliseconds. - * - * @param maxPackets the maximum number of RTP packets to be sent by - * this OutputDataStream through its DatagramSocket - * per the specified number of milliseconds; -1 if no maximum - * is to be set - * @param perMillis the number of milliseconds per which - * maxPackets are to be sent by this OutputDataStream - * through its DatagramSocket - */ - public void setMaxPacketsPerMillis(int maxPackets, long perMillis) - { - if (maxPackets < 1) - { - this.maxPackets = -1; - this.perNanos = -1; - } - else - { - if (perMillis < 1) - throw new IllegalArgumentException("perMillis"); - - this.maxPackets = maxPackets; - this.perNanos = perMillis * 1000000; - } - } - - /** - * Queues a specific RTP packet to be sent through the - * DatagramSocket of this OutputDataStream. - * - * @param packet the RTP packet to be queued for sending through the - * DatagramSocket of this OutputDataStream - */ - public void write(RawPacket packet) - { - while (true) - { - try - { - packetQueue.put(packet); - break; - } - catch (InterruptedException iex) - { - } - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPImpl.java b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPImpl.java deleted file mode 100644 index fd2d56d76..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.net.*; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * RTPConnector implementation for UDP. - * - * @author Sebastien Vincent - */ -public class RTPConnectorTCPImpl - extends AbstractRTPConnector -{ - /** - * The TCP socket this instance uses to send and receive RTP packets. - */ - private Socket dataSocket; - - /** - * The TCP socket this instance uses to send and receive RTCP packets. - */ - private Socket controlSocket; - - /** - * Initializes a new RTPConnectorTCPImpl which is to use a given - * pair of sockets for RTP and RTCP traffic specified in the form - * of a StreamConnector. - * - * @param connector the pair of sockets for RTP and RTCP traffic - * the new instance is to use - */ - public RTPConnectorTCPImpl(StreamConnector connector) - { - super(connector); - } - - /** - * Gets the TCP socket this instance uses to send and receive RTP packets. - * - * @return the TCP socket this instance uses to send and receive RTP packets - */ - public Socket getDataSocket() - { - if (dataSocket == null) - dataSocket = connector.getDataTCPSocket(); - return dataSocket; - } - - /** - * Gets the TCP Socket this instance uses to send and receive RTCP packets. - * - * @return the TCP Socket this instance uses to send and receive RTCP - * packets - */ - public Socket getControlSocket() - { - if (controlSocket == null) - controlSocket = connector.getControlTCPSocket(); - return controlSocket; - } - - /** - * Creates the RTCP packet input stream to be used by RTPManager. - * - * @return a new RTCP packet input stream to be used by RTPManager - * @throws IOException if an error occurs during the creation of the RTCP - * packet input stream - */ - protected RTPConnectorInputStream createControlInputStream() - throws IOException - { - return new RTPConnectorTCPInputStream(getControlSocket()); - } - - /** - * Creates the RTCP packet output stream to be used by RTPManager. - * - * @return a new RTCP packet output stream to be used by RTPManager - * @throws IOException if an error occurs during the creation of the RTCP - * packet output stream - */ - protected RTPConnectorOutputStream createControlOutputStream() - throws IOException - { - return new RTPConnectorTCPOutputStream(getControlSocket()); - } - - /** - * Creates the RTP packet input stream to be used by RTPManager. - * - * @return a new RTP packet input stream to be used by RTPManager - * @throws IOException if an error occurs during the creation of the RTP - * packet input stream - */ - protected RTPConnectorInputStream createDataInputStream() - throws IOException - { - return new RTPConnectorTCPInputStream(getDataSocket()); - } - - /** - * Creates the RTP packet output stream to be used by RTPManager. - * - * @return a new RTP packet output stream to be used by RTPManager - * @throws IOException if an error occurs during the creation of the RTP - * packet output stream - */ - protected RTPConnectorOutputStream createDataOutputStream() - throws IOException - { - return new RTPConnectorTCPOutputStream(getDataSocket()); - } -} \ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPInputStream.java b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPInputStream.java deleted file mode 100644 index 7b4750f3f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPInputStream.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.net.*; - -import net.java.sip.communicator.service.packetlogging.*; -import net.java.sip.communicator.util.*; -import org.ice4j.socket.*; - -/** - * RTPConnectorInputStream implementation for TCP protocol. - * - * @author Sebastien Vincent - */ -public class RTPConnectorTCPInputStream - extends RTPConnectorInputStream -{ - /** - * The Logger used by instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(RTPConnectorTCPInputStream.class); - - /** - * TCP socket used to receive data. - */ - private final Socket socket; - - /** - * Initializes a new RTPConnectorInputStream which is to receive - * packet data from a specific TCP socket. - * - * @param socket the TCP socket the new instance is to receive data from - */ - public RTPConnectorTCPInputStream(Socket socket) - { - this.socket = socket; - - if(socket != null) - { - try - { - socket.setReceiveBufferSize(65535); - } - catch(Throwable t) - { - } - - closed = false; - receiverThread = new Thread(this); - receiverThread.start(); - } - } - - /** - * Close this stream, stops the worker thread. - */ - @Override - public synchronized void close() - { - closed = true; - if(socket != null) - { - try - { - socket.close(); - } - catch(IOException e) - { - } - } - } - - /** - * Log the packet. - * - * @param p packet to log - */ - protected void doLogPacket(DatagramPacket p) - { - if(socket.getLocalAddress() == null) - return; - - // Do not log the packet if this one has been processed (and already - // logged) by the ice4j stack. - if(socket instanceof MultiplexingSocket) - return; - - PacketLoggingService packetLogging - = NeomediaActivator.getPacketLogging(); - - if (packetLogging != null) - packetLogging.logPacket( - PacketLoggingService.ProtocolName.RTP, - (p.getAddress() != null) - ? p.getAddress().getAddress() - : new byte[] { 0,0,0,0 }, - p.getPort(), - socket.getLocalAddress().getAddress(), - socket.getLocalPort(), - PacketLoggingService.TransportName.TCP, - false, - p.getData(), - p.getOffset(), - p.getLength()); - } - - /** - * Receive packet. - * - * @param p packet for receiving - * @throws IOException if something goes wrong during receiving - */ - protected void receivePacket(DatagramPacket p) - throws IOException - { - int len = -1; - byte data[] = null; - - try - { - data = p.getData(); - len = socket.getInputStream().read(data); - } - catch(Exception e) - { - logger.info("problem read: " + e); - } - - if(len > 0) - { - p.setData(data); - p.setLength(len); - p.setAddress(socket.getInetAddress()); - p.setPort(socket.getPort()); - } - else - { - throw new IOException("Failed to read on TCP socket"); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPOutputStream.java b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPOutputStream.java deleted file mode 100644 index c4e2819dc..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPOutputStream.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.net.*; - -import net.java.sip.communicator.service.packetlogging.*; -import org.ice4j.socket.*; - -/** - * RTPConnectorOutputStream implementation for TCP protocol. - * - * @author Sebastien Vincent - */ -public class RTPConnectorTCPOutputStream - extends RTPConnectorOutputStream -{ - /** - * UDP socket used to send packet data - */ - private final Socket socket; - - /** - * Initializes a new RTPConnectorTCPOutputStream. - * - * @param socket a Socket - */ - public RTPConnectorTCPOutputStream(Socket socket) - { - this.socket = socket; - } - - /** - * Sends a specific RawPacket through this - * OutputDataStream to a specific InetSocketAddress. - * - * @param packet the RawPacket to send through this - * OutputDataStream to the specified target - * @param target the InetSocketAddress to which the specified - * packet is to be sent through this OutputDataStream - * @throws IOException if anything goes wrong while sending the specified - * packet through this OutputDataStream to the specified - * target - */ - protected void sendToTarget(RawPacket packet, InetSocketAddress target) - throws IOException - { - socket.getOutputStream().write( - packet.getBuffer(), - packet.getOffset(), - packet.getLength()); - } - - /** - * Log the packet. - * - * @param packet packet to log - */ - protected void doLogPacket(RawPacket packet, InetSocketAddress target) - { - // Do not log the packet if this one has been processed (and already - // logged) by the ice4j stack. - if(socket instanceof MultiplexingSocket) - return; - - PacketLoggingService packetLogging - = NeomediaActivator.getPacketLogging(); - - if (packetLogging != null) - packetLogging.logPacket( - PacketLoggingService.ProtocolName.RTP, - socket.getLocalAddress().getAddress(), - socket.getLocalPort(), - target.getAddress().getAddress(), - target.getPort(), - PacketLoggingService.TransportName.TCP, - true, - packet.getBuffer(), - packet.getOffset(), - packet.getLength()); - } - - /** - * Returns whether or not this RTPConnectorOutputStream has a valid - * socket. - * - * @returns true if this RTPConnectorOutputStream has a valid - * socket, false otherwise - */ - @Override - protected boolean isSocketValid() - { - return (socket != null); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPImpl.java b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPImpl.java deleted file mode 100644 index 3f6e61180..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.net.*; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * RTPConnector implementation for UDP. - * - * @author Sebastien Vincent - */ -public class RTPConnectorUDPImpl - extends AbstractRTPConnector -{ - /** - * The UDP socket this instance uses to send and receive RTP packets. - */ - private DatagramSocket dataSocket; - - /** - * The UDP socket this instance uses to send and receive RTCP packets. - */ - private DatagramSocket controlSocket; - - /** - * Initializes a new RTPConnectorUDPImpl which is to use a given - * pair of datagram sockets for RTP and RTCP traffic specified in the form - * of a StreamConnector. - * - * @param connector the pair of datagram sockets for RTP and RTCP traffic - * the new instance is to use - */ - public RTPConnectorUDPImpl(StreamConnector connector) - { - super(connector); - } - - /** - * Gets the UDP socket this instance uses to send and receive RTP packets. - * - * @return the UDP socket this instance uses to send and receive RTP packets - */ - public DatagramSocket getDataSocket() - { - if (dataSocket == null) - dataSocket = connector.getDataSocket(); - return dataSocket; - } - - /** - * Gets the UDP Socket this instance uses to send and receive RTCP packets. - * - * @return the UDP Socket this instance uses to send and receive RTCP - * packets - */ - public DatagramSocket getControlSocket() - { - if (controlSocket == null) - controlSocket = connector.getControlSocket(); - return controlSocket; - } - - /** - * Creates the RTCP packet input stream to be used by RTPManager. - * - * @return a new RTCP packet input stream to be used by RTPManager - * @throws IOException if an error occurs during the creation of the RTCP - * packet input stream - */ - protected RTPConnectorInputStream createControlInputStream() - throws IOException - { - return new RTCPConnectorInputStream(getControlSocket()); - } - - /** - * Creates the RTCP packet output stream to be used by RTPManager. - * - * @return a new RTCP packet output stream to be used by RTPManager - * @throws IOException if an error occurs during the creation of the RTCP - * packet output stream - */ - protected RTPConnectorOutputStream createControlOutputStream() - throws IOException - { - return new RTPConnectorUDPOutputStream(getControlSocket()); - } - - /** - * Creates the RTP packet input stream to be used by RTPManager. - * - * @return a new RTP packet input stream to be used by RTPManager - * @throws IOException if an error occurs during the creation of the RTP - * packet input stream - */ - protected RTPConnectorInputStream createDataInputStream() - throws IOException - { - return new RTPConnectorUDPInputStream(getDataSocket()); - } - - /** - * Creates the RTP packet output stream to be used by RTPManager. - * - * @return a new RTP packet output stream to be used by RTPManager - * @throws IOException if an error occurs during the creation of the RTP - * packet output stream - */ - protected RTPConnectorOutputStream createDataOutputStream() - throws IOException - { - return new RTPConnectorUDPOutputStream(getDataSocket()); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPInputStream.java b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPInputStream.java deleted file mode 100644 index 4cef9e3b0..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPInputStream.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.net.*; - -import net.java.sip.communicator.service.packetlogging.*; -import org.ice4j.socket.*; - -/** - * RTPConnectorInputStream implementation for UDP protocol. - * - * @author Sebastien Vincent - */ -public class RTPConnectorUDPInputStream - extends RTPConnectorInputStream -{ - /** - * UDP socket used to receive data. - */ - private final DatagramSocket socket; - - /** - * Receive size configured flag. - */ - private boolean receivedSizeFlag = false; - - /** - * Initializes a new RTPConnectorInputStream which is to receive - * packet data from a specific UDP socket. - * - * @param socket the UDP socket the new instance is to receive data from - */ - public RTPConnectorUDPInputStream(DatagramSocket socket) - { - this.socket = socket; - - if(socket != null) - { - closed = false; - receiverThread = new Thread(this); - receiverThread.start(); - } - } - - /** - * Close this stream, stops the worker thread. - */ - @Override - public synchronized void close() - { - closed = true; - if(socket != null) - { - socket.close(); - } - } - - /** - * Log the packet. - * - * @param p packet to log - */ - protected void doLogPacket(DatagramPacket p) - { - if(socket.getLocalAddress() == null) - return; - - // Do not log the packet if this one has been processed (and already - // logged) by the ice4j stack. - if(socket instanceof MultiplexingDatagramSocket) - return; - - PacketLoggingService packetLogging - = NeomediaActivator.getPacketLogging(); - - if (packetLogging != null) - packetLogging.logPacket( - PacketLoggingService.ProtocolName.RTP, - p.getAddress().getAddress(), - p.getPort(), - socket.getLocalAddress().getAddress(), - socket.getLocalPort(), - PacketLoggingService.TransportName.UDP, - false, - p.getData(), - p.getOffset(), - p.getLength()); - } - - /** - * Receive packet. - * - * @param p packet for receiving - * @throws IOException if something goes wrong during receiving - */ - protected void receivePacket(DatagramPacket p) - throws IOException - { - if(!receivedSizeFlag) - { - receivedSizeFlag = true; - - try - { - socket.setReceiveBufferSize(65535); - } - catch(Throwable t) - { - } - } - socket.receive(p); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPOutputStream.java b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPOutputStream.java deleted file mode 100644 index de2b00e2e..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPOutputStream.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.net.*; - -import net.java.sip.communicator.service.packetlogging.*; -import org.ice4j.socket.*; - -/** - * RTPConnectorOutputStream implementation for UDP protocol. - * - * @author Sebastien Vincent - */ -public class RTPConnectorUDPOutputStream - extends RTPConnectorOutputStream -{ - /** - * UDP socket used to send packet data - */ - private final DatagramSocket socket; - - /** - * Initializes a new RTPConnectorUDPOutputStream. - * - * @param socket a DatagramSocket - */ - public RTPConnectorUDPOutputStream(DatagramSocket socket) - { - this.socket = socket; - } - - /** - * Sends a specific RawPacket through this - * OutputDataStream to a specific InetSocketAddress. - * - * @param packet the RawPacket to send through this - * OutputDataStream to the specified target - * @param target the InetSocketAddress to which the specified - * packet is to be sent through this OutputDataStream - * @throws IOException if anything goes wrong while sending the specified - * packet through this OutputDataStream to the specified - * target - */ - protected void sendToTarget(RawPacket packet, InetSocketAddress target) - throws IOException - { - socket.send( - new DatagramPacket( - packet.getBuffer(), - packet.getOffset(), - packet.getLength(), - target.getAddress(), - target.getPort())); - } - - /** - * Log the packet. - * - * @param packet packet to log - */ - protected void doLogPacket(RawPacket packet, InetSocketAddress target) - { - // Do not log the packet if this one has been processed (and already - // logged) by the ice4j stack. - if(socket instanceof MultiplexingDatagramSocket) - return; - - PacketLoggingService packetLogging - = NeomediaActivator.getPacketLogging(); - - if (packetLogging != null) - packetLogging.logPacket( - PacketLoggingService.ProtocolName.RTP, - socket.getLocalAddress().getAddress(), - socket.getLocalPort(), - target.getAddress().getAddress(), - target.getPort(), - PacketLoggingService.TransportName.UDP, - true, - packet.getBuffer(), - packet.getOffset(), - packet.getLength()); - } - - /** - * Returns whether or not this RTPConnectorOutputStream has a valid - * socket. - * - * @returns true if this RTPConnectorOutputStream has a valid - * socket, false otherwise - */ - @Override - protected boolean isSocketValid() - { - return (socket != null); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPTranslatorImpl.java b/src/net/java/sip/communicator/impl/neomedia/RTPTranslatorImpl.java deleted file mode 100644 index 9fb4a3646..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RTPTranslatorImpl.java +++ /dev/null @@ -1,1545 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; - -import javax.media.*; -import javax.media.format.*; -import javax.media.protocol.*; -import javax.media.rtp.*; -import javax.media.rtp.event.*; -import javax.media.rtp.rtcp.*; - -import com.sun.media.rtp.*; - -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.util.*; - -/** - * Implements RTPTranslator which represents an RTP translator which - * forwards RTP and RTCP traffic between multiple MediaStreams. - * - * @author Lyubomir Marinov - */ -public class RTPTranslatorImpl - implements ReceiveStreamListener, - RTPTranslator -{ - /** - * The Logger used by the RTPTranslatorImpl class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(RTPTranslatorImpl.class); - - /** - * An array with long element type and no elements explicitly - * defined to reduce unnecessary allocations. - */ - private static final long[] EMPTY_LONG_ARRAY = new long[0]; - - /** - * The RTPConnector which is used by {@link #manager} and which - * delegates to the RTPConnectors of the StreamRTPManagers - * attached to this instance. - */ - private RTPConnectorImpl connector; - - /** - * The RTPManager which implements the actual RTP management of - * this instance. - */ - private final RTPManager manager = RTPManager.newInstance(); - - /** - * The SendStreams created by the RTPManager and the - * StreamRTPManager-specific views to them. - */ - private final List sendStreams - = new LinkedList(); - - /** - * The list of StreamRTPManagers i.e. MediaStreams which - * this instance forwards RTP and RTCP traffic between. - */ - private final List streamRTPManagers - = new ArrayList(); - - /** - * Initializes a new RTPTranslatorImpl instance. - */ - public RTPTranslatorImpl() - { - manager.addReceiveStreamListener(this); - } - - public synchronized void addFormat( - StreamRTPManager streamRTPManager, - Format format, int payloadType) - { - manager.addFormat(format, payloadType); - - getStreamRTPManagerDesc(streamRTPManager, true) - .addFormat(format, payloadType); - } - - public synchronized void addReceiveStreamListener( - StreamRTPManager streamRTPManager, - ReceiveStreamListener listener) - { - getStreamRTPManagerDesc(streamRTPManager, true) - .addReceiveStreamListener(listener); - } - - public void addRemoteListener( - StreamRTPManager streamRTPManager, - RemoteListener listener) - { - manager.addRemoteListener(listener); - } - - public void addSendStreamListener( - StreamRTPManager streamRTPManager, - SendStreamListener listener) - { - // TODO Auto-generated method stub - } - - public void addSessionListener( - StreamRTPManager streamRTPManager, - SessionListener listener) - { - // TODO Auto-generated method stub - } - - private synchronized void closeSendStream(SendStreamDesc sendStreamDesc) - { - if (sendStreams.contains(sendStreamDesc) - && (sendStreamDesc.getSendStreamCount() < 1)) - { - sendStreamDesc.sendStream.close(); - sendStreams.remove(sendStreamDesc); - } - } - - public synchronized SendStream createSendStream( - StreamRTPManager streamRTPManager, - DataSource dataSource, int streamIndex) - throws IOException, - UnsupportedFormatException - { - SendStreamDesc sendStreamDesc = null; - - for (SendStreamDesc s : sendStreams) - if ((s.dataSource == dataSource) && (s.streamIndex == streamIndex)) - { - sendStreamDesc = s; - break; - } - if (sendStreamDesc == null) - { - SendStream sendStream - = manager.createSendStream(dataSource, streamIndex); - - if (sendStream != null) - { - sendStreamDesc - = new SendStreamDesc(dataSource, streamIndex, sendStream); - sendStreams.add(sendStreamDesc); - } - } - return - (sendStreamDesc == null) - ? null - : sendStreamDesc.getSendStream(streamRTPManager, true); - } - - /** - * Releases the resources allocated by this instance in the course of its - * execution and prepares it to be garbage collected. - */ - public synchronized void dispose() - { - manager.removeReceiveStreamListener(this); - manager.dispose(); - } - - public synchronized void dispose(StreamRTPManager streamRTPManager) - { - Iterator streamRTPManagerIter - = streamRTPManagers.iterator(); - - while (streamRTPManagerIter.hasNext()) - { - StreamRTPManagerDesc streamRTPManagerDesc - = streamRTPManagerIter.next(); - - if (streamRTPManagerDesc.streamRTPManager == streamRTPManager) - { - RTPConnectorDesc connectorDesc - = streamRTPManagerDesc.connectorDesc; - - if (connectorDesc != null) - { - if (this.connector != null) - { - this.connector.removeConnector(connectorDesc); - connectorDesc.connector.close(); - } - streamRTPManagerDesc.connectorDesc = null; - } - - streamRTPManagerIter.remove(); - break; - } - } - } - - private synchronized StreamRTPManagerDesc - findStreamRTPManagerDescByReceiveSSRC( - long receiveSSRC, - StreamRTPManagerDesc exclusion) - { - for (int i = 0, count = streamRTPManagers.size(); i < count; i++) - { - StreamRTPManagerDesc s = streamRTPManagers.get(i); - - if ((s != exclusion) && s.containsReceiveSSRC(receiveSSRC)) - return s; - } - return null; - } - - public Object getControl( - StreamRTPManager streamRTPManager, - String controlType) - { - return manager.getControl(controlType); - } - - public GlobalReceptionStats getGlobalReceptionStats( - StreamRTPManager streamRTPManager) - { - return manager.getGlobalReceptionStats(); - } - - public GlobalTransmissionStats getGlobalTransmissionStats( - StreamRTPManager streamRTPManager) - { - return manager.getGlobalTransmissionStats(); - } - - public long getLocalSSRC(StreamRTPManager streamRTPManager) - { - return ((RTPSessionMgr) manager).getLocalSSRC(); - } - - public synchronized Vector getReceiveStreams( - StreamRTPManager streamRTPManager) - { - StreamRTPManagerDesc streamRTPManagerDesc - = getStreamRTPManagerDesc(streamRTPManager, false); - Vector receiveStreams = null; - - if (streamRTPManagerDesc != null) - { - Vector managerReceiveStreams = manager.getReceiveStreams(); - - if (managerReceiveStreams != null) - { - receiveStreams - = new Vector(managerReceiveStreams.size()); - for (Object s : managerReceiveStreams) - { - ReceiveStream receiveStream = (ReceiveStream) s; - - if (streamRTPManagerDesc.containsReceiveSSRC( - receiveStream.getSSRC())) - receiveStreams.add(receiveStream); - } - } - } - return receiveStreams; - } - - public synchronized Vector getSendStreams( - StreamRTPManager streamRTPManager) - { - Vector managerSendStreams = manager.getSendStreams(); - Vector sendStreams = null; - - if (managerSendStreams != null) - { - sendStreams = new Vector(managerSendStreams.size()); - for (SendStreamDesc sendStreamDesc : this.sendStreams) - if (managerSendStreams.contains(sendStreamDesc.sendStream)) - { - SendStream sendStream - = sendStreamDesc.getSendStream(streamRTPManager, false); - - if (sendStream != null) - sendStreams.add(sendStream); - } - } - return sendStreams; - } - - private synchronized StreamRTPManagerDesc getStreamRTPManagerDesc( - StreamRTPManager streamRTPManager, - boolean create) - { - for (StreamRTPManagerDesc s : streamRTPManagers) - if (s.streamRTPManager == streamRTPManager) - return s; - - StreamRTPManagerDesc s; - - if (create) - { - s = new StreamRTPManagerDesc(streamRTPManager); - streamRTPManagers.add(s); - } - else - s = null; - return s; - } - - public synchronized void initialize( - StreamRTPManager streamRTPManager, - RTPConnector connector) - { - if (this.connector == null) - { - this.connector = new RTPConnectorImpl(); - manager.initialize(this.connector); - } - - StreamRTPManagerDesc streamRTPManagerDesc - = getStreamRTPManagerDesc(streamRTPManager, true); - RTPConnectorDesc connectorDesc = streamRTPManagerDesc.connectorDesc; - - if ((connectorDesc == null) || (connectorDesc.connector != connector)) - { - if (connectorDesc != null) - this.connector.removeConnector(connectorDesc); - streamRTPManagerDesc.connectorDesc - = connectorDesc - = (connector == null) - ? null - : new RTPConnectorDesc(streamRTPManagerDesc, connector); - if (connectorDesc != null) - this.connector.addConnector(connectorDesc); - } - } - - private int read( - PushSourceStreamDesc streamDesc, - byte[] buffer, int offset, int length, - int read) - throws IOException - { - boolean data = streamDesc.data; - StreamRTPManagerDesc streamRTPManagerDesc - = streamDesc.connectorDesc.streamRTPManagerDesc; - Format format = null; - - if (data) - { - if (length >= 12) - { - long ssrc = readInt(buffer, offset + 8); - - if (!streamRTPManagerDesc.containsReceiveSSRC(ssrc)) - { - if (findStreamRTPManagerDescByReceiveSSRC( - ssrc, - streamRTPManagerDesc) - == null) - streamRTPManagerDesc.addReceiveSSRC(ssrc); - else - return 0; - } - - int payloadType = buffer[offset + 1] & 0x7f; - - format = streamRTPManagerDesc.getFormat(payloadType); - } - } - - OutputDataStreamImpl outputStream - = data - ? connector.getDataOutputStream() - : connector.getControlOutputStream(); - - if (outputStream != null) - { - outputStream.write( - buffer, offset, read, - format, - streamRTPManagerDesc); - } - - return read; - } - - /** - * Reads an int from a specific byte buffer starting at a - * specific offset. The implementation is the same as - * {@link DataInputStream#readInt()}. - * - * @param buffer the byte buffer to read an int from - * @param offset the zero-based offset in buffer to start reading - * an int from - * @return an int read from the specified buffer starting - * at the specified offset - */ - private static int readInt(byte[] buffer, int offset) - { - return - ((buffer[offset++] & 0xff) << 24) - | ((buffer[offset++] & 0xff) << 16) - | ((buffer[offset++] & 0xff) << 8) - | (buffer[offset] & 0xff); - } - - public synchronized void removeReceiveStreamListener( - StreamRTPManager streamRTPManager, - ReceiveStreamListener listener) - { - StreamRTPManagerDesc streamRTPManagerDesc - = getStreamRTPManagerDesc(streamRTPManager, false); - - if (streamRTPManagerDesc != null) - streamRTPManagerDesc.removeReceiveStreamListener(listener); - } - - public void removeRemoteListener( - StreamRTPManager streamRTPManager, - RemoteListener listener) - { - manager.removeRemoteListener(listener); - } - - public void removeSendStreamListener( - StreamRTPManager streamRTPManager, - SendStreamListener listener) - { - // TODO Auto-generated method stub - } - - public void removeSessionListener( - StreamRTPManager streamRTPManager, - SessionListener listener) - { - // TODO Auto-generated method stub - } - - /** - * Notifies this ReceiveStreamListener about a specific event - * related to a ReceiveStream. - * - * @param event a ReceiveStreamEvent which contains the specifics - * of the event this ReceiveStreamListener is being notified about - * @see ReceiveStreamListener#update(ReceiveStreamEvent) - */ - public void update(ReceiveStreamEvent event) - { - /* - * Because NullPointerException was seen during testing, be thorough - * with the null checks. - */ - if (event != null) - { - ReceiveStream receiveStream = event.getReceiveStream(); - - if (receiveStream != null) - { - StreamRTPManagerDesc streamRTPManagerDesc - = findStreamRTPManagerDescByReceiveSSRC( - receiveStream.getSSRC(), - null); - - if (streamRTPManagerDesc != null) - for (ReceiveStreamListener listener - : streamRTPManagerDesc.getReceiveStreamListeners()) - listener.update(event); - } - } - } - - private static class OutputDataStreamDesc - { - public RTPConnectorDesc connectorDesc; - - public OutputDataStream stream; - - public OutputDataStreamDesc( - RTPConnectorDesc connectorDesc, - OutputDataStream stream) - { - this.connectorDesc = connectorDesc; - this.stream = stream; - } - } - - private static class OutputDataStreamImpl - implements OutputDataStream, - Runnable - { - private static final int WRITE_QUEUE_CAPACITY - = RTPConnectorOutputStream - .MAX_PACKETS_PER_MILLIS_POLICY_PACKET_QUEUE_CAPACITY; - - private boolean closed; - - private final boolean data; - - private final List streams - = new ArrayList(); - - private final RTPTranslatorBuffer[] writeQueue - = new RTPTranslatorBuffer[WRITE_QUEUE_CAPACITY]; - - private int writeQueueHead; - - private int writeQueueLength; - - private Thread writeThread; - - public OutputDataStreamImpl(boolean data) - { - this.data = data; - } - - public synchronized void addStream( - RTPConnectorDesc connectorDesc, - OutputDataStream stream) - { - for (OutputDataStreamDesc streamDesc : streams) - if ((streamDesc.connectorDesc == connectorDesc) - && (streamDesc.stream == stream)) - return; - streams.add(new OutputDataStreamDesc(connectorDesc, stream)); - } - - public synchronized void close() - { - closed = true; - writeThread = null; - notify(); - } - - private synchronized void createWriteThread() - { - writeThread = new Thread(this, getClass().getName()); - writeThread.setDaemon(true); - writeThread.start(); - } - - private synchronized int doWrite( - byte[] buffer, int offset, int length, - Format format, - StreamRTPManagerDesc exclusion) - { - int write = 0; - - for (int streamIndex = 0, streamCount = streams.size(); - streamIndex < streamCount; - streamIndex++) - { - OutputDataStreamDesc streamDesc = streams.get(streamIndex); - StreamRTPManagerDesc streamRTPManagerDesc - = streamDesc.connectorDesc.streamRTPManagerDesc; - - if (streamRTPManagerDesc != exclusion) - { - if (data && (format != null) && (length > 0)) - { - Integer payloadType - = streamRTPManagerDesc.getPayloadType(format); - - if ((payloadType == null) && (exclusion != null)) - payloadType = exclusion.getPayloadType(format); - if (payloadType != null) - { - int payloadTypeByteIndex = offset + 1; - - buffer[payloadTypeByteIndex] - = (byte) - ((buffer[payloadTypeByteIndex] & 0x80) - | (payloadType & 0x7f)); - } - } - - int streamWrite - = streamDesc.stream.write(buffer, offset, length); - - if (write < streamWrite) - write = streamWrite; - } - } - return write; - } - - public synchronized void removeStreams(RTPConnectorDesc connectorDesc) - { - Iterator streamIter = streams.iterator(); - - while (streamIter.hasNext()) - { - OutputDataStreamDesc streamDesc = streamIter.next(); - - if (streamDesc.connectorDesc == connectorDesc) - streamIter.remove(); - } - } - - public void run() - { - try - { - while (true) - { - int writeIndex; - byte[] buffer; - StreamRTPManagerDesc exclusion; - Format format; - int length; - - synchronized (this) - { - if (closed - || !Thread.currentThread().equals(writeThread)) - break; - if (writeQueueLength < 1) - { - boolean interrupted = false; - - try - { - wait(); - } - catch (InterruptedException ie) - { - interrupted = true; - } - if (interrupted) - Thread.currentThread().interrupt(); - continue; - } - - writeIndex = writeQueueHead; - - RTPTranslatorBuffer write = writeQueue[writeIndex]; - - buffer = write.data; - write.data = null; - exclusion = write.exclusion; - write.exclusion = null; - format = write.format; - write.format = null; - length = write.length; - write.length = 0; - - writeQueueHead++; - if (writeQueueHead >= writeQueue.length) - writeQueueHead = 0; - writeQueueLength--; - } - - try - { - doWrite(buffer, 0, length, format, exclusion); - } - finally - { - synchronized (this) - { - RTPTranslatorBuffer write = writeQueue[writeIndex]; - - if ((write != null) && (write.data == null)) - write.data = buffer; - } - } - } - } - catch (Throwable t) - { - logger.error("Failed to translate RTP packet", t); - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - } - finally - { - synchronized (this) - { - if (Thread.currentThread().equals(writeThread)) - writeThread = null; - if (!closed - && (writeThread == null) - && (writeQueueLength > 0)) - createWriteThread(); - } - } - } - - public int write(byte[] buffer, int offset, int length) - { - return doWrite(buffer, offset, length, null, null); - } - - public synchronized void write( - byte[] buffer, int offset, int length, - Format format, - StreamRTPManagerDesc exclusion) - { - if (closed) - return; - - int writeIndex; - - if (writeQueueLength < writeQueue.length) - { - writeIndex - = (writeQueueHead + writeQueueLength) % writeQueue.length; - } - else - { - writeIndex = writeQueueHead; - writeQueueHead++; - if (writeQueueHead >= writeQueue.length) - writeQueueHead = 0; - writeQueueLength--; - logger.warn("Will not translate RTP packet."); - } - - RTPTranslatorBuffer write - = writeQueue[writeIndex]; - - if (write == null) - writeQueue[writeIndex] = write = new RTPTranslatorBuffer(); - - byte[] data = write.data; - - if ((data == null) || (data.length < length)) - write.data = data = new byte[length]; - System.arraycopy(buffer, offset, data, 0, length); - - write.exclusion = exclusion; - write.format = format; - write.length = length; - - writeQueueLength++; - - if (writeThread == null) - createWriteThread(); - else - notify(); - } - } - - private static class PushSourceStreamDesc - { - public final RTPConnectorDesc connectorDesc; - - public final boolean data; - - public final PushSourceStream stream; - - public PushSourceStreamDesc( - RTPConnectorDesc connectorDesc, - PushSourceStream stream, - boolean data) - { - this.connectorDesc = connectorDesc; - this.stream = stream; - this.data = data; - } - } - - private class PushSourceStreamImpl - implements PushSourceStream, - SourceTransferHandler - { - private final boolean data; - - private final List streams - = new LinkedList(); - - private PushSourceStreamDesc streamToReadFrom; - - private SourceTransferHandler transferHandler; - - public PushSourceStreamImpl(boolean data) - { - this.data = data; - } - - public synchronized void addStream( - RTPConnectorDesc connectorDesc, - PushSourceStream stream) - { - for (PushSourceStreamDesc streamDesc : streams) - if ((streamDesc.connectorDesc == connectorDesc) - && (streamDesc.stream == stream)) - return; - streams.add( - new PushSourceStreamDesc(connectorDesc, stream, this.data)); - stream.setTransferHandler(this); - } - - public void close() - { - // TODO Auto-generated method stub - } - - public boolean endOfStream() - { - // TODO Auto-generated method stub - return false; - } - - public ContentDescriptor getContentDescriptor() - { - // TODO Auto-generated method stub - return null; - } - - public long getContentLength() - { - return LENGTH_UNKNOWN; - } - - public Object getControl(String controlType) - { - // TODO Auto-generated method stub - return null; - } - - public Object[] getControls() - { - // TODO Auto-generated method stub - return null; - } - - public synchronized int getMinimumTransferSize() - { - int minimumTransferSize = 0; - - for (PushSourceStreamDesc streamDesc : streams) - { - int streamMinimumTransferSize - = streamDesc.stream.getMinimumTransferSize(); - - if (minimumTransferSize < streamMinimumTransferSize) - minimumTransferSize = streamMinimumTransferSize; - } - return minimumTransferSize; - } - - public int read(byte[] buffer, int offset, int length) - throws IOException - { - PushSourceStreamDesc streamDesc; - int read; - - synchronized (this) - { - streamDesc = streamToReadFrom; - read - = (streamDesc == null) - ? 0 - : streamDesc.stream.read(buffer, offset, length); - } - if (read > 0) - { - read - = RTPTranslatorImpl.this.read( - streamDesc, - buffer, offset, length, - read); - } - return read; - } - - public synchronized void removeStreams(RTPConnectorDesc connectorDesc) - { - Iterator streamIter = streams.iterator(); - - while (streamIter.hasNext()) - { - PushSourceStreamDesc streamDesc = streamIter.next(); - - if (streamDesc.connectorDesc == connectorDesc) - { - streamDesc.stream.setTransferHandler(null); - streamIter.remove(); - if (streamToReadFrom == streamDesc) - streamToReadFrom = null; - } - } - } - - public synchronized void setTransferHandler( - SourceTransferHandler transferHandler) - { - if (this.transferHandler != transferHandler) - { - this.transferHandler = transferHandler; - for (PushSourceStreamDesc streamDesc : streams) - streamDesc.stream.setTransferHandler(this); - } - } - - public synchronized void transferData(PushSourceStream stream) - { - SourceTransferHandler transferHandler = null; - - for (PushSourceStreamDesc streamDesc : streams) - if (streamDesc.stream == stream) - { - streamToReadFrom = streamDesc; - transferHandler = this.transferHandler; - break; - } - - if (transferHandler != null) - transferHandler.transferData(this); - } - } - - private static class RTPConnectorDesc - { - public final RTPConnector connector; - - public final StreamRTPManagerDesc streamRTPManagerDesc; - - public RTPConnectorDesc( - StreamRTPManagerDesc streamRTPManagerDesc, - RTPConnector connector) - { - this.streamRTPManagerDesc = streamRTPManagerDesc; - this.connector = connector; - } - } - - /** - * Implements the RTPConnector with which this instance initializes - * its RTPManager. It delegates to the RTPConnector of the - * various StreamRTPManagers. - */ - private class RTPConnectorImpl - implements RTPConnector - { - /** - * The RTPConnectors this instance delegates to. - */ - private final List connectors - = new LinkedList(); - - private PushSourceStreamImpl controlInputStream; - - private OutputDataStreamImpl controlOutputStream; - - private PushSourceStreamImpl dataInputStream; - - private OutputDataStreamImpl dataOutputStream; - - public synchronized void addConnector(RTPConnectorDesc connector) - { - if (!connectors.contains(connector)) - { - connectors.add(connector); - if (this.controlInputStream != null) - { - PushSourceStream controlInputStream = null; - - try - { - controlInputStream - = connector.connector.getControlInputStream(); - } - catch (IOException ioe) - { - throw new UndeclaredThrowableException(ioe); - } - if (controlInputStream != null) - { - this.controlInputStream.addStream( - connector, - controlInputStream); - } - } - if (this.controlOutputStream != null) - { - OutputDataStream controlOutputStream = null; - - try - { - controlOutputStream - = connector.connector.getControlOutputStream(); - } - catch (IOException ioe) - { - throw new UndeclaredThrowableException(ioe); - } - if (controlOutputStream != null) - { - this.controlOutputStream.addStream( - connector, - controlOutputStream); - } - } - if (this.dataInputStream != null) - { - PushSourceStream dataInputStream = null; - - try - { - dataInputStream - = connector.connector.getDataInputStream(); - } - catch (IOException ioe) - { - throw new UndeclaredThrowableException(ioe); - } - if (dataInputStream != null) - { - this.dataInputStream.addStream( - connector, - dataInputStream); - } - } - if (this.dataOutputStream != null) - { - OutputDataStream dataOutputStream = null; - - try - { - dataOutputStream - = connector.connector.getDataOutputStream(); - } - catch (IOException ioe) - { - throw new UndeclaredThrowableException(ioe); - } - if (dataOutputStream != null) - { - this.dataOutputStream.addStream( - connector, - dataOutputStream); - } - } - } - } - - public synchronized void close() - { - if (controlInputStream != null) - { - controlInputStream.close(); - controlInputStream = null; - } - if (controlOutputStream != null) - { - controlOutputStream.close(); - controlOutputStream = null; - } - if (dataInputStream != null) - { - dataInputStream.close(); - dataInputStream = null; - } - if (dataOutputStream != null) - { - dataOutputStream.close(); - dataOutputStream = null; - } - - for (RTPConnectorDesc connectorDesc : connectors) - connectorDesc.connector.close(); - } - - public synchronized PushSourceStream getControlInputStream() - throws IOException - { - if (this.controlInputStream == null) - { - this.controlInputStream = new PushSourceStreamImpl(false); - for (RTPConnectorDesc connectorDesc : connectors) - { - PushSourceStream controlInputStream - = connectorDesc.connector.getControlInputStream(); - - if (controlInputStream != null) - { - this.controlInputStream.addStream( - connectorDesc, - controlInputStream); - } - } - } - return this.controlInputStream; - } - - public synchronized OutputDataStreamImpl getControlOutputStream() - throws IOException - { - if (this.controlOutputStream == null) - { - this.controlOutputStream = new OutputDataStreamImpl(false); - for (RTPConnectorDesc connectorDesc : connectors) - { - OutputDataStream controlOutputStream - = connectorDesc.connector.getControlOutputStream(); - - if (controlOutputStream != null) - { - this.controlOutputStream.addStream( - connectorDesc, - controlOutputStream); - } - } - } - return this.controlOutputStream; - } - - public synchronized PushSourceStream getDataInputStream() - throws IOException - { - if (this.dataInputStream == null) - { - this.dataInputStream = new PushSourceStreamImpl(true); - for (RTPConnectorDesc connectorDesc : connectors) - { - PushSourceStream dataInputStream - = connectorDesc.connector.getDataInputStream(); - - if (dataInputStream != null) - { - this.dataInputStream.addStream( - connectorDesc, - dataInputStream); - } - } - } - return this.dataInputStream; - } - - public synchronized OutputDataStreamImpl getDataOutputStream() - throws IOException - { - if (this.dataOutputStream == null) - { - this.dataOutputStream = new OutputDataStreamImpl(true); - for (RTPConnectorDesc connectorDesc : connectors) - { - OutputDataStream dataOutputStream - = connectorDesc.connector.getDataOutputStream(); - - if (dataOutputStream != null) - { - this.dataOutputStream.addStream( - connectorDesc, - dataOutputStream); - } - } - } - return this.dataOutputStream; - } - - public int getReceiveBufferSize() - { - return -1; - } - - public double getRTCPBandwidthFraction() - { - return -1; - } - - public double getRTCPSenderBandwidthFraction() - { - return -1; - } - - public int getSendBufferSize() - { - return -1; - } - - public synchronized void removeConnector(RTPConnectorDesc connector) - { - if (connectors.contains(connector)) - { - if (controlInputStream != null) - controlInputStream.removeStreams(connector); - if (controlOutputStream != null) - controlOutputStream.removeStreams(connector); - if (dataInputStream != null) - dataInputStream.removeStreams(connector); - if (dataOutputStream != null) - dataOutputStream.removeStreams(connector); - connectors.remove(connector); - } - } - - public void setReceiveBufferSize(int receiveBufferSize) - throws IOException - { - // TODO Auto-generated method stub - } - - public void setSendBufferSize(int sendBufferSize) - throws IOException - { - // TODO Auto-generated method stub - } - } - - private static class RTPTranslatorBuffer - { - public byte[] data; - - public StreamRTPManagerDesc exclusion; - - public Format format; - - public int length; - } - - /** - * Describes a SendStream created by the RTPManager of - * this instance. Contains information about the DataSource and its - * stream index from which the SendStream has been created so that - * various StreamRTPManager receive different views of one and the - * same SendStream. - */ - private class SendStreamDesc - { - /** - * The DataSource from which {@link #sendStream} has been - * created. - */ - public final DataSource dataSource; - - /** - * The SendStream created from the stream of - * {@link #dataSource} at index {@link #streamIndex}. - */ - public final SendStream sendStream; - - /** - * The list of StreamRTPManager-specific views to - * {@link #sendStream}. - */ - private final List sendStreams - = new LinkedList(); - - /** - * The number of StreamRTPManagers which have started their - * views of {@link #sendStream}. - */ - private int started; - - /** - * The index of the stream of {@link #dataSource} from which - * {@link #sendStream} has been created. - */ - public final int streamIndex; - - public SendStreamDesc( - DataSource dataSource, int streamIndex, - SendStream sendStream) - { - this.dataSource = dataSource; - this.sendStream = sendStream; - this.streamIndex = streamIndex; - } - - void close(SendStreamImpl sendStream) - { - boolean close = false; - - synchronized (this) - { - if (sendStreams.contains(sendStream)) - { - sendStreams.remove(sendStream); - close = sendStreams.isEmpty(); - } - } - if (close) - RTPTranslatorImpl.this.closeSendStream(this); - } - - public synchronized SendStreamImpl getSendStream( - StreamRTPManager streamRTPManager, - boolean create) - { - for (SendStreamImpl sendStream : sendStreams) - if (sendStream.streamRTPManager == streamRTPManager) - return sendStream; - if (create) - { - SendStreamImpl sendStream - = new SendStreamImpl(streamRTPManager, this); - - sendStreams.add(sendStream); - return sendStream; - } - else - return null; - } - - public synchronized int getSendStreamCount() - { - return sendStreams.size(); - } - - synchronized void start(SendStreamImpl sendStream) - throws IOException - { - if (sendStreams.contains(sendStream)) - { - if (started < 1) - { - this.sendStream.start(); - started = 1; - } - else - started++; - } - } - - synchronized void stop(SendStreamImpl sendStream) - throws IOException - { - if (sendStreams.contains(sendStream)) - { - if (started == 1) - { - this.sendStream.stop(); - started = 0; - } - else if (started > 1) - started--; - } - } - } - - private static class SendStreamImpl - implements SendStream - { - private boolean closed; - - public final SendStreamDesc sendStreamDesc; - - private boolean started; - - public final StreamRTPManager streamRTPManager; - - public SendStreamImpl( - StreamRTPManager streamRTPManager, - SendStreamDesc sendStreamDesc) - { - this.sendStreamDesc = sendStreamDesc; - this.streamRTPManager = streamRTPManager; - } - - public void close() - { - if (!closed) - { - try - { - if (started) - stop(); - } - catch (IOException ioe) - { - throw new UndeclaredThrowableException(ioe); - } - finally - { - sendStreamDesc.close(this); - closed = true; - } - } - } - - public DataSource getDataSource() - { - return sendStreamDesc.sendStream.getDataSource(); - } - - public Participant getParticipant() - { - return sendStreamDesc.sendStream.getParticipant(); - } - - public SenderReport getSenderReport() - { - return sendStreamDesc.sendStream.getSenderReport(); - } - - public TransmissionStats getSourceTransmissionStats() - { - return sendStreamDesc.sendStream.getSourceTransmissionStats(); - } - - public long getSSRC() - { - return sendStreamDesc.sendStream.getSSRC(); - } - - public int setBitRate(int bitRate) - { - // TODO Auto-generated method stub - return 0; - } - - public void setSourceDescription(SourceDescription[] sourceDescription) - { - // TODO Auto-generated method stub - } - - public void start() - throws IOException - { - if (closed) - { - throw - new IOException( - "Cannot start SendStream" - + " after it has been closed."); - } - if (!started) - { - sendStreamDesc.start(this); - started = true; - } - } - - public void stop() - throws IOException - { - if (!closed && started) - { - sendStreamDesc.stop(this); - started = false; - } - } - } - - private static class StreamRTPManagerDesc - { - public RTPConnectorDesc connectorDesc; - - private final Map formats - = new HashMap(); - - private long[] receiveSSRCs = EMPTY_LONG_ARRAY; - - private final List receiveStreamListeners - = new LinkedList(); - - public final StreamRTPManager streamRTPManager; - - public StreamRTPManagerDesc(StreamRTPManager streamRTPManager) - { - this.streamRTPManager = streamRTPManager; - } - - public void addFormat(Format format, int payloadType) - { - synchronized (formats) - { - formats.put(payloadType, format); - } - } - - public synchronized void addReceiveSSRC(long receiveSSRC) - { - if (!containsReceiveSSRC(receiveSSRC)) - { - int receiveSSRCCount = receiveSSRCs.length; - long[] newReceiveSSRCs = new long[receiveSSRCCount + 1]; - - System.arraycopy( - receiveSSRCs, 0, - newReceiveSSRCs, 0, - receiveSSRCCount); - newReceiveSSRCs[receiveSSRCCount] = receiveSSRC; - receiveSSRCs = newReceiveSSRCs; - } - } - - public void addReceiveStreamListener(ReceiveStreamListener listener) - { - synchronized (receiveStreamListeners) - { - if (!receiveStreamListeners.contains(listener)) - receiveStreamListeners.add(listener); - } - } - - public Format getFormat(int payloadType) - { - synchronized (formats) - { - return formats.get(payloadType); - } - } - - public Integer getPayloadType(Format format) - { - synchronized (formats) - { - for (Map.Entry entry : formats.entrySet()) - { - Format entryFormat = entry.getValue(); - - if (entryFormat.matches(format) - || format.matches(entryFormat)) - return entry.getKey(); - } - } - return null; - } - - public ReceiveStreamListener[] getReceiveStreamListeners() - { - synchronized (receiveStreamListeners) - { - return - receiveStreamListeners.toArray( - new ReceiveStreamListener[ - receiveStreamListeners.size()]); - } - } - - public synchronized boolean containsReceiveSSRC(long receiveSSRC) - { - for (int i = 0; i < receiveSSRCs.length; i++) - if (receiveSSRCs[i] == receiveSSRC) - return true; - return false; - } - - public void removeReceiveStreamListener(ReceiveStreamListener listener) - { - synchronized (receiveStreamListeners) - { - receiveStreamListeners.remove(listener); - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/RawPacket.java b/src/net/java/sip/communicator/impl/neomedia/RawPacket.java deleted file mode 100644 index 6f90fa8eb..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RawPacket.java +++ /dev/null @@ -1,962 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -/** - * When using TransformConnector, a RTP/RTCP packet is represented using - * RawPacket. RawPacket stores the buffer holding the RTP/RTCP packet, as well - * as the inner offset and length of RTP/RTCP packet data. - * - * After transformation, data is also store in RawPacket objects, either the - * original RawPacket (in place transformation), or a newly created RawPacket. - * - * Besides packet info storage, RawPacket also provides some other operations - * such as readInt() to ease the development process. - * - * @author Werner Dittmann (Werner.Dittmann@t-online.de) - * @author Bing SU (nova.su@gmail.com) - * @author Emil Ivov - * @author Damian Minkov - */ -public class RawPacket -{ - /** - * The size of the fixed part of the RTP header as defined by RFC 3550. - */ - public static final int FIXED_HEADER_SIZE = 12; - - /** - * The size of the extension header as defined by RFC 3550. - */ - public static final int EXT_HEADER_SIZE = 4; - - /** - * Byte array storing the content of this Packet - */ - private byte[] buffer; - - /** - * Start offset of the packet data inside buffer. - * Usually this value would be 0. But in order to be compatible with - * RTPManager we store this info. (Not assuming the offset is always zero) - */ - private int offset; - - /** - * Length of this packet's data - */ - private int length; - - /** - * Construct an empty RawPacket - * - */ - public RawPacket() - { - } - - /** - * Construct a RawPacket using specified value. - * - * @param buffer Byte array holding the content of this Packet - * @param offset Start offset of packet content inside buffer - * @param length Length of the packet's data - */ - public RawPacket(byte[] buffer, int offset, int length) - { - this.buffer = buffer; - this.offset = offset; - this.length = length; - } - - /** - * Get buffer containing the content of this packet - * - * @return buffer containing the content of this packet - */ - public byte[] getBuffer() - { - return this.buffer; - } - - /** - * Get the length of this packet's data - * - * @return length of this packet's data - */ - public int getLength() - { - return this.length; - } - - /** - * Get the start offset of this packet's data inside storing buffer - * - * @return start offset of this packet's data inside storing buffer - */ - public int getOffset() - { - return this.offset; - } - - /** - * @param buffer the buffer to set - */ - protected void setBuffer(byte[] buffer) { - this.buffer = buffer; - } - /** - * @param offset the offset to set - */ - protected void setOffset(int offset) { - this.offset = offset; - } - - /** - * @param length the length to set - */ - protected void setLength(int length) { - this.length = length; - } - - - /** - * Sets or resets the marker bit of this packet according to the - * marker parameter. - * @param marker true if we are to raise the marker bit and - * false otherwise. - */ - public void setMarker(boolean marker) - { - if(marker) - { - buffer[offset + 1] |= (byte) 0x80; - } - else - { - buffer[offset + 1] &= (byte) 0x7F; - } - } - - /** - * Sets the payload of this packet. - * - * @param payload the RTP payload type describing the content of this - * packet. - */ - public void setPayload(byte payload) - { - //this is supposed to be a 7bit payload so make sure that the leftmost - //bit is 0 so that we don't accidentally overwrite the marker. - payload &= (byte)0x7F; - - buffer[offset + 1] = (byte)((buffer[offset + 1] & 0x80) | payload); - } - - /** - * Returns the timestamp for this RTP RawPacket. - * - * @return the timestamp for this RTP RawPacket. - */ - public long getTimestamp() - { - return readInt(offset + 4); - } - - /** - * Set the timestamp value of the RTP Packet - * - * @param timestamp : the RTP Timestamp - */ - public void setTimestamp(long timestamp) - { - writeInt(offset + 4, (int)timestamp); - } - - /** - * Read a integer from this packet at specified offset - * - * @param off start offset of the integer to be read - * @return the integer to be read - */ - public int readInt(int off) - { - return (this.buffer[this.offset + off + 0] << 24) | - ((this.buffer[this.offset + off + 1] & 0xff) << 16) | - ((this.buffer[this.offset + off + 2] & 0xff) << 8) | - (this.buffer[this.offset + off + 3] & 0xff); - } - - /** - * Set an integer at specified offset in network order. - * - * @param off Offset into the buffer - * @param data The integer to store in the packet - */ - public void writeInt(int off, int data) - { - buffer[offset + off++] = (byte)(data>>24); - buffer[offset + off++] = (byte)(data>>16); - buffer[offset + off++] = (byte)(data>>8); - buffer[offset + off] = (byte)data; - } - - /** - * Read a short from this packet at specified offset - * - * @param off start offset of this short - * @return short value at offset - */ - public short readShort(int off) - { - return (short) ((this.buffer[this.offset + off + 0] << 8) | - (this.buffer[this.offset + off + 1] & 0xff)); - } - - /** - * Read an unsigned short at specified offset as a int - * - * @param off start offset of the unsigned short - * @return the int value of the unsigned short at offset - */ - public int readUnsignedShortAsInt(int off) - { - int b1 = (0x000000FF & (this.buffer[this.offset + off + 0])); - int b2 = (0x000000FF & (this.buffer[this.offset + off + 1])); - int val = b1 << 8 | b2; - return val; - } - - /** - * Read a byte from this packet at specified offset - * - * @param off start offset of the byte - * @return byte at offset - */ - public byte readByte(int off) - { - return buffer[offset + off]; - } - - /** - * Write a byte to this packet at specified offset - * - * @param off start offset of the byte - * @param b byte to write - */ - public void writeByte(int off, byte b) - { - buffer[offset + off] = b; - } - - /** - * Read an unsigned integer as long at specified offset - * - * @param off start offset of this unsigned integer - * @return unsigned integer as long at offset - */ - public long readUnsignedIntAsLong(int off) - { - int b0 = (0x000000FF & (this.buffer[this.offset + off + 0])); - int b1 = (0x000000FF & (this.buffer[this.offset + off + 1])); - int b2 = (0x000000FF & (this.buffer[this.offset + off + 2])); - int b3 = (0x000000FF & (this.buffer[this.offset + off + 3])); - - return ((b0 << 24 | b1 << 16 | b2 << 8 | b3)) & 0xFFFFFFFFL; - } - - /** - * Read a byte region from specified offset with specified length - * - * @param off start offset of the region to be read - * @param len length of the region to be read - * @return byte array of [offset, offset + length) - */ - public byte[] readRegion(int off, int len) - { - int startOffset = this.offset + off; - if (off < 0 || len <= 0 || startOffset + len > this.buffer.length) - return null; - - byte[] region = new byte[len]; - - System.arraycopy(this.buffer, startOffset, region, 0, len); - - return region; - } - - /** - * Read a byte region from specified offset with specified length in given - * buffer - * - * @param off start offset of the region to be read - * @param len length of the region to be read - * @param outBuff output buffer - */ - public void readRegionToBuff(int off, int len, byte[] outBuff) - { - int startOffset = this.offset + off; - if (off < 0 || len <= 0 || startOffset + len > this.buffer.length) - return; - - if (outBuff.length < len) - return; - - System.arraycopy(this.buffer, startOffset, outBuff, 0, len); - } - - /** - * Grow the internal packet buffer. - * - * This will change the data buffer of this packet but not the - * length of the valid data. Use this to grow the internal buffer - * to avoid buffer re-allocations when appending data. - * - * @param howMuch number of bytes to grow - */ - public void grow(int howMuch) { - if (howMuch == 0) { - return; - } - byte[] newBuffer = new byte[this.length + howMuch]; - System.arraycopy(this.buffer, this.offset, newBuffer, 0, this.length); - offset = 0; - buffer = newBuffer; - } - - /** - * Append a byte array to the end of the packet. This may change the data - * buffer of this packet. - * - * @param data byte array to append - * @param len the number of bytes to append - */ - public void append(byte[] data, int len) { - if (data == null || len == 0) { - return; - } - - // re-allocate internal buffer if it is too small - if ((this.length + len) > (buffer.length - this.offset)) { - byte[] newBuffer = new byte[this.length + len]; - System.arraycopy(this.buffer, this.offset, newBuffer, 0, this.length); - this.offset = 0; - this.buffer = newBuffer; - } - // append data - System.arraycopy(data, 0, this.buffer, this.length, len); - this.length = this.length + len; - - } - - /** - * Shrink the buffer of this packet by specified length - * - * @param len length to shrink - */ - public void shrink(int len) - { - if (len <= 0) - return; - - this.length -= len; - if (this.length < 0) - this.length = 0; - } - - /** - * Returns the number of CSRC identifiers currently included in this packet. - * - * @return the CSRC count for this RawPacket. - */ - public int getCsrcCount() - { - return (buffer[offset] & 0x0f); - } - - /** - * Replaces the existing CSRC list (even if empty) with newCsrcList - * and updates the CC (CSRC count) field of this RawPacket - * accordingly. - * - * @param newCsrcList the list of CSRC identifiers that we'd like to set for - * this RawPacket. - */ - public void setCsrcList(long[] newCsrcList) - { - int newCsrcCount = newCsrcList.length; - byte[] csrcBuff = new byte[newCsrcCount * 4]; - int csrcOffset = 0; - - for(long csrc : newCsrcList) - { - csrcBuff[csrcOffset] = (byte)(csrc >> 24); - csrcBuff[csrcOffset+1] = (byte)(csrc >> 16); - csrcBuff[csrcOffset+2] = (byte)(csrc >> 8); - csrcBuff[csrcOffset+3] = (byte)csrc; - - csrcOffset += 4; - } - - int oldCsrcCount = getCsrcCount(); - - byte[] oldBuffer = this.getBuffer(); - - //the new buffer needs to be bigger than the new one in order to - //accommodate the list of CSRC IDs (unless there were more of them - //previously than after setting the new list). - byte[] newBuffer - = new byte[length + offset + csrcBuff.length - oldCsrcCount*4]; - - //copy the part up to the CSRC list - System.arraycopy( - oldBuffer, 0, newBuffer, 0, offset + FIXED_HEADER_SIZE); - - //copy the new CSRC list - System.arraycopy( csrcBuff, 0, newBuffer, - offset + FIXED_HEADER_SIZE, csrcBuff.length); - - //now copy the payload from the old buff and make sure we don't copy - //the CSRC list if there was one in the old packet - int payloadOffsetForOldBuff - = offset + FIXED_HEADER_SIZE + oldCsrcCount*4; - - int payloadOffsetForNewBuff - = offset + FIXED_HEADER_SIZE + newCsrcCount*4; - - System.arraycopy( oldBuffer, payloadOffsetForOldBuff, - newBuffer, payloadOffsetForNewBuff, - length - payloadOffsetForOldBuff); - - //set the new CSRC count - newBuffer[offset] = (byte)((newBuffer[offset] & 0xF0) - | newCsrcCount); - - this.buffer = newBuffer; - this.length = payloadOffsetForNewBuff + length - - payloadOffsetForOldBuff - offset; - } - - /** - * Returns the list of CSRC IDs, currently encapsulated in this packet. - * - * @return an array containing the list of CSRC IDs, currently encapsulated - * in this packet. - */ - public long[] extractCsrcList() - { - int csrcCount = getCsrcCount(); - long[] csrcList = new long[csrcCount]; - int csrcStartIndex = offset + FIXED_HEADER_SIZE; - - for (int i = 0; i < csrcCount; i++) - { - csrcList[i] = readInt(csrcStartIndex); - - csrcStartIndex += 4; - } - - return csrcList; - } - - /** - * Get RTP padding size from a RTP packet - * - * @return RTP padding size from source RTP packet - */ - public int getPaddingSize() - { - if ((buffer[offset] & 0x4) == 0) - return 0; - else - return buffer[offset + length - 1]; - } - - /** - * Get RTP header length from a RTP packet - * - * @return RTP header length from source RTP packet - */ - public int getHeaderLength() - { - if(getExtensionBit()) - return FIXED_HEADER_SIZE + 4 * getCsrcCount() - + EXT_HEADER_SIZE + getExtensionLength(); - else - return FIXED_HEADER_SIZE + 4 * getCsrcCount(); - } - - /** - * Get RTP payload length from a RTP packet - * - * @return RTP payload length from source RTP packet - */ - public int getPayloadLength() - { - return length - getHeaderLength(); - } - - /** - * Get RTP SSRC from a RTP packet - * - * @return RTP SSRC from source RTP packet - */ - public int getSSRC() - { - return (int)(readUnsignedIntAsLong(8) & 0xffffffff); - } - - /** - * Get RTCP SSRC from a RTCP packet - * - * @return RTP SSRC from source RTP packet - */ - public long getRTCPSSRC() - { - return (int)(readUnsignedIntAsLong(4) & 0xffffffff); - } - - /** - * Get RTP sequence number from a RTP packet - * - * @return RTP sequence num from source packet - */ - public int getSequenceNumber() - { - return readUnsignedShortAsInt(2); - } - - /** - * Get SRTCP sequence number from a SRTCP packet - * - * @param authTagLen authentication tag length - * @return SRTCP sequence num from source packet - */ - public int getSRTCPIndex(int authTagLen) - { - int offset = getLength() - (4 + authTagLen); - return readInt(offset); - } - /** - * Test whether if a RTP packet is padded - * - * @return whether if source RTP packet is padded - */ - public boolean isPacketMarked() - { - return (buffer[offset + 1] & 0x80) != 0; - } - - /** - * Get RTP payload type from a RTP packet - * - * @return RTP payload type of source RTP packet - */ - public byte getPayloadType() - { - return (byte) (buffer[offset + 1] & (byte)0x7F); - } - - /** - * Get the RTP payload (bytes) of this RTP packet. - * - * @return an array of bytes which represents the RTP payload of - * this RTP packet - */ - public byte[] getPayload() - { - return readRegion(getHeaderLength(), getPayloadLength()); - } - - /** - * Get RTP timestamp from a RTP packet - * - * @return RTP timestamp of source RTP packet - */ - public byte[] readTimeStampIntoByteArray() - { - return readRegion(4, 4); - } - - /** - * Returns true if the extension bit of this packet has been set - * and false otherwise. - * - * @return true if the extension bit of this packet has been set - * and false otherwise. - */ - public boolean getExtensionBit() - { - return (buffer[offset] & 0x10) == 0x10; - } - - /** - * Raises the extension bit of this packet is extBit is - * true or set it to 0 if extBit is - * false. - * - * @param extBit the flag that indicates whether we are to set or clear - * the extension bit of this packet. - */ - private void setExtensionBit(boolean extBit) - { - if(extBit) - buffer[offset] |= 0x10; - else - buffer[offset] &= 0xEF; - } - - /** - * Returns the length of the extensions currently added to this packet. - * - * @return the length of the extensions currently added to this packet. - */ - public int getExtensionLength() - { - if (!getExtensionBit()) - return 0; - - //the extension length comes after the RTP header, the CSRC list, and - //after two bytes in the extension header called "defined by profile" - int extLenIndex = offset - + FIXED_HEADER_SIZE - + getCsrcCount()*4 + 2; - - return ((buffer[extLenIndex] << 8) | buffer[extLenIndex + 1]) * 4; - } - - /** - * Adds the extBuff buffer to as an extension of this packet - * according the rules specified in RFC 5285. Note that this method does - * not replace extensions so if you add the same buffer twice it would be - * added as to separate extensions. - * - * @param extBuff the buffer that we'd like to add as an extension in this - * packet. - * @param newExtensionLen the length of the data in extBuff. - */ - public void addExtension(byte[] extBuff, int newExtensionLen) - { - int newBuffLen = length + offset + newExtensionLen; - int bufferOffset = offset; - int newBufferOffset = offset; - int lengthToCopy = FIXED_HEADER_SIZE + getCsrcCount()*4; - boolean extensionBit = getExtensionBit(); - //if there was no extension previously, we also need to consider adding - //the extension header. - if (extensionBit) - { - // without copying the extension length value, will set it later - lengthToCopy += EXT_HEADER_SIZE - 2; - } - else - newBuffLen += EXT_HEADER_SIZE; - - byte[] newBuffer = new byte[ newBuffLen ]; - - /* - * Copy header, CSRC list and the leading two bytes of the extension - * header if any. - */ - System.arraycopy(buffer, bufferOffset, - newBuffer, newBufferOffset, lengthToCopy); - //raise the extension bit. - newBuffer[newBufferOffset] |= 0x10; - bufferOffset += lengthToCopy; - newBufferOffset += lengthToCopy; - - // Set the extension header or modify the existing one. - int totalExtensionLen = newExtensionLen + getExtensionLength(); - - //if there were no extensions previously, we need to add the hdr now - if(extensionBit) - bufferOffset += 4; - else - { - // we will now be adding the RFC 5285 ext header which looks like - // this: - // - // 0 1 2 3 - // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - // | 0xBE | 0xDE | length=3 | - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - newBuffer[newBufferOffset++] = (byte)0xBE; - newBuffer[newBufferOffset++] = (byte)0xDE; - } - // length field counts the number of 32-bit words in the extension - int lengthInWords = (totalExtensionLen + 3)/4; - newBuffer[newBufferOffset++] = (byte)(lengthInWords >> 8); - newBuffer[newBufferOffset++] = (byte)lengthInWords; - - // Copy the existing extension content if any. - if (extensionBit) - { - lengthToCopy = getExtensionLength(); - System.arraycopy(buffer, bufferOffset, - newBuffer, newBufferOffset, lengthToCopy); - bufferOffset += lengthToCopy; - newBufferOffset += lengthToCopy; - } - - //copy the extension content from the new extension. - System.arraycopy(extBuff, 0, - newBuffer, newBufferOffset, newExtensionLen); - newBufferOffset += newExtensionLen; - - //now copy the payload - System.arraycopy(buffer, bufferOffset, - newBuffer, newBufferOffset, getPayloadLength()); - newBufferOffset += getPayloadLength(); - - buffer = newBuffer; - this.length = newBufferOffset - offset; - } - - /** - * Removes the extension from the packet and its header. - */ - public void removeExtension() - { - if(!getExtensionBit()) - return; - - int payloadOffset = offset + getHeaderLength(); - - int extHeaderLen = getExtensionLength() + EXT_HEADER_SIZE; - - System.arraycopy(buffer, payloadOffset, - buffer, payloadOffset - extHeaderLen, getPayloadLength()); - - this.length -= extHeaderLen; - - setExtensionBit(false); - } - - /** - * Returns a map binding CSRC IDs to audio levels as reported by the remote - * party that sent this packet. - * - * @param csrcExtID the ID of the extension that's transporting csrc audio - * levels in the session that this RawPacket belongs to. - * - * @return an array representing a map binding CSRC IDs to audio levels as - * reported by the remote party that sent this packet. The entries of the - * map are contained in consecutive elements of the returned array where - * elements at even indices stand for CSRC IDs and elements at odd indices - * stand for the associated audio levels - */ - public long[] extractCsrcLevels(byte csrcExtID) - { - if (!getExtensionBit() - || (getExtensionLength() == 0) - || (getCsrcCount() == 0)) - return null; - - int csrcCount = getCsrcCount(); - /* - * XXX The guideline which is also supported by Google and recommended - * for Android is that single-dimensional arrays should be preferred to - * multi-dimensional arrays in Java because the former take less space - * than the latter and are thus more efficient in terms of memory and - * garbage collection. - */ - long[] csrcLevels = new long[csrcCount * 2]; - - //first extract the csrc IDs - int csrcStartIndex = offset + FIXED_HEADER_SIZE; - for (int i = 0; i < csrcCount; i++) - { - int csrcLevelsIndex = 2 * i; - - csrcLevels[csrcLevelsIndex] = readInt(csrcStartIndex); - csrcLevels[csrcLevelsIndex + 1] = getCsrcLevel(i, csrcExtID); - - csrcStartIndex += 4; - } - - return csrcLevels; - } - - /** - * Returns the CSRC level at the specified index or 0 if there was - * no level at that index. - * - * @param index the sequence number of the CSRC audio level extension to - * return. - * @param csrcExtID the ID of the extension that's transporting csrc audio - * levels in the session that this RawPacket belongs to. - * - * @return the CSRC audio level at the specified index of the csrc audio - * level option or 0 if there was no level at that index. - */ - private int getCsrcLevel(int index, byte csrcExtID) - { - if( !getExtensionBit() || getExtensionLength() == 0) - return 0; - - int levelsStart = findExtension(csrcExtID); - - if(levelsStart == -1) - return 0; - - int levelsCount = getLengthForExtension(levelsStart); - - if(levelsCount < index) - { - //apparently the remote side sent more CSRCs than levels. - // ... yeah remote sides do that now and then ... - return 0; - } - - return buffer[levelsStart + index]; - } - - /** - * Returns the index of the element in this packet's buffer where the - * content of the header with the specified extensionID starts. - * - * @param extensionID the ID of the extension whose content we are looking - * for. - * - * @return the index of the first byte of the content of the extension - * with the specified extensionID or -1 if no such extension was - * found. - */ - private int findExtension(int extensionID) - { - if( !getExtensionBit() || getExtensionLength() == 0) - return 0; - - int extOffset = offset + FIXED_HEADER_SIZE - + getCsrcCount()*4 + EXT_HEADER_SIZE; - - int extensionEnd = extOffset + getExtensionLength(); - int extHdrLen = getExtensionHeaderLength(); - - if (extHdrLen != 1 && extHdrLen != 2) - { - return -1; - } - - while (extOffset < extensionEnd) - { - int currType = -1; - int currLen = -1; - - if(extHdrLen == 1) - { - //short header. type is in the lefter 4 bits and length is on - //the right; like this: - // 0 - // 0 1 2 3 4 5 6 7 - // +-+-+-+-+-+-+-+-+ - // | ID | len | - // +-+-+-+-+-+-+-+-+ - - currType = buffer[extOffset] >> 4; - currLen = (buffer[extOffset] & 0x0F) + 1; //add one as per 5285 - - //now skip the header - extOffset ++; - } - else - { - //long header. type is in the first byte and length is in the - //second - // 0 1 - // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - // | ID | length | - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - currType = buffer[extOffset]; - currLen = buffer[extOffset + 1]; - - //now skip the header - extOffset += 2; - } - - if(currType == extensionID) - { - return extOffset; - } - - extOffset += currLen; - } - - return -1; - } - - /** - * Returns the length of the header extension that is carrying the content - * starting at contentStart. In other words this method checks the - * size of extension headers in this packet and then either returns the - * value of the byte right before contentStart or its lower 4 bits. - * This is a very basic method so if you are using it - make sure u know - * what you are doing. - * - * @param contentStart the index of the first element of the content of - * the extension whose size we are trying to obtain. - * - * @return the length of the extension carrying the content starting at - * contentStart. - */ - private int getLengthForExtension(int contentStart) - { - int hdrLen = getExtensionHeaderLength(); - - if( hdrLen == 1 ) - return ( buffer[contentStart - 1] & 0x0F ) + 1; - else - return buffer[contentStart - 1]; - } - - /** - * Returns the length of the extension header being used in this packet or - * -1 in case there were no extension headers here or we didn't - * understand the kind of extension being used. - * - * @return the length of the extension header being used in this packet or - * -1 in case there were no extension headers here or we didn't - * understand the kind of extension being used. - */ - private int getExtensionHeaderLength() - { - if (!getExtensionBit()) - return -1; - - //the type of the extension header comes right after the RTP header and - //the CSRC list. - int extLenIndex = offset + FIXED_HEADER_SIZE + getCsrcCount()*4; - - //0xBEDE means short extension header. - if (buffer[extLenIndex] == (byte)0xBE - && buffer[extLenIndex + 1] == (byte)0xDE) - return 1; - - //0x100 means a two-byte extension header. - if (buffer[extLenIndex]== (byte)0x10 - && (buffer[extLenIndex + 1] >> 4)== 0) - return 2; - - return -1; - } - - /** - * Return the define by profile part of the extension header. - * @return the starting two bytes of extension header. - */ - public int getHeaderExtensionType() - { - if (!getExtensionBit()) - return 0; - - return readUnsignedShortAsInt( - offset + FIXED_HEADER_SIZE + getCsrcCount()*4); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/RecorderImpl.java b/src/net/java/sip/communicator/impl/neomedia/RecorderImpl.java deleted file mode 100644 index 14ee2eae6..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/RecorderImpl.java +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.util.*; - -import javax.media.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.MediaException; // disambiguation -import net.java.sip.communicator.util.*; - -/** - * The call recording implementation. - * Provides the capability to start and stop call recording. - * - * @author Dmitri Melnikov - * @author Lubomir Marinov - */ -public class RecorderImpl - implements Recorder -{ - - /** - * The list of formats in which RecorderImpl instances support - * recording media. - */ - static final String[] SUPPORTED_FORMATS - = new String[] - { - SoundFileUtils.aif, - SoundFileUtils.au, - SoundFileUtils.gsm, - SoundFileUtils.mp3, - SoundFileUtils.wav - }; - - /** - * The AudioMixerMediaDevice which is to be or which is already - * being recorded by this Recorder. - */ - private final AudioMixerMediaDevice device; - - /** - * The MediaDeviceSession is used to create an output data source. - */ - private MediaDeviceSession deviceSession; - - /** - * The List of Recorder.Listeners interested in - * notifications from this Recorder. - */ - private final List listeners - = new ArrayList(); - - /** - * DataSink used to save the output data. - */ - private DataSink sink; - - /** - * The indicator which determines whether this Recorder - * is set to skip media from mic. - */ - private boolean mute = false; - - /** - * The filename we will use to record data, supplied - * when Recorder is started. - */ - private String filename = null; - - /** - * Constructs the RecorderImpl with the provided session. - * - * @param device device that can create a session that provides the output - * data source - */ - public RecorderImpl(AudioMixerMediaDevice device) - { - if (device == null) - throw new NullPointerException("device"); - - this.device = device; - } - - /** - * Adds a new Recorder.Listener to the list of listeners interested - * in notifications from this Recorder. - * - * @param listener the new Recorder.Listener to be added to the - * list of listeners interested in notifications from this Recorder - * @see Recorder#addListener(Recorder.Listener) - */ - public void addListener(Recorder.Listener listener) - { - if (listener == null) - throw new NullPointerException("listener"); - - synchronized (listeners) - { - if (!listeners.contains(listener)) - listeners.add(listener); - } - } - - /** - * Returns a content descriptor to create a recording session with. - * - * @param format the format that corresponding to the content descriptor - * @return content descriptor - * @throws IllegalArgumentException if the specified format is not - * a supported recording format - */ - private ContentDescriptor getContentDescriptor(String format) - throws IllegalArgumentException - { - String type; - - if (SoundFileUtils.wav.equalsIgnoreCase(format)) - type = FileTypeDescriptor.WAVE; - else if (SoundFileUtils.mp3.equalsIgnoreCase(format)) - type = FileTypeDescriptor.MPEG_AUDIO; - else if (SoundFileUtils.gsm.equalsIgnoreCase(format)) - type = FileTypeDescriptor.GSM; - else if (SoundFileUtils.au.equalsIgnoreCase(format)) - type = FileTypeDescriptor.BASIC_AUDIO; - else if (SoundFileUtils.aif.equalsIgnoreCase(format)) - type = FileTypeDescriptor.AIFF; - else - { - throw - new IllegalArgumentException( - format + " is not a supported recording format."); - } - - return new ContentDescriptor(type); - } - - /** - * Gets a list of the formats in which this Recorder supports - * recording media. - * - * @return a List of the formats in which this Recorder - * supports recording media - * @see Recorder#getSupportedFormats() - */ - public List getSupportedFormats() - { - return Arrays.asList(SUPPORTED_FORMATS); - } - - /** - * Removes a existing Recorder.Listener from the list of listeners - * interested in notifications from this Recorder. - * - * @param listener the existing Recorder.Listener to be removed - * from the list of listeners interested in notifications from this - * Recorder - * @see Recorder#removeListener(Recorder.Listener) - */ - public void removeListener(Recorder.Listener listener) - { - if (listener != null) - { - synchronized (listeners) - { - listeners.remove(listener); - } - } - } - - /** - * Starts the recording of the media associated with this Recorder - * (e.g. the media being sent and received in a Call) into a file - * with a specific name. - * - * @param format the format into which the media associated with this - * Recorder is to be recorded into the specified file - * @param filename the name of the file into which the media associated with - * this Recorder is to be recorded - * @throws IOException if anything goes wrong with the input and/or output - * performed by this Recorder - * @throws MediaException if anything else goes wrong while starting the - * recording of media performed by this Recorder - * @see Recorder#start(String, String) - */ - public void start(String format, String filename) - throws IOException, - MediaException - { - if (this.sink == null) - { - if (format == null) - throw new NullPointerException("format"); - if (filename == null) - throw new NullPointerException("filename"); - - this.filename = filename; - - /* - * A file without an extension may not only turn out to be a touch - * more difficult to play but is suspected to also cause an - * exception inside of JMF. - */ - int extensionBeginIndex = filename.lastIndexOf('.'); - - if (extensionBeginIndex < 0) - filename += '.' + format; - else if (extensionBeginIndex == filename.length() - 1) - filename += format; - - MediaDeviceSession deviceSession = device.createSession(); - - try - { - deviceSession.setContentDescriptor(getContentDescriptor(format)); - - // set initial mute state, if mute was set before starting - // the recorder - deviceSession.setMute(mute); - - /* - * This RecorderImpl will use deviceSession to get a hold of the - * media being set to the remote peers associated with the same - * AudioMixerMediaDevice i.e. this RecorderImpl needs - * deviceSession to only capture and not play back. - */ - deviceSession.start(MediaDirection.SENDONLY); - - this.deviceSession = deviceSession; - } - finally - { - if (this.deviceSession == null) - { - throw new MediaException( - "Failed to create MediaDeviceSession from" - + " AudioMixerMediaDevice for the purposes of" - + " recording"); - } - } - - Throwable exception = null; - - try - { - DataSource outputDataSource - = deviceSession.getOutputDataSource(); - DataSink sink - = Manager.createDataSink( - outputDataSource, - new MediaLocator("file:" + filename)); - - sink.open(); - sink.start(); - - this.sink = sink; - } - catch (NoDataSinkException ndsex) - { - exception = ndsex; - } - finally - { - if ((this.sink == null) || (exception != null)) - { - stop(); - - throw new MediaException( - "Failed to start recording into file " + filename, - exception); - } - } - } - } - - /** - * Stops the recording of the media associated with this Recorder - * (e.g. the media being sent and received in a Call) if it has - * been started and prepares this Recorder for garbage collection. - * - * @see Recorder#stop() - */ - public void stop() - { - if (deviceSession != null) - { - deviceSession.close(); - deviceSession = null; - } - - if (sink != null) - { - sink.close(); - sink = null; - - /* - * RecorderImpl creates the sink upon start() and it does it only if - * it is null so this RecorderImpl has really stopped only if it has - * managed to close() the (existing) sink. Notify the registered - * listeners. - */ - Recorder.Listener[] listeners; - - synchronized (this.listeners) - { - listeners - = this.listeners.toArray( - new Recorder.Listener[this.listeners.size()]); - } - for (Recorder.Listener listener : listeners) - listener.recorderStopped(this); - } - } - - /** - * Put the recorder in mute state. It won't record the local input. - * This is used when the local call is muted and we don't won't to record - * the local input. - * @param mute the new value of the mute property - */ - public void setMute(boolean mute) - { - this.mute = mute; - - if(deviceSession != null) - { - deviceSession.setMute(mute); - } - } - - /** - * Returns the filename we are last started or stopped recording to, - * null if not started. - * @return the filename we are last started or stopped recording to, - * null if not started. - */ - public String getFilename() - { - return filename; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/SecurityConfigForm.java b/src/net/java/sip/communicator/impl/neomedia/SecurityConfigForm.java index eea71677a..5bd8146ac 100644 --- a/src/net/java/sip/communicator/impl/neomedia/SecurityConfigForm.java +++ b/src/net/java/sip/communicator/impl/neomedia/SecurityConfigForm.java @@ -10,9 +10,10 @@ import javax.swing.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * The SecurityConfigForm allows the user to make all needed call * security configurations. It now wraps the ZRTP form in order to provide some @@ -86,4 +87,4 @@ protected void close(boolean escaped) {} mainPanel.add(buttonPanel, BorderLayout.SOUTH); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/neomedia/StreamRTPManager.java b/src/net/java/sip/communicator/impl/neomedia/StreamRTPManager.java deleted file mode 100644 index 812de9802..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/StreamRTPManager.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; -import java.util.*; - -import javax.media.*; -import javax.media.format.*; -import javax.media.protocol.*; -import javax.media.rtp.*; - -import com.sun.media.rtp.*; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * Implements the RTPManager interface as used by a - * MediaStream. - * - * @author Lyubomir Marinov - */ -public class StreamRTPManager -{ - /** - * The RTPManager this instance is to delegate to when it is not - * attached to an RTPTranslator. - */ - private final RTPManager manager; - - /** - * The RTPTranslator which this instance is attached to and which - * forwards the RTP and RTCP flows of the MediaStream associated - * with this instance to other MediaStreams. - */ - private final RTPTranslatorImpl translator; - - /** - * Initializes a new StreamRTPManager instance which is, - * optionally, attached to a specific RTPTranslator which is to - * forward the RTP and RTCP flows of the associated MediaStream to - * other MediaStreams. - * - * @param translator the RTPTranslator to attach the new instance - * to or null if the new instance is to not be attached to any - * RTPTranslator - */ - public StreamRTPManager(RTPTranslator translator) - { - this.translator = (RTPTranslatorImpl) translator; - - manager = (this.translator == null) ? RTPManager.newInstance() : null; - } - - public void addFormat(Format format, int payloadType) - { - if (translator == null) - manager.addFormat(format, payloadType); - else - translator.addFormat(this, format, payloadType); - } - - public void addReceiveStreamListener(ReceiveStreamListener listener) - { - if (translator == null) - manager.addReceiveStreamListener(listener); - else - translator.addReceiveStreamListener(this, listener); - } - - public void addRemoteListener(RemoteListener listener) - { - if (translator == null) - manager.addRemoteListener(listener); - else - translator.addRemoteListener(this, listener); - } - - public void addSendStreamListener(SendStreamListener listener) - { - if (translator == null) - manager.addSendStreamListener(listener); - else - translator.addSendStreamListener(this, listener); - } - - public void addSessionListener(SessionListener listener) - { - if (translator == null) - manager.addSessionListener(listener); - else - translator.addSessionListener(this, listener); - } - - public SendStream createSendStream(DataSource dataSource, int streamIndex) - throws IOException, - UnsupportedFormatException - { - if (translator == null) - return manager.createSendStream(dataSource, streamIndex); - else - return translator.createSendStream(this, dataSource, streamIndex); - } - - public void dispose() - { - if (translator == null) - manager.dispose(); - else - translator.dispose(this); - } - - public Object getControl(String controlType) - { - if (translator == null) - return manager.getControl(controlType); - else - return translator.getControl(this, controlType); - } - - public GlobalReceptionStats getGlobalReceptionStats() - { - if (translator == null) - return manager.getGlobalReceptionStats(); - else - return translator.getGlobalReceptionStats(this); - } - - public GlobalTransmissionStats getGlobalTransmissionStats() - { - if (translator == null) - return manager.getGlobalTransmissionStats(); - else - return translator.getGlobalTransmissionStats(this); - } - - public long getLocalSSRC() - { - if (translator == null) - return ((RTPSessionMgr) manager).getLocalSSRC(); - else - return translator.getLocalSSRC(this); - } - - @SuppressWarnings("rawtypes") - public Vector getReceiveStreams() - { - if (translator == null) - return manager.getReceiveStreams(); - else - return translator.getReceiveStreams(this); - } - - @SuppressWarnings("rawtypes") - public Vector getSendStreams() - { - if (translator == null) - return manager.getSendStreams(); - else - return translator.getSendStreams(this); - } - - public void initialize(RTPConnector connector) - { - if (translator == null) - manager.initialize(connector); - else - translator.initialize(this, connector); - } - - public void removeReceiveStreamListener(ReceiveStreamListener listener) - { - if (translator == null) - manager.removeReceiveStreamListener(listener); - else - translator.removeReceiveStreamListener(this, listener); - } - - public void removeRemoteListener(RemoteListener listener) - { - if (translator == null) - manager.removeRemoteListener(listener); - else - translator.removeRemoteListener(this, listener); - } - - public void removeSendStreamListener(SendStreamListener listener) - { - if (translator == null) - manager.removeSendStreamListener(listener); - else - translator.removeSendStreamListener(this, listener); - } - - public void removeSessionListener(SessionListener listener) - { - if (translator == null) - manager.removeSessionListener(listener); - else - translator.removeSessionListener(this, listener); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/VideoMediaStreamImpl.java b/src/net/java/sip/communicator/impl/neomedia/VideoMediaStreamImpl.java deleted file mode 100644 index 193ee8404..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/VideoMediaStreamImpl.java +++ /dev/null @@ -1,1251 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.awt.*; -import java.util.*; -import java.util.List; -import java.util.regex.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.protocol.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.QualityControl; // disambiguation -import net.java.sip.communicator.service.neomedia.control.*; -import net.java.sip.communicator.service.neomedia.control.KeyFrameControl; // disambiguation -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; -import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.event.*; - -/** - * Extends MediaStreamImpl in order to provide an implementation of - * VideoMediaStream. - * - * @author Lyubomir Marinov - * @author Sebastien Vincent - */ -public class VideoMediaStreamImpl - extends MediaStreamImpl - implements VideoMediaStream -{ - - /** - * The Logger used by the VideoMediaStreamImpl class and - * its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(VideoMediaStreamImpl.class); - - /** - * Negotiated output size of the video stream. - * It may need to scale original capture device stream. - */ - private Dimension outputSize; - - /** - * The indicator which determines whether RTCP feedback Picture Loss - * Indication messages are to be used. - */ - private boolean usePLI = true; - - /** - * The KeyFrameControl of this VideoMediaStream. - */ - private KeyFrameControl keyFrameControl; - - /** - * The QualityControl of this VideoMediaStream. - */ - private final QualityControlImpl qualityControl = new QualityControlImpl(); - - /** - * Selects the VideoFormat from the list of supported formats of a - * specific video DataSource which has a size as close as possible - * to a specific size and sets it as the format of the specified video - * DataSource. - * - * @param videoDS the video DataSource which is to have its - * supported formats examined and its format changed to the - * VideoFormat which is as close as possible to the specified - * preferredWidth and preferredHeight - * @param preferredWidth the width of the VideoFormat to be - * selected - * @param preferredHeight the height of the VideoFormat to be - * selected - * @return the size of the VideoFormat from the list of supported - * formats of videoDS which is as close as possible to - * preferredWidth and preferredHeight and which has been - * set as the format of videoDS - */ - public static Dimension selectVideoSize( - DataSource videoDS, - final int preferredWidth, final int preferredHeight) - { - if (videoDS == null) - return null; - - FormatControl formatControl - = (FormatControl) videoDS.getControl(FormatControl.class.getName()); - - if (formatControl == null) - return null; - - Format[] formats = formatControl.getSupportedFormats(); - final int count = formats.length; - - if (count < 1) - return null; - - VideoFormat selectedFormat = null; - - if (count == 1) - selectedFormat = (VideoFormat) formats[0]; - else - { - class FormatInfo - { - public final VideoFormat format; - - public final double difference; - - public final Dimension dimension; - - public FormatInfo(VideoFormat format) - { - this.format = format; - - this.dimension = format.getSize(); - - this.difference = getDifference(this.dimension); - } - - public FormatInfo(Dimension size) - { - this.format = null; - - this.dimension = size; - - this.difference = getDifference(this.dimension); - } - - private double getDifference(Dimension size) - { - int width = (size == null) ? 0 : size.width; - double xScale; - - if (width == 0) - xScale = Double.POSITIVE_INFINITY; - else if (width == preferredWidth) - xScale = 1; - else - xScale = (preferredWidth / (double) width); - - int height = (size == null) ? 0 : size.height; - double yScale; - - if (height == 0) - yScale = Double.POSITIVE_INFINITY; - else if (height == preferredHeight) - yScale = 1; - else - yScale = (preferredHeight / (double) height); - - return Math.abs(1 - Math.min(xScale, yScale)); - } - } - - FormatInfo[] infos = new FormatInfo[count]; - - for (int i = 0; i < count; i++) - { - FormatInfo info - = infos[i] - = new FormatInfo((VideoFormat) formats[i]); - - if (info.difference == 0) - { - selectedFormat = info.format; - break; - } - } - if (selectedFormat == null) - { - Arrays.sort(infos, new Comparator() - { - public int compare(FormatInfo info0, FormatInfo info1) - { - return - Double.compare(info0.difference, info1.difference); - } - }); - selectedFormat = infos[0].format; - } - - /* - * If videoDS states to support any size, use the sizes that we - * support which is closest(or smaller) to the preferred one. - */ - if ((selectedFormat != null) - && (selectedFormat.getSize() == null)) - { - VideoFormat currentFormat - = (VideoFormat) formatControl.getFormat(); - Dimension currentSize = null; - int width = preferredWidth; - int height = preferredHeight; - - // Try to preserve the aspect ratio - if (currentFormat != null) - currentSize = currentFormat.getSize(); - - // sort supported resolutions by aspect - FormatInfo[] supportedInfos - = new FormatInfo[ - DeviceConfiguration.SUPPORTED_RESOLUTIONS.length]; - for (int i = 0; i < supportedInfos.length; i++) - { - supportedInfos[i] - = new FormatInfo( - DeviceConfiguration.SUPPORTED_RESOLUTIONS[i]); - } - Arrays.sort(infos, new Comparator() - { - public int compare(FormatInfo info0, FormatInfo info1) - { - return - Double.compare(info0.difference, info1.difference); - } - }); - - FormatInfo preferredFormat = - new FormatInfo(new Dimension(preferredWidth, preferredHeight)); - - Dimension closestAspect = null; - // lets choose the closest size to the preferred one, - // finding the first sutable aspect - for(FormatInfo supported : supportedInfos) - { - // find the first matching aspect - if(preferredFormat.difference > supported.difference) - continue; - else if(closestAspect == null) - closestAspect = supported.dimension; - - if(supported.dimension.height <= preferredHeight - && supported.dimension.width <= preferredWidth) - { - currentSize = supported.dimension; - } - } - - if(currentSize == null) - currentSize = closestAspect; - - if ((currentSize.width > 0) && (currentSize.height > 0)) - { - width = currentSize.width; - height = currentSize.height; - } - selectedFormat - = (VideoFormat)new VideoFormat( - null, - new Dimension(width, height), - Format.NOT_SPECIFIED, - null, - Format.NOT_SPECIFIED) - .intersects(selectedFormat); - } - } - - Format setFormat = formatControl.setFormat(selectedFormat); - - return - (setFormat instanceof VideoFormat) - ? ((VideoFormat) setFormat).getSize() - : null; - } - - /** - * The VideoListener which handles VideoEvents from the - * MediaDeviceSession of this instance and fires respective - * VideoEvents from this VideoMediaStream to its - * VideoListeners. - */ - private VideoListener deviceSessionVideoListener; - - /** - * The facility which aids this instance in managing a list of - * VideoListeners and firing VideoEvents to them. - *

- * Since the videoNotifierSupport of this - * VideoMediaStreamImpl just forwards the VideoEvents of - * the associated VideoMediaDeviceSession at the time of this - * writing, it does not make sense to have videoNotifierSupport - * executing asynchronously because it does not know whether it has to wait - * for the delivery of the VideoEvents and thus it has to default - * to waiting anyway. - *

- */ - private final VideoNotifierSupport videoNotifierSupport - = new VideoNotifierSupport(this, true); - - /** - * Initializes a new VideoMediaStreamImpl instance which will use - * the specified MediaDevice for both capture and playback of video - * exchanged via the specified StreamConnector. - * - * @param connector the StreamConnector the new instance is to use - * for sending and receiving video - * @param device the MediaDevice the new instance is to use for - * both capture and playback of video exchanged via the specified - * StreamConnector - * @param srtpControl a control which is already created, used to control - * the srtp operations. - */ - public VideoMediaStreamImpl(StreamConnector connector, MediaDevice device, - SrtpControl srtpControl) - { - super(connector, device, srtpControl); - - if(logger.isTraceEnabled()) - logger.trace("Created Video Stream with hashCode " + hashCode()); - } - - /** - * Adds a specific VideoListener to this VideoMediaStream - * in order to receive notifications when visual/video Components - * are being added and removed. - *

- * Adding a listener which has already been added does nothing i.e. it is - * not added more than once and thus does not receive one and the same - * VideoEvent multiple times. - *

- * - * @param listener the VideoListener to be notified when - * visual/video Components are being added or removed in this - * VideoMediaStream - */ - public void addVideoListener(VideoListener listener) - { - videoNotifierSupport.addVideoListener(listener); - } - - /** - * Performs any optional configuration on a specific - * RTPConnectorOuputStream of an RTPManager to be used by - * this MediaStreamImpl. - * - * @param dataOutputStream the RTPConnectorOutputStream to be used - * by an RTPManager of this MediaStreamImpl and to be - * configured - */ - @Override - protected void configureDataOutputStream( - RTPConnectorOutputStream dataOutputStream) - { - super.configureDataOutputStream(dataOutputStream); - - /* - * XXX Android's current video CaptureDevice is based on MediaRecorder - * which gives no control over the number and the size of the packets, - * frame dropping is not implemented because it is hard since - * MediaRecorder generates encoded video. - */ - if (!OSUtils.IS_ANDROID) - { - int maxBandwidth - = NeomediaActivator - .getMediaServiceImpl() - .getDeviceConfiguration() - .getVideoMaxBandwidth(); - - // maximum one packet for X milliseconds(the settings are for one - // second) - dataOutputStream.setMaxPacketsPerMillis(1, 1000 / maxBandwidth); - } - } - - /** - * Performs any optional configuration on the BufferControl of the - * specified RTPManager which is to be used as the - * RTPManager of this MediaStreamImpl. - * - * @param rtpManager the RTPManager which is to be used by this - * MediaStreamImpl - * @param bufferControl the BufferControl of rtpManager on - * which any optional configuration is to be performed - */ - @Override - protected void configureRTPManagerBufferControl( - StreamRTPManager rtpManager, - BufferControl bufferControl) - { - super.configureRTPManagerBufferControl(rtpManager, bufferControl); - - bufferControl.setBufferLength(BufferControl.MAX_VALUE); - } - - /** - * Creates the visual Component depicting the video being streamed - * from the local peer to the remote peer. - * - * @param flipLocalVideoDisplay Tells to flip the local video display (true, - * in case of diplaying the webcam as a mirror), or not (false, for desktop - * streaming). - * - * @return the visual Component depicting the video being streamed - * from the local peer to the remote peer if it was immediately created or - * null if it was not immediately created and it is to be delivered - * to the currently registered VideoListeners in a - * VideoEvent with type {@link VideoEvent#VIDEO_ADDED} and origin - * {@link VideoEvent#LOCAL} - */ - public Component createLocalVisualComponent(boolean flipLocalVideoDisplay) - { - MediaDeviceSession deviceSession = getDeviceSession(); - - return - (deviceSession instanceof VideoMediaDeviceSession) - ? ((VideoMediaDeviceSession) deviceSession) - .createLocalVisualComponent(flipLocalVideoDisplay) - : null; - } - - /** - * Notifies this MediaStream that the MediaDevice (and - * respectively the MediaDeviceSession with it) which this instance - * uses for capture and playback of media has been changed. Makes sure that - * the VideoListeners of this instance get VideoEvents for - * the new/current VideoMediaDeviceSession and not for the old one. - * - * @param oldValue the MediaDeviceSession with the - * MediaDevice this instance used work with - * @param newValue the MediaDeviceSession with the - * MediaDevice this instance is to work with - * @see MediaStreamImpl#deviceSessionChanged(MediaDeviceSession, - * MediaDeviceSession) - */ - @Override - protected void deviceSessionChanged( - MediaDeviceSession oldValue, - MediaDeviceSession newValue) - { - super.deviceSessionChanged(oldValue, newValue); - - if (oldValue instanceof VideoMediaDeviceSession) - { - VideoMediaDeviceSession oldVideoMediaDeviceSession - = (VideoMediaDeviceSession) oldValue; - - if (deviceSessionVideoListener != null) - oldVideoMediaDeviceSession.removeVideoListener( - deviceSessionVideoListener); - - /* - * The oldVideoMediaDeviceSession is being disconnected from this - * VideoMediaStreamImpl so do not let it continue using its - * keyFrameControl. - */ - oldVideoMediaDeviceSession.setKeyFrameControl(null); - } - if (newValue instanceof VideoMediaDeviceSession) - { - VideoMediaDeviceSession newVideoMediaDeviceSession - = (VideoMediaDeviceSession) newValue; - - if (deviceSessionVideoListener == null) - { - deviceSessionVideoListener = new VideoListener() - { - - /** - * Notifies that a visual Component representing - * video has been added to the provider this listener has - * been added to. - * - * @param e a VideoEvent describing the added - * visual Component representing video and the - * provider it was added into - * @see VideoListener#videoAdded(VideoEvent) - */ - public void videoAdded(VideoEvent e) - { - if (fireVideoEvent( - e.getType(), - e.getVisualComponent(), - e.getOrigin(), - true)) - e.consume(); - } - - /** - * Notifies that a visual Component representing - * video has been removed from the provider this listener - * has been added to. - * - * @param e a VideoEvent describing the removed - * visual Component representing video and the - * provider it was removed from - * @see VideoListener#videoRemoved(VideoEvent) - */ - public void videoRemoved(VideoEvent e) - { - videoAdded(e); - } - - public void videoUpdate(VideoEvent e) - { - fireVideoEvent(e, true); - } - }; - } - newVideoMediaDeviceSession.addVideoListener( - deviceSessionVideoListener); - - newVideoMediaDeviceSession.setOutputSize(outputSize); - - AbstractRTPConnector rtpConnector = getRTPConnector(); - - if (rtpConnector != null) - newVideoMediaDeviceSession.setConnector(rtpConnector); - newVideoMediaDeviceSession.setRtcpFeedbackPLI(usePLI); - - /* - * The newVideoMediaDeviceSession is being connected to this - * VideoMediaStreamImpl so the key frame-related logic will be - * controlled by the keyFrameControl of this VideoMediaStreamImpl. - */ - newVideoMediaDeviceSession.setKeyFrameControl(getKeyFrameControl()); - } - } - - /** - * Disposes of the visual Component of the local peer. - * - * @param component the visual Component of the local peer to - * dispose of - */ - public void disposeLocalVisualComponent(Component component) - { - MediaDeviceSession deviceSession = getDeviceSession(); - - if(deviceSession instanceof VideoMediaDeviceSession) - ((VideoMediaDeviceSession) deviceSession) - .disposeLocalVisualComponent(component); - } - - /** - * Notifies the VideoListeners registered with this - * VideoMediaStream about a specific type of change in the - * availability of a specific visual Component depicting video. - * - * @param type the type of change as defined by VideoEvent in the - * availability of the specified visual Component depicting video - * @param visualComponent the visual Component depicting video - * which has been added or removed in this VideoMediaStream - * @param origin {@link VideoEvent#LOCAL} if the origin of the video is - * local (e.g. it is being locally captured); {@link VideoEvent#REMOTE} if - * the origin of the video is remote (e.g. a remote peer is streaming it) - * @param wait true if the call is to wait till the specified - * VideoEvent has been delivered to the VideoListeners; - * otherwise, false - * @return true if this event and, more specifically, the visual - * Component it describes have been consumed and should be - * considered owned, referenced (which is important because - * Components belong to a single Container at a time); - * otherwise, false - */ - protected boolean fireVideoEvent( - int type, Component visualComponent, int origin, - boolean wait) - { - if (logger.isTraceEnabled()) - logger - .trace( - "Firing VideoEvent with type " - + VideoEvent.typeToString(type) - + " and origin " - + VideoEvent.originToString(origin)); - - return - videoNotifierSupport.fireVideoEvent( - type, visualComponent, origin, - wait); - } - - /** - * Notifies the VideoListeners registered with this instance about - * a specific VideoEvent. - * - * @param event the VideoEvent to be fired to the - * VideoListeners registered with this instance - * @param wait true if the call is to wait till the specified - * VideoEvent has been delivered to the VideoListeners; - * otherwise, false - */ - protected void fireVideoEvent(VideoEvent event, boolean wait) - { - videoNotifierSupport.fireVideoEvent(event, wait); - } - - /** - * Gets the visual Component where video from the remote peer is - * being rendered or null if no video is currently being rendered. - * - * @return the visual Component where video from the remote peer is - * being rendered or null if no video is currently being rendered - * @see VideoMediaStream#getVisualComponent() - */ - @Deprecated - public Component getVisualComponent() - { - List visualComponents = getVisualComponents(); - - return visualComponents.isEmpty() ? null : visualComponents.get(0); - } - - /** - * Gets a list of the visual Components where video from the remote - * peer is being rendered. - * - * @return a list of the visual Components where video from the - * remote peer is being rendered - * @see VideoMediaStream#getVisualComponents() - */ - public List getVisualComponents() - { - MediaDeviceSession deviceSession = getDeviceSession(); - List visualComponents; - - if (deviceSession instanceof VideoMediaDeviceSession) - { - visualComponents - = ((VideoMediaDeviceSession) deviceSession) - .getVisualComponents(); - } - else - visualComponents = Collections.emptyList(); - return visualComponents; - } - - /** - * Gets the visual Components rendering the ReceiveStream - * corresponding to the given ssrc. - * - * @param ssrc the src-id of the receive stream, which visual - * Component we're looking for - * @return the visual Component rendering the - * ReceiveStream corresponding to the given ssrc - */ - public Component getVisualComponent(long ssrc) - { - MediaDeviceSession deviceSession = getDeviceSession(); - - if (deviceSession instanceof VideoMediaDeviceSession) - { - return ((VideoMediaDeviceSession) deviceSession) - .getVisualComponent(ssrc); - } - - return null; - } - - /** - * Removes a specific VideoListener from this - * VideoMediaStream in order to have to no longer receive - * notifications when visual/video Components are being added and - * removed. - * - * @param listener the VideoListener to no longer be notified when - * visual/video Components are being added or removed in this - * VideoMediaStream - */ - public void removeVideoListener(VideoListener listener) - { - videoNotifierSupport.removeVideoListener(listener); - } - - /** - * Notifies this MediaStream implementation that its - * RTPConnector instance has changed from a specific old value to a - * specific new value. Allows extenders to override and perform additional - * processing after this MediaStream has changed its - * RTPConnector instance. - * - * @param oldValue the RTPConnector of this MediaStream - * implementation before it got changed to newValue - * @param newValue the current RTPConnector of this - * MediaStream which replaced oldValue - * @see MediaStreamImpl#rtpConnectorChanged(AbstractRTPConnector, - * AbstractRTPConnector) - */ - @Override - protected void rtpConnectorChanged( - AbstractRTPConnector oldValue, - AbstractRTPConnector newValue) - { - super.rtpConnectorChanged(oldValue, newValue); - - if (newValue != null) - { - MediaDeviceSession deviceSession = getDeviceSession(); - - if (deviceSession instanceof VideoMediaDeviceSession) - { - ((VideoMediaDeviceSession) deviceSession) - .setConnector(newValue); - } - } - } - - /** - * Handles attributes contained in MediaFormat. - * - * @param format the MediaFormat to handle the attributes of - * @param attrs the attributes Map to handle - */ - @Override - protected void handleAttributes( - MediaFormat format, - Map attrs) - { - /* walk through attributes and see if we recognized something - * we support - */ - if(attrs != null) - { - String width = null; - String height = null; - - for(Map.Entry mapEntry : attrs.entrySet()) - { - String key = mapEntry.getKey(); - String value = mapEntry.getValue(); - - if(key.equals("rtcp-fb")) - { - if (value.equals("nack pli")) - usePLI = true; - } - else if(key.equals("imageattr")) - { - Dimension res[] = parseSendRecvResolution(value); - - if(res != null) - { - // if we have width or height attributes - // don't override any previous output size - if((attrs.containsKey("width") - || attrs.containsKey("height")) - && outputSize != null) - continue; - - outputSize = res[1]; - - qualityControl.setRemoteSendMaxPreset( - new QualityPreset(res[0])); - qualityControl.setRemoteReceiveResolution(outputSize); - ((VideoMediaDeviceSession)getDeviceSession()). - setOutputSize(outputSize); - } - } - else if(key.equals("CIF")) - { - Dimension dim = new Dimension(352, 288); - - if(outputSize == null || (outputSize.width < dim.width && - outputSize.height < dim.height)) - { - outputSize = dim; - ((VideoMediaDeviceSession)getDeviceSession()). - setOutputSize(outputSize); - } - } - else if(key.equals("QCIF")) - { - Dimension dim = new Dimension(176, 144); - - if(outputSize == null || (outputSize.width < dim.width && - outputSize.height < dim.height)) - { - outputSize = dim; - ((VideoMediaDeviceSession)getDeviceSession()). - setOutputSize(outputSize); - } - } - else if(key.equals("VGA")) // X-lite send it - { - Dimension dim = new Dimension(640, 480); - - if(outputSize == null || (outputSize.width < dim.width && - outputSize.height < dim.height)) - { - /* X-lite does not display anything if we send 640x480 - * video - */ - outputSize = dim; - ((VideoMediaDeviceSession)getDeviceSession()). - setOutputSize(outputSize); - } - } - else if(key.equals("CUSTOM")) - { - String args[] = value.split(","); - - if(args.length < 3) - continue; - - try - { - Dimension dim = new Dimension(Integer.parseInt(args[0]), - Integer.parseInt(args[1])); - - if(outputSize == null || (outputSize.width < dim.width - && outputSize.height < dim.height)) - { - outputSize = dim; - ((VideoMediaDeviceSession)getDeviceSession()). - setOutputSize(outputSize); - } - } - catch(Exception e) - { - } - } - else if (key.equals("width")) - { - width = value; - - if(height != null) - { - outputSize = new Dimension( - Integer.parseInt(width), - Integer.parseInt(height)); - - ((VideoMediaDeviceSession)getDeviceSession()). - setOutputSize(outputSize); - } - } - else if (key.equals("height")) - { - height = value; - - if(width != null) - { - outputSize = new Dimension( - Integer.parseInt(width), - Integer.parseInt(height)); - ((VideoMediaDeviceSession)getDeviceSession()). - setOutputSize(outputSize); - } - } - } - } - } - - /** - * Extracts and returns maximum resolution can receive from the image - * attribute. - * - * @param imgattr send/recv resolution string - * @return maximum resolution array (first element is send, second one is - * recv). Elements could be null if image attribute is not present or if - * resolution is a wildcard. - */ - public static java.awt.Dimension[] parseSendRecvResolution(String imgattr) - { - java.awt.Dimension res[] = new java.awt.Dimension[2]; - String token = null; - Pattern pSendSingle = Pattern.compile("send \\[x=[0-9]+,y=[0-9]+\\]"); - Pattern pRecvSingle = Pattern.compile("recv \\[x=[0-9]+,y=[0-9]+\\]"); - Pattern pSendRange = Pattern.compile( - "send \\[x=\\[[0-9]+-[0-9]+\\],y=\\[[0-9]+-[0-9]+\\]\\]"); - Pattern pRecvRange = Pattern.compile( - "recv \\[x=\\[[0-9]+-[0-9]+\\],y=\\[[0-9]+-[0-9]+\\]\\]"); - Pattern pNumeric = Pattern.compile("[0-9]+"); - Matcher mSingle = null; - Matcher mRange = null; - Matcher m = null; - - /* resolution (width and height) can be on four forms - * - * - single value [x=1920,y=1200] - * - range of values [x=[800-1024],y=[600-768]] - * - fixed range of values [x=[800,1024],y=[600,768]] - * - range of values with step [x=[800:32:1024],y=[600:32:768]] - * - * For the moment we only support the first two forms. - */ - - /* send part */ - mSingle = pSendSingle.matcher(imgattr); - mRange = pSendRange.matcher(imgattr); - - if(mSingle.find()) - { - int val[] = new int[2]; - int i = 0; - token = imgattr.substring(mSingle.start(), mSingle.end()); - m = pNumeric.matcher(token); - - while(m.find() && i < 2) - { - val[i] = Integer.parseInt(token.substring(m.start(), m.end())); - } - - res[0] = new java.awt.Dimension(val[0], val[1]); - } - else if(mRange.find()) /* try with range */ - { - /* have two value for width and two for height (min-max) */ - int val[] = new int[4]; - int i = 0; - token = imgattr.substring(mRange.start(), mRange.end()); - m = pNumeric.matcher(token); - - while(m.find() && i < 4) - { - val[i] = Integer.parseInt(token.substring(m.start(), m.end())); - i++; - } - - res[0] = new java.awt.Dimension(val[1], val[3]); - } - - /* recv part */ - mSingle = pRecvSingle.matcher(imgattr); - mRange = pRecvRange.matcher(imgattr); - - if(mSingle.find()) - { - int val[] = new int[2]; - int i = 0; - token = imgattr.substring(mSingle.start(), mSingle.end()); - m = pNumeric.matcher(token); - - while(m.find() && i < 2) - { - val[i] = Integer.parseInt(token.substring(m.start(), m.end())); - } - - res[1] = new java.awt.Dimension(val[0], val[1]); - } - else if(mRange.find()) /* try with range */ - { - /* have two value for width and two for height (min-max) */ - int val[] = new int[4]; - int i = 0; - token = imgattr.substring(mRange.start(), mRange.end()); - m = pNumeric.matcher(token); - - while(m.find() && i < 4) - { - val[i] = Integer.parseInt(token.substring(m.start(), m.end())); - i++; - } - - res[1] = new java.awt.Dimension(val[1], val[3]); - } - - token = null; - mSingle = null; - mRange = null; - m = null; - pRecvRange = null; - pSendSingle = null; - pRecvSingle = null; - pSendRange = null; - - return res; - } - - /** - * Set local SSRC. - * - * @param localSourceID source ID - */ - @Override - protected void setLocalSourceID(long localSourceID) - { - super.setLocalSourceID(localSourceID); - - ((VideoMediaDeviceSession) getDeviceSession()).setLocalSSRC( - localSourceID); - } - - /** - * Set remote SSRC. - * - * @param ssrc remote SSRC - */ - @Override - protected void addRemoteSourceID(long ssrc) - { - super.addRemoteSourceID(ssrc); - - ((VideoMediaDeviceSession) getDeviceSession()).setRemoteSSRC(ssrc); - } - - /** - * The priority of the video is 5, which is meant to be higher than - * other threads and lower than the audio one. - * @return video priority. - */ - @Override - protected int getPriority() - { - return 5; - } - - /** - * Implements {@link VideoMediaStream#getKeyFrameControl()}. - * - * {@inheritDoc} - * @see VideoMediaStream#getKeyFrameControl() - */ - public KeyFrameControl getKeyFrameControl() - { - if (keyFrameControl == null) - keyFrameControl = new KeyFrameControlAdapter(); - return keyFrameControl; - } - - /** - * Gets the QualityControl of this VideoMediaStream. - * - * @return the QualityControl of this VideoMediaStream - */ - public QualityControl getQualityControl() - { - return qualityControl; - } - - /** - * Updates the QualityControl of this VideoMediaStream. - * - * @param advancedParams parameters of advanced attributes that may affect - * quality control - */ - public void updateQualityControl( - Map advancedParams) - { - for(Map.Entry entry : advancedParams.entrySet()) - { - if(entry.getKey().equals("imageattr")) - { - Dimension res[] = parseSendRecvResolution(entry.getValue()); - - if(res != null) - { - qualityControl.setRemoteSendMaxPreset( - new QualityPreset(res[0])); - qualityControl.setRemoteReceiveResolution( - res[1]); - outputSize = res[1]; - ((VideoMediaDeviceSession)getDeviceSession()). - setOutputSize(outputSize); - } - } - } - } - - /** - * Move origin of a partial desktop streaming MediaDevice. - * - * @param x new x coordinate origin - * @param y new y coordinate origin - */ - public void movePartialDesktopStreaming(int x, int y) - { - MediaDeviceImpl dev = (MediaDeviceImpl)getDevice(); - - if(!dev.getCaptureDeviceInfo().getLocator().getProtocol().equals( - DeviceSystem.LOCATOR_PROTOCOL_IMGSTREAMING)) - return; - - /* To move origin of the desktop capture, we need to access the - * JMF DataSource of imgstreaming - */ - VideoMediaDeviceSession session = - (VideoMediaDeviceSession)getDeviceSession(); - - DataSource ds = session.getCaptureDevice(); - if(ds instanceof RewritablePullBufferDataSource) - { - RewritablePullBufferDataSource ds2 = - (RewritablePullBufferDataSource)ds; - ds = ds2.getWrappedDataSource(); - } - - // Makes the screen detection with a point inside a real screen: - // (x and y > 0). - int tmpX = (x < 0)? 0: x; - int tmpY = (y < 0)? 0: y; - ScreenDevice screen = - NeomediaActivator.getMediaServiceImpl().getScreenForPoint( - new Point(tmpX, tmpY)); - ScreenDevice currentScreen = screen; - - if(screen == null) - return; - - Rectangle bounds = ((ScreenDeviceImpl)screen).getBounds(); - - x -= bounds.x; - y -= bounds.y; - /*((net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.imgstreaming.DataSource) - ds)*/ - Object imgStreamingDataSource = ds.getControl( - net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.imgstreaming.DataSource.class.getName()); - if(imgStreamingDataSource != null) - { - ((net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.imgstreaming.DataSource) - imgStreamingDataSource) - .setOrigin(0, currentScreen.getIndex(), x, y); - } - } - - /** - * Implements the QualityControl of this VideoMediaStream. - * - * @author Damian Minkov - */ - private class QualityControlImpl - implements QualityControl - { - /** - * The current used preset. - */ - private QualityPreset preset; - - /** - * The minimum values for resolution, framerate ... - */ - private QualityPreset minPreset; - - /** - * The maximum values for resolution, framerate ... - */ - private QualityPreset maxPreset; - - /** - * This is the local settings from the config panel. - */ - private QualityPreset localSettingsPreset; - - /** - * Sets the preset. - * @param preset the desired video settings - * @throws OperationFailedException - */ - private void setRemoteReceivePreset(QualityPreset preset) - throws OperationFailedException - { - if(preset.compareTo(getPreferredSendPreset()) > 0) - this.preset = getPreferredSendPreset(); - else - { - this.preset = preset; - - if(logger.isInfoEnabled() - && preset != null && preset.getResolution() != null) - { - logger.info("video send resolution: " - + preset.getResolution().width + "x" - + preset.getResolution().height); - } - } - } - - /** - * The current preset. - * @return the current preset - */ - public QualityPreset getRemoteReceivePreset() - { - return preset; - } - - /** - * The minimum resolution values for remote part. - * @return minimum resolution values for remote part. - */ - public QualityPreset getRemoteSendMinPreset() - { - return minPreset; - } - - /** - * The max resolution values for remote part. - * @return max resolution values for remote part. - */ - public QualityPreset getRemoteSendMaxPreset() - { - return maxPreset; - } - - /** - * Does nothing specific locally. - * - * @param preset the max preset - * @throws OperationFailedException not thrown. - */ - public void setPreferredRemoteSendMaxPreset(QualityPreset preset) - throws OperationFailedException - { - setRemoteSendMaxPreset(preset); - } - - /** - * Changes remote send preset, the one we will receive. - * @param preset - */ - public void setRemoteSendMaxPreset(QualityPreset preset) - { - this.maxPreset = preset; - } - - /** - * Gets the local setting of capture. - * @return the local setting of capture - */ - private QualityPreset getPreferredSendPreset() - { - if(localSettingsPreset == null) - { - DeviceConfiguration deviceConfiguration = - NeomediaActivator.getMediaServiceImpl() - .getDeviceConfiguration(); - - localSettingsPreset = new QualityPreset( - deviceConfiguration.getVideoSize(), - deviceConfiguration.getFrameRate()); - } - return localSettingsPreset; - } - - /** - * Sets maximum resolution. - * @param res - */ - public void setRemoteReceiveResolution(Dimension res) - { - try - { - this.setRemoteReceivePreset(new QualityPreset(res)); - } - catch(OperationFailedException ofe){} - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/ZrtpConfigurePanel.java b/src/net/java/sip/communicator/impl/neomedia/ZrtpConfigurePanel.java index 2ae45d725..eef4d7ab6 100644 --- a/src/net/java/sip/communicator/impl/neomedia/ZrtpConfigurePanel.java +++ b/src/net/java/sip/communicator/impl/neomedia/ZrtpConfigurePanel.java @@ -14,10 +14,11 @@ import javax.swing.event.*; import javax.swing.table.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * @author Werner Dittmann * @author Lubomir Marinov diff --git a/src/net/java/sip/communicator/impl/neomedia/ZrtpConfigureUtils.java b/src/net/java/sip/communicator/impl/neomedia/ZrtpConfigureUtils.java deleted file mode 100644 index dffea771c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/ZrtpConfigureUtils.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import net.java.sip.communicator.service.configuration.*; -import gnu.java.zrtp.ZrtpConfigure; -import gnu.java.zrtp.ZrtpConstants; - -public class ZrtpConfigureUtils -{ - public static >String getPropertyID(T algo) - { - Class clazz = algo.getDeclaringClass(); - return "net.java.sip.communicator." + clazz.getName().replace('$', '_'); - } - - public static ZrtpConfigure getZrtpConfiguration() - { - ZrtpConfigure active = new ZrtpConfigure(); - setupConfigure(ZrtpConstants.SupportedPubKeys.DH2K, active); - setupConfigure(ZrtpConstants.SupportedHashes.S256, active); - setupConfigure(ZrtpConstants.SupportedSymCiphers.AES1, active); - setupConfigure(ZrtpConstants.SupportedSASTypes.B32, active); - setupConfigure(ZrtpConstants.SupportedAuthLengths.HS32, active); - - return active; - } - - private static > void - setupConfigure(T algo, ZrtpConfigure active) - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - String savedConf = null; - - if (cfg != null) - { - String id = ZrtpConfigureUtils.getPropertyID(algo); - - savedConf = cfg.getString(id); - } - if (savedConf == null) - savedConf = ""; - - Class clazz = algo.getDeclaringClass(); - String savedAlgos[] = savedConf.split(";"); - - // Configure saved algorithms as active - for (String str : savedAlgos) - { - try - { - T algoEnum = Enum.valueOf(clazz, str); - - if (algoEnum != null) - active.addAlgo(algoEnum); - } - catch (IllegalArgumentException iae) - { - // Ignore it and continue the loop. - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/ZrtpControlImpl.java b/src/net/java/sip/communicator/impl/neomedia/ZrtpControlImpl.java deleted file mode 100644 index 279af2311..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/ZrtpControlImpl.java +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import gnu.java.zrtp.*; -import gnu.java.zrtp.utils.*; - -import java.util.*; - -import net.java.sip.communicator.impl.neomedia.transform.zrtp.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.event.*; - -/** - * Controls zrtp in the MediaStream. - * - * @author Damian Minkov - */ -public class ZrtpControlImpl - implements ZrtpControl -{ - /** - * The listener interested in security events about zrtp. - */ - private SrtpListener zrtpListener = null; - - /** - * Additional info codes for and data to support ZRTP4J. - * These could be added to the library. However they are specific for this - * implementation, needing them for various GUI changes. - */ - public static enum ZRTPCustomInfoCodes - { - ZRTPNotEnabledByUser, - ZRTPDisabledByCallEnd, - ZRTPEngineInitFailure, - ZRTPEnabledByDefault - } - - /** - * The zrtp engine control by this ZrtpControl. - */ - private ZRTPTransformEngine zrtpEngine = null; - - /** - * This is the connector, required to send ZRTP packets - * via the DatagramSocket. - */ - private AbstractRTPConnector zrtpConnector = null; - - /** - * Whether current is master session. - */ - private boolean masterSession = false; - - /** - * Creates the control. - */ - ZrtpControlImpl() - { - } - - /** - * Cleans up the current zrtp control and its engine. - */ - public void cleanup() - { - if(zrtpEngine != null) - { - zrtpEngine.stopZrtp(); - zrtpEngine.cleanup(); - } - - zrtpEngine = null; - zrtpConnector = null; - } - - /** - * Sets a ZrtpListener that will listen for zrtp security events. - * - * @param zrtpListener the ZrtpListener to set - */ - public void setSrtpListener(SrtpListener zrtpListener) - { - this.zrtpListener = zrtpListener; - } - - /** - * Returns the ZrtpListener which listens for security events. - * - * @return the ZrtpListener which listens for security events - */ - public SrtpListener getSrtpListener() - { - return this.zrtpListener; - } - - /** - * Method for getting the default secure status value for communication - * - * @return the default enabled/disabled status value for secure - * communication - */ - public boolean getSecureCommunicationStatus() - { - return - (zrtpEngine != null) && zrtpEngine.getSecureCommunicationStatus(); - } - - /** - * Sets the SAS verification - * - * @param verified the new SAS verification status - */ - public void setSASVerification(boolean verified) - { - ZRTPTransformEngine engine = getTransformEngine(); - - if (verified) - engine.SASVerified(); - else - engine.resetSASVerified(); - } - - /** - * Returns the zrtp engine currently used by this stream. - * @return the zrtp engine - */ - public ZRTPTransformEngine getTransformEngine() - { - if(zrtpEngine == null) - { - zrtpEngine = new ZRTPTransformEngine(); - - // NOTE: set paranoid mode before initializing - // zrtpEngine.setParanoidMode(paranoidMode); - zrtpEngine.initialize( - "GNUZRTP4J.zid", - false, - ZrtpConfigureUtils.getZrtpConfiguration()); - zrtpEngine.setUserCallback(new SecurityEventManager(this)); - } - return zrtpEngine; - } - - /** - * When in multistream mode, enables the master session. - * @param masterSession whether current control, controls the master session. - */ - public void setMasterSession(boolean masterSession) - { - // by default its not master, change only if set to be master - // sometimes (jingle) streams are re-initing and - // we must reuse old value (true) event that false is submitted - if(masterSession) - this.masterSession = masterSession; - } - - /** - * Starts and enables zrtp in the stream holding this control. - * @param mediaType the media type of the stream this control controls. - */ - public void start(MediaType mediaType) - { - boolean zrtpAutoStart; - - // ZRTP engine initialization - ZRTPTransformEngine engine = getTransformEngine(); - // Create security user callback for each peer. - SecurityEventManager securityEventManager = engine.getUserCallback(); - - // Decide if this will become the ZRTP Master session: - // - Statement: audio media session will be started before video - // media session - // - if no other audio session was started before then this will - // become - // ZRTP Master session - // - only the ZRTP master sessions start in "auto-sensing" mode - // to immediately catch ZRTP communication from other client - // - after the master session has completed its key negotiation - // it will start other media sessions (see SCCallback) - if (masterSession) - { - zrtpAutoStart = true; - securityEventManager.setDHSession(true); - - // we know that audio is considered as master for zrtp - securityEventManager.setSessionType( - mediaType.equals(MediaType.AUDIO) ? - SecurityEventManager.AUDIO_SESSION - : SecurityEventManager.VIDEO_SESSION - ); - } - else - { - // check whether video was not already started - // it may happen when using multistreams, audio has inited - // and started video - // initially engine has value enableZrtp = false - zrtpAutoStart = zrtpEngine.isEnableZrtp(); - securityEventManager.setSessionType( - mediaType.equals(MediaType.AUDIO) ? - SecurityEventManager.AUDIO_SESSION - : SecurityEventManager.VIDEO_SESSION); - } - engine.setConnector(zrtpConnector); - - securityEventManager.setSrtpListener(zrtpListener); - - // tells the engine whether to autostart(enable) - // zrtp communication, if false it just passes packets without - // transformation - engine.setEnableZrtp(zrtpAutoStart); - - engine.sendInfo( - ZrtpCodes.MessageSeverity.Info, - EnumSet.of( - ZRTPCustomInfoCodes.ZRTPEnabledByDefault)); - } - - /** - * Start multi-stream ZRTP sessions. - * - * After the ZRTP Master (DH) session reached secure state the SCCallback - * calls this method to start the multi-stream ZRTP sessions. - * - * enable auto-start mode (auto-sensing) to the engine. - * @param master master SRTP data - */ - public void setMultistream(SrtpControl master) - { - if(master == null || master == this) - return; - - if(!(master instanceof ZrtpControlImpl)) - throw new IllegalArgumentException("master is no ZRTP control"); - - ZRTPTransformEngine engine = getTransformEngine(); - - engine.setMultiStrParams(((ZrtpControlImpl) master) - .getTransformEngine().getMultiStrParams()); - engine.setEnableZrtp(true); - } - - /** - * Return the zrtp hello hash String. - * - * @return String the zrtp hello hash. - */ - public String getHelloHash() - { - return getTransformEngine().getHelloHash(); - } - - /** - * Get the ZRTP Hello Hash data - separate strings. - * - * @return String array containing the version string at offset 0, the Hello - * hash value as hex-digits at offset 1. Hello hash is available - * immediately after class instantiation. Returns null - * if ZRTP is not available. - */ - public String[] getHelloHashSep() - { - return getTransformEngine().getHelloHashSep(); - } - - /** - * Sets the RTPConnector which is to use or uses this ZRTP engine. - * - * @param connector the RTPConnector which is to use or uses this - * ZRTP engine - */ - public void setConnector(AbstractRTPConnector connector) - { - zrtpConnector = connector; - } - - /* - * (non-Javadoc) - * - * @see - * net.java.sip.communicator.service.neomedia.ZrtpControl#getSecurityString - * () - */ - public String getSecurityString() - { - return getTransformEngine().getUserCallback().getSecurityString(); - } - - /* - * (non-Javadoc) - * - * @see - * net.java.sip.communicator.service.neomedia.ZrtpControl#getCiperString - * () - */ - public String getCipherString() - { - return getTransformEngine().getUserCallback().getCipherString(); - } - - /* - * (non-Javadoc) - * - * @see - * net.java.sip.communicator.service.neomedia.ZrtpControl#isSecurityVerified - * () - */ - public boolean isSecurityVerified() - { - return getTransformEngine().getUserCallback().isSecurityVerified(); - } - - /* - * (non-Javadoc) - * - * @see - * net.java.sip.communicator.service.neomedia.ZrtpControl#getPeerZid - * () - */ - public byte[] getPeerZid() - { - return getTransformEngine().getPeerZid(); - } - - /* - * (non-Javadoc) - * - * @see - * net.java.sip.communicator.service.neomedia.ZrtpControl#getPeerZidString - * () - */ - public String getPeerZidString() - { - byte[] zid = getPeerZid(); - String s = new String(ZrtpUtils.bytesToHexString(zid, zid.length)); - return s; - } - - /** - * Returns false, ZRTP exchanges is keys over the media path. - * - * @return false - */ - public boolean requiresSecureSignalingTransport() - { - return false; - } - - /** - * Returns the timeout value that will we will wait - * and fire timeout secure event if call is not secured. - * The value is in milliseconds. - * @return the timeout value that will we will wait - * and fire timeout secure event if call is not secured. - */ - public long getTimeoutValue() - { - // this is the default value as mentioned in rfc6189 - // we will later grab this setting from zrtp - return 3750; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/ZrtpFortunaEntropyGatherer.java b/src/net/java/sip/communicator/impl/neomedia/ZrtpFortunaEntropyGatherer.java deleted file mode 100644 index 608963e18..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/ZrtpFortunaEntropyGatherer.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia; - -import java.io.*; - -import javax.media.*; -import javax.media.control.FormatControl; -import javax.media.format.*; -import javax.media.protocol.*; - -import gnu.java.zrtp.utils.*; - -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.util.*; - -/** - * ZrtpFortunaEntropyGatherer initializes the Fortuna PRNG with entropy - * data. - * - * ZrtpFortunaEntropyGatherer gets the media device configuration and - * checks which media systems are available. It then reads some data from media - * input (capture) devices and uses this data to seed the Fortuna PRNG. The - * ZrtpFortuna PRNG is a singleton and all other methods that require - * random data shall use this singleton. - * - * Use ZrtpFortunaEntropyGatherer during startup and initialization - * phase of Jitsi but after initialization of the media devices to get entropy - * data at the earliest point. Also make sure that entropy data is read from - * local sources only and that entropy data is never send out (via networks - * for example). - * - * @author Werner Dittmann - * @author Lyubomir Marinov - */ -public class ZrtpFortunaEntropyGatherer -{ - /** - * The Logger used by GatherEntropy - * class for logging output. - */ - private static final Logger logger - = Logger.getLogger(ZrtpFortunaEntropyGatherer.class); - - /** - * Device config to look for capture devices. - */ - private final DeviceConfiguration deviceConfiguration; - - /** - * Other methods shall/may check this to see if Fortuna was seeded with - * entropy. - */ - private static boolean entropyOk = false; - - /** - * Number of gathered entropy bytes. - */ - private int gatheredEntropy = 0; - - /** - * How many bytes to gather. This number depends on sample rate, sample - * size, number of channels and number of audio seconds to use for random - * data. - */ - private int bytesToGather = 0; - - /** - * Bytes per 20ms time slice. - */ - private int bytes20ms = 0; - - /** - * How many seconds of audio to read. - * - */ - private static final int NUM_OF_SECONDS = 2; - - /** - * Constructor. - * - * @param deviceConfiguration DeviceConfiguration needed to - * initialize GatherEntropy - */ - public ZrtpFortunaEntropyGatherer(DeviceConfiguration deviceConfiguration) - { - this.deviceConfiguration = deviceConfiguration; - } - - /** - * Get status of entropy flag. - * - * @return Status if entropy was gathered and set in Fortuna PRNG. - */ - public static boolean isEntropyOk() - { - return entropyOk; - } - - /** - * @return the number of gathered entropy bytes. - */ - protected int getGatheredEntropy() - { - return gatheredEntropy; - } - /** - * Set entropy to ZrtpFortuna singleton. - * - * The methods reads entropy data and seeds the ZrtpFortuna singleton. - * The methods seeds the first pool (0) of Fortuna to make sure that - * this entropy is always used. - * - * @return true if entropy data was available, false otherwise. - */ - public boolean setEntropy() - { - boolean retValue = false; - GatherAudio gatherer = new GatherAudio(); - retValue = gatherer.prepareAudioEntropy(); - if (retValue) - gatherer.start(); - return retValue; - } - - private class GatherAudio - extends Thread - implements BufferTransferHandler - { - /** - * The PortAudio DataSource which provides - * {@link #audioStream}. - */ - private DataSource dataSource = null; - - /** - * The PortAudioStream from which audio data is captured. - */ - private SourceStream audioStream = null; - - /** - * The next three elements control the push buffer that Javasound - * uses. - */ - private final Buffer firstBuf = new Buffer(); - private boolean bufferAvailable = false; - private final Object bufferSync = new Object(); - - /** - * Prepares to read entropy data from portaudio capture device. - * - * The method gets an PortAudio instance with a set of capture - * parameters. - * - * @return True if the PortAudio input stream is available. - */ - private boolean prepareAudioEntropy() - { - CaptureDeviceInfo audioCaptureDevice = - deviceConfiguration.getAudioCaptureDevice(); - if (audioCaptureDevice == null) - return false; - - MediaLocator audioCaptureDeviceLocator - = audioCaptureDevice.getLocator(); - - if (audioCaptureDeviceLocator == null) - return false; - - try - { - dataSource = Manager.createDataSource(audioCaptureDeviceLocator); - } - catch (NoDataSourceException e) - { - logger.warn("No data source during entropy preparation", e); - return false; - } - catch (IOException e) - { - logger.warn("Got an IO Exception during entropy preparation", e); - return false; - } - FormatControl fc = ((CaptureDevice)dataSource).getFormatControls()[0]; - AudioFormat af = (AudioFormat)fc.getFormat(); - int framesToRead = (int)(af.getSampleRate() * NUM_OF_SECONDS); - int frameSize = (af.getSampleSizeInBits() / 8) * af.getChannels(); - bytesToGather = framesToRead * frameSize; - bytes20ms = frameSize * (int)(af.getSampleRate() /50); - - if (dataSource instanceof PullBufferDataSource) - { - audioStream = ((PullBufferDataSource) dataSource).getStreams()[0]; - } - else - { - audioStream = ((PushBufferDataSource) dataSource).getStreams()[0]; - ((PushBufferStream)audioStream).setTransferHandler(this); - } - return (audioStream != null); - } - - public void transferData(PushBufferStream stream) - { - try - { - stream.read(firstBuf); - } - catch (IOException e) - { - logger.warn("Got IOException during transfer data", e); - } - synchronized (bufferSync) - { - bufferAvailable = true; - bufferSync.notifyAll(); - } - } - /** - * Gather entropy from portaudio capture device and seed Fortuna PRNG. - * - * The method gathers a number of samples and seeds the Fortuna PRNG. - */ - @Override - public void run() - { - ZrtpFortuna fortuna = ZrtpFortuna.getInstance(); - - if ((dataSource == null) || (audioStream == null)) - return; - - try - { - dataSource.start(); - - int i = 0; - while (gatheredEntropy < bytesToGather) - { - if (audioStream instanceof PushBufferStream) - { - synchronized (bufferSync) - { - while (!bufferAvailable) - { - try - { - bufferSync.wait(); - } - catch (InterruptedException e) - { - // ignore - } - } - bufferAvailable = false; - } - } - else - ((PullBufferStream)audioStream).read(firstBuf); - byte[] entropy = (byte[])firstBuf.getData(); - gatheredEntropy += entropy.length; - - // distribute first buffers evenly over the pools, put - // others on the first pools. This method is adapted to - // SC requirements to get random data - if (i < 32) - fortuna.addSeedMaterial(entropy); - else - { - fortuna - .addSeedMaterial((i%3), entropy, 0, entropy.length); - } - i = gatheredEntropy / bytes20ms; - } - entropyOk = true; - if (logger.isInfoEnabled()) - logger.info("GatherEntropy got: " + gatheredEntropy + " bytes"); - } - catch (IOException ioex) - { - // ignore exception - } - finally - { - audioStream = null; - dataSource.disconnect(); - } - // this forces a Fortuna to use the new seed (entropy) data. - byte[] random = new byte[300]; - fortuna.nextBytes(random); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/audiolevel/AudioLevelCalculator.java b/src/net/java/sip/communicator/impl/neomedia/audiolevel/AudioLevelCalculator.java deleted file mode 100644 index f28399517..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/audiolevel/AudioLevelCalculator.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.audiolevel; - -import net.java.sip.communicator.impl.neomedia.*; - -/** - * @author Damian Minkov - * @author Lyubomir Marinov - */ -public class AudioLevelCalculator -{ - - /** - * The decrease percentage. The decrease cannot be done with more than this - * value in percents. - */ - private static final double DEC_LEVEL = 0.2; - - /** - * The increase percentage. The increase cannot be done with more than this - * value in percents. - */ - private static final double INC_LEVEL = 0.4; - - /** - * The maximum level we can get as a result after compute. - */ - private static final int MAX_AUDIO_LEVEL = Short.MAX_VALUE; - - /** - * The maximum sound pressure level which matches the maximum of the sound - * meter. - */ - private static final double MAX_SOUND_PRESSURE_LEVEL - = 127 /* HUMAN TINNITUS (RINGING IN THE EARS) BEGINS */; - - /** - * The minimum level we can get as a result after compute. - */ - private static final int MIN_AUDIO_LEVEL = Short.MIN_VALUE; - - /** - * Modifies a specific level value so that its multiple uses for - * the purposes of a sound meter will result in a smoother, animation-like - * display of its changes. - * - * @param level the level to animate - * @param minLevel the minimum value of the range to which level - * belongs - * @param maxLevel the maximum value of the range to which level - * belongs - * @param lastLevel the last level which has been previously calculated - * @return the value which represents level with animation taken - * into account - */ - private static int animateLevel( - int level, - int minLevel, int maxLevel, int lastLevel) - { - // we don't allow to quick level changes - // the speed ot fthe change is controlled by - int diff = lastLevel - level; - - if(diff >= 0) - { - int maxDiff = (int)(maxLevel*DEC_LEVEL); - - if(diff > maxDiff) - level = lastLevel - maxDiff; - } - else - { - int maxDiff = (int)(maxLevel*INC_LEVEL); - - if(diff > maxDiff) - level = lastLevel + maxDiff; - } - return level; - } - - /** - * Estimates the signal power and use the levelRatio to scale it to the - * needed levels. - * - * @param samples the samples of the signal to calculate the signal power - * level of - * @param offset the offset that data starts. - * @param length the length of the data - * @param minLevel the minimum value of the result - * @param maxLevel the maximum value of the result - * @param lastLevel the last level we calculated. - * @return the power of the signal in dB SWL. - */ - public static int calculateSignalPowerLevel( - byte[] samples, int offset, int length, - int minLevel, int maxLevel, int lastLevel) - { - if(length == 0) - return 0; - - int samplesNumber = length/2; - int absoluteMeanSoundLevel = 0; - // magic ratio which scales good visually our levels - double levelRatio = MAX_AUDIO_LEVEL/(maxLevel - minLevel)/16; - - // Do the processing - for (int i = 0; i < samplesNumber; i++) - { - int tempL = samples[offset++]; - int tempH = samples[offset++]; - int soundLevel = tempH << 8 | (tempL & 255); - - if (soundLevel > MAX_AUDIO_LEVEL) - soundLevel = MAX_AUDIO_LEVEL; - else if (soundLevel < MIN_AUDIO_LEVEL) - soundLevel = MIN_AUDIO_LEVEL; - - absoluteMeanSoundLevel += Math.abs(soundLevel); - } - - int result - = (int)(absoluteMeanSoundLevel/samplesNumber/levelRatio); - - result = ensureLevelRange(result, minLevel, maxLevel); - result = animateLevel(result, minLevel, maxLevel, lastLevel); - return result; - } - - /** - * Calculates the sound pressure level of a signal with specific - * samples and makes sure that it is expressed as a value in the - * range between minLevel and maxLevel. - * - * @param samples the samples of the signal to calculate the sound pressure - * level of - * @param offset the offset in samples in which the samples start - * @param length the length in bytes of the samples in samples - * starting at offset - * @param minLevel the minimum value of the level to be returned - * @param maxLevel the maximum value of the level to be returned - * @param lastLevel the last level which has been previously calculated - * @return the sound pressure level of the specified signal as a value in - * the range between minLevel and maxLevel - */ - public static int calculateSoundPressureLevel( - byte[] samples, int offset, int length, - int minLevel, int maxLevel, int lastLevel) - { - double rms = 0; - int sampleCount = 0; - - while (offset < length) - { - double sample = ArrayIOUtils.readShort(samples, offset); - - sample /= Short.MAX_VALUE; - rms += sample * sample; - sampleCount++; - - offset += 2; - } - rms = (sampleCount == 0) ? 0 : Math.sqrt(rms / sampleCount); - - double db; - - if (rms > 0) - db = 20 * Math.log10(rms / 0.00002); - else - db = -MAX_SOUND_PRESSURE_LEVEL; - - return ensureLevelRange((int) db, minLevel, maxLevel); - } - - /** - * Ensures that a specific level value is in a specific range - * between minLevel and maxLevel. - * - * @param level the level to check - * @param minLevel the minimum value of the specified range - * @param maxLevel the maximum value of the specified range - * @return level if its value is between minLevel and - * maxLevel, minLevel if level has a value which - * is less than minLevel, or maxLevel if level - * has a value which is greater than maxLevel - */ - private static int ensureLevelRange(int level, int minLevel, int maxLevel) - { - if (level < minLevel) - return minLevel; - else if(level > maxLevel) - return maxLevel; - else - return level; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/audiolevel/AudioLevelEffect.java b/src/net/java/sip/communicator/impl/neomedia/audiolevel/AudioLevelEffect.java deleted file mode 100644 index 0c5119b5f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/audiolevel/AudioLevelEffect.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.audiolevel; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.control.*; -import net.java.sip.communicator.service.neomedia.event.*; - -/** - * An effect that would pass data to the AudioLevelEventDispatcher - * so that it would calculate levels and dispatch changes to interested parties. - * - * @author Damian Minkov - * @author Emil Ivov - * @author Lyubomir Marinov - */ -public class AudioLevelEffect - extends ControlsAdapter - implements Effect -{ - /** - * The indicator which determines whether AudioLevelEffect - * instances are to perform the copying of the data from input - * Buffers to output Buffers themselves (e.g. using - * {@link System#arraycopy(Object, int, Object, int, int)}). - */ - private static final boolean COPY_DATA_FROM_INPUT_TO_OUTPUT = true; - - /** - * The SimpleAudioLevelListener which this instance associates with - * its {@link #eventDispatcher}. - */ - private SimpleAudioLevelListener audioLevelListener = null; - - /** - * The dispatcher of the events which handles the calculation and the event - * firing in different thread in order to now slow down the JMF codec chain. - */ - private final AudioLevelEventDispatcher eventDispatcher - = new AudioLevelEventDispatcher("AudioLevelEffect Dispatcher"); - - /** - * The indicator which determines whether {@link #open()} has been called on - * this instance without an intervening {@link #close()}. - */ - private boolean open = false; - - /** - * The supported audio formats by this effect. - */ - private Format[] supportedAudioFormats; - - /** - * The minimum and maximum values of the scale - */ - public AudioLevelEffect() - { - supportedAudioFormats - = new Format[] - { - new AudioFormat( - AudioFormat.LINEAR, - Format.NOT_SPECIFIED, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - 16, - Format.NOT_SPECIFIED, - Format.byteArray) - }; - } - - /** - * Sets (or unsets if listener is null), the listener that - * is going to be notified of audio level changes detected by this effect. - * Given the semantics of the {@link AudioLevelEventDispatcher} this effect - * would do no real work if no listener is set or if it is set to - * null. - * - * @param listener the SimplAudioLevelListener that we'd like to - * receive level changes or null if we'd like level measurements - * to stop. - */ - public void setAudioLevelListener(SimpleAudioLevelListener listener) - { - synchronized (eventDispatcher) - { - audioLevelListener = listener; - if (open) - eventDispatcher.setAudioLevelListener(audioLevelListener); - } - } - - /** - * Returns audio level listener. - * - * @return audio level listener or null if not exist - */ - public SimpleAudioLevelListener getAudioLevelListener() - { - synchronized (eventDispatcher) - { - return audioLevelListener; - } - } - - /** - * Lists all of the input formats that this codec accepts. - * - * @return An array that contains the supported input Formats. - */ - public Format[] getSupportedInputFormats() - { - return supportedAudioFormats; - } - - /** - * Lists the output formats that this codec can generate. - * - * @param input The Format of the data to be used as input to the - * plug-in. - * @return An array that contains the supported output Formats. - */ - public Format[] getSupportedOutputFormats(Format input) - { - return - new Format[] - { - new AudioFormat( - AudioFormat.LINEAR, - ((AudioFormat)input).getSampleRate(), - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - 16, - Format.NOT_SPECIFIED, - Format.byteArray) - }; - } - - /** - * Sets the format of the data to be input to this codec. - * - * @param format The Format to be set. - * @return The Format that was set. - */ - public Format setInputFormat(Format format) - { - return (format instanceof AudioFormat) ? (AudioFormat) format : null; - } - - /** - * Sets the format for the data this codec outputs. - * - * @param format The Format to be set. - * @return The Format that was set. - */ - public Format setOutputFormat(Format format) - { - return (format instanceof AudioFormat) ? (AudioFormat) format : null; - } - - /** - * Performs the media processing defined by this codec. - * - * @param inputBuffer The Buffer that contains the media data to be - * processed. - * @param outputBuffer The Buffer in which to store the processed - * media data. - * @return BUFFER_PROCESSED_OK if the processing is successful. - * @see PlugIn - */ - public int process(Buffer inputBuffer, Buffer outputBuffer) - { - /* - * In accord with what an Effect is generally supposed to do, copy the - * data from the inputBuffer into outputBuffer. - */ - if (COPY_DATA_FROM_INPUT_TO_OUTPUT) - { - // Copy the actual data from the input to the output. - Object data = outputBuffer.getData(); - int inputBufferLength = inputBuffer.getLength(); - byte[] bufferData; - - if ((data instanceof byte[]) && - (((byte[])data).length >= inputBufferLength)) - { - bufferData = (byte[])data; - } - else - { - bufferData = new byte[inputBufferLength]; - outputBuffer.setData(bufferData); - } - outputBuffer.setLength(inputBufferLength); - outputBuffer.setOffset(0); - - System.arraycopy( - inputBuffer.getData(), inputBuffer.getOffset(), - bufferData, 0, - inputBufferLength); - - // Now copy the remaining attributes. - outputBuffer.setFormat(inputBuffer.getFormat()); - outputBuffer.setHeader(inputBuffer.getHeader()); - outputBuffer.setSequenceNumber(inputBuffer.getSequenceNumber()); - outputBuffer.setTimeStamp(inputBuffer.getTimeStamp()); - outputBuffer.setFlags(inputBuffer.getFlags()); - outputBuffer.setDiscard(inputBuffer.isDiscard()); - outputBuffer.setEOM(inputBuffer.isEOM()); - outputBuffer.setDuration(inputBuffer.getDuration()); - } - else - { - outputBuffer.copy(inputBuffer); - } - - /* - * At long last, do the job which this AudioLevelEffect exists for i.e. - * deliver the data to eventDispatcher so that its audio level gets - * calculated and delivered to audioEventListener. - */ - eventDispatcher.addData(outputBuffer); - - return BUFFER_PROCESSED_OK; - } - - /** - * Gets the name of this plug-in as a human-readable string. - * - * @return A String that contains the descriptive name of the - * plug-in. - */ - public String getName() - { - return "Audio Level Effect"; - } - - /** - * Opens this effect. - * - * @throws ResourceUnavailableException If all of the required resources - * cannot be acquired. - */ - public void open() - throws ResourceUnavailableException - { - synchronized (eventDispatcher) - { - if (!open) - { - open = true; - eventDispatcher.setAudioLevelListener(audioLevelListener); - } - } - } - - /** - * Closes this effect. - */ - public void close() - { - synchronized (eventDispatcher) - { - if (open) - { - open = false; - eventDispatcher.setAudioLevelListener(null); - } - } - } - - /** - * Resets its state. - */ - public void reset() - { - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/audiolevel/AudioLevelEventDispatcher.java b/src/net/java/sip/communicator/impl/neomedia/audiolevel/AudioLevelEventDispatcher.java deleted file mode 100644 index 81b6de491..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/audiolevel/AudioLevelEventDispatcher.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.audiolevel; - -import javax.media.*; - -import net.java.sip.communicator.service.neomedia.event.*; - -/** - * The class implements an audio level measurement thread. The thread will - * measure new data every time it is added through the addData() method - * and would then deliver it to a registered listener if any. (No measurement - * would be performed until we have a levelListener). We use a - * separate thread so that we could compute and deliver audio levels in a way - * that won't delay the media processing thread. - *

- * Note that, for performance reasons this class is not 100% thread safe and you - * should not modify add or remove audio listeners in this dispatcher in the - * notification thread (i.e. in the thread where you were notified of an audio - * level change). - * - * @author Damian Minkov - * @author Emil Ivov - * @author Lyubomir Marinov - */ -public class AudioLevelEventDispatcher -{ - /** - * The interval of time in milliseconds which the Thread of - * AudioLevelEventDispatcher is to idly wait for data to be provided for - * audio level calculation before it exits. - */ - private static final long IDLE_TIMEOUT = 30 * 1000; - - /** - * The AudioLevelMap in which the audio calculations run by this - * AudioLevelEventDispatcher are to be cached in addition to - * dispatching them to {@link #listener}. - */ - private AudioLevelMap cache = null; - - /** - * The data to process. - */ - private byte[] data = null; - - /** - * The length of the data last recorded in the data array. - */ - private int dataLength = 0; - - /** - * This is the last level we fired. - */ - private int lastLevel = 0; - - /** - * The listener which is interested in audio level changes. - */ - private SimpleAudioLevelListener listener; - - /** - * The SSRC of the stream we are measuring that we should use as a key for - * entries of the levelMap level cache. - */ - private long ssrc = -1; - - /** - * The Thread which runs the actual audio level calculations and - * dispatches to {@link #listener}. - */ - private Thread thread; - - /** - * The name of the Thread which is to run the actual audio level - * calculations and to dispatch to {@link #listener}. - */ - private final String threadName; - - /** - * Initializes a new AudioLevelEventDispatcher instance which is to - * use a specific name for its Thread which is to run the actual - * audio level calculations and to dispatch to its - * SimpleAudioLevelListener - * - * @param threadName - */ - public AudioLevelEventDispatcher(String threadName) - { - this.threadName = threadName; - } - - /** - * Runs the actual audio level calculations and dispatches to the - * {@link #listener}. - */ - private void run() - { - long idleTimeoutStart = -1; - - while (true) - { - SimpleAudioLevelListener listener; - AudioLevelMap cache; - long ssrc; - - byte[] data; - int dataLength; - - synchronized(this) - { - if (!Thread.currentThread().equals(thread)) - break; - - listener = this.listener; - cache = this.cache; - ssrc = this.ssrc; - /* - * If no one is interested in the audio level, do not even keep - * the Thread waiting. - */ - if ((listener == null) && ((cache == null) || (ssrc == -1))) - break; - - data = this.data; - dataLength = this.dataLength; - /* - * If there is no data to calculate the audio level of, wait for - * such data to be provided. - */ - if ((data == null) || (dataLength < 1)) - { - // The current thread is idle. - if (idleTimeoutStart == -1) - idleTimeoutStart = System.currentTimeMillis(); - else if ((System.currentTimeMillis() - idleTimeoutStart) - >= IDLE_TIMEOUT) - break; - - boolean interrupted = false; - - try - { - wait(IDLE_TIMEOUT); - } - catch (InterruptedException ie) - { - interrupted = true; - } - if (interrupted) - Thread.currentThread().interrupt(); - - continue; - } - // The values of data and dataLength seem valid so consume them. - this.data = null; - this.dataLength = 0; - // The current thread is no longer idle. - idleTimeoutStart = -1; - } - - int newLevel - = AudioLevelCalculator.calculateSoundPressureLevel( - data, 0, dataLength, - SimpleAudioLevelListener.MIN_LEVEL, - SimpleAudioLevelListener.MAX_LEVEL, - lastLevel); - - /* - * In order to try to mitigate the issue with allocating data, try - * to return the one which we have just calculated the audio level - * of. - */ - synchronized (this) - { - if ((this.data == null) - && (this.listener == null) - && ((this.cache == null) || (this.ssrc == -1))) - this.data = data; - } - - try - { - // Cache the newLevel if requested. - if ((cache != null) && (ssrc != -1)) - cache.putLevel(ssrc, newLevel); - // Notify the listener about the newLevel if requested. - if (listener != null) - listener.audioLevelChanged(newLevel); - } - finally - { - lastLevel = newLevel; - } - } - } - - /** - * Adds data to be processed. - * - * @param buffer the data that we'd like to queue for processing. - */ - public synchronized void addData(Buffer buffer) - { - /* - * If no one is interested in the audio level, do not even add the - * Buffer data. - */ - if ((listener == null) && ((cache == null) || (ssrc == -1))) - return; - - dataLength = buffer.getLength(); - if (dataLength > 0) - { - if((data == null) || (data.length < dataLength)) - data = new byte[dataLength]; - - Object bufferData = buffer.getData(); - - if (bufferData != null) - { - System.arraycopy( - bufferData, buffer.getOffset(), - data, 0, - dataLength); - } - - if (thread == null) - startThread(); - else - notify(); - } - } - - /** - * Sets the new listener that will be gathering all events from this - * dispatcher. - * - * @param listener the listener that we will be notifying or null - * if we are to remove it. - */ - public synchronized void setAudioLevelListener( - SimpleAudioLevelListener listener) - { - if (this.listener != listener) - { - this.listener = listener; - startOrNotifyThread(); - } - } - - /** - * Sets an AudioLevelMap that this dispatcher could use to cache - * levels it's measuring in addition to simply delivering them to a - * listener. - * - * @param cache the AudioLevelMap where this dispatcher should - * cache measured results. - * @param ssrc the SSRC key where entries should be logged - */ - public synchronized void setAudioLevelCache(AudioLevelMap cache, long ssrc) - { - if ((this.cache != cache) || (this.ssrc != ssrc)) - { - this.cache = cache; - this.ssrc = ssrc; - startOrNotifyThread(); - } - } - - /** - * Starts the Thread which is to run the audio level calculations - * and to dispatch to {@link #listener} if necessary or notifies it about a - * change it the state on which it depends. - */ - private synchronized void startOrNotifyThread() - { - if ((this.listener == null) && ((cache == null) || (ssrc == -1))) - { - thread = null; - notify(); - } - else if ((data != null) && (dataLength > 0)) - { - if (thread == null) - startThread(); - else - notify(); - } - } - - /** - * Starts the Thread which is to run the audio level calculations - * and to dispatch to {@link #listener}. - */ - private synchronized void startThread() - { - thread - = new Thread() - { - @Override - public void run() - { - try - { - AudioLevelEventDispatcher.this.run(); - } - finally - { - synchronized (AudioLevelEventDispatcher.this) - { - if (Thread.currentThread().equals(thread)) - thread = null; - /* - * If the thread of this AudioLevelEventDispatcher - * is dying yet the state suggests that it should be - * running, restart it. - */ - if ((thread == null) - && ((listener != null) - || ((cache != null) - && (ssrc != -1))) - && (data != null) - && (dataLength > 0)) - startThread(); - } - } - } - }; - thread.setDaemon(true); - if (threadName != null) - thread.setName(threadName); - - thread.start(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/audiolevel/AudioLevelMap.java b/src/net/java/sip/communicator/impl/neomedia/audiolevel/AudioLevelMap.java deleted file mode 100644 index a382ea608..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/audiolevel/AudioLevelMap.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.audiolevel; - -/** - * The class implements a basic mapping utility that allows binding - * long CSRC ID-s to int audio levels. The class does not - * implement any synchronization for neither read nor write operations but it - * is still intended to handle concurrent access in a manner that can be - * considered graceful for the audio level use case. The class uses a - * bi-dimensional long[][] matrix that is recreated every time a - * new CSRC is added or an existing one is removed. Iterating through the - * matrix is only possible after obtaining a direct reference to it. It is - * possible for this reference to become invalid shortly after someone has - * obtained it (e.g. because someone added a new CSRC) but this should not - * cause problems for the CSRC audio level delivery case. - * - * @author Emil Ivov - */ -public class AudioLevelMap -{ - /** - * The matrix containing a CSRC-to-level mappings. - */ - private long[][] levels = null; - - /** - * If this map already contains csrc this method updates its level, - * otherwise we add a new entry mapping csrc to level. - * - * @param csrc the CSRC key that we'd like to add/update. - * @param level the new audio level for the specified csrc. - */ - public void putLevel(long csrc, int level) - { - //copy the levels matrix so that no one pulls it from under our feet. - long[][] levelsRef = levels; - int csrcIndex = findCSRC(levelsRef, csrc); - - if (csrcIndex == -1) - { - //we don't have the csrc in there yet so we need a new row. - levels = appendCSRCToMatrix(levelsRef, csrc, level); - } - else - { - levelsRef[csrcIndex][1] = level; - } - } - - /** - * Removes csrc and its mapped level from this map. - * - * @param csrc the CSRC ID that we'd like to remove from this map. - * - * @return true if csrc was present in the Map - * and false otherwise. - */ - public boolean removeLevel(long csrc) - { - //copy the levels matrix so that no one pulls it from under our feet. - long[][] levelsRef = levels; - int index = findCSRC(levelsRef, csrc); - - if (index == -1) - return false; - - if (levelsRef.length == 1) - { - levels = null; - return true; - } - - //copy levelsRef into newLevels ref making sure we skip the entry - //containing the CSRC ID that we are trying to remove; - long[][] newLevelsRef = new long[levelsRef.length - 1][]; - - System.arraycopy(levelsRef, 0, newLevelsRef, 0, index); - System.arraycopy( - levelsRef, index + 1, - newLevelsRef, index, newLevelsRef.length - index); - - levels = newLevelsRef; - return true; - } - - /** - * Returns the audio level of the specified csrc id or -1 - * if csrc is not currently registered in this map. - * - * @param csrc the CSRC ID whose level we'd like to obtain. - * - * @return the audio level of the specified csrc id or -1 - * if csrc is not currently registered in this map. - */ - public int getLevel(long csrc) - { - long[][] levelsRef = levels; - int index = findCSRC(levelsRef, csrc); - - return (index == -1) ? -1 : ((int) levelsRef[index][1]); - } - - /** - * Returns the index of the specified csrc level in the - * levels matrix or -1 if levels is null - * or does not contain csrc. - * - * @param levels the bi-dimensional array that we'd like to search for - * the specified csrc. - * @param csrc the CSRC identifier that we are looking for. - * - * @return the the index of the specified csrc level in the - * levels matrix or -1 if levels is null - * or does not contain csrc. - */ - private int findCSRC(long[][] levels, long csrc) - { - if (levels != null) - { - for (int i = 0; i < levels.length; i++) - { - if (levels[i][0] == csrc) - return i; - } - } - return -1; - } - - /** - * Creates a new bi-dimensional array containing all entries (if any) from - * the levels matrix and an extra entry for the specified - * csrc and level. - * - * @param levels the bi-dimensional levels array that we'd like to add a - * mapping to. - * @param csrc the CSRC identifier that we'd like to add to the - * levels bi-dimensional array. - * @param level the level corresponding to the csrc identifier. - * - * @return a new matrix containing all entries from levels and a new one - * mapping csrc to level - */ - private long[][] appendCSRCToMatrix(long[][] levels, long csrc, int level) - { - int newLength = 1 + ((levels == null) ? 0 : levels.length); - long[][] newLevels = new long[newLength][]; - - //put the new level. - newLevels[0] = new long[] { csrc, level }; - - if (newLength == 1) - return newLevels; - - System.arraycopy(levels, 0, newLevels, 1, levels.length); - - return newLevels; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/AbstractCodecExt.java b/src/net/java/sip/communicator/impl/neomedia/codec/AbstractCodecExt.java deleted file mode 100644 index f0287fd44..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/AbstractCodecExt.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec; - -import javax.media.*; - -import net.sf.fmj.media.*; - -/** - * Extends FMJ's AbstractCodec to make it even easier to implement a - * Codec. - * - * @author Lyubomir Marinov - */ -public abstract class AbstractCodecExt - extends AbstractCodec -{ - private final Class formatClass; - - /** - * The name of this PlugIn. - */ - private final String name; - - private final Format[] supportedOutputFormats; - - /** - * Initializes a new AbstractCodecExt instance with a specific - * PlugIn name, a specific Class of input and output - * Formats and a specific list of Formats supported as - * output. - * - * @param name the PlugIn name of the new instance - * @param formatClass the Class of input and output - * Formats supported by the new instance - * @param supportedOutputFormats the list of Formats supported by - * the new instance as output - */ - protected AbstractCodecExt( - String name, - Class formatClass, - Format[] supportedOutputFormats) - { - this.formatClass = formatClass; - this.name = name; - this.supportedOutputFormats = supportedOutputFormats; - - /* - * An Effect is a Codec that does not modify the Format of the data, it - * modifies the contents. - */ - if (this instanceof Effect) - inputFormats = this.supportedOutputFormats; - } - - @Override - public void close() - { - if (!opened) - return; - - doClose(); - - opened = false; - super.close(); - } - - protected void discardOutputBuffer(Buffer outputBuffer) - { - outputBuffer.setDiscard(true); - } - - protected abstract void doClose(); - - /** - * Opens this Codec and acquires the resources that it needs to - * operate. A call to {@link PlugIn#open()} on this instance will result in - * a call to doOpen only if {@link AbstractCodec#opened} is - * false. All required input and/or output formats are assumed to - * have been set on this Codec before doOpen is called. - * - * @throws ResourceUnavailableException if any of the resources that this - * Codec needs to operate cannot be acquired - */ - protected abstract void doOpen() - throws ResourceUnavailableException; - - protected abstract int doProcess(Buffer inputBuffer, Buffer outputBuffer); - - /** - * Get the output formats matching a specific input format. - * - * @param inputFormat the input format to get the matching output formats of - * @return the output formats matching the specified input format - */ - protected Format[] getMatchingOutputFormats(Format inputFormat) - { - /* - * An Effect is a Codec that does not modify the Format of the data, it - * modifies the contents. - */ - if (this instanceof Effect) - return new Format[] { inputFormat }; - - if (supportedOutputFormats != null) - return supportedOutputFormats.clone(); - return new Format[0]; - } - - @Override - public String getName() - { - return (name == null) ? super.getName() : name; - } - - /** - * Implements {@link AbstractCodec#getSupportedOutputFormats(Format)}. - * - * @param inputFormat input format - * @return array of supported output format - * @see AbstractCodec#getSupportedOutputFormats(Format) - */ - public Format[] getSupportedOutputFormats(Format inputFormat) - { - if (inputFormat == null) - return supportedOutputFormats; - - if (!formatClass.isInstance(inputFormat) - || (matches(inputFormat, inputFormats) == null)) - return new Format[0]; - - return getMatchingOutputFormats(inputFormat); - } - - /** - * Utility to perform format matching. - * - * @param in input format - * @param outs array of output formats - * @return the first output format that is supported - */ - public static Format matches(Format in, Format outs[]) - { - for (Format out : outs) - if (in.matches(out)) - return out; - return null; - } - - /** - * Opens this PlugIn software or hardware component and acquires - * the resources that it needs to operate. All required input and/or output - * formats have to be set on this PlugIn before open is - * called. Buffers should not be passed into this PlugIn without - * first calling open. - * - * @throws ResourceUnavailableException if any of the resources that this - * PlugIn needs to operate cannot be acquired - * @see AbstractPlugIn#open() - */ - @Override - public void open() - throws ResourceUnavailableException - { - if (opened) - return; - - doOpen(); - - opened = true; - super.open(); - } - - /** - * Implements AbstractCodec#process(Buffer, Buffer). - * - * @param inputBuffer - * @param outputBuffer - * @return BUFFER_PROCESSED_OK if all go OK or BUFFER_PROCESSED_FAILED if - * problems occurred - * @see AbstractCodec#process(Buffer, Buffer) - */ - public int process(Buffer inputBuffer, Buffer outputBuffer) - { - if (!checkInputBuffer(inputBuffer)) - return BUFFER_PROCESSED_FAILED; - if (isEOM(inputBuffer)) - { - propagateEOM(outputBuffer); - return BUFFER_PROCESSED_OK; - } - if (inputBuffer.isDiscard()) - { - discardOutputBuffer(outputBuffer); - return BUFFER_PROCESSED_OK; - } - - return doProcess(inputBuffer, outputBuffer); - } - - @Override - public Format setInputFormat(Format format) - { - if (!formatClass.isInstance(format) - || (matches(format, inputFormats) == null)) - return null; - - return super.setInputFormat(format); - } - - @Override - public Format setOutputFormat(Format format) - { - if (!formatClass.isInstance(format) - || (matches(format, getMatchingOutputFormats(inputFormat)) - == null)) - return null; - - return super.setOutputFormat(format); - } - - /** - * Updates the format, length and offset of a - * specific output Buffer to specific values. - * - * @param outputBuffer the output Buffer to update the properties - * of - * @param format the Format to set on outputBuffer - * @param length the length to set on outputBuffer - * @param offset the offset to set on outputBuffer - */ - protected void updateOutput( - Buffer outputBuffer, - Format format, int length, int offset) - { - outputBuffer.setFormat(format); - outputBuffer.setLength(length); - outputBuffer.setOffset(offset); - } - - protected byte[] validateByteArraySize(Buffer buffer, int newSize) - { - Object data = buffer.getData(); - byte[] newBytes; - - if (data instanceof byte[]) - { - byte[] bytes = (byte[]) data; - - if (bytes.length >= newSize) - return bytes; - - newBytes = new byte[newSize]; - System.arraycopy(bytes, 0, newBytes, 0, bytes.length); - } - else - { - newBytes = new byte[newSize]; - buffer.setLength(0); - buffer.setOffset(0); - } - - buffer.setData(newBytes); - return newBytes; - } - - protected short[] validateShortArraySize(Buffer buffer, int newSize) - { - Object data = buffer.getData(); - short[] newShorts; - - if (data instanceof short[]) - { - short[] shorts = (short[]) data; - - if (shorts.length >= newSize) - return shorts; - - newShorts = new short[newSize]; - System.arraycopy(shorts, 0, newShorts, 0, shorts.length); - } - else - { - newShorts = new short[newSize]; - buffer.setLength(0); - buffer.setOffset(0); - } - - buffer.setData(newShorts); - return newShorts; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/Constants.java b/src/net/java/sip/communicator/impl/neomedia/codec/Constants.java deleted file mode 100644 index 803c329eb..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/Constants.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec; - -import net.java.sip.communicator.util.*; - -/** - * Allows start import of net.java.sip.communicator.impl.neomedia.codec - * in order to get the constants define in - * net.java.sip.communicator.impl.neomedia.codec.Constants without star - * import of net.java.sip.communicator.impl.neomedia.codec. - * - * @author Lubomir Marinov - */ -public class Constants -{ - /** - * The ALAW/RTP constant. - */ - public static final String ALAW_RTP = "ALAW/rtp"; - - /** - * The G722 constant. - */ - public static final String G722 = "g722"; - - /** - * The G722/RTP constant. - */ - public static final String G722_RTP = "g722/rtp"; - - /** - * The iLBC constant. - */ - public static final String ILBC = "ilbc"; - - /** - * The iLBC/RTP constant. - */ - public static final String ILBC_RTP = "ilbc/rtp"; - - /** - * The SILK constant. - */ - public static final String SILK = "SILK"; - - /** - * The SILK/RTP constant. - */ - public static final String SILK_RTP = "SILK/rtp"; - - /** - * The SPEEX constant. - */ - public static final String SPEEX = "speex"; - - /** - * The SPEEX/RTP constant. - */ - public static final String SPEEX_RTP = "speex/rtp"; - - /** - * The H264 constant. - */ - public static final String H264 = "h264"; - - /** - * The H264/RTP constant. - */ - public static final String H264_RTP = "h264/rtp"; - - /** - * The H263+ constant. - */ - public static final String H263P = "H263-1998"; - - /** - * The H263+/RTP constant. - */ - public static final String H263P_RTP = "h263-1998/rtp"; - - /** - * Pseudo format representing DTMF tones sent over RTP. - */ - public static final String TELEPHONE_EVENT = "telephone-event"; - - /** - * mode : Frame size for the encoding/decoding - * 20 - 20 ms - * 30 - 30 ms - */ - public static int ILBC_MODE = 30; - - /** - * Default video width. - */ - public static final int VIDEO_WIDTH; - - /** - * Default video height. - */ - public static final int VIDEO_HEIGHT; - - static - { - - /* - * On Mac OS X, the Apple iSight camera reports two sizes 640x480 and - * 320x240 if we use the default size 352x288 we must use source format - * 640x480 in this situation we suffer from high cpu usage as every - * frame is scaled, so we use the non-standard format 320x240. - */ - if (OSUtils.IS_MAC) - { - VIDEO_WIDTH = 320; - VIDEO_HEIGHT = 240; - } - else - { - VIDEO_WIDTH = 352; - VIDEO_HEIGHT = 288; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/EncodingConfiguration.java b/src/net/java/sip/communicator/impl/neomedia/codec/EncodingConfiguration.java deleted file mode 100644 index d50b12943..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/EncodingConfiguration.java +++ /dev/null @@ -1,752 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec; - -import java.io.*; -import java.util.*; - -import javax.media.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.format.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.format.*; -import net.java.sip.communicator.util.*; - -/** - * Simple configuration of encoding priorities. - * - * @author Damian Minkov - * @author Lyubomir Marinov - */ -public class EncodingConfiguration -{ - - /** - * The Logger used by this EncodingConfiguration instance - * for logging output. - */ - private final Logger logger = Logger.getLogger(EncodingConfiguration.class); - - /** - * The SDP preference property. - */ - private static final String PROP_SDP_PREFERENCE - = "net.java.sip.communicator.impl.neomedia.codec.EncodingConfiguration"; - - /** - * The indicator which determines whether the G.729 codec is enabled. - * - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ - public static final boolean G729 = false; - - /** - * The additional custom JMF codecs. - */ - private static final String[] CUSTOM_CODECS = - { - "net.java.sip.communicator.impl.neomedia.codec.audio.alaw.DePacketizer", - "net.java.sip.communicator.impl.neomedia.codec.audio.alaw.JavaEncoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.alaw.Packetizer", - "net.java.sip.communicator.impl.neomedia.codec.audio.ulaw.JavaDecoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.ulaw.JavaEncoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.ulaw.Packetizer", - "net.java.sip.communicator.impl.neomedia.codec.audio.speex.JNIDecoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.speex.JNIEncoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.speex.SpeexResampler", - "net.java.sip.communicator.impl.neomedia.codec.audio.speex.JavaDecoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.speex.JavaEncoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.mp3.JNIEncoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.ilbc.JavaDecoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.ilbc.JavaEncoder", - G729 - ? "net.java.sip.communicator.impl.neomedia.codec.audio.g729.JavaDecoder" - : null, - G729 - ? "net.java.sip.communicator.impl.neomedia.codec.audio.g729.JavaEncoder" - : null, - "net.java.sip.communicator.impl.neomedia.codec.audio.g722.JNIDecoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.g722.JNIEncoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.gsm.Decoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.gsm.Encoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.gsm.DePacketizer", - "net.java.sip.communicator.impl.neomedia.codec.audio.gsm.Packetizer", - "net.java.sip.communicator.impl.neomedia.codec.audio.silk.JavaDecoder", - "net.java.sip.communicator.impl.neomedia.codec.audio.silk.JavaEncoder", - "net.java.sip.communicator.impl.neomedia.codec.video.h263p.DePacketizer", - "net.java.sip.communicator.impl.neomedia.codec.video.h263p.JNIDecoder", - "net.java.sip.communicator.impl.neomedia.codec.video.h263p.JNIEncoder", - "net.java.sip.communicator.impl.neomedia.codec.video.h263p.Packetizer", - "net.java.sip.communicator.impl.neomedia.codec.video.h264.DePacketizer", - "net.java.sip.communicator.impl.neomedia.codec.video.h264.JNIDecoder", - "net.java.sip.communicator.impl.neomedia.codec.video.h264.JNIEncoder", - "net.java.sip.communicator.impl.neomedia.codec.video.h264.Packetizer", - "net.java.sip.communicator.impl.neomedia.codec.video.SwScaler" - }; - - /** - * The package prefixes of the additional JMF DataSources (e.g. low - * latency PortAudio and ALSA CaptureDevices). - */ - private static final String[] CUSTOM_PACKAGES - = new String[] - { - "net.java.sip.communicator.impl.neomedia.jmfext", - "net.sf.fmj" - }; - - /** - * The Comparator which sorts the sets according to the settings in - * encodingPreferences. - */ - private final Comparator encodingComparator - = new Comparator() - { - public int compare(MediaFormat s1, MediaFormat s2) - { - return compareEncodingPreferences(s1, s2); - } - }; - - /** - * That's where we keep format preferences matching SDP formats to integers. - * We keep preferences for both audio and video formats here in case we'd - * ever need to compare them to one another. In most cases however both - * would be decorelated and other components (such as the UI) should present - * them separately. - */ - private final Map encodingPreferences - = new HashMap(); - - /** - * The cache of supported AudioMediaFormats ordered by decreasing - * priority. - */ - private Set supportedAudioEncodings; - - /** - * The cache of supported VideoMediaFormats ordered by decreasing - * priority. - */ - private Set supportedVideoEncodings; - - /** - * Initializes a new EncodingConfiguration instance. - */ - public EncodingConfiguration() - { - initializeFormatPreferences(); - registerCustomPackages(); - registerCustomCodecs(); - } - - /** - * Retrieves (from the configuration service) preferences specified for - * various formats and assigns default ones to those that haven't been - * mentioned. - */ - private void initializeFormatPreferences() - { - // first init default preferences - // video - setEncodingPreference( - "H264", - VideoMediaFormatImpl.DEFAULT_CLOCK_RATE, - 1100); - - setEncodingPreference( - "H263-1998", - VideoMediaFormatImpl.DEFAULT_CLOCK_RATE, - 0); - /* - setEncodingPreference( - "H263", - VideoMediaFormatImpl.DEFAULT_CLOCK_RATE, - 1000); - */ - setEncodingPreference( - "JPEG", - VideoMediaFormatImpl.DEFAULT_CLOCK_RATE, - 950); - setEncodingPreference( - "H261", - VideoMediaFormatImpl.DEFAULT_CLOCK_RATE, - 800); - - // audio - setEncodingPreference("G722", 8000 /* actually, 16 kHz */, 705); - setEncodingPreference("SILK", 24000, 704); - setEncodingPreference("SILK", 16000, 703); - setEncodingPreference("speex", 32000, 701); - setEncodingPreference("speex", 16000, 700); - setEncodingPreference("PCMU", 8000, 650); - setEncodingPreference("PCMA", 8000, 600); - setEncodingPreference("iLBC", 8000, 500); - setEncodingPreference("GSM", 8000, 450); - setEncodingPreference("speex", 8000, 352); - setEncodingPreference("DVI4", 8000, 300); - setEncodingPreference("DVI4", 16000, 250); - setEncodingPreference("G723", 8000, 150); - - setEncodingPreference("SILK", 12000, 0); - setEncodingPreference("SILK", 8000, 0); - setEncodingPreference("G729", 8000, 0 /* proprietary */); - - // enables by default telephone event(DTMF rfc4733), with lowest - // priority as it is not needed to order it with audio codecs - setEncodingPreference(Constants.TELEPHONE_EVENT, 8000, 1); - - // now override with those that are specified by the user. - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - for (String pName - : cfg.getPropertyNamesByPrefix(PROP_SDP_PREFERENCE, false)) - { - String prefStr = cfg.getString(pName); - String fmtName = pName.substring(pName.lastIndexOf('.') + 1); - - // legacy - if (fmtName.contains("sdp")) - { - fmtName = fmtName.replaceAll("sdp", ""); - /* - * If the current version of the property name is also - * associated with a value, ignore the value for the legacy - * one. - */ - if (cfg.getString(PROP_SDP_PREFERENCE + "." + fmtName) - != null) - continue; - } - - int preference = -1; - String encoding; - double clockRate; - - try - { - preference = Integer.parseInt(prefStr); - - int encodingClockRateSeparator = fmtName.lastIndexOf('/'); - - if (encodingClockRateSeparator > -1) - { - encoding - = fmtName.substring(0, encodingClockRateSeparator); - clockRate - = Double.parseDouble( - fmtName.substring( - encodingClockRateSeparator + 1)); - } - else - { - encoding = fmtName; - clockRate = MediaFormatFactory.CLOCK_RATE_NOT_SPECIFIED; - } - } - catch (NumberFormatException nfe) - { - logger.warn( - "Failed to parse format (" - + fmtName - + ") or preference (" - + prefStr - + ").", - nfe); - continue; - } - - setEncodingPreference(encoding, clockRate, preference); - } - } - - // now update the arrays so that they are returned by order of - // preference. - updateSupportedEncodings(); - } - - /** - * Updates the codecs in the supported sets according to the preferences in - * encodingPreferences. If the preference value is 0, the codec is - * disabled. - */ - private void updateSupportedEncodings() - { - /* - * If they need updating, their caches are invalid and need rebuilding - * next time they are requested. - */ - supportedAudioEncodings = null; - supportedVideoEncodings = null; - } - - /** - * Gets the Set of enabled available MediaFormats with the - * specified MediaType sorted in decreasing priority. - * - * @param type the MediaType of the MediaFormats to get - * @return a Set of enabled available MediaFormats with - * the specified MediaType sorted in decreasing priority - */ - private Set updateSupportedEncodings(MediaType type) - { - Set supported - = new TreeSet(encodingComparator); - - for (MediaFormat format : getAvailableEncodings(type)) - if (getPriority(format) > 0) - supported.add(format); - return supported; - } - - /** - * Sets pref as the preference associated with encoding. - * Use this method for both audio and video encodings and don't worry if - * preferences are equal since we rarely need to compare prefs of video - * encodings to those of audio encodings. - * - * @param encoding the SDP int of the encoding whose pref we're setting. - * @param clockRate clock rate - * @param pref a positive int indicating the preference for that encoding. - */ - private void setEncodingPreference( - String encoding, double clockRate, - int pref) - { - MediaFormat mediaFormat = null; - - /* - * The key in encodingPreferences associated with a MediaFormat is - * currently composed of the encoding and the clockRate only so it makes - * sense to ignore the format parameters. - */ - for (MediaFormat mf : MediaUtils.getMediaFormats(encoding)) - if (mf.getClockRate() == clockRate) - { - mediaFormat = mf; - break; - } - if (mediaFormat != null) - { - encodingPreferences.put( - getEncodingPreferenceKey(mediaFormat), - pref); - } - } - - /** - * Sets priority as the preference associated with - * encoding. Use this method for both audio and video encodings and - * don't worry if the preferences are equal since we rarely need to compare - * the preferences of video encodings to those of audio encodings. - * - * @param encoding the MediaFormat specifying the encoding to set - * the priority of - * @param priority a positive int indicating the priority of - * encoding to set - */ - public void setPriority(MediaFormat encoding, int priority) - { - String encodingEncoding = encoding.getEncoding(); - - /* - * Since we'll be remembering the priority in the ConfigurationService - * by associating it with a property name/key based on encoding and - * clock rate only, it does not make sense to store the MediaFormat in - * encodingPreferences because MediaFormat is much more specific than - * just encoding and clock rate. - */ - setEncodingPreference( - encodingEncoding, encoding.getClockRate(), - priority); - - updateSupportedEncodings(); - } - - /** - * Sets the priority of the given encoding in the configuration service. - * - * @param encoding the MediaFormat specifying the encoding to set - * the priority of - * @param priority a positive int indicating the priority of - * encoding to set - */ - public void setPriorityConfig(MediaFormat encoding, int priority) - { - String encodingEncoding = encoding.getEncoding(); - - // save the settings - NeomediaActivator.getConfigurationService() - .setProperty( - PROP_SDP_PREFERENCE - + "." - + encodingEncoding - + "/" - + encoding.getClockRateString(), - priority); - } - - /** - * Set the priority for a MediaFormat. - * @param encoding the MediaFormat - * @return the priority - */ - public int getPriority(MediaFormat encoding) - { - - /* - * Directly returning encodingPreference.get(encoding) will throw a - * NullPointerException if encodingPreferences does not contain a - * mapping for encoding. - */ - Integer priority - = encodingPreferences.get(getEncodingPreferenceKey(encoding)); - - return (priority == null) ? 0 : priority; - } - - /** - * Register in JMF the custom codecs we provide - */ - private void registerCustomCodecs() - { - // Register the custom codec which haven't already been registered. - @SuppressWarnings("unchecked") - Collection registeredPlugins - = new HashSet( - PlugInManager.getPlugInList( - null, - null, - PlugInManager.CODEC)); - boolean commit = false; - - // Remove JavaRGBToYUV. - PlugInManager.removePlugIn( - "com.sun.media.codec.video.colorspace.JavaRGBToYUV", - PlugInManager.CODEC); - PlugInManager.removePlugIn( - "com.sun.media.codec.video.colorspace.JavaRGBConverter", - PlugInManager.CODEC); - PlugInManager.removePlugIn( - "com.sun.media.codec.video.colorspace.RGBScaler", - PlugInManager.CODEC); - - // Remove JMF's H263 codec. - PlugInManager.removePlugIn( - "com.sun.media.codec.video.vh263.NativeDecoder", - PlugInManager.CODEC); - PlugInManager.removePlugIn( - "com.ibm.media.codec.video.h263.NativeEncoder", - PlugInManager.CODEC); - - // Remove JMF's GSM codec. As working only on some OS. - String gsmCodecPackage = "com.ibm.media.codec.audio.gsm."; - String[] gsmCodecClasses - = new String[] - { - "JavaDecoder", - "JavaDecoder_ms", - "JavaEncoder", - "JavaEncoder_ms", - "NativeDecoder", - "NativeDecoder_ms", - "NativeEncoder", - "NativeEncoder_ms", - "Packetizer" - }; - for(String gsmCodecClass : gsmCodecClasses) - { - PlugInManager.removePlugIn( - gsmCodecPackage + gsmCodecClass, - PlugInManager.CODEC); - } - - /* - * Remove FMJ's JavaSoundCodec because it seems to slow down the - * building of the filter graph and we do not currently seem to need it. - */ - PlugInManager.removePlugIn( - "net.sf.fmj.media.codec.JavaSoundCodec", - PlugInManager.CODEC); - - for (String className : CUSTOM_CODECS) - { - - /* - * A codec with a className of null is configured at compile time to - * not be registered. - */ - if (className == null) - continue; - - if (registeredPlugins.contains(className)) - { - if (logger.isDebugEnabled()) - logger.debug( - "Codec " + className + " is already registered"); - } - else - { - commit = true; - - boolean registered; - Throwable exception = null; - - try - { - Codec codec = (Codec) - Class.forName(className).newInstance(); - - registered = - PlugInManager.addPlugIn( - className, - codec.getSupportedInputFormats(), - codec.getSupportedOutputFormats(null), - PlugInManager.CODEC); - } - catch (Throwable ex) - { - registered = false; - exception = ex; - } - if (registered) - { - if (logger.isDebugEnabled()) - logger.debug( - "Codec " - + className - + " is successfully registered"); - } - else - { - if (logger.isDebugEnabled()) - logger.debug( - "Codec " - + className - + " is NOT succsefully registered", exception); - } - } - } - - /* - * If Jitsi provides a codec which is also provided by FMJ and/or JMF, - * use Jitsi's version. - */ - @SuppressWarnings("unchecked") - Vector codecs - = PlugInManager.getPlugInList(null, null, PlugInManager.CODEC); - - if (codecs != null) - { - boolean setPlugInList = false; - - for (int i = CUSTOM_CODECS.length - 1; i >= 0; i--) - { - String className = CUSTOM_CODECS[i]; - - if (className != null) - { - int classNameIndex = codecs.indexOf(className); - - if (classNameIndex != -1) - { - codecs.remove(classNameIndex); - codecs.add(0, className); - setPlugInList = true; - } - } - } - - if (setPlugInList) - PlugInManager.setPlugInList(codecs, PlugInManager.CODEC); - } - - if (commit && !MediaServiceImpl.isJmfRegistryDisableLoad()) - { - try - { - PlugInManager.commit(); - } - catch (IOException ex) - { - logger.error("Cannot commit to PlugInManager", ex); - } - } - } - - /** - * Register in JMF the custom packages we provide - */ - private void registerCustomPackages() - { - @SuppressWarnings("unchecked") - Vector packages = PackageManager.getProtocolPrefixList(); - boolean loggerIsDebugEnabled = logger.isDebugEnabled(); - - for (String customPackage : CUSTOM_PACKAGES) - { - /* - * Linear search in a loop but it doesn't have to scale since the - * list is always short. - */ - if (!packages.contains(customPackage)) - { - packages.add(customPackage); - if (loggerIsDebugEnabled) - if (logger.isDebugEnabled()) - logger.debug("Adding package : " + customPackage); - } - } - - PackageManager.setProtocolPrefixList(packages); - PackageManager.commitProtocolPrefixList(); - if (loggerIsDebugEnabled) - { - if (logger.isDebugEnabled()) - logger.debug( - "Registering new protocol prefix list: " + packages); - } - } - - /** - * Get the available encodings for a specific MediaType. - * - * @param type the MediaType we would like to know its available - * encodings - * @return array of MediaFormat supported for the - * MediaType - */ - public MediaFormat[] getAvailableEncodings(MediaType type) - { - return MediaUtils.getMediaFormats(type); - } - - /** - * Gets the supported MediaFormats i.e. the enabled available - * MediaFormats sorted in decreasing priority. - * - * @param type the MediaType of the supported MediaFormats - * to get - * @return an array of the supported MediaFormats i.e. the enabled - * available MediaFormats sorted in decreasing priority - */ - public MediaFormat[] getSupportedEncodings(MediaType type) - { - Set supportedEncodings; - - switch (type) - { - case AUDIO: - if (supportedAudioEncodings == null) - supportedAudioEncodings = updateSupportedEncodings(type); - supportedEncodings = supportedAudioEncodings; - break; - case VIDEO: - if (supportedVideoEncodings == null) - supportedVideoEncodings = updateSupportedEncodings(type); - supportedEncodings = supportedVideoEncodings; - break; - default: - return MediaUtils.EMPTY_MEDIA_FORMATS; - } - return - supportedEncodings.toArray( - new MediaFormat[supportedEncodings.size()]); - } - - /** - * Compares the two formats for order. Returns a negative integer, zero, or - * a positive integer as the first format has been assigned a preference - * higher, equal to, or greater than the one of the second. - * - * @param enc1 the first format to compare for preference. - * @param enc2 the second format to compare for preference - * @return a negative integer, zero, or a positive integer as the first - * format has been assigned a preference higher, equal to, or greater than - * the one of the second - */ - private int compareEncodingPreferences(MediaFormat enc1, MediaFormat enc2) - { - int res = getPriority(enc2) - getPriority(enc1); - - /* - * If the encodings are with same priority, compare them by name. If we - * return equals, TreeSet will not add equal encodings. - */ - if (res == 0) - { - res = enc1.getEncoding().compareToIgnoreCase(enc2.getEncoding()); - /* - * There are formats with one and the same encoding (name) but - * different clock rates. - */ - if (res == 0) - { - res = Double.compare(enc2.getClockRate(), enc1.getClockRate()); - /* - * And then again, there are formats (e.g. H.264) with one and - * the same encoding (name) and clock rate but different format - * parameters (e.g. packetization-mode). - */ - if (res == 0) - { - // Try to preserve the order specified by MediaUtils. - int index1; - int index2; - - if (((index1 = MediaUtils.getMediaFormatIndex(enc1)) != -1) - && ((index2 = MediaUtils.getMediaFormatIndex(enc2)) - != -1)) - { - res = (index1 - index2); - } - - if (res == 0) - { - /* - * The format with more parameters will be considered - * here to be the format with higher priority. - */ - Map fmtps1 = enc1.getFormatParameters(); - Map fmtps2 = enc2.getFormatParameters(); - int fmtpCount1 = (fmtps1 == null) ? 0 : fmtps1.size(); - int fmtpCount2 = (fmtps2 == null) ? 0 : fmtps2.size(); - - /* - * TODO Even if the number of format parameters is - * equal, the two formats may still be different. - * Consider ordering by the values of the format - * parameters as well. - */ - res = (fmtpCount2 - fmtpCount1); - } - } - } - } - return res; - } - - /** - * Gets the key in {@link #encodingPreferences} which is associated with the - * priority of a specific MediaFormat. - * - * @param encoding the MediaFormat to get the key in - * {@link #encodingPreferences} of - * @return the key in {@link #encodingPreferences} which is associated with - * the priority of the specified encoding - */ - private String getEncodingPreferenceKey(MediaFormat encoding) - { - return encoding.getEncoding() + "/" + encoding.getClockRateString(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/FFmpeg.java b/src/net/java/sip/communicator/impl/neomedia/codec/FFmpeg.java deleted file mode 100644 index 07788f59f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/FFmpeg.java +++ /dev/null @@ -1,802 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec; - -/** - * Provides the interface to the native FFmpeg library. - * - * @author Lyubomir Marinov - * @author Sebastien Vincent - */ -public class FFmpeg -{ - /** - * No pts value. - */ - public static final long AV_NOPTS_VALUE = 0x8000000000000000L; - - /** - * The AV sample format for signed 16. - */ - public static final int AV_SAMPLE_FMT_S16 = 1; - - /** - * Loop filter flag. - */ - public static final int CODEC_FLAG_LOOP_FILTER = 0x00000800; - - /** - * H263+ UMV flag. - */ - public static final int CODEC_FLAG_H263P_UMV = 0x01000000 ; - - /** - * AC pred flag. - */ - public static final int CODEC_FLAG_AC_PRED = 0x02000000; - - /** - * H263+ slice struct flag. - */ - public static final int CODEC_FLAG_H263P_SLICE_STRUCT = 0x10000000; - - /** - * Intra refresh flag2. - */ - public static final int CODEC_FLAG2_INTRA_REFRESH = 0x00200000; - - /** - * Allow to pass incomplete frame to decoder. - */ - public static final int CODEC_FLAG2_CHUNKS = 0x00008000; - - /** - * H264 codec ID. - */ - public static final int CODEC_ID_H264 = 28; - - /** - * H263 codec ID. - */ - public static final int CODEC_ID_H263 = 5; - - /** - * H263+ codec ID. - */ - public static final int CODEC_ID_H263P = 20; - - /** - * MJPEG codec ID. - */ - public static final int CODEC_ID_MJPEG = 8; - - /** - * MP3 codec ID. - */ - public static final int CODEC_ID_MP3 = 0x15000 + 1; - - /** - * Work around bugs in encoders which sometimes cannot be detected - * automatically. - */ - public static final int FF_BUG_AUTODETECT = 1; - - public static final int FF_CMP_CHROMA = 256; - - /** - * Padding size for FFmpeg input buffer. - */ - public static final int FF_INPUT_BUFFER_PADDING_SIZE = 8; - - public static final int FF_MB_DECISION_SIMPLE = 0; - - /** - * The minimum encoding buffer size defined by libavcodec. - */ - public static final int FF_MIN_BUFFER_SIZE = 16384; - - /** - * The H264 baseline profile. - */ - public static final int FF_PROFILE_H264_BASELINE = 66; - - /** - * The H264 main profile. - */ - public static final int FF_PROFILE_H264_MAIN = 77; - - /** - * ARGB format. - */ - public static final int PIX_FMT_ARGB = 27; - - /** - * BGR32 format handled in endian specific manner. - * It is stored as ABGR on big-endian and RGBA on little-endian. - */ - public static final int PIX_FMT_BGR32; - - /** - * BGR32_1 format handled in endian specific manner. - * It is stored as BGRA on big-endian and ARGB on little-endian. - */ - public static final int PIX_FMT_BGR32_1; - - /** - * "NONE" format. - */ - public static final int PIX_FMT_NONE = -1; - - /** - * NV12 format. - */ - public static final int PIX_FMT_NV12 = 25; - - /** - * RGB24 format as of FFmpeg. - */ - public static final int PIX_FMT_RGB24_1 = 2; - - /** - * BGR24 format as of FFmpeg. - */ - public static final int PIX_FMT_BGR24_1 = 3; - - /** - * RGB24 format handled in endian specific manner. - * It is stored as RGB on big-endian and BGR on little-endian. - */ - public static final int PIX_FMT_RGB24; - - /** - * RGB32 format handled in endian specific manner. - * It is stored as ARGB on big-endian and BGRA on little-endian. - */ - public static final int PIX_FMT_RGB32; - - /** - * RGB32_1 format handled in endian specific manner. - * It is stored as RGBA on big-endian and ABGR on little-endian. - */ - public static final int PIX_FMT_RGB32_1; - - /** - * UYVY422 format. - */ - public static final int PIX_FMT_UYVY422 = 17; - - /** - * UYYVYY411 format. - */ - public static final int PIX_FMT_UYYVYY411 = 18; - - /** - * YUV420P format. - */ - public static final int PIX_FMT_YUV420P = 0; - - /** - * YUYV422 format. - */ - public static final int PIX_FMT_YUYV422 = 1; - - /** - * YUVJ422P format. - */ - public static final int PIX_FMT_YUVJ422P = 13; - - /** - * BICUBIC type for libswscale conversion. - */ - public static final int SWS_BICUBIC = 4; - - //public static final int X264_RC_ABR = 2; - - /** - * Free a native pointer allocated by av_malloc. - * - * @param ptr native pointer to free - */ - public static native void av_free(long ptr); - - /** - * Allocate memory. - * - * @param size size to allocate - * @return native pointer or 0 if av_malloc failed - */ - public static native long av_malloc(int size); - - /** - * Initialize libavformat and register all the muxers, demuxers and - * protocols. - */ - public static native void av_register_all(); - - /** - * Allocate a AVContext. - * - * @return native pointer to AVContext - */ - public static native long avcodec_alloc_context(); - - /** - * Allocate a AVFrame. - * - * @return native pointer to AVFrame - */ - public static native long avcodec_alloc_frame(); - - /** - * Close an AVCodecContext - * - * @param avctx pointer to AVCodecContex - * @return 0 if success, -1 otherwise - */ - public static native int avcodec_close(long avctx); - - /** - * Decode a video frame. - * - * @param avctx codec context - * @param frame frame decoded - * @param got_picture if the decoding has produced a valid picture - * @param buf the input buffer - * @param buf_size input buffer size - * @return number of bytes written to buff if success - */ - public static native int avcodec_decode_video(long avctx, long frame, - boolean[] got_picture, byte[] buf, int buf_size); - - /** - * Decode a video frame. - * - * @param avctx codec context - * @param avframe frame decoded - * @param src input buffer - * @param src_length input buffer size - * @return number of bytes written to buff if success - */ - public static native int avcodec_decode_video(long avctx, - long avframe, long src, int src_length); - - /** - * Encodes an audio frame from samples into buf. - * - * @param avctx the codec context - * @param buf the output buffer - * @param buf_offset the output buffer offset - * @param buf_size the output buffer size - * @param samples the input buffer containing the samples. The number of - * samples read from this buffer is frame_size*channels, - * both of which are defined in avctx. For PCM audio the number of - * samples read from samples is equal to - * buf_size*input_sample_size/output_sample_size. - * @param samples_offset the offset in the input buffer containing the - * samples - * @return on error a negative value is returned, on success zero or the - * number of bytes used to encode the data read from the input buffer - */ - public static native int avcodec_encode_audio( - long avctx, - byte[] buf, int buf_offset, int buf_size, - byte[] samples, int samples_offset); - - /** - * Encode a video frame. - * - * @param avctx codec context - * @param buff the output buffer - * @param buf_size output buffer size - * @param frame frame to encode - * @return number of bytes written to buff if success - */ - public static native int avcodec_encode_video(long avctx, byte[] buff, - int buf_size, long frame); - - /** - * Find a registered decoder with a matching ID. - * - * @param id CodecID of the requested encoder - * @return an AVCodec encoder if one was found; 0, - * otherwise - */ - public static native long avcodec_find_decoder(int id); - - /** - * Finds a registered encoder with a matching codec ID. - * - * @param id CodecID of the requested encoder - * @return an AVCodec encoder if one was found; 0, - * otherwise - */ - public static native long avcodec_find_encoder(int id); - - /** - * Initializes FFmpeg's avcodec. - */ - public static native void avcodec_init(); - - /** - * Initializes the specified AVCodecContext to use the specified - * AVCodec. - * - * @param avctx the AVCodecContext which will be set up to use the - * specified AVCodec - * @param codec the AVCodec to use within the - * AVCodecContext - * @return zero on success, a negative value on error - */ - public static native int avcodec_open(long avctx, long codec); - - /** - * Add specific flags to AVCodecContext's flags member. - * - * @param avctx pointer to AVCodecContext - * @param flags flags to add - */ - public static native void avcodeccontext_add_flags(long avctx, int flags); - - /** - * Add specific flags to AVCodecContext's flags2 member. - * - * @param avctx pointer to AVCodecContext - * @param flags2 flags to add - */ - public static native void avcodeccontext_add_flags2(long avctx, int flags2); - - /** - * Add specified partitions to the avcodeccontext. - * - * @param avctx pointer to AVCodecContext - * @param partitions the partitions to add - */ - public static native void avcodeccontext_add_partitions(long avctx, - int partitions); - - /** - * Gets the samples per packet of the specified AVCodecContext. The - * property is set by libavcodec upon {@link #avcodec_open(long, long)}. - * - * @param avctx the AVCodecContext to get the samples per packet of - * @return the samples per packet of the specified AVCodecContext - */ - public static native int avcodeccontext_get_frame_size(long avctx); - - /** - * Get height of the video. - * - * @param avctx pointer to AVCodecContext - * @return video height - */ - public static native int avcodeccontext_get_height(long avctx); - - /** - * Get pixel format. - * - * @param avctx pointer to AVCodecContext - * @return pixel format - */ - public static native int avcodeccontext_get_pix_fmt(long avctx); - - /** - * Get width of the video. - * - * @param avctx pointer to AVCodecContext - * @return video width - */ - public static native int avcodeccontext_get_width(long avctx); - - /** - * Set the B-Frame strategy. - * - * @param avctx AVCodecContext pointer - * @param b_frame_strategy strategy - */ - public static native void avcodeccontext_set_b_frame_strategy(long avctx, - int b_frame_strategy); - - /** - * Sets the average bit rate of the specified AVCodecContext. The - * property is to be set by the user when encoding and is unused for - * constant quantizer encoding. It is set by libavcodec when decoding and - * its value is 0 or some bitrate if this info is available in the - * stream. - * - * @param avctx the AVCodecContext to set the average bit rate of - * @param bit_rate the average bit rate to be set to the specified - * AVCodecContext - */ - public static native void avcodeccontext_set_bit_rate(long avctx, - int bit_rate); - - /** - * Set the bit rate tolerance - * - * @param avctx the AVCodecContext to set the bit rate of - * @param bit_rate_tolerance bit rate tolerance - */ - public static native void avcodeccontext_set_bit_rate_tolerance(long avctx, - int bit_rate_tolerance); - - /** - * Sets the number of channels of the specified AVCodecContext. The - * property is audio only. - * - * @param avctx the AVCodecContext to set the number of channels of - * @param channels the number of channels to set to the specified - * AVCodecContext - */ - public static native void avcodeccontext_set_channels( - long avctx, int channels); - - public static native void avcodeccontext_set_chromaoffset(long avctx, - int chromaoffset); - - public static native void avcodeccontext_set_crf(long avctx, float crf); - - public static native void avcodeccontext_set_deblockbeta(long avctx, - int deblockbeta); - - /** - * Set the gop size (key frame interval). - * - * @param avctx the AVCodecContext to set the gop size of - * @param gop_size key frame interval - */ - public static native void avcodeccontext_set_gop_size(long avctx, - int gop_size); - - public static native void avcodeccontext_set_i_quant_factor(long avctx, - float i_quant_factor); - - /** - * Sets the minimum GOP size. - * - * @param avctx the AVCodecContext to set the minimum GOP size of - * @param keyint_min the minimum GOP size to set on avctx - */ - public static native void avcodeccontext_set_keyint_min(long avctx, - int keyint_min); - - /** - * Set the maximum B frames. - * - * @param avctx the AVCodecContext to set the maximum B frames of - * @param max_b_frames maximum B frames - */ - public static native void avcodeccontext_set_max_b_frames(long avctx, - int max_b_frames); - - public static native void avcodeccontext_set_mb_decision(long avctx, - int mb_decision); - - public static native void avcodeccontext_set_me_cmp(long avctx, int me_cmp); - - public static native void avcodeccontext_set_me_method(long avctx, - int me_method); - - public static native void avcodeccontext_set_me_range(long avctx, - int me_range); - - public static native void avcodeccontext_set_me_subpel_quality(long avctx, - int me_subpel_quality); - - /** - * Set the pixel format. - * - * @param avctx the AVCodecContext to set the pixel format of - * @param pix_fmt pixel format - */ - public static native void avcodeccontext_set_pix_fmt(long avctx, - int pix_fmt); - - public static native void avcodeccontext_set_profile(long avctx, - int profile); - - public static native void avcodeccontext_set_qcompress(long avctx, - float qcompress); - - public static native void avcodeccontext_set_quantizer(long avctx, - int qmin, int qmax, int max_qdiff); - - public static native void avcodeccontext_set_rc_buffer_size(long avctx, - int rc_buffer_size); - - public static native void avcodeccontext_set_rc_eq(long avctx, String rc_eq); - - public static native void avcodeccontext_set_rc_max_rate(long avctx, - int rc_max_rate); - - public static native void avcodeccontext_set_refs(long avctx, - int refs); - - /** - * Set the RTP payload size. - * - * @param avctx the AVCodecContext to set the RTP payload size of - * @param rtp_payload_size RTP payload size - */ - public static native void avcodeccontext_set_rtp_payload_size(long avctx, - int rtp_payload_size); - - public static native void avcodeccontext_set_sample_aspect_ratio( - long avctx, int num, int den); - - public static native void avcodeccontext_set_sample_fmt( - long avctx, int sample_fmt); - - /** - * Sets the samples per second of the specified AVCodecContext. The - * property is audio only. - * - * @param avctx the AVCodecContext to set the samples per second of - * @param sample_rate the samples per second to set to the specified - * AVCodecContext - */ - public static native void avcodeccontext_set_sample_rate( - long avctx, int sample_rate); - - /** - * Set the scene change threshold (in percent). - * - * @param avctx AVCodecContext pointer - * @param scenechange_threshold value between 0 and 100 - */ - public static native void avcodeccontext_set_scenechange_threshold( - long avctx, int scenechange_threshold); - - /** - * Set the size of the video. - * - * @param avctx pointer to AVCodecContext - * @param width video width - * @param height video height - */ - public static native void avcodeccontext_set_size(long avctx, int width, - int height); - - /** - * Set the number of thread. - * - * @param avctx the AVCodecContext to set the number of thread of - * @param thread_count number of thread to set - */ - public static native void avcodeccontext_set_thread_count(long avctx, - int thread_count); - - public static native void avcodeccontext_set_ticks_per_frame(long avctx, - int ticks_per_frame); - - public static native void avcodeccontext_set_time_base(long avctx, int num, - int den); - - public static native void avcodeccontext_set_trellis(long avctx, - int trellis); - - public static native void avcodeccontext_set_workaround_bugs(long avctx, - int workaround_bugs); - - public static native long avframe_get_pts(long frame); - - public static native void avframe_set_data(long frame, long data0, - long offset1, long offset2); - - public static native void avframe_set_key_frame(long frame, - boolean key_frame); - - public static native void avframe_set_linesize(long frame, int linesize0, - int linesize1, int linesize2); - - public static native int avpicture_fill(long picture, long ptr, - int pix_fmt, int width, int height); - - public static native long avpicture_get_data0(long picture); - - public static native int avpicture_get_size(int pix_fmt, int width, - int height); - - public static native void memcpy(int[] dst, int dst_offset, int dst_length, - long src); - - public static native void memcpy(long dst, byte[] src, int src_offset, - int src_length); - - /** - * Get BGR32 pixel format. - * - * @return BGR32 pixel format - */ - private static native int PIX_FMT_BGR32(); - - /** - * Get BGR32_1 pixel format. - * - * @return BGR32_1 pixel format - */ - private static native int PIX_FMT_BGR32_1(); - - /** - * Get RGB24 pixel format. - * - * @return RGB24 pixel format - */ - private static native int PIX_FMT_RGB24(); - - /** - * Get RGB32 pixel format. - * - * @return RGB32 pixel format - */ - private static native int PIX_FMT_RGB32(); - - /** - * Get RGB32_1 pixel format. - * - * @return RGB32_1 pixel format - */ - private static native int PIX_FMT_RGB32_1(); - - /** - * Free an SwsContext. - * - * @param context SwsContext native pointer - */ - public static native void sws_freeContext(long context); - - /** - * Get a SwsContext pointer. - * - * @param context SwsContext - * @param srcW width of source image - * @param srcH height of source image - * @param srcFormat image format - * @param dstW width of destination image - * @param dstH height destination image - * @param dstFormat destination format - * @param flags flags - * @return cached SwsContext pointer - */ - public static native long sws_getCachedContext( - long context, - int srcW, int srcH, int srcFormat, - int dstW, int dstH, int dstFormat, - int flags); - - /** - * Scale an image. - * - * @param context SwsContext native pointer - * @param src source image (native pointer) - * @param srcSliceY slice Y of source image - * @param srcSliceH slice H of source image - * @param dst destination image (java type) - * @param dstFormat destination format - * @param dstW width of destination image - * @param dstH height destination image - * @return 0 if success, -1 otherwise - */ - public static native int sws_scale( - long context, - long src, int srcSliceY, int srcSliceH, - Object dst, int dstFormat, int dstW, int dstH); - - /** - * Scale image an image. - * - * @param context SwsContext native pointer - * @param src source image (java type) - * @param srcFormat image format - * @param srcW width of source image - * @param srcH height of source image - * @param srcSliceY slice Y of source image - * @param srcSliceH slice H of source image - * @param dst destination image (java type) - * @param dstFormat destination format - * @param dstW width of destination image - * @param dstH height destination image - * @return 0 if success, -1 otherwise - */ - public static native int sws_scale( - long context, - Object src, int srcFormat, int srcW, int srcH, - int srcSliceY, int srcSliceH, - Object dst, int dstFormat, int dstW, int dstH); - - /** - * Allocates a new AVFilterGraph instance. - * - * @return a pointer to the newly-allocated AVFilterGraph instance - */ - public static native long avfilter_graph_alloc(); - - /** - * Checks the validity and configures all the links and formats in a - * specific AVFilterGraph instance. - * - * @param graph a pointer to the AVFilterGraph instance to check - * the validity of and configure - * @param log_ctx the AVClass context to be used for logging - * @return 0 on success; a negative AVERROR on error - */ - public static native int avfilter_graph_config(long graph, long log_ctx); - - /** - * Frees a specific AVFilterGraph instance and destroys its links. - * - * @param graph a pointer to the AVFilterGraph instance to free - */ - public static native void avfilter_graph_free(long graph); - - /** - * Gets a pointer to an AVFilterContext instance with a specific - * name in a specific AVFilterGraph instance. - * - * @param graph a pointer to the AVFilterGraph instance where the - * AVFilterContext instance with the specified name is to be found - * @param name the name of the AVFilterContext instance which is to - * be found in the specified graph - * @return the filter graph pointer - */ - public static native long avfilter_graph_get_filter( - long graph, - String name); - - /** - * Adds a filter graph described by a String to a specific - * AVFilterGraph instance. - * - * @param graph a pointer to the AVFilterGraph instance where to - * link the parsed graph context - * @param filters the String to be parsed - * @param inputs a pointer to a linked list to the inputs of the graph if - * any; otherwise, 0 - * @param outputs a pointer to a linked list to the outputs of the graph if - * any; otherwise, 0 - * @param log_ctx the AVClass context to be used for logging - * @return 0 on success; a negative AVERROR on error - */ - public static native int avfilter_graph_parse( - long graph, - String filters, long inputs, long outputs, long log_ctx); - - /** - * Initializes the libavfilter system and registers all built-in - * filters. - */ - public static native void avfilter_register_all(); - - /** - * Removes a reference to a buffer. If the specified - * AVFilterBufferRef is the last reference to the buffer, the - * buffer is also automatically freed. - * - * @param ref a pointer to the AVFilterBufferRef instance to remove - */ - public static native void avfilter_unref_buffer(long ref); - - public static native long get_filtered_video_frame( - long input, int width, int height, int pixFmt, - long buffer, - long ffsink, - long output); - - static - { - System.loadLibrary("jnffmpeg"); - - av_register_all(); - avfilter_register_all(); - avcodec_init(); - - PIX_FMT_BGR32 = PIX_FMT_BGR32(); - PIX_FMT_BGR32_1 = PIX_FMT_BGR32_1(); - PIX_FMT_RGB24 = PIX_FMT_RGB24(); - PIX_FMT_RGB32 = PIX_FMT_RGB32(); - PIX_FMT_RGB32_1 = PIX_FMT_RGB32_1(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/alaw/DePacketizer.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/alaw/DePacketizer.java deleted file mode 100644 index c695b7915..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/alaw/DePacketizer.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.alaw; - -import javax.media.*; -import javax.media.format.*; - -import com.sun.media.codec.audio.*; -import net.java.sip.communicator.impl.neomedia.codec.*; - -/** - * DePacketizer for ALAW codec - * @author Damian Minkov - */ -public class DePacketizer - extends AudioCodec -{ - /** - * Creates DePacketizer - */ - public DePacketizer() - { - inputFormats = new Format[]{new AudioFormat(Constants.ALAW_RTP)}; - } - - /** - * Returns the name of the DePacketizer - * @return String - */ - public String getName() - { - return "ALAW DePacketizer"; - } - - /** - * Returns the supported output formats - * @param in Format - * @return Format[] - */ - public Format[] getSupportedOutputFormats(Format in) - { - - if (in == null) - { - return new Format[]{new AudioFormat(AudioFormat.ALAW)}; - } - - if (matches(in, inputFormats) == null) - { - return new Format[1]; - } - - if (! (in instanceof AudioFormat)) - { - return new Format[]{new AudioFormat(AudioFormat.ALAW)}; - } - - AudioFormat af = (AudioFormat) in; - return new Format[] - { - new AudioFormat( - AudioFormat.ALAW, - af.getSampleRate(), - af.getSampleSizeInBits(), - af.getChannels()) - }; - } - - /** - * Initializes the codec. - */ - public void open() - {} - - /** - * Clean up - */ - public void close() - {} - - /** - * decode the buffer - * @param inputBuffer Buffer - * @param outputBuffer Buffer - * @return int - */ - public int process(Buffer inputBuffer, Buffer outputBuffer) - { - - if (!checkInputBuffer(inputBuffer)) - { - return BUFFER_PROCESSED_FAILED; - } - - if (isEOM(inputBuffer)) - { - propagateEOM(outputBuffer); - return BUFFER_PROCESSED_OK; - } - - Object outData = outputBuffer.getData(); - outputBuffer.setData(inputBuffer.getData()); - inputBuffer.setData(outData); - outputBuffer.setLength(inputBuffer.getLength()); - outputBuffer.setFormat(outputFormat); - outputBuffer.setOffset(inputBuffer.getOffset()); - return BUFFER_PROCESSED_OK; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/alaw/JavaEncoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/alaw/JavaEncoder.java deleted file mode 100644 index fceeae04d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/alaw/JavaEncoder.java +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.alaw; - -import javax.media.*; -import javax.media.format.*; - -/** - * The ALAW Encoder. Used the FMJ ALawEncoderUtil. - * - * @author Damian Minkov - */ -public class JavaEncoder - extends com.ibm.media.codec.audio.AudioCodec -{ - /** - * The last used format. - */ - private Format lastFormat = null; - - /** - * The input sample size in bits. - */ - private int inputSampleSize; - - /** - * The byte order. - */ - private boolean bigEndian = false; - - /** - * Constructs the encoder and init the supported formats. - */ - public JavaEncoder() - { - supportedInputFormats = new AudioFormat[] - { - new AudioFormat( - AudioFormat.LINEAR, - Format.NOT_SPECIFIED, - 16, - 1, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED - ), - new AudioFormat( - AudioFormat.LINEAR, - Format.NOT_SPECIFIED, - 8, - 1, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED - )}; // support 1 channel and 8/16 bit samples - - defaultOutputFormats = new AudioFormat[] - { - new AudioFormat( - AudioFormat.ALAW, - 8000, - 8, - 1, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED - )}; - PLUGIN_NAME = "pcm to alaw converter"; - } - - /** - * Returns the output formats according to the input. - * @param in the input format. - * @return the possible output formats. - */ - protected Format[] getMatchingOutputFormats(Format in) - { - AudioFormat inFormat = (AudioFormat) in; - int sampleRate = (int) (inFormat.getSampleRate()); - - supportedOutputFormats = new AudioFormat[] - { - new AudioFormat( - AudioFormat.ALAW, - sampleRate, - 8, - 1, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED - )}; - - return supportedOutputFormats; - } - - /** - * No resources to be opened. - * @throws ResourceUnavailableException if open failed (which cannot - * happend for this codec since no resources are to be opened) - */ - public void open() throws ResourceUnavailableException - {} - - /** - * No resources used to be cleared. - */ - public void close() - {} - - /** - * Calculate the output data size. - * @param inputLength input length. - * @return the output data size. - */ - private int calculateOutputSize(int inputLength) - { - if (inputSampleSize == 16) - { - inputLength /= 2; - } - - return inputLength; - } - - /** - * Init the converter to the new format - * @param inFormat AudioFormat - */ - private void initConverter(AudioFormat inFormat) - { - lastFormat = inFormat; - inputSampleSize = inFormat.getSampleSizeInBits(); - - bigEndian = inFormat.getEndian()==AudioFormat.BIG_ENDIAN; - } - - /** - * Encodes the input buffer passing it to the output one - * @param inputBuffer Buffer - * @param outputBuffer Buffer - * @return int - */ - public int process(Buffer inputBuffer, Buffer outputBuffer) - { - if (!checkInputBuffer(inputBuffer)) - { - return BUFFER_PROCESSED_FAILED; - } - - if (isEOM(inputBuffer)) - { - propagateEOM(outputBuffer); - return BUFFER_PROCESSED_OK; - } - - Format newFormat = inputBuffer.getFormat(); - - if (lastFormat != newFormat) - { - initConverter( (AudioFormat) newFormat); - } - - if (inputBuffer.getLength() == 0) - { - return OUTPUT_BUFFER_NOT_FILLED; - } - - int outLength = calculateOutputSize(inputBuffer.getLength()); - - byte[] inpData = (byte[]) inputBuffer.getData(); - byte[] outData = validateByteArraySize(outputBuffer, outLength); - - aLawEncode(bigEndian, - inpData, inputBuffer.getOffset(), inputBuffer.getLength(), - outData); - - updateOutput(outputBuffer, outputFormat, outLength, 0); - return BUFFER_PROCESSED_OK; - } - - /** - * maximum that can be held in 15 bits - */ - public static final int MAX = 0x7fff; - - /** - * An array where the index is the 16-bit PCM input, and the value is - * the a-law result. - */ - private static byte[] pcmToALawMap; - - static - { - pcmToALawMap = new byte[65536]; - for (int i = Short.MIN_VALUE; i <= Short.MAX_VALUE; i++) - pcmToALawMap[uShortToInt((short) i)] = encode(i); - } - - /** - * 65535 - */ - public static final int MAX_USHORT = (Short.MAX_VALUE) * 2 + 1; - - /** - * Unsigned short to integer. - * @param value unsigned short. - * @return integer. - */ - public static int uShortToInt(short value) - { - if (value >= 0) - return value; - else - return MAX_USHORT + 1 + value; - } - - /** - * Encode an array of pcm values into a pre-allocated target array - * - * @param bigEndian the data byte order. - * @param data An array of bytes in Little-Endian format - * @param target A pre-allocated array to receive the A-law bytes. - * This array must be at least half the size of the source. - * @param offset of the input. - * @param length of the input. - */ - public static void aLawEncode(boolean bigEndian, - byte[] data, int offset, int length, byte[] target) - { - if (bigEndian) - aLawEncodeBigEndian(data, offset, length, target); - else - aLawEncodeLittleEndian(data, offset, length, target); - } - - /** - * Encode little endian data. - * @param data the input data. - * @param offset the input offset. - * @param length the input length. - * @param target the target array to fill. - */ - public static void aLawEncodeLittleEndian(byte[] data, - int offset, int length, byte[] target) - { - int size = length / 2; - for (int i = 0; i < size; i++) - target[i] = - aLawEncode( - ((data[offset + 2 * i + 1] & 0xff) << 8) - | (data[offset + 2 * i]) & 0xff); - } - - /** - * Encode big endian data. - * @param data the input data. - * @param offset the input offset. - * @param length the input length. - * @param target the target array to fill. - */ - public static void aLawEncodeBigEndian(byte[] data, int offset, int length, byte[] target) - { - int size = length / 2; - for (int i = 0; i < size; i++) - target[i] = aLawEncode(((data[offset + 2 * i + 1]) & 0xff) | ((data[offset + 2 * i] & 0xff) << 8)); - } - - /** - * Encode a pcm value into a a-law byte - * - * @param pcm A 16-bit pcm value - * @return A a-law encoded byte - */ - public static byte aLawEncode(int pcm) - { - return pcmToALawMap[uShortToInt((short) (pcm & 0xffff))]; - } - - /** - * Encode one a-law byte from a 16-bit signed integer. Internal use only. - * - * @param pcm A 16-bit signed pcm value - * @return A a-law encoded byte - */ - private static byte encode(int pcm) - { - //Get the sign bit. Shift it for later use without further modification - int sign = (pcm & 0x8000) >> 8; - //If the number is negative, make it positive (now it's a magnitude) - if (sign != 0) - pcm = -pcm; - //The magnitude must fit in 15 bits to avoid overflow - if (pcm > MAX) pcm = MAX; - - /* Finding the "exponent" - * Bits: - * 1 2 3 4 5 6 7 8 9 A B C D E F G - * S 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 - * We want to find where the first 1 after the sign bit is. - * We take the corresponding value from - * the second row as the exponent value. - * (i.e. if first 1 at position 7 -> exponent = 2) - * The exponent is 0 if the 1 is not found in bits 2 through 8. - * This means the exponent is 0 even if the "first 1" doesn't exist. - */ - int exponent = 7; - //Move to the right and decrement exponent until - //we hit the 1 or the exponent hits 0 - for (int expMask = 0x4000; - (pcm & expMask) == 0 && exponent>0; - exponent--, expMask >>= 1) { } - - /* The last part - the "mantissa" - * We need to take the four bits after the 1 we just found. - * To get it, we shift 0x0f : - * 1 2 3 4 5 6 7 8 9 A B C D E F G - * S 0 0 0 0 0 1 . . . . . . . . . (say that exponent is 2) - * . . . . . . . . . . . . 1 1 1 1 - * We shift it 5 times for an exponent of two, meaning - * we will shift our four bits (exponent + 3) bits. - * For convenience, we will actually just shift the number, - * then AND with 0x0f. - * - * NOTE: If the exponent is 0: - * 1 2 3 4 5 6 7 8 9 A B C D E F G - * S 0 0 0 0 0 0 0 Z Y X W V U T S (we know nothing about bit 9) - * . . . . . . . . . . . . 1 1 1 1 - * We want to get ZYXW, which means a shift of 4 instead of 3 - */ - int mantissa = (pcm >> ((exponent == 0) ? 4 : (exponent + 3))) & 0x0f; - - //The a-law byte bit arrangement is SEEEMMMM - //(Sign, Exponent, and Mantissa.) - byte alaw = (byte)(sign | exponent << 4 | mantissa); - - //Last is to flip every other bit, and the sign bit (0xD5 = 1101 0101) - return (byte)(alaw^0xD5); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/alaw/Packetizer.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/alaw/Packetizer.java deleted file mode 100644 index fc56ec6b4..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/alaw/Packetizer.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.alaw; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; - -/** - * Implements an RTP packetizer for the A-law codec. - * - * @author Damian Minkov - * @author Lyubomir Marinov - */ -public class Packetizer - extends com.ibm.media.codec.audio.AudioPacketizer -{ - /** - * Initializes a new Packetizer instance. - */ - public Packetizer() - { - defaultOutputFormats - = new AudioFormat[] - { - new AudioFormat( - Constants.ALAW_RTP, - Format.NOT_SPECIFIED, - 8, - 1, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - 8, - Format.NOT_SPECIFIED, - Format.byteArray) - }; - packetSize = 160; - PLUGIN_NAME = "A-law Packetizer"; - supportedInputFormats - = new AudioFormat[] - { - new AudioFormat( - AudioFormat.ALAW, - Format.NOT_SPECIFIED, - 8, - 1, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - 8, - Format.NOT_SPECIFIED, - Format.byteArray) - }; - } - - public Object[] getControls() - { - if (controls == null) - { - controls - = new Control[] - { - new PacketSizeAdapter(this, packetSize, true) - }; - } - return controls; - } - - protected Format[] getMatchingOutputFormats(Format in) - { - AudioFormat af = (AudioFormat) in; - double sampleRate = af.getSampleRate(); - - supportedOutputFormats - = new AudioFormat[] - { - new AudioFormat( - Constants.ALAW_RTP, - sampleRate, - 8, - 1, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - 8, - sampleRate, - Format.byteArray) - }; - return supportedOutputFormats; - } - - public void open() - throws ResourceUnavailableException - { - setPacketSize(packetSize); - reset(); - } - - /** - * Sets the packet size to be used by this Packetizer. - * - * @param newPacketSize the new packet size to be used by this - * Packetizer - */ - private synchronized void setPacketSize(int newPacketSize) - { - packetSize = newPacketSize; - - sample_count = packetSize; - - if (history == null) - { - history = new byte[packetSize]; - } - else if (packetSize > history.length) - { - byte[] newHistory = new byte[packetSize]; - - System.arraycopy(history, 0, newHistory, 0, historyLength); - history = newHistory; - } - } - - private static class PacketSizeAdapter - extends com.sun.media.controls.PacketSizeAdapter - { - public PacketSizeAdapter(Codec owner, int packetSize, boolean settable) - { - super(owner, packetSize, settable); - } - - @Override - public int setPacketSize(int numBytes) - { - if (numBytes < 10) - numBytes = 10; - if (numBytes > 8000) - numBytes = 8000; - - packetSize = numBytes; - - ((Packetizer)owner).setPacketSize(packetSize); - - return packetSize; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g722/JNIDecoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g722/JNIDecoder.java deleted file mode 100644 index 3696820d9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g722/JNIDecoder.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g722; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; - -/** - * - * @author Lyubomir Marinov - */ -public class JNIDecoder - extends AbstractCodecExt -{ - static final Format[] SUPPORTED_INPUT_FORMATS - = new Format[] - { - new AudioFormat( - Constants.G722_RTP, - 8000, - Format.NOT_SPECIFIED /* sampleSizeInBits */, - 1) - }; - - static final Format[] SUPPORTED_OUTPUT_FORMATS - = new Format[] - { - new AudioFormat( - AudioFormat.LINEAR, - 16000, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED /* frameSizeInBits */, - Format.NOT_SPECIFIED /* frameRate */, - Format.byteArray) - }; - - static - { - System.loadLibrary("jng722"); - } - - private static native void g722_decoder_close(long decoder); - - private static native long g722_decoder_open(); - - private static native void g722_decoder_process( - long decoder, - byte[] input, int inputOffset, - byte[] output, int outputOffset, int outputLength); - - private long decoder; - - /** - * Initializes a new JNIDecoder instance. - */ - public JNIDecoder() - { - super("G.722 JNI Decoder", AudioFormat.class, SUPPORTED_OUTPUT_FORMATS); - - inputFormats = SUPPORTED_INPUT_FORMATS; - } - - /** - * - * @see AbstractCodecExt#doClose() - */ - protected void doClose() - { - g722_decoder_close(decoder); - } - - /** - * - * @throws ResourceUnavailableException - * @see AbstractCodecExt#doOpen() - */ - protected void doOpen() - throws ResourceUnavailableException - { - decoder = g722_decoder_open(); - if (decoder == 0) - throw new ResourceUnavailableException("g722_decoder_open"); - } - - /** - * - * @param inputBuffer - * @param outputBuffer - * @return - * @see AbstractCodecExt#doProcess(Buffer, Buffer) - */ - protected int doProcess(Buffer inputBuffer, Buffer outputBuffer) - { - byte[] input = (byte[]) inputBuffer.getData(); - - int outputOffset = outputBuffer.getOffset(); - int outputLength = inputBuffer.getLength() * 4; - byte[] output - = validateByteArraySize(outputBuffer, outputOffset + outputLength); - - g722_decoder_process( - decoder, - input, inputBuffer.getOffset(), - output, outputOffset, outputLength); - - outputBuffer.setDuration( - (outputLength * 1000000L) - / (16L /* kHz */ * 2L /* sampleSizeInBits / 8 */)); - outputBuffer.setFormat(getOutputFormat()); - outputBuffer.setLength(outputLength); - return BUFFER_PROCESSED_OK; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g722/JNIEncoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g722/JNIEncoder.java deleted file mode 100644 index a48ab050f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g722/JNIEncoder.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g722; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; - -/** - * @author Lyubomir Marinov - */ -public class JNIEncoder - extends AbstractCodecExt -{ - static - { - System.loadLibrary("jng722"); - } - - private static native void g722_encoder_close(long encoder); - - private static native long g722_encoder_open(); - - private static native void g722_encoder_process( - long encoder, - byte[] input, int inputOffset, - byte[] output, int outputOffset, int outputLength); - - private long encoder; - - /** - * Initializes a new JNIEncoder instance. - */ - public JNIEncoder() - { - super( - "G.722 JNI Encoder", - AudioFormat.class, - JNIDecoder.SUPPORTED_INPUT_FORMATS); - - inputFormats = JNIDecoder.SUPPORTED_OUTPUT_FORMATS; - } - - /** - * - * @param length - * @return - */ - private long computeDuration(long length) - { - return (length * 1000000L) / 8L; - } - - /** - * - * @see AbstractCodecExt#doClose() - */ - protected void doClose() - { - g722_encoder_close(encoder); - } - - /** - * - * @throws ResourceUnavailableException - * @see AbstractCodecExt#doOpen() - */ - protected void doOpen() - throws ResourceUnavailableException - { - encoder = g722_encoder_open(); - if (encoder == 0) - throw new ResourceUnavailableException("g722_encoder_open"); - } - - /** - * - * @param inputBuffer - * @param outputBuffer - * @return - * @see AbstractCodecExt#doProcess(Buffer, Buffer) - */ - protected int doProcess(Buffer inputBuffer, Buffer outputBuffer) - { - int inputOffset = inputBuffer.getOffset(); - int inputLength = inputBuffer.getLength(); - byte[] input = (byte[]) inputBuffer.getData(); - - int outputOffset = outputBuffer.getOffset(); - int outputLength = inputLength / 4; - byte[] output - = validateByteArraySize(outputBuffer, outputOffset + outputLength); - - g722_encoder_process( - encoder, - input, inputOffset, - output, outputOffset, outputLength); - outputBuffer.setDuration(computeDuration(outputLength)); - outputBuffer.setFormat(getOutputFormat()); - outputBuffer.setLength(outputLength); - return BUFFER_PROCESSED_OK; - } - - /** - * Get the output Format. - * - * @return output Format configured for this Codec - * @see net.sf.fmj.media.AbstractCodec#getOutputFormat() - */ - @Override - public Format getOutputFormat() - { - Format outputFormat = super.getOutputFormat(); - - if ((outputFormat != null) - && (outputFormat.getClass() == AudioFormat.class)) - { - AudioFormat outputAudioFormat = (AudioFormat) outputFormat; - - setOutputFormat( - new AudioFormat( - outputAudioFormat.getEncoding(), - outputAudioFormat.getSampleRate(), - outputAudioFormat.getSampleSizeInBits(), - outputAudioFormat.getChannels(), - outputAudioFormat.getEndian(), - outputAudioFormat.getSigned(), - outputAudioFormat.getFrameSizeInBits(), - outputAudioFormat.getFrameRate(), - outputAudioFormat.getDataType()) - { - private static final long serialVersionUID = 0L; - - @Override - public long computeDuration(long length) - { - return JNIEncoder.this.computeDuration(length); - } - }); - } - return outputFormat; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/AcelpCo.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/AcelpCo.java deleted file mode 100644 index b0df9dc19..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/AcelpCo.java +++ /dev/null @@ -1,755 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * Fixed codebook encoding routines. - * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class AcelpCo -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : ACELP_CO.C - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - - -/** - * - * @param x (i) :Target vector - * @param h (i) :Impulse response of filters - * @param t0 (i) :Pitch lag - * @param pitch_sharp (i) :Last quantized pitch gain - * @param i_subfr (i) :Indicator of 1st subframe, - * @param code (o) :Innovative codebook - * @param y (o) :Filtered innovative codebook - * @param sign (o) :Signs of 4 pulses - * @return index of pulses positions - */ -int ACELP_codebook( - float x[], - float h[], - int t0, - float pitch_sharp, - int i_subfr, - float code[], - float y[], - IntReference sign -) -{ - int DIM_RR = Ld8k.DIM_RR; - int L_SUBFR = Ld8k.L_SUBFR; - - int i, index; - float[] dn = new float[L_SUBFR]; - float[] rr = new float[DIM_RR]; - - /*----------------------------------------------------------------* - * Include fixed-gain pitch contribution into impulse resp. h[] * - * Find correlations of h[] needed for the codebook search. * - *-----------------------------------------------------------------*/ - - if(t0 < L_SUBFR) - for (i = t0; i < L_SUBFR; i++) - h[i] += pitch_sharp * h[i-t0]; - - cor_h(h, rr); - - /*----------------------------------------------------------------* - * Compute correlation of target vector with impulse response. * - *-----------------------------------------------------------------*/ - - CorFunc.cor_h_x(h, x, dn); /* backward filtered target vector dn */ - - /*----------------------------------------------------------------* - * Find innovative codebook. * - *-----------------------------------------------------------------*/ - - index = d4i40_17(dn, rr, h, code, y, sign, i_subfr); - - /*------------------------------------------------------* - * - Add the fixed-gain pitch contribution to code[]. * - *-------------------------------------------------------*/ - - if(t0 < L_SUBFR) - for (i = t0; i < L_SUBFR; i++) - code[i] += pitch_sharp * code[i-t0]; - - return index; -} - -/** - * Compute correlations of h[] needed for the codebook search. - * - * @param h (i) :Impulse response of filters - * @param rr (o) :Correlations of H[] - */ -private void cor_h( - float[] h, - float[] rr -) -{ - int MSIZE = Ld8k.MSIZE; - int NB_POS = Ld8k.NB_POS; - int STEP = Ld8k.STEP; - - int rri0i0, rri1i1, rri2i2, rri3i3, rri4i4; - int rri0i1, rri0i2, rri0i3, rri0i4; - int rri1i2, rri1i3, rri1i4; - int rri2i3, rri2i4; - - int p0, p1, p2, p3, p4; - - int ptr_hd, ptr_hf, ptr_h1, ptr_h2; - float cor; - int i, k, ldec, l_fin_sup, l_fin_inf; - - /* Init pointers */ - rri0i0 = 0; - rri1i1 = rri0i0 + NB_POS; - rri2i2 = rri1i1 + NB_POS; - rri3i3 = rri2i2 + NB_POS; - rri4i4 = rri3i3 + NB_POS; - rri0i1 = rri4i4 + NB_POS; - rri0i2 = rri0i1 + MSIZE; - rri0i3 = rri0i2 + MSIZE; - rri0i4 = rri0i3 + MSIZE; - rri1i2 = rri0i4 + MSIZE; - rri1i3 = rri1i2 + MSIZE; - rri1i4 = rri1i3 + MSIZE; - rri2i3 = rri1i4 + MSIZE; - rri2i4 = rri2i3 + MSIZE; - - /*------------------------------------------------------------* - * Compute rri0i0[], rri1i1[], rri2i2[], rri3i3 and rri4i4[] * - *------------------------------------------------------------*/ - - p0 = rri0i0 + NB_POS-1; /* Init pointers to last position of rrixix[] */ - p1 = rri1i1 + NB_POS-1; - p2 = rri2i2 + NB_POS-1; - p3 = rri3i3 + NB_POS-1; - p4 = rri4i4 + NB_POS-1; - - ptr_h1 = 0; - cor = 0.0f; - for(i=0; i= 0.0f) - { - p_sign[i] = 1.0f; - } - else { - p_sign[i] = -1.0f; - dn[i] = -dn[i]; - } - } - - /*-------------------------------------------------------------------* - * - Compute the search threshold after three pulses * - *-------------------------------------------------------------------*/ - - - average = dn[0] + dn[1] + dn[2]; - max0 = dn[0]; - max1 = dn[1]; - max2 = dn[2]; - for (i = 5; i < L_SUBFR; i+=STEP) - { - average += dn[i] + dn[i+1]+ dn[i+2]; - if (dn[i] > max0) max0 = dn[i]; - if (dn[i+1] > max1) max1 = dn[i+1]; - if (dn[i+2] > max2) max2 = dn[i+2]; - } - max0 += max1+max2; - average *= 0.125f; /* 1/8 */ - thres = average + (max0-average)*THRESHFCB; - - /*-------------------------------------------------------------------* - * Modification of rrixiy to take into account signs. * - *-------------------------------------------------------------------*/ - ptr_ri0i1 = rri0i1; - ptr_ri0i2 = rri0i2; - ptr_ri0i3 = rri0i3; - ptr_ri0i4 = rri0i4; - - for(i0=0; i0 thres) - { - ptr_ri3i3 = rri3i3; /* Init. pointers that depend on 4th loop */ - - for (i3 = 3; i3 < L_SUBFR; i3 += STEP) - { - ps3 = ps2 + dn[i3]; - alp3 = alp2 + rr[ptr_ri3i3] + 2.0f*(rr[ptr_ri1i3] + rr[ptr_ri0i3] + rr[ptr_ri2i3]); - ptr_ri3i3++; - ptr_ri1i3++; - ptr_ri0i3++; - ptr_ri2i3++; - - ps3c = ps3*ps3; - if( (ps3c*alpha) > (psc * alp3) ) - { - psc = ps3c; - alpha = alp3; - ip0 = i0; - ip1 = i1; - ip2 = i2; - ip3 = i3; - } - } /* end of for i3 = */ - - ptr_ri0i3 -= NB_POS; - ptr_ri1i3 -= NB_POS; - - ptr_ri4i4 = rri4i4; /* Init. pointers that depend on 4th loop */ - - for (i3 = 4; i3 < L_SUBFR; i3 += STEP) - { - ps3 = ps2 + dn[i3]; - alp3 = alp2 + rr[ptr_ri4i4] + 2.0f*(rr[ptr_ri1i4] + rr[ptr_ri0i4] + rr[ptr_ri2i4]); - ptr_ri4i4++; - ptr_ri1i4++; - ptr_ri0i4++; - ptr_ri2i4++; - - ps3c = ps3*ps3; - if( (ps3c*alpha) > (psc * alp3) ) - { - psc = ps3c; - alpha = alp3; - ip0 = i0; - ip1 = i1; - ip2 = i2; - ip3 = i3; - } - } /* end of for i3 = */ - ptr_ri0i4 -= NB_POS; - ptr_ri1i4 -= NB_POS; - - time --; - if(time <= 0 ) break end_search; /* Maximum time finish */ - - } /* end of if >thres */ - else { - ptr_ri2i3 += NB_POS; - ptr_ri2i4 += NB_POS; - } - - } /* end of for i2 = */ - - ptr_ri0i2 -= NB_POS; - ptr_ri1i3 += NB_POS; - ptr_ri1i4 += NB_POS; - - } /* end of for i1 = */ - - ptr_ri0i2 += NB_POS; - ptr_ri0i3 += NB_POS; - ptr_ri0i4 += NB_POS; - - } /* end of for i0 = */ - - extra = time; - - /* Find the codeword corresponding to the selected positions */ - - for(i=0; i 0.0f) - for(i=ip0, j=0; i 0.0f) - for(i=ip1, j=0; i 0.0f) - for(i=ip2, j=0; i 0.0f) - for(i=ip3, j=0; i 0.0f) i+=1; - if(p_sign[ip1] > 0.0f) i+=2; - if(p_sign[ip2] > 0.0f) i+=4; - if(p_sign[ip3] > 0.0f) i+=8; - signs.value = i; - - ip0 = ip0 / 5; - ip1 = ip1 / 5; - ip2 = ip2 / 5; - j = (ip3 % 5) - 3; - ip3 = ( (ip3 / 5) << 1 ) + j; - - i = (ip0) + (ip1<<3) + (ip2<<6) + (ip3<<9); - - return i; -} -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Bits.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Bits.java deleted file mode 100644 index 1872e9d9a..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Bits.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * Bit stream manipulation routines. - *

prm2bits_ld8k -converts encoder parameter vector into vector of serial bits

- *

bits2prm_ld8k - converts serial received bits to encoder parameter vector

- *
- * The transmitted parameters for 8000 bits/sec are:
- *
- *     LPC:     1st codebook           7+1 bit
- *              2nd codebook           5+5 bit
- *
- *     1st subframe:
- *          pitch period                 8 bit
- *          parity check on 1st period   1 bit
- *          codebook index1 (positions) 13 bit
- *          codebook index2 (signs)      4 bit
- *          pitch and codebook gains   4+3 bit
- *
- *     2nd subframe:
- *          pitch period (relative)      5 bit
- *          codebook index1 (positions) 13 bit
- *          codebook index2 (signs)      4 bit
- *          pitch and codebook gains   4+3 bit
- * 
- * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Bits -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : BITS.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - - -/** - * Converts encoder parameter vector into vector of serial bits. - * - * @param prm input : encoded parameters - * @param bits output: serial bits - */ -static void prm2bits_ld8k( - int prm[], - short bits[] -) -{ - int PRM_SIZE = Ld8k.PRM_SIZE; - short SIZE_WORD = Ld8k.SIZE_WORD; - short SYNC_WORD = Ld8k.SYNC_WORD; - int[] bitsno = TabLd8k.bitsno; - - int j = 0, i; - bits[j] = SYNC_WORD; /* At receiver this bit indicates BFI */ - j++; - bits[j] = SIZE_WORD; /* Number of bits in this frame */ - j++; - - for (i = 0; i < PRM_SIZE; i++) - { - int2bin(prm[i], bitsno[i], bits, j); - j += bitsno[i]; - } -} - -/** - * Convert integer to binary and write the bits bitstream array. - * - * @param value input : decimal value - * @param no_of_bits input : number of bits to use - * @param bitstream output: bitstream - * @param bitstream_offset input: bitstream offset - */ -private static void int2bin( - int value, - int no_of_bits, - short[] bitstream, - int bitstream_offset -) -{ - short BIT_0 = Ld8k.BIT_0; - short BIT_1 = Ld8k.BIT_1; - - int pt_bitstream; - int i, bit; - - pt_bitstream = bitstream_offset + no_of_bits; - - for (i = 0; i < no_of_bits; i++) - { - bit = value & 0x0001; /* get lsb */ - if (bit == 0) - bitstream[--pt_bitstream] = BIT_0; - else - bitstream[--pt_bitstream] = BIT_1; - value >>= 1; - } -} - -/** - * Converts serial received bits to encoder parameter vector. - * - * @param bits input : serial bits - * @param prm output: decoded parameters - */ -static void bits2prm_ld8k(short[] bits, int[] prm) -{ - bits2prm_ld8k(bits, 0, prm, 0); -} - -/** - * Converts serial received bits to encoder parameter vector. - * - * @param bits input : serial bits - * @param bits_offset input : serial bits offset - * @param prm output: decoded parameters - * @param prm_offset input: decoded parameters offset - */ -static void bits2prm_ld8k( - short bits[], - int bits_offset, - int prm[], - int prm_offset -) -{ - int PRM_SIZE = Ld8k.PRM_SIZE; - int[] bitsno = TabLd8k.bitsno; - - int i; - for (i = 0; i < PRM_SIZE; i++) - { - prm[i+prm_offset] = bin2int(bitsno[i], bits, bits_offset); - bits_offset += bitsno[i]; - } -} - - -/** - * Read specified bits from bit array and convert to integer value. - * - * @param no_of_bits input : number of bits to read - * @param bitstream input : array containing bits - * @param bitstream_offset input : array offset - * @return decimal value of bit pattern - */ -private static int bin2int( - int no_of_bits, - short[] bitstream, - int bitstream_offset -) -{ - short BIT_1 = Ld8k.BIT_1; - - int value, i; - int bit; - - value = 0; - for (i = 0; i < no_of_bits; i++) - { - value <<= 1; - bit = bitstream[bitstream_offset ++]; - if (bit == BIT_1) value += 1; - } - return(value); -} -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/CodLd8k.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/CodLd8k.java deleted file mode 100644 index 3a1726f00..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/CodLd8k.java +++ /dev/null @@ -1,498 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * Functions coder_ld8k and init_coder_ld8k - * Coder constant parameters (defined in "ld8k.h") - *
- *   L_WINDOW    : LPC analysis window size.
- *   L_NEXT      : Samples of next frame needed for autocor.
- *   L_FRAME     : Frame size.
- *   L_SUBFR     : Sub-frame size.
- *   M           : LPC order.
- *   MP1         : LPC order+1
- *   L_TOTAL     : Total size of speech buffer.
- *   PIT_MIN     : Minimum pitch lag.
- *   PIT_MAX     : Maximum pitch lag.
- *   L_INTERPOL  : Length of filter for interpolation
- * 
- * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class CodLd8k - extends Ld8k -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : COD_LD8K.C - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - - - - - /*--------------------------------------------------------* - * Static memory allocation. * - *--------------------------------------------------------*/ - - /* Speech vector */ -private final float[] old_speech = new float[L_TOTAL]; -float[] new_speech; -int new_speech_offset; -private float[] speech; -private int speech_offset; -private float[] p_window; -private int p_window_offset; - - /* Weighted speech vector */ - -private final float[] old_wsp = new float[L_FRAME+PIT_MAX]; -private float[] wsp; -private int wsp_offset; - - /* Excitation vector */ - -private final float[] old_exc = new float[L_FRAME+PIT_MAX+L_INTERPOL]; -private float[] exc; -private int exc_offset; - - /* Zero vector */ - -private final float[] ai_zero = new float[L_SUBFR+MP1]; -private float[] zero; -private int zero_offset; - - - /* Lsp (Line spectral pairs) */ -private final float[/* M */] lsp_old = - { 0.9595f, 0.8413f, 0.6549f, 0.4154f, 0.1423f, - -0.1423f, -0.4154f, -0.6549f, -0.8413f, -0.9595f}; -private final float[] lsp_old_q = new float[M]; - - /* Filter's memory */ - -private final float[] mem_syn = new float[M]; -private final float[] mem_w0 = new float[M]; -private final float[] mem_w = new float[M]; -private final float[] mem_err = new float[M+L_SUBFR]; -private float[] error; -private int error_offset; - -private float sharp; - -private final AcelpCo acelpCo = new AcelpCo(); -private final Pwf pwf = new Pwf(); -private final QuaGain quaGain = new QuaGain(); -private final QuaLsp quaLsp = new QuaLsp(); -private final Taming taming = new Taming(); - -/** - * Initialization of variables for the encoder. - * Initialize pointers to speech vector. - *
- *   |--------------------|-------------|-------------|------------|
- *     previous speech           sf1           sf2         L_NEXT
- *
- *   <----------------  Total speech vector (L_TOTAL)   ----------->
- *   |   <------------  LPC analysis window (L_WINDOW)  ----------->
- *   |   |               <-- present frame (L_FRAME) -->
- * old_speech            |              <-- new speech (L_FRAME) -->
- *     p_wind            |              |
- *                     speech           |
- *                             new_speech
- * 
- */ -void init_coder_ld8k() -{ - - new_speech = old_speech; - new_speech_offset = L_TOTAL - L_FRAME; /* New speech */ - speech = new_speech; /* Present frame */ - speech_offset = new_speech_offset - L_NEXT; - p_window = old_speech; - p_window_offset = L_TOTAL - L_WINDOW; /* For LPC window */ - - /* Initialize static pointers */ - - wsp = old_wsp; - wsp_offset = PIT_MAX; - exc = old_exc; - exc_offset = PIT_MAX + L_INTERPOL; - zero = ai_zero; - zero_offset = MP1; - error = mem_err; - error_offset = M; - - /* Static vectors to zero */ - Util.set_zero(old_speech, L_TOTAL); - Util.set_zero(old_exc, PIT_MAX+L_INTERPOL); - Util.set_zero(old_wsp, PIT_MAX); - Util.set_zero(mem_syn, M); - Util.set_zero(mem_w, M); - Util.set_zero(mem_w0, M); - Util.set_zero(mem_err, M); - Util.set_zero(zero, zero_offset, L_SUBFR); - sharp = SHARPMIN; - - /* Initialize lsp_old_q[] */ - Util.copy(lsp_old, lsp_old_q, M); - - quaLsp.lsp_encw_reset(); - taming.init_exc_err(); -} - -/** - * Encoder routine ( speech data should be in new_speech ). - * - * @param ana output: analysis parameters - */ -void coder_ld8k( - int ana[] -) -{ - /* LPC coefficients */ - float[] r = new float[MP1]; /* Autocorrelations low and hi */ - float[] A_t = new float[(MP1)*2]; /* A(z) unquantized for the 2 subframes */ - float[] Aq_t = new float[(MP1)*2]; /* A(z) quantized for the 2 subframes */ - float[] Ap1 = new float[MP1]; /* A(z) with spectral expansion */ - float[] Ap2 = new float[MP1]; /* A(z) with spectral expansion */ - float[] A, Aq; /* Pointer on A_t and Aq_t */ - int A_offset, Aq_offset; - - /* LSP coefficients */ - float[] lsp_new = new float[M], lsp_new_q = new float[M]; /* LSPs at 2th subframe */ - float[] lsf_int = new float[M]; /* Interpolated LSF 1st subframe. */ - float[] lsf_new = new float[M]; - - /* Variable added for adaptive gamma1 and gamma2 of the PWF */ - - float[] rc = new float[M]; /* Reflection coefficients */ - float[] gamma1 = new float[2]; /* Gamma1 for 1st and 2nd subframes */ - float[] gamma2 = new float[2]; /* Gamma2 for 1st and 2nd subframes */ - - /* Other vectors */ - float[] synth = new float[L_FRAME]; /* Buffer for synthesis speech */ - float[] h1 = new float[L_SUBFR]; /* Impulse response h1[] */ - float[] xn = new float[L_SUBFR]; /* Target vector for pitch search */ - float[] xn2 = new float[L_SUBFR]; /* Target vector for codebook search */ - float[] code = new float[L_SUBFR]; /* Fixed codebook excitation */ - float[] y1 = new float[L_SUBFR]; /* Filtered adaptive excitation */ - float[] y2 = new float[L_SUBFR]; /* Filtered fixed codebook excitation */ - float[] g_coeff = new float[5]; /* Correlations between xn, y1, & y2: - , , , ,*/ - - /* Scalars */ - - int i, j, i_gamma, i_subfr; - IntReference iRef = new IntReference(); - int T_op, t0; - IntReference t0_min = new IntReference(), t0_max = new IntReference(), t0_frac = new IntReference(); - int index, taming; - float gain_pit, gain_code = 0.0f; - FloatReference _gain_pit = new FloatReference(), _gain_code = new FloatReference(); - - int ana_offset = 0; - -/*------------------------------------------------------------------------* - * - Perform LPC analysis: * - * * autocorrelation + lag windowing * - * * Levinson-durbin algorithm to find a[] * - * * convert a[] to lsp[] * - * * quantize and code the LSPs * - * * find the interpolated LSPs and convert to a[] for the 2 * - * subframes (both quantized and unquantized) * - *------------------------------------------------------------------------*/ - - /* LP analysis */ - - Lpc.autocorr(p_window, p_window_offset, M, r); /* Autocorrelations */ - Lpc.lag_window(M, r); /* Lag windowing */ - Lpc.levinson(r, A_t, MP1, rc); /* Levinson Durbin */ - Lpc.az_lsp(A_t, MP1, lsp_new, lsp_old); /* From A(z) to lsp */ - - /* LSP quantization */ - - quaLsp.qua_lsp(lsp_new, lsp_new_q, ana); - ana_offset += 2; /* Advance analysis parameters pointer */ - - /*--------------------------------------------------------------------* - * Find interpolated LPC parameters in all subframes (both quantized * - * and unquantized). * - * The interpolated parameters are in array A_t[] of size (M+1)*4 * - * and the quantized interpolated parameters are in array Aq_t[] * - *--------------------------------------------------------------------*/ - - Lpcfunc.int_lpc(lsp_old, lsp_new, lsf_int, lsf_new, A_t); - Lpcfunc.int_qlpc(lsp_old_q, lsp_new_q, Aq_t); - - /* update the LSPs for the next frame */ - - for(i=0; i PIT_MAX) - { - t0_max.value = PIT_MAX; - t0_min.value = t0_max.value - 6; - } - - /*------------------------------------------------------------------------* - * Loop for every subframe in the analysis frame * - *------------------------------------------------------------------------* - * To find the pitch and innovation parameters. The subframe size is * - * L_SUBFR and the loop is repeated L_FRAME/L_SUBFR times. * - * - find the weighted LPC coefficients * - * - find the LPC residual signal * - * - compute the target signal for pitch search * - * - compute impulse response of weighted synthesis filter (h1[]) * - * - find the closed-loop pitch parameters * - * - encode the pitch delay * - * - update the impulse response h1[] by including fixed-gain pitch * - * - find target vector for codebook search * - * - codebook search * - * - encode codebook address * - * - VQ of pitch and codebook gains * - * - find synthesis speech * - * - update states of weighting filter * - *------------------------------------------------------------------------*/ - - A = A_t; /* pointer to interpolated LPC parameters */ - A_offset = 0; - Aq = Aq_t; /* pointer to interpolated quantized LPC parameters */ - Aq_offset = 0; - - i_gamma = 0; - - for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR) - { - /*---------------------------------------------------------------* - * Find the weighted LPC coefficients for the weighting filter. * - *---------------------------------------------------------------*/ - - Lpcfunc.weight_az(A, A_offset, gamma1[i_gamma], M, Ap1); - Lpcfunc.weight_az(A, A_offset, gamma2[i_gamma], M, Ap2); - i_gamma++; - - /*---------------------------------------------------------------* - * Compute impulse response, h1[], of weighted synthesis filter * - *---------------------------------------------------------------*/ - - for (i = 0; i <= M; i++) ai_zero[i] = Ap1[i]; - Filter.syn_filt(Aq, Aq_offset, ai_zero, 0, h1, 0, L_SUBFR, zero, zero_offset, 0); - Filter.syn_filt(Ap2, 0, h1, 0, h1, 0, L_SUBFR, zero, zero_offset, 0); - - /*------------------------------------------------------------------------* - * * - * Find the target vector for pitch search: * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * * - * |------| res[n] * - * speech[n]---| A(z) |-------- * - * |------| | |--------| error[n] |------| * - * zero -- (-)--| 1/A(z) |-----------| W(z) |-- target * - * exc |--------| |------| * - * * - * Instead of subtracting the zero-input response of filters from * - * the weighted input speech, the above configuration is used to * - * compute the target vector. This configuration gives better performance * - * with fixed-point implementation. The memory of 1/A(z) is updated by * - * filtering (res[n]-exc[n]) through 1/A(z), or simply by subtracting * - * the synthesis speech from the input speech: * - * error[n] = speech[n] - syn[n]. * - * The memory of W(z) is updated by filtering error[n] through W(z), * - * or more simply by subtracting the filtered adaptive and fixed * - * codebook excitations from the target: * - * target[n] - gain_pit*y1[n] - gain_code*y2[n] * - * as these signals are already available. * - * * - *------------------------------------------------------------------------*/ - - - Filter.residu(Aq, Aq_offset, speech, speech_offset + i_subfr, exc, exc_offset + i_subfr, L_SUBFR); /* LPC residual */ - - Filter.syn_filt(Aq, Aq_offset, exc, exc_offset + i_subfr, error, error_offset, L_SUBFR, mem_err, 0, 0); - - Filter.residu(Ap1, 0, error, error_offset, xn, 0, L_SUBFR); - - Filter.syn_filt(Ap2, 0, xn, 0, xn, 0, L_SUBFR, mem_w0, 0, 0); /* target signal xn[]*/ - - /*----------------------------------------------------------------------* - * Closed-loop fractional pitch search * - *----------------------------------------------------------------------*/ - - t0 = Pitch.pitch_fr3(exc, exc_offset + i_subfr, xn, h1, L_SUBFR, t0_min.value, t0_max.value, - i_subfr, t0_frac); - - - index = Pitch.enc_lag3(t0, t0_frac.value, t0_min, t0_max,PIT_MIN,PIT_MAX,i_subfr); - - ana[ana_offset] = index; - ana_offset++; - if (i_subfr == 0) - { - ana[ana_offset] = PParity.parity_pitch(index); - ana_offset++; - } - - - /*-----------------------------------------------------------------* - * - find unity gain pitch excitation (adaptive codebook entry) * - * with fractional interpolation. * - * - find filtered pitch exc. y1[]=exc[] convolve with h1[]) * - * - compute pitch gain and limit between 0 and 1.2 * - * - update target vector for codebook search * - * - find LTP residual. * - *-----------------------------------------------------------------*/ - - PredLt3.pred_lt_3(exc, exc_offset + i_subfr, t0, t0_frac.value, L_SUBFR); - - Filter.convolve(exc, exc_offset + i_subfr, h1, y1, L_SUBFR); - - gain_pit = Pitch.g_pitch(xn, y1, g_coeff, L_SUBFR); - - /* clip pitch gain if taming is necessary */ - taming = this.taming.test_err(t0, t0_frac.value); - - if( taming == 1){ - if ( gain_pit> GPCLIP) { - gain_pit = GPCLIP; - } - } - - for (i = 0; i < L_SUBFR; i++) - xn2[i] = xn[i] - y1[i]*gain_pit; - - /*-----------------------------------------------------* - * - Innovative codebook search. * - *-----------------------------------------------------*/ - - iRef.value = i; - index = acelpCo.ACELP_codebook(xn2, h1, t0, sharp, i_subfr, code, y2, iRef); - i = iRef.value; - ana[ana_offset] = index; /* Positions index */ - ana_offset++; - ana[ana_offset] = i; /* Signs index */ - ana_offset++; - - - /*-----------------------------------------------------* - * - Quantization of gains. * - *-----------------------------------------------------*/ - CorFunc.corr_xy2(xn, y1, y2, g_coeff); - - _gain_pit.value = gain_pit; - _gain_code.value = gain_code; - ana[ana_offset] = quaGain.qua_gain(code, g_coeff, L_SUBFR, _gain_pit, _gain_code, taming ); - gain_pit = _gain_pit.value; - gain_code = _gain_code.value; - ana_offset++; - - /*------------------------------------------------------------* - * - Update pitch sharpening "sharp" with quantized gain_pit * - *------------------------------------------------------------*/ - - sharp = gain_pit; - if (sharp > SHARPMAX) sharp = SHARPMAX; - if (sharp < SHARPMIN) sharp = SHARPMIN; - /*------------------------------------------------------* - * - Find the total excitation * - * - find synthesis speech corresponding to exc[] * - * - update filters' memories for finding the target * - * vector in the next subframe * - * (update error[-m..-1] and mem_w0[]) * - * update error function for taming process * - *------------------------------------------------------*/ - - for (i = 0; i < L_SUBFR; i++) - exc[exc_offset + i+i_subfr] = gain_pit*exc[exc_offset + i+i_subfr] + gain_code*code[i]; - - this.taming.update_exc_err(gain_pit, t0); - - Filter.syn_filt(Aq, Aq_offset, exc, exc_offset + i_subfr, synth, i_subfr, L_SUBFR, mem_syn, 0, 1); - - for (i = L_SUBFR-M, j = 0; i < L_SUBFR; i++, j++) - { - mem_err[j] = speech[speech_offset + i_subfr+i] - synth[i_subfr+i]; - mem_w0[j] = xn[i] - gain_pit*y1[i] - gain_code*y2[i]; - } - A_offset += MP1; /* interpolated LPC parameters for next subframe */ - Aq_offset += MP1; - - } - - /*--------------------------------------------------* - * Update signal for next frame. * - * -> shift to the left by L_FRAME: * - * speech[], wsp[] and exc[] * - *--------------------------------------------------*/ - - Util.copy(old_speech, L_FRAME, old_speech, L_TOTAL-L_FRAME); - Util.copy(old_wsp, L_FRAME, old_wsp, PIT_MAX); - Util.copy(old_exc, L_FRAME, old_exc, PIT_MAX+L_INTERPOL); -} - -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Coder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Coder.java deleted file mode 100644 index 7f4bc3c59..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Coder.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -import java.io.*; - -/** - * Main program of the ITU-T G.729 8 kbit/s encoder. - * Usage : coder speech_file bitstream_file - * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Coder - extends Ld8k -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : CODER.C - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - - /** - * Init the PreProc - */ - private final PreProc preProc = new PreProc(); - - /** - * Init the Ld8k Coder - */ - private final CodLd8k codLd8k = new CodLd8k(); - - /** - * Transmitted parameters - */ - private final int[] prm = new int[PRM_SIZE]; - - /** - * Initialization of the coder. - */ - Coder() - { - preProc.init_pre_process(); - codLd8k.init_coder_ld8k(); /* Initialize the coder */ - } -/** - * Usage : coder speech_file bitstream_file - * - * Format for speech_file: - * Speech is read form a binary file of 16 bits data. - * - * Format for bitstream_file: - * One word (2-bytes) to indicate erasure. - * One word (2 bytes) to indicate bit rate - * 80 words (2-bytes) containing 80 bits. - * - * @param args speech_file bitstream_file - * @throws java.io.IOException - */ -public static void main(String[] args) - throws IOException -{ - InputStream f_speech; /* Speech data */ - OutputStream f_serial; /* Serial bit stream */ - - short[] sp16 = new short[L_FRAME]; /* Buffer to read 16 bits speech */ - short[] serial = new short[SERIAL_SIZE]; /* Output bit stream buffer */ - - int frame; - - System.out.printf("\n"); - System.out.printf("************ ITU G.729 8 Kbit/S SPEECH CODER **************\n"); - System.out.printf("\n"); - System.out.printf("----------------- Floating point C simulation ----------------\n"); - System.out.printf("\n"); - System.out.printf("------------ Version 1.01 (Release 2, November 2006) --------\n"); - System.out.printf("\n"); - - - /*-----------------------------------------------------------------------* - * Open speech file and result file (output serial bit stream) * - *-----------------------------------------------------------------------*/ - - if ( args.length != 2 ) - { - System.out.printf("Usage : coder speech_file bitstream_file \n"); - System.out.printf("\n"); - System.out.printf("Format for speech_file:\n"); - System.out.printf(" Speech is read form a binary file of 16 bits data.\n"); - System.out.printf("\n"); - System.out.printf("Format for bitstream_file:\n"); - System.out.printf(" One word (2-bytes) to indicate erasure.\n"); - System.out.printf(" One word (2 bytes) to indicate bit rate\n"); - System.out.printf(" 80 words (2-bytes) containing 80 bits.\n"); - System.out.printf("\n"); - System.exit( 1 ); - } - - try - { - f_speech = new FileInputStream(args[0]); - } - catch (IOException ex) - { - System.out.printf("Codder - Error opening file %s !!\n", args[0]); - System.exit(0); - throw ex; // Silence the compiler. - } - System.out.printf(" Input speech file : %s\n", args[0]); - - try - { - f_serial = new FileOutputStream(args[1]); - } - catch (IOException ex) - { - System.out.printf("Coder - Error opening file %s !!\n", args[1]); - System.exit(0); - throw ex; // Silence the compiler - } - System.out.printf(" Output bitstream file : %s\n", args[1]); - - /*-------------------------------------------------* - * Initialization of the coder. * - *-------------------------------------------------*/ - - Coder coder = new Coder(); - - /*-------------------------------------------------------------------------* - * Loop for every analysis/transmission frame. * - * -New L_FRAME data are read. (L_FRAME = number of speech data per frame) * - * -Conversion of the speech data from 16 bit integer to real * - * -Call cod_ld8k to encode the speech. * - * -The compressed serial output stream is written to a file. * - * -The synthesis speech is written to a file * - *-------------------------------------------------------------------------* - */ - - frame=0; - while(Util.fread(sp16, L_FRAME, f_speech) == L_FRAME){ - frame++; - System.out.printf(" Frame: %d\r", frame); - - coder.process(sp16, serial); - - Util.fwrite(serial, SERIAL_SIZE, f_serial); - } - - f_serial.close(); - f_speech.close(); -} /* end of main() */ - - /** - * Process L_FRAME short of speech. - * - * @param sp16 input : speach short array - * @param serial output : serial array encoded in bits_ld8k - */ - void process(short[] sp16, short[] serial) - { - float[] new_speech = codLd8k.new_speech; /* Pointer to new speech data */ - int new_speech_offset = codLd8k.new_speech_offset; - - for (int i = 0; i < L_FRAME; i++) - new_speech[new_speech_offset + i] = sp16[i]; - - preProc.pre_process(new_speech, new_speech_offset, L_FRAME); - - codLd8k.coder_ld8k(prm); - - Bits.prm2bits_ld8k(prm, serial); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/CorFunc.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/CorFunc.java deleted file mode 100644 index 6cd5b017b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/CorFunc.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * Functions corr_xy2() and cor_h_x(). - * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class CorFunc -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : COR_FUNC.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -/** - * Compute the correlation products needed for gain computation. - * - * @param xn input : target vector x[0:l_subfr] - * @param y1 input : filtered adaptive codebook vector - * @param y2 input : filtered 1st codebook innovation - * @param g_coeff output: , -2 , and 2 - */ -static void corr_xy2( - float xn[], - float y1[], - float y2[], - float g_coeff[] -) -{ - int L_SUBFR = Ld8k.L_SUBFR; - - float y2y2, xny2, y1y2; - int i; - - y2y2= 0.01f; - for (i = 0; i < L_SUBFR; i++) y2y2 += y2[i]*y2[i]; - g_coeff[2] = y2y2 ; - - xny2 = 0.01f; - for (i = 0; i < L_SUBFR; i++) xny2+= xn[i]*y2[i]; - g_coeff[3] = -2.0f * xny2; - - y1y2 = 0.01f; - for (i = 0; i < L_SUBFR; i++) y1y2 += y1[i]*y2[i]; - g_coeff[4] = 2.0f * y1y2 ; -} - -/** - * Compute correlations of input response h[] with the target vector X[]. - * - * @param h (i) :Impulse response of filters - * @param x (i) :Target vector - * @param d (o) :Correlations between h[] and x[] - */ -static void cor_h_x( - float h[], - float x[], - float d[] -) -{ - int L_SUBFR = Ld8k.L_SUBFR; - - int i, j; - float s; - - for (i = 0; i < L_SUBFR; i++) - { - s = 0.0f; - for (j = i; j < L_SUBFR; j++) - s += x[j] * h[j-i]; - d[i] = s; - } -} - -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/DeAcelp.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/DeAcelp.java deleted file mode 100644 index 429df8772..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/DeAcelp.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class DeAcelp -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : DE_ACELP.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - - -/** - * Algebraic codebook decoder. - * - * @param sign input : signs of 4 pulses - * @param index input : positions of 4 pulses - * @param cod output: innovative codevector - */ -static void decod_ACELP( - int sign, - int index, - float cod[] -) -{ - int L_SUBFR = Ld8k.L_SUBFR; - - int[] pos = new int[4]; - int i, j; - - /* decode the positions of 4 pulses */ - - i = index & 7; - pos[0] = i*5; - - index >>= 3; - i = index & 7; - pos[1] = i*5 + 1; - - index >>= 3; - i = index & 7; - pos[2] = i*5 + 2; - - index >>= 3; - j = index & 1; - index >>= 1; - i = index & 7; - pos[3] = i*5 + 3 + j; - - /* find the algebraic codeword */ - - for (i = 0; i < L_SUBFR; i++) cod[i] = 0; - - /* decode the signs of 4 pulses */ - - for (j=0; j<4; j++) - { - - i = sign & 1; - sign >>= 1; - - if (i != 0) { - cod[pos[j]] = 1.0f; - } - else { - cod[pos[j]] = -1.0f; - } - } -} -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/DecGain.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/DecGain.java deleted file mode 100644 index f846e3665..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/DecGain.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class DecGain -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ -/* - File : DEC_GAIN.C - Used for the floating point version of both - G.729 main body and G.729A -*/ -private final float[/* 4 */] past_qua_en={-14.0f,-14.0f,-14.0f,-14.0f}; - -/** - * Decode the adaptive and fixed codebook gains. - * - * @param index input : quantizer index - * @param code input : fixed code book vector - * @param l_subfr input : subframe size - * @param bfi input : bad frame indicator good = 0 - * @param gain_pit output: quantized acb gain - * @param gain_code output: quantized fcb gain - */ -void dec_gain( - int index, - float code[], - int l_subfr, - int bfi, - FloatReference gain_pit, - FloatReference gain_code -) -{ - int NCODE2 = Ld8k.NCODE2; - float[][] gbk1 = TabLd8k.gbk1; - float[][] gbk2 = TabLd8k.gbk2; - int[] imap1 = TabLd8k.imap1; - int[] imap2 = TabLd8k.imap2; - - int index1,index2; - float gcode0, g_code; - - /*----------------- Test erasure ---------------*/ - if (bfi != 0) - { - gain_pit.value *= 0.9f; - if(gain_pit.value > 0.9f) gain_pit.value=0.9f; - gain_code.value *= 0.98f; - - /*----------------------------------------------* - * update table of past quantized energies * - * (frame erasure) * - *----------------------------------------------*/ - Gainpred.gain_update_erasure(past_qua_en); - - return; - } - - /*-------------- Decode pitch gain ---------------*/ - - index1 = imap1[index/NCODE2] ; - index2 = imap2[index%NCODE2] ; - gain_pit.value = gbk1[index1][0]+gbk2[index2][0] ; - - /*-------------- Decode codebook gain ---------------*/ - - /*---------------------------------------------------* - *- energy due to innovation -* - *- predicted energy -* - *- predicted codebook gain => gcode0[exp_gcode0] -* - *---------------------------------------------------*/ - - gcode0 = Gainpred.gain_predict( past_qua_en, code, l_subfr); - - /*-----------------------------------------------------------------* - * *gain_code = (gbk1[indice1][1]+gbk2[indice2][1]) * gcode0; * - *-----------------------------------------------------------------*/ - - g_code = gbk1[index1][1]+gbk2[index2][1]; - gain_code.value = g_code * gcode0; - - /*----------------------------------------------* - * update table of past quantized energies * - *----------------------------------------------*/ - - Gainpred.gain_update( past_qua_en, g_code); -} -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/DecLag3.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/DecLag3.java deleted file mode 100644 index 0ee826c5b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/DecLag3.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class DecLag3 -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : DEC_LAG3.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -/** - * Decoding of fractional pitch lag with 1/3 resolution. - * See the source for more details about the encoding procedure. - * - * @param index input : received pitch index - * @param pit_min input : minimum pitch lag - * @param pit_max input : maximum pitch lag - * @param i_subfr input : subframe flag - * @param T0 output: integer part of pitch lag - * @param T0_frac output: fractional part of pitch lag - */ -static void dec_lag3( - int index, - int pit_min, - int pit_max, - int i_subfr, - IntReference T0, - IntReference T0_frac -) -{ - int i; - int _T0 = T0.value, _T0_frac = T0_frac.value; - int T0_min, T0_max; - - if (i_subfr == 0) /* if 1st subframe */ - { - if (index < 197) - { - _T0 = (index+2)/3 + 19; - _T0_frac = index - _T0*3 + 58; - } - else - { - _T0 = index - 112; - _T0_frac = 0; - } - } - - else /* second subframe */ - { - /* find T0_min and T0_max for 2nd subframe */ - - T0_min = _T0 - 5; - if (T0_min < pit_min) - T0_min = pit_min; - - T0_max = T0_min + 9; - if(T0_max > pit_max) - { - T0_max = pit_max; - T0_min = T0_max -9; - } - - i = (index+2)/3 - 1; - _T0 = i + T0_min; - _T0_frac = index - 2 - i*3; - } - T0.value = _T0; - T0_frac.value = _T0_frac; -} -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/DecLd8k.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/DecLd8k.java deleted file mode 100644 index c1516550a..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/DecLd8k.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * Functions init_decod_ld8k and decod_ld8k. - *
- * Decoder constant parameters (defined in "ld8k.h")
- *   L_FRAME     : Frame size.
- *   L_SUBFR     : Sub-frame size.
- *   M           : LPC order.
- *   MP1         : LPC order+1
- *   PIT_MIN     : Minimum pitch lag.
- *   PIT_MAX     : Maximum pitch lag.
- *   L_INTERPOL  : Length of filter for interpolation
- *   PRM_SIZE    : Size of vector containing analysis parameters
- * 
- * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class DecLd8k - extends Ld8k -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : DEC_LD8K.C - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - -/*--------------------------------------------------------* - * Static memory allocation. * - *--------------------------------------------------------*/ - -/** - * Excitation vector - */ -private final float[] old_exc = new float[L_FRAME+PIT_MAX+L_INTERPOL]; - -/** - * Excitation vector - */ -private float[] exc; - -/** - * Excitation vector offset - */ -private int exc_offset; - -/** - * Lsp (Line spectral pairs) - */ -private final float[/* M */] lsp_old={ - 0.9595f, 0.8413f, 0.6549f, 0.4154f, 0.1423f, - -0.1423f, -0.4154f, -0.6549f, -0.8413f, -0.9595f}; - -/** - * Filter's memory - */ -private final float[] mem_syn = new float[M]; - -/** - * pitch sharpening of previous fr - */ -private float sharp ; - -/** -* integer delay of previous frame -*/ -private int old_t0; - -/** - * fixed codebook gain - */ -private final FloatReference gain_code = new FloatReference(); - -/** - * adaptive codebook gain - */ -private final FloatReference gain_pitch = new FloatReference(); - -private final DecGain decGain = new DecGain(); -private final Lspdec lspdec = new Lspdec(); - -/** - * Initialization of variables for the decoder section. - */ -void init_decod_ld8k() -{ - /* Initialize static pointer */ - exc = old_exc; - exc_offset = PIT_MAX + L_INTERPOL; - - /* Static vectors to zero */ - Util.set_zero(old_exc,PIT_MAX + L_INTERPOL); - Util.set_zero(mem_syn, M); - - sharp = SHARPMIN; - old_t0 = 60; - gain_code.value = 0.f; - gain_pitch.value = 0.f; - - lspdec.lsp_decw_reset(); -} - -/** - * Decoder - * - * @param parm input : synthesis parameters (parm[0] = bfi) - * @param voicing input : voicing decision from previous frame - * @param synth output: synthesized speech - * @param synth_offset input : synthesized speech offset - * @param A_t output: two sets of A(z) coefficients length=2*MP1 - * @return output: integer delay of first subframe - */ -int decod_ld8k( - int parm[], - int voicing, - float synth[], - int synth_offset, - float A_t[] -) -{ - int parm_offset = 0; - - int t0_first = 0; /* output: integer delay of first subframe */ - float[] Az; /* Pointer to A_t (LPC coefficients) */ - int Az_offset; - float[] lsp_new = new float[M]; /* LSPs */ - float[] code = new float[L_SUBFR]; /* algebraic codevector */ - - /* Scalars */ - int i, i_subfr; - IntReference t0 = new IntReference(), t0_frac = new IntReference(); - int index; - - int bfi; - int bad_pitch; - - /* Test bad frame indicator (bfi) */ - - bfi = parm[parm_offset]; - parm_offset++; - - /* Decode the LSPs */ - - lspdec.d_lsp(parm, parm_offset, lsp_new, bfi); - parm_offset += 2; /* Advance synthesis parameters pointer */ - - /* Interpolation of LPC for the 2 subframes */ - - Lpcfunc.int_qlpc(lsp_old, lsp_new, A_t); - - /* update the LSFs for the next frame */ - - Util.copy(lsp_new, lsp_old, M); - -/*------------------------------------------------------------------------* - * Loop for every subframe in the analysis frame * - *------------------------------------------------------------------------* - * The subframe size is L_SUBFR and the loop is repeated L_FRAME/L_SUBFR * - * times * - * - decode the pitch delay * - * - decode algebraic code * - * - decode pitch and codebook gains * - * - find the excitation and compute synthesis speech * - *------------------------------------------------------------------------*/ - - Az = A_t; /* pointer to interpolated LPC parameters */ - Az_offset = 0; - - for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR) { - - index = parm[parm_offset]; /* pitch index */ - parm_offset++; - - if (i_subfr == 0) { /* if first subframe */ - i = parm[parm_offset]; /* get parity check result */ - parm_offset++; - bad_pitch = bfi+ i; - if( bad_pitch == 0) - { - DecLag3.dec_lag3(index, PIT_MIN, PIT_MAX, i_subfr, t0, t0_frac); - old_t0 = t0.value; - } - else /* Bad frame, or parity error */ - { - t0.value = old_t0; - t0_frac.value = 0; - old_t0++; - if( old_t0> PIT_MAX) { - old_t0 = PIT_MAX; - } - } - t0_first = t0.value; /* If first frame */ - } - else /* second subframe */ - { - if( bfi == 0) - { - DecLag3.dec_lag3(index, PIT_MIN, PIT_MAX, i_subfr, t0, t0_frac); - old_t0 = t0.value; - } - else - { - t0.value = old_t0; - t0_frac.value = 0; - old_t0++; - if( old_t0 >PIT_MAX) { - old_t0 = PIT_MAX; - } - } - } - - - /*-------------------------------------------------* - * - Find the adaptive codebook vector. * - *--------------------------------------------------*/ - - PredLt3.pred_lt_3(exc, exc_offset + i_subfr, t0.value, t0_frac.value, L_SUBFR); - - /*-------------------------------------------------------* - * - Decode innovative codebook. * - * - Add the fixed-gain pitch contribution to code[]. * - *-------------------------------------------------------*/ - - if(bfi != 0) { /* Bad Frame Error Concealment */ - parm[parm_offset + 0] = (Util.random_g729() & 0x1fff); /* 13 bits random*/ - parm[parm_offset + 1]= (Util.random_g729() & 0x000f); /* 4 bits random */ - } - - DeAcelp.decod_ACELP(parm[parm_offset + 1], parm[parm_offset + 0], code); - parm_offset +=2; - for (i = t0.value; i < L_SUBFR; i++) code[i] += sharp * code[i-t0.value]; - - /*-------------------------------------------------* - * - Decode pitch and codebook gains. * - *-------------------------------------------------*/ - - index = parm[parm_offset]; /* index of energy VQ */ - parm_offset++; - decGain.dec_gain(index, code, L_SUBFR, bfi, gain_pitch, gain_code); - - /*-------------------------------------------------------------* - * - Update pitch sharpening "sharp" with quantized gain_pitch * - *-------------------------------------------------------------*/ - - sharp = gain_pitch.value; - if (sharp > SHARPMAX) sharp = SHARPMAX; - if (sharp < SHARPMIN) sharp = SHARPMIN; - - /*-------------------------------------------------------* - * - Find the total excitation. * - *-------------------------------------------------------*/ - - if(bfi != 0 ) { - if(voicing == 0) { /* for unvoiced frame */ - for (i = 0; i < L_SUBFR; i++) { - exc[exc_offset + i+i_subfr] = gain_code.value*code[i]; - } - } else { /* for voiced frame */ - for (i = 0; i < L_SUBFR; i++) { - exc[exc_offset + i+i_subfr] = gain_pitch.value*exc[exc_offset + i+i_subfr]; - } - } - } else { /* No frame errors */ - for (i = 0; i < L_SUBFR; i++) { - exc[exc_offset + i+i_subfr] = gain_pitch.value*exc[exc_offset + i+i_subfr] + gain_code.value*code[i]; - } - } - - /*-------------------------------------------------------* - * - Find synthesis speech corresponding to exc[]. * - *-------------------------------------------------------*/ - - Filter.syn_filt(Az, Az_offset, exc, exc_offset + i_subfr, synth, synth_offset + i_subfr, L_SUBFR, mem_syn, 0, 1); - - Az_offset += MP1; /* interpolated LPC parameters for next subframe */ - } - - /*--------------------------------------------------* - * Update signal for next frame. * - * -> shift to the left by L_FRAME exc[] * - *--------------------------------------------------*/ - Util.copy(old_exc, L_FRAME, old_exc, PIT_MAX+L_INTERPOL); - return t0_first; -} -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Decoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Decoder.java deleted file mode 100644 index fa085d737..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Decoder.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -import java.io.*; - -/** - * Main program of the G.729 8.0 kbit/s decoder. - * Usage : decoder bitstream_file synth_file. - * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Decoder - extends Ld8k -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : DECODER.C - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - - /** - * DecLd8k reference - */ - private final DecLd8k decLd8k = new DecLd8k(); - - /** - * Postfil reference - */ - private final Postfil postfil = new Postfil(); - - /** - * PostPro reference - */ - private final PostPro postPro = new PostPro(); - /** - * Synthesis - */ - private final float[] synth_buf = new float[L_FRAME+M]; - - /** - * Synthesis - */ - private final float[] synth; - - - /** - * Synthesis - */ - private int synth_offset; - - /** - * Synthesis parameters + BFI - */ - private final int[] parm = new int[PRM_SIZE+1]; - - /** - * Synthesis parameters + BFI - */ - private final float[] Az_dec = new float[2*MP1]; - - /** - * postfilter output - */ - private final float[] pst_out = new float[L_FRAME]; - - /** - * voicing for previous subframe - */ - private int voicing; - - /** - * Initialization of decoder - */ - Decoder() - { - - synth = synth_buf; - synth_offset = M; - - decLd8k.init_decod_ld8k(); - postfil.init_post_filter(); - postPro.init_post_process(); - - voicing = 60; - } - - /** - * Converts floats array into shorts array. - * - * @param floats - * @param shorts - */ - private static void floats2shorts(float[] floats, short[] shorts) - { - for (int i = 0; i < floats.length; i++) - { - /* round and convert to int */ - float f = floats[i]; - if (f >= 0.0f) - f += 0.5f; - else - f -= 0.5f; - if (f > 32767.0f) - f = 32767.0f; - if (f < -32768.0f) - f = -32768.0f; - shorts[i] = (short) f; - } - } - -/** - * Main decoder routine - * Usage :Decoder bitstream_file outputspeech_file - * - * Format for bitstream_file: - * One (2-byte) synchronization word - * One (2-byte) size word, - * 80 words (2-byte) containing 80 bits. - * - * Format for outputspeech_file: - * Synthesis is written to a binary file of 16 bits data. - * - * @param args bitstream_file outputspeech_file - * @throws java.io.IOException - */ -public static void main(String[] args) - throws IOException -{ - OutputStream f_syn; - InputStream f_serial; - - short[] serial = new short[SERIAL_SIZE]; /* Serial stream */ - short[] sp16 = new short[L_FRAME]; /* Buffer to write 16 bits speech */ - - int frame; - - System.out.printf("\n"); - System.out.printf("************** G.729 8 KBIT/S SPEECH DECODER ************\n"); - System.out.printf("\n"); - System.out.printf("----------------- Floating point C simulation ----------------\n"); - System.out.printf("\n"); - System.out.printf("------------ Version 1.01 (Release 2, November 2006) --------\n"); - System.out.printf("\n"); - - /* Passed arguments */ - - if ( args.length != 2) - { - System.out.printf("Usage :Decoder bitstream_file outputspeech_file\n"); - System.out.printf("\n"); - System.out.printf("Format for bitstream_file:\n"); - System.out.printf(" One (2-byte) synchronization word \n"); - System.out.printf(" One (2-byte) size word,\n"); - System.out.printf(" 80 words (2-byte) containing 80 bits.\n"); - System.out.printf("\n"); - System.out.printf("Format for outputspeech_file:\n"); - System.out.printf(" Synthesis is written to a binary file of 16 bits data.\n"); - System.exit( 1 ); - } - - /* Open file for synthesis and packed serial stream */ - - try - { - f_serial = new FileInputStream(args[0]); - } - catch (IOException ex) - { - System.out.printf("Decoder - Error opening file %s !!\n", args[0]); - System.exit(0); - throw ex; // Silence the compiler. - } - - try - { - f_syn = new FileOutputStream(args[1]); - } - catch (IOException ex) - { - System.out.printf("Decoder - Error opening file %s !!\n", args[1]); - System.exit(0); - throw ex; // Silence the compiler. - } - - System.out.printf("Input bitstream file : %s\n",args[0]); - System.out.printf("Synthesis speech file : %s\n",args[1]); - -/*-----------------------------------------------------------------* - * Initialization of decoder * - *-----------------------------------------------------------------*/ - - Decoder decoder = new Decoder(); - -/*-----------------------------------------------------------------* - * Loop for each "L_FRAME" speech data * - *-----------------------------------------------------------------*/ - - frame =0; - while(Util.fread(serial, SERIAL_SIZE, f_serial) == SERIAL_SIZE) - { - frame++; - System.out.printf(" Frame: %d\r", frame); - - decoder.process(serial, sp16); - - Util.fwrite(sp16, L_FRAME, f_syn); - } - - f_syn.close(); - f_serial.close(); -} - - /** - * Process SERIAL_SIZE short of speech. - * - * @param serial input : serial array encoded in bits_ld8k - * @param sp16 output : speech short array - */ - void process(short[] serial, short[] sp16) - { - Bits.bits2prm_ld8k(serial, 2, parm, 1); - - /* the hardware detects frame erasures by checking if all bits - are set to zero - */ - parm[0] = 0; /* No frame erasure */ - for (int i=2; i < SERIAL_SIZE; i++) - if (serial[i] == 0 ) parm[0] = 1; /* frame erased */ - - /* check parity and put 1 in parm[4] if parity error */ - - parm[4] = PParity.check_parity_pitch(parm[3], parm[4] ); - - int t0_first = decLd8k.decod_ld8k(parm, voicing, synth, synth_offset, Az_dec); /* Decoder */ - - /* Post-filter and decision on voicing parameter */ - voicing = 0; - - float[] ptr_Az = Az_dec; /* Decoded Az for post-filter */ - int ptr_Az_offset = 0; - - for(int i=0; iSIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * General filter routines. - * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Filter -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : FILTER.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -/** - * Convolve vectors x and h and put result in y. - * - * @param x input : input vector x[0:l] - * @param x_offset input : input vector offset - * @param h input : impulse response or second input h[0:l] - * @param y output: x convolved with h , y[0:l] - * @param l input : dimension of all vectors - */ -static void convolve( - float x[], - int x_offset, - float h[], - float y[], - int l -) -{ - float temp; - int i, n; - - for (n = 0; n < l; n++) - { - temp = 0.0f; - for (i = 0; i <= n; i++) - temp += x[x_offset + i]*h[n-i]; - y[n] = temp; - } -} - -/** - * Filter with synthesis filter 1/A(z). - * - * @param a input : predictor coefficients a[0:m] - * @param a_offset input : predictor coefficients a offset - * @param x input : excitation signal - * @param x_offset input : excitation signal offset - * @param y output: filtered output signal - * @param y_offset output: filtered output signal offset - * @param l input : vector dimension - * @param mem in/out: filter memory - * @param mem_offset input : filter memory ofset - * @param update input : 0 = no memory update, 1 = update - */ -static void syn_filt( - float a[], - int a_offset, - float x[], - int x_offset, - float y[], - int y_offset, - int l, - float mem[], - int mem_offset, - int update -) -{ - int L_SUBFR = Ld8k.L_SUBFR; - int M = Ld8k.M; - - int i,j; - - /* This is usually done by memory allocation (l+m) */ - float[] yy_b = new float[L_SUBFR+M]; - float s; - int yy, py, pa; - /* Copy mem[] to yy[] */ - yy = 0; //index instead of pointer - for (i = 0; i SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Gainpred -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : GAINPRED.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -/** - * MA prediction is performed on the innovation energy (in dB with mean - * removed). - * - * @param past_qua_en (i) :Past quantized energies - * @param code (i) :Innovative vector. - * @param l_subfr (i) :Subframe length. - * @return Predicted codebook gain - */ -static float gain_predict( - float past_qua_en[], - float code[], - int l_subfr -) -{ - float MEAN_ENER = Ld8k.MEAN_ENER; - float[] pred = TabLd8k.pred; - - float ener_code, pred_code; - int i; - float gcode0; /* (o) :Predicted codebook gain */ - - pred_code = MEAN_ENER ; - - /* innovation energy */ - ener_code = 0.01f; - for(i=0; i 0; i--) - past_qua_en[i] = past_qua_en[i-1]; - past_qua_en[0] = 20.0f*(float)Math.log10((double)g_code); -} - -/** - * Update table of past quantized energies (frame erasure). - *
- *     av_pred_en = 0.0;                                                     
- *     for (i = 0; i < 4; i++)                                               
- *        av_pred_en += past_qua_en[i];                                      
- *     av_pred_en = av_pred_en*0.25 - 4.0;                                   
- *     if (av_pred_en < -14.0) av_pred_en = -14.0; 
- * 
- * - * @param past_qua_en input/output:Past quantized energies - */ -static void gain_update_erasure( - float past_qua_en[] -) -{ - int i; - float av_pred_en; - - av_pred_en = 0.0f; - for (i = 0; i < 4; i++) - av_pred_en += past_qua_en[i]; - av_pred_en = av_pred_en*0.25f - 4.0f; - if (av_pred_en < -14.0f) av_pred_en = -14.0f; - - for (i = 3; i > 0; i--) - past_qua_en[i] = past_qua_en[i-1]; - past_qua_en[0] = av_pred_en; -} - -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/IntReference.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/IntReference.java deleted file mode 100644 index dc35aeca2..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/IntReference.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov - */ -class IntReference -{ - int value; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/JavaDecoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/JavaDecoder.java deleted file mode 100644 index c19fd02ff..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/JavaDecoder.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.sf.fmj.media.*; - -/** - * @author Lubomir Marinov - */ -public class JavaDecoder - extends AbstractCodecExt -{ - private static final short BIT_0 = Ld8k.BIT_0; - - private static final short BIT_1 = Ld8k.BIT_1; - - private static final int L_FRAME = Ld8k.L_FRAME; - - private static final int SERIAL_SIZE = Ld8k.SERIAL_SIZE; - - private static final short SIZE_WORD = Ld8k.SIZE_WORD; - - private static final short SYNC_WORD = Ld8k.SYNC_WORD; - - private static final int INPUT_FRAME_SIZE_IN_BYTES = L_FRAME / 8; - - private static final int OUTPUT_FRAME_SIZE_IN_BYTES = 2 * L_FRAME; - - private Decoder decoder; - - private short[] serial; - - private short[] sp16; - - /** - * Initializes a new JavaDecoder instance. - */ - public JavaDecoder() - { - super( - "G.729 Decoder", - AudioFormat.class, - new AudioFormat[] - { - new AudioFormat( - AudioFormat.LINEAR, - 8000, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED) - }); - - inputFormats - = new AudioFormat[] - { - new AudioFormat( - AudioFormat.G729_RTP, - 8000, - AudioFormat.NOT_SPECIFIED, - 1) - }; - } - - private void depacketize( - byte[] inputFrame, - int inputFrameOffset, - short[] serial) - { - serial[0] = SYNC_WORD; - serial[1] = SIZE_WORD; - for (int s = 0; s < L_FRAME; s++) - { - int input = inputFrame[inputFrameOffset + s / 8]; - - input &= 1 << (7 - (s % 8)); - serial[2 + s] = (0 != input) ? BIT_1 : BIT_0; - } - } - - /* - * Implements AbstractCodecExt#doClose(). - */ - protected void doClose() - { - serial = null; - sp16 = null; - decoder = null; - } - - /** - * Opens this Codec and acquires the resources that it needs to - * operate. A call to {@link PlugIn#open()} on this instance will result in - * a call to doOpen only if {@link AbstractCodec#opened} is - * false. All required input and/or output formats are assumed to - * have been set on this Codec before doOpen is called. - * - * @throws ResourceUnavailableException if any of the resources that this - * Codec needs to operate cannot be acquired - * @see AbstractCodecExt#doOpen() - */ - protected void doOpen() - throws ResourceUnavailableException - { - serial = new short[SERIAL_SIZE]; - sp16 = new short[L_FRAME]; - decoder = new Decoder(); - } - - /* - * Implements AbstractCodecExt#doProcess(Buffer, Buffer). - */ - protected int doProcess(Buffer inputBuffer, Buffer outputBuffer) - { - byte[] input = (byte[]) inputBuffer.getData(); - - int inputLength = inputBuffer.getLength(); - - if (inputLength < INPUT_FRAME_SIZE_IN_BYTES) - { - discardOutputBuffer(outputBuffer); - return BUFFER_PROCESSED_OK | OUTPUT_BUFFER_NOT_FILLED; - } - - int inputOffset = inputBuffer.getOffset(); - - depacketize(input, inputOffset, serial); - inputLength -= INPUT_FRAME_SIZE_IN_BYTES; - inputBuffer.setLength(inputLength); - inputOffset += INPUT_FRAME_SIZE_IN_BYTES; - inputBuffer.setOffset(inputOffset); - - decoder.process(serial, sp16); - - byte[] output - = validateByteArraySize( - outputBuffer, - outputBuffer.getOffset() + OUTPUT_FRAME_SIZE_IN_BYTES); - - writeShorts(sp16, output, outputBuffer.getOffset()); - outputBuffer.setLength(OUTPUT_FRAME_SIZE_IN_BYTES); - - int processResult = BUFFER_PROCESSED_OK; - - if (inputLength > 0) - processResult |= INPUT_BUFFER_NOT_CONSUMED; - return processResult; - } - - private static void writeShorts( - short[] input, - byte[] output, - int outputOffset) - { - for (int i=0, o=outputOffset; iBuffer
produced by this Codec - * in nanosecond. We packetize 2 audio frames in one G729 packet. - */ - private int duration = OUTPUT_FRAME_SIZE_IN_BYTES * 2 * 1000000; - - /** - * Initializes a new JavaEncoder instance. - */ - public JavaEncoder() - { - super( - "G.729 Encoder", - AudioFormat.class, - new AudioFormat[] - { - new AudioFormat( - AudioFormat.G729_RTP, - 8000, - AudioFormat.NOT_SPECIFIED, - 1) - }); - - inputFormats - = new AudioFormat[] - { - new AudioFormat( - AudioFormat.LINEAR, - 8000, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED) - }; - } - - /** - * Get the output format. - * - * @return output format - * @see net.sf.fmj.media.AbstractCodec#getOutputFormat() - */ - @Override - public Format getOutputFormat() - { - Format outputFormat = super.getOutputFormat(); - - if ((outputFormat != null) - && (outputFormat.getClass() == AudioFormat.class)) - { - AudioFormat outputAudioFormat = (AudioFormat) outputFormat; - - outputFormat = setOutputFormat( - new AudioFormat( - outputAudioFormat.getEncoding(), - outputAudioFormat.getSampleRate(), - outputAudioFormat.getSampleSizeInBits(), - outputAudioFormat.getChannels(), - outputAudioFormat.getEndian(), - outputAudioFormat.getSigned(), - outputAudioFormat.getFrameSizeInBits(), - outputAudioFormat.getFrameRate(), - outputAudioFormat.getDataType()) - { - private static final long serialVersionUID = 0L; - - @Override - public long computeDuration(long length) - { - return JavaEncoder.this.duration; - } - }); - } - return outputFormat; - } - - protected void discardOutputBuffer(Buffer outputBuffer) - { - super.discardOutputBuffer(outputBuffer); - - outputFrameCount = 0; - } - - /* - * Implements AbstractCodecExt#doClose(). - */ - protected void doClose() - { - prevInput = null; - prevInputLength = 0; - - sp16 = null; - serial = null; - coder = null; - } - - /** - * Opens this Codec and acquires the resources that it needs to - * operate. A call to {@link PlugIn#open()} on this instance will result in - * a call to doOpen only if {@link AbstractCodec#opened} is - * false. All required input and/or output formats are assumed to - * have been set on this Codec before doOpen is called. - * - * @throws ResourceUnavailableException if any of the resources that this - * Codec needs to operate cannot be acquired - * @see AbstractCodecExt#doOpen() - */ - protected void doOpen() - throws ResourceUnavailableException - { - prevInput = new byte[INPUT_FRAME_SIZE_IN_BYTES]; - prevInputLength = 0; - - sp16 = new short[L_FRAME]; - serial = new short[SERIAL_SIZE]; - coder = new Coder(); - - outputFrameCount = 0; - } - - /* - * Implements AbstractCodecExt#doProcess(Buffer, Buffer). - */ - protected int doProcess(Buffer inputBuffer, Buffer outputBuffer) - { - byte[] input = (byte[]) inputBuffer.getData(); - - int inputLength = inputBuffer.getLength(); - int inputOffset = inputBuffer.getOffset(); - - if ((prevInputLength + inputLength) < INPUT_FRAME_SIZE_IN_BYTES) - { - System.arraycopy( - input, - inputOffset, - prevInput, - prevInputLength, - inputLength); - prevInputLength += inputLength; - return BUFFER_PROCESSED_OK | OUTPUT_BUFFER_NOT_FILLED; - } - - int readShorts = 0; - - if (prevInputLength > 0) - { - readShorts - += readShorts(prevInput, 0, sp16, 0, prevInputLength / 2); - prevInputLength = 0; - } - readShorts - = readShorts( - input, - inputOffset, - sp16, - readShorts, - sp16.length - readShorts); - - int readBytes = 2 * readShorts; - - inputLength -= readBytes; - inputBuffer.setLength(inputLength); - inputOffset += readBytes; - inputBuffer.setOffset(inputOffset); - - coder.process(sp16, serial); - - byte[] output - = validateByteArraySize( - outputBuffer, - outputBuffer.getOffset() + 2 * OUTPUT_FRAME_SIZE_IN_BYTES); - - packetize( - serial, - output, - outputBuffer.getOffset() - + OUTPUT_FRAME_SIZE_IN_BYTES * outputFrameCount); - outputBuffer.setLength( - outputBuffer.getLength() + OUTPUT_FRAME_SIZE_IN_BYTES); - - outputBuffer.setFormat(outputFormat); - - int processResult = BUFFER_PROCESSED_OK; - - if (outputFrameCount == 1) - outputFrameCount = 0; - else - { - outputFrameCount = 1; - processResult |= OUTPUT_BUFFER_NOT_FILLED; - } - if (inputLength > 0) - processResult |= INPUT_BUFFER_NOT_CONSUMED; - - if(processResult == BUFFER_PROCESSED_OK) - { - updateOutput( - outputBuffer, - getOutputFormat(), outputBuffer.getLength(), - outputBuffer.getOffset()); - outputBuffer.setDuration(duration); - } - return processResult; - } - - private void packetize( - short[] serial, - byte[] outputFrame, - int outputFrameOffset) - { - Arrays.fill( - outputFrame, - outputFrameOffset, - outputFrameOffset + L_FRAME / 8, - (byte) 0); - - for (int s = 0; s < L_FRAME; s++) - if (BIT_1 == serial[2 + s]) - { - int o = outputFrameOffset + s / 8; - int output = outputFrame[o]; - - output |= 1 << (7 - (s % 8)); - outputFrame[o] = (byte) (output & 0xFF); - } - } - - private static int readShorts( - byte[] input, - int inputOffset, - short[] output, - int outputOffset, - int outputLength) - { - for (int o=outputOffset, i=inputOffset; oSIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Ld8k -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : LD8K.H - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - - -/*--------------------------------------------------------------------------- - * ld8k.h - include file for all ITU-T 8 kb/s CELP coder routines - *--------------------------------------------------------------------------- - */ - -static final float PI = 3.14159265358979323846f; -/** - * Largest floating point number - */ -static final float FLT_MAX_G729 = 1.e38f; -/** - * Largest floating point number - */ -static final float FLT_MIN_G729 = -FLT_MAX_G729; - -/** - * Total size of speech buffer - */ -static final int L_TOTAL = 240; -/** - * LPC update frame size - */ -static final int L_FRAME = 80; -/** - * Sub-frame size - */ -static final int L_SUBFR = 40; - -/*---------------------------------------------------------------------------* - * Constants for bitstream packing * - *---------------------------------------------------------------------------*/ -/** - * Definition of one-bit in bit-stream. - */ -static final short BIT_1 = 0x0081; -/** - * Definition of zero-bit in bit-stream. - */ -static final short BIT_0 = 0x007f; -/** - * Definition of frame erasure flag. - */ -static final short SYNC_WORD = 0x6b21; -/** - * Size of bitstream frame. - */ -static final short SIZE_WORD = 80; -/** - * Number of parameters per 10 ms frame. - */ -static final int PRM_SIZE = 11; -/** - * Bits per frame. - */ -static final int SERIAL_SIZE = 82; - -/*---------------------------------------------------------------------------* - * Constants for lpc analysis and lsp quantizer. * - *---------------------------------------------------------------------------*/ -/** - * LPC analysis window size. - */ -static final int L_WINDOW = 240; -/** - * Samples of next frame needed for LPC ana. - */ -static final int L_NEXT = 40; - -/** - * LPC order. - */ -static final int M = 10; -/** - * LPC order+1. - */ -static final int MP1 = (M+1); -/** - * Resolution of lsp search. - */ -static final int GRID_POINTS = 60; - -/** - * MA prediction order for LSP. - */ -static final int MA_NP = 4; -/** - * Number of modes for MA prediction. - */ -static final int MODE = 2; -/** - * Number of bits in first stage. - */ -static final int NC0_B = 7; -/** - * Number of entries in first stage. - */ -static final int NC0 = (1<0 - */ -static final float GAMMA3_PLUS = 0.2f; -/** - * tilt weighting factor when k1<0 - */ -static final float GAMMA3_MINUS = 0.9f; - -/* long term pst parameters : */ -/** - * Sub-frame size + 1 - */ -static final int L_SUBFRP1 = (L_SUBFR + 1); -/** - * resolution for fractionnal delay - */ -static final int F_UP_PST = 8; -/** - * length of short interp. subfilters - */ -static final int LH2_S = 4; -/** - * length of long interp. subfilters - */ -static final int LH2_L = 16; -/** - * threshold LT pst switch off - */ -static final float THRESCRIT = 0.5f; -/** - * LT weighting factor - */ -static final float GAMMA_G = 0.5f; -/** - * gain adjustment factor - */ -static final float AGC_FAC = 0.9875f; -/** - * gain adjustment factor - */ -static final float AGC_FAC1 = (1.f - AGC_FAC); -static final int LH_UP_S = (LH2_S/2); -static final int LH_UP_L = (LH2_L/2); -static final int LH2_L_P1 = (LH2_L + 1); -/** - * LT gain minimum - */ -static final float MIN_GPLT = (1.f / (1.f + GAMMA_G)); - -/* Array sizes */ -static final int MEM_RES2 = (PIT_MAX + 1 + LH_UP_L); -static final int SIZ_RES2 = (MEM_RES2 + L_SUBFR); -static final int SIZ_Y_UP = ((F_UP_PST-1) * L_SUBFRP1); -static final int SIZ_TAB_HUP_L = ((F_UP_PST-1) * LH2_L); -static final int SIZ_TAB_HUP_S = ((F_UP_PST-1) * LH2_S); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Lpc.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Lpc.java deleted file mode 100644 index 8f4eb6b13..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Lpc.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * Lpc analysis routines. - * NOTE: these routines are assuming that the order is defined as M - * and that NC is defined as M/2. M has to be even - * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Lpc -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : LPC.C - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - - - -/** - * Compute the auto-correlations of windowed speech signal - * - * @param x (i) input signal x[0:L_WINDOW] - * @param x_offset (i) input signal offset - * @param m (i) LPC order - * @param r (o) auto-correlation vector r[0:M] - */ -static void autocorr( - float[] x, - int x_offset, - int m, - float[] r -) -{ - int L_WINDOW = Ld8k.L_WINDOW; - float[] hamwindow = TabLd8k.hamwindow; - - float[] y = new float[L_WINDOW]; - float sum; - int i, j; - - - for (i = 0; i < L_WINDOW; i++) - y[i] = x[x_offset + i]*hamwindow[i]; - - for (i = 0; i <= m; i++) - { - sum = 0.0f; - for (j = 0; j < L_WINDOW-i; j++) - sum += y[j]*y[j+i]; - r[i] = sum; - } - if (r[0]<1.0f) r[0]=1.0f; -} - -/** - * Lag windowing of the autocorrelations - * - * @param m (i) LPC order - * @param r (i/o) correlation - */ -static void lag_window( - int m, - float r[] -) -{ - float[] lwindow = TabLd8k.lwindow; - - int i; - - for (i=1; i<= m; i++) - r[i] *= lwindow[i-1]; -} - -/** - * Levinson-Durbin recursion to compute LPC parameters. - * - * @param r (i) auto correlation coefficients r[0:M] - * @param a (o) lpc coefficients a[0] = 1 - * @param a_offset (i) lpc coefficients offset - * @param rc (o) reflection coefficients rc[0:M-1] - * @return prediction error (energy) - */ -static float levinson( - float[] r, - float[] a, - int a_offset, - float[] rc -) -{ - int M = Ld8k.M; - - float s, at, err; - int i, j, l; - - rc[0] = (-r[1])/r[0]; - a[a_offset + 0] = 1.0f; - a[a_offset + 1] = rc[0]; - err = r[0] + r[1]*rc[0]; - for (i = 2; i <= M; i++) - { - s = 0.0f; - for (j = 0; j < i; j++) - s += r[i-j]*a[a_offset + j]; - rc[i-1]= (-s)/(err); - for (j = 1; j <= (i/2); j++) - { - l = i-j; - at = a[a_offset + j] + rc[i-1]*a[a_offset + l]; - a[a_offset + l] += rc[i-1]*a[a_offset + j]; - a[a_offset + j] = at; - } - a[a_offset + i] = rc[i-1]; - err += rc[i-1]*s; - if (err <= 0.0f) - err = 0.001f; - } - return (err); -} - -/** * - * Compute the LSPs from the LP coefficients a[] using Chebyshev - * polynomials. The found LSPs are in the cosine domain with values - * in the range from 1 down to -1. - * The table grid[] contains the points (in the cosine domain) at - * which the polynomials are evaluated. The table corresponds to - * NO_POINTS frequencies uniformly spaced between 0 and pi. - * - * @param a (i) LP filter coefficients - * @param a_offset (i) LP filter coefficients offset - * @param lsp (o) Line spectral pairs (in the cosine domain) - * @param old_lsp (i) LSP vector from past frame - */ -static void az_lsp( - float[] a, - int a_offset, - float[] lsp, - float[] old_lsp -) -{ - int GRID_POINTS = Ld8k.GRID_POINTS; - int M = Ld8k.M; - int NC = Ld8k.NC; - float[] grid = TabLd8k.grid; - - int i, j, nf, ip; - float xlow,ylow,xhigh,yhigh,xmid,ymid,xint; - float[] coef; - - float[] f1 = new float[NC+1], f2 = new float[NC+1]; - - /*-------------------------------------------------------------* - * find the sum and diff polynomials F1(z) and F2(z) * - * F1(z) = [A(z) + z^11 A(z^-1)]/(1+z^-1) * - * F2(z) = [A(z) - z^11 A(z^-1)]/(1-z^-1) * - *-------------------------------------------------------------*/ - - f1[0] = 1.0f; - f2[0] = 1.0f; - for (i=1, j=a_offset+M; i<=NC; i++, j--){ - float ai = a[a_offset + i]; - float aj = a[j]; - f1[i] = ai+aj-f1[i-1]; - f2[i] = ai-aj+f2[i-1]; - } - - /*---------------------------------------------------------------------* - * Find the LSPs (roots of F1(z) and F2(z) ) using the * - * Chebyshev polynomial evaluation. * - * The roots of F1(z) and F2(z) are alternatively searched. * - * We start by finding the first root of F1(z) then we switch * - * to F2(z) then back to F1(z) and so on until all roots are found. * - * * - * - Evaluate Chebyshev pol. at grid points and check for sign change.* - * - If sign change track the root by subdividing the interval * - * NO_ITER times and ckecking sign change. * - *---------------------------------------------------------------------*/ - - nf=0; /* number of found frequencies */ - ip=0; /* flag to first polynomial */ - - coef = f1; /* start with F1(z) */ - - xlow=grid[0]; - ylow = chebyshev(xlow,coef,NC); - - j = 0; - while ( (nf < M) && (j < GRID_POINTS) ) - { - j++; - xhigh = xlow; - yhigh = ylow; - xlow = grid[j]; - ylow = chebyshev(xlow,coef,NC); - - if (ylow*yhigh <= 0.0f) /* if sign change new root exists */ - { - j--; - - /* divide the interval of sign change by 4 */ - - for (i = 0; i < 4; i++) - { - xmid = 0.5f*(xlow + xhigh); - ymid = chebyshev(xmid,coef,NC); - if (ylow*ymid <= 0.0f) - { - yhigh = ymid; - xhigh = xmid; - } - else - { - ylow = ymid; - xlow = xmid; - } - } - - /* linear interpolation for evaluating the root */ - - xint = xlow - ylow*(xhigh-xlow)/(yhigh-ylow); - - lsp[nf] = xint; /* new root */ - nf++; - - ip = 1 - ip; /* flag to other polynomial */ - coef = (ip != 0) ? f2 : f1; /* pointer to other polynomial */ - - xlow = xint; - ylow = chebyshev(xlow,coef,NC); - } - } - - /* Check if M roots found */ - /* if not use the LSPs from previous frame */ - - if ( nf < M) - for(i=0; iSIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Lpcfunc -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - - -/* - File : LPCFUNC.C - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - -/** - * Convert LSPs to predictor coefficients a[] - * - * @param lsp input : lsp[0:M-1] - * @param a output: predictor coeffs a[0:M], a[0] = 1. - * @param a_offset input: predictor coeffs a offset. - */ -private static void lsp_az( - float[] lsp, - float[] a, - int a_offset -) -{ - int M = Ld8k.M; - int NC = Ld8k.NC; - - float[] f1 = new float[NC+1], f2 = new float[NC+1]; - int i,j; - - - get_lsp_pol(lsp, 0,f1); - get_lsp_pol(lsp, 1,f2); - - for (i = NC; i > 0; i--) - { - f1[i] += f1[i-1]; - f2[i] -= f2[i-1]; - } - a[a_offset + 0] = 1.0f; - for (i = 1, j = M; i <= NC; i++, j--) - { - a[a_offset + i] = 0.5f*(f1[i] + f2[i]); - a[a_offset + j] = 0.5f*(f1[i] - f2[i]); - } -} - - -/** - * Find the polynomial F1(z) or F2(z) from the LSFs - * - * @param lsp input : line spectral freq. (cosine domain) - * @param lsp_offset input : line spectral freq offset - * @param f output: the coefficients of F1 or F2 - */ -private static void get_lsp_pol( - float lsp[], - int lsp_offset, - float f[] -) -{ - int NC = Ld8k.NC; - - float b; - int i,j; - - f[0] = 1.0f; - b = -2.0f*lsp[lsp_offset + 0]; - f[1] = b; - for (i = 2; i <= NC; i++) - { - b = -2.0f*lsp[lsp_offset + 2*i-2]; - f[i] = b*f[i-1] + 2.0f*f[i-2]; - for (j = i-1; j > 1; j--) - f[j] += b*f[j-1] + f[j-2]; - f[1] += b; - } -} - -/** - * Convert from lsf[0..M-1 to lsp[0..M-1] - * - * @param lsf input : lsf - * @param lsp output: lsp - * @param m input : length - */ -static void lsf_lsp( - float lsf[], - float lsp[], - int m -) -{ - int i; - for ( i = 0; i < m; i++ ) - lsp[i] = (float)Math.cos((double)lsf[i]); -} - -/** - * Convert from lsp[0..M-1 to lsf[0..M-1] - * - * @param lsp input : lsp coefficients - * @param lsf output: lsf (normalized frequencies - * @param m input: length - */ -static void lsp_lsf( - float lsp[], - float lsf[], - int m -) -{ - int i; - - for ( i = 0; i < m; i++ ) - lsf[i] = (float)Math.acos((double)lsp[i]); -} - - -/** - * Weighting of LPC coefficients ap[i] = a[i] * (gamma ** i) - * - * @param a input : lpc coefficients a[0:m] - * @param a_offset input : lpc coefficients offset - * @param gamma input : weighting factor - * @param m input : filter order - * @param ap output: weighted coefficients ap[0:m] - */ -static void weight_az( - float[] a, - int a_offset, - float gamma, - int m, - float[] ap -) -{ - float fac; - int i; - - ap[0] = a[a_offset + 0]; - fac = gamma; - for (i = 1; i SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Lspdec -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : LSPDEC.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -private static final int M = Ld8k.M; -private static final int MA_NP = Ld8k.MA_NP; - -/* static memory */ -/** - * Previous LSP vector - */ -private final float[][] freq_prev = new float[MA_NP][M]; -/** - * Previous LSP vector(init) - */ -private static final float[/* M */] FREQ_PREV_RESET = { - 0.285599f, 0.571199f, 0.856798f, 1.142397f, 1.427997f, - 1.713596f, 1.999195f, 2.284795f, 2.570394f, 2.855993f -}; /* PI*(float)(j+1)/(float)(M+1) */ - -/* static memory for frame erase operation */ -/** - * Previous MA prediction coef - */ -private int prev_ma; -/** - * Previous LSP vector - */ -private final float[] prev_lsp = new float[M]; - - -/** - * Set the previous LSP vectors. - */ -void lsp_decw_reset() -{ - int i; - - for(i=0; i>> NC0_B) & 1; - code0 = prm[prm_offset + 0] & (short)(NC0 - 1); - code1 = (prm[prm_offset + 1] >>> NC1_B) & (short)(NC1 - 1); - code2 = prm[prm_offset + 1] & (short)(NC1 - 1); - - Lspgetq.lsp_get_quant(lspcb1, lspcb2, code0, code1, code2, fg[mode_index], - freq_prev, lsp_q, fg_sum[mode_index]); - - Util.copy(lsp_q, prev_lsp, M ); - prev_ma = mode_index; - } - else /* Frame erased */ - { - Util.copy(prev_lsp, lsp_q, M ); - - /* update freq_prev */ - Lspgetq.lsp_prev_extract(prev_lsp, buf, - fg[prev_ma], freq_prev, fg_sum_inv[prev_ma]); - Lspgetq.lsp_prev_update(buf, freq_prev); - } -} - -/** - * Decode lsp parameters - * - * @param index input : indexes - * @param index_offset input : indexes offset - * @param lsp_q output: decoded lsp - * @param bfi input : frame erase information - */ -void d_lsp( - int index[], - int index_offset, - float lsp_q[], - int bfi -) -{ - int i; - - lsp_iqua_cs(index, index_offset, lsp_q,bfi); /* decode quantized information */ - - /* Convert LSFs to LSPs */ - - for (i=0; iSIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Lspgetq -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : LSPGETQ.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -/** - * Reconstruct quantized LSP parameter and check the stabilty - * - * @param lspcb1 input : first stage LSP codebook - * @param lspcb2 input : Second stage LSP codebook - * @param code0 input : selected code of first stage - * @param code1 input : selected code of second stage - * @param code2 input : selected code of second stage - * @param fg input : MA prediction coef. - * @param freq_prev input : previous LSP vector - * @param lspq output: quantized LSP parameters - * @param fg_sum input : present MA prediction coef. - */ -static void lsp_get_quant( - float lspcb1[][/* M */], - float lspcb2[][/* M */], - int code0, - int code1, - int code2, - float fg[][/* M */], - float freq_prev[][/* M */], - float lspq[], - float fg_sum[] -) -{ - float GAP1 = Ld8k.GAP1; - float GAP2 = Ld8k.GAP2; - int M = Ld8k.M; - int NC = Ld8k.NC; - - int j; - float[] buf = new float[M]; - - - for(j=0; j 0) { - buf[j-1] -= tmp; - buf[j] += tmp; - } - } -} - -/** - * Check for higher (5-9) - * - * @param buf in/out: lsp vectors - * @param gap input : gap - */ -static void lsp_expand_2( - float buf[], - float gap -) -{ - int M = Ld8k.M; - int NC = Ld8k.NC; - - int j; - float diff, tmp; - - for(j=NC; j 0) { - buf[j-1] -= tmp; - buf[j] += tmp; - } - } -} - -/** - * - * @param buf in/out: LSP parameters - * @param gap input: gap - */ -static void lsp_expand_1_2( - float buf[], - float gap -) -{ - int M = Ld8k.M; - - int j; - float diff, tmp; - - for(j=1; j 0) { - buf[j-1] -= tmp; - buf[j] += tmp; - } - } -} - - - -/* - Functions which use previous LSP parameter (freq_prev). -*/ - - -/** - * Compose LSP parameter from elementary LSP with previous LSP. - * - * @param lsp_ele (i) Q13 : LSP vectors - * @param lsp (o) Q13 : quantized LSP parameters - * @param fg (i) Q15 : MA prediction coef. - * @param freq_prev (i) Q13 : previous LSP vector - * @param fg_sum (i) Q15 : present MA prediction coef. - */ -private static void lsp_prev_compose( - float lsp_ele[], - float lsp[], - float fg[][/* M */], - float freq_prev[][/* M */], - float fg_sum[] -) -{ - int M = Ld8k.M; - int MA_NP = Ld8k.MA_NP; - - int j, k; - - for(j=0; j 0 ; k-- ) - Util.copy(freq_prev[k-1], freq_prev[k], M); - - Util.copy(lsp_ele, freq_prev[0], M); -} - -/** - * Check stability of lsp coefficients - * - * @param buf in/out: LSP parameters - */ -private static void lsp_stability( - float buf[] -) -{ - float GAP3 = Ld8k.GAP3; - float L_LIMIT = Ld8k.L_LIMIT; - int M = Ld8k.M; - float M_LIMIT = Ld8k.M_LIMIT; - - int j; - float diff, tmp; - - - for(j=0; j M_LIMIT ) { - buf[M-1] = M_LIMIT; - System.out.printf("warning LSP High \n"); - } -} -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/PParity.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/PParity.java deleted file mode 100644 index be9553731..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/PParity.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class PParity -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : P_PARITY.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -/** - * Compute parity bit for first 6 MSBs - * - * @param pitch_index input : index for which parity is computed - * @return parity bit (XOR of 6 MSB bits) - */ -static int parity_pitch( - int pitch_index -) -{ - int temp, sum, i, bit; - - temp = pitch_index >> 1; - - sum = 1; - for (i = 0; i <= 5; i++) { - temp >>= 1; - bit = temp & 1; - sum = sum + bit; - } - sum = sum & 1; - return (sum); -} - -/** - * Check parity of index with transmitted parity - * - * @param pitch_index input : index of parameter - * @param parity input : parity bit - * @return 0 = no error, 1= error - */ -static int check_parity_pitch( - int pitch_index, - int parity -) -{ - int temp, sum, i, bit; - temp = pitch_index >> 1; - - sum = 1; - for (i = 0; i <= 5; i++) { - temp >>= 1; - bit = temp & 1; - sum = sum + bit; - } - sum += parity; - sum = sum & 1; - return (sum); -} -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Pitch.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Pitch.java deleted file mode 100644 index 5b6934a52..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Pitch.java +++ /dev/null @@ -1,516 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * Long Term Prediction Routines - * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Pitch -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : PITCH.C - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - -/** - * Compute the open loop pitch lag. - * - * @param signal input : signal to compute pitch - * s[-PIT_MAX : l_frame-1] - * @param signal_offset input : signal offset - * @param pit_min input : minimum pitch lag - * @param pit_max input : maximum pitch lag - * @param l_frame input : error minimization window - * @return open-loop pitch lag - */ -static int pitch_ol( - float[] signal, - - int signal_offset, - int pit_min, - int pit_max, - int l_frame -) -{ - float THRESHPIT = Ld8k.THRESHPIT; - - float max1, max2, max3; - int p_max1, p_max2, p_max3; - - /*--------------------------------------------------------------------* - * The pitch lag search is divided in three sections. * - * Each section cannot have a pitch multiple. * - * We find a maximum for each section. * - * We compare the maxima of each section by favoring small lag. * - * * - * First section: lag delay = PIT_MAX to 80 * - * Second section: lag delay = 79 to 40 * - * Third section: lag delay = 39 to 20 * - *--------------------------------------------------------------------*/ - - FloatReference maxRef = new FloatReference(); - p_max1 = lag_max(signal, signal_offset, l_frame, pit_max, 80 , maxRef); - max1 = maxRef.value; - p_max2 = lag_max(signal, signal_offset, l_frame, 79 , 40 , maxRef); - max2 = maxRef.value; - p_max3 = lag_max(signal, signal_offset, l_frame, 39 , pit_min , maxRef); - max3 = maxRef.value; - - /*--------------------------------------------------------------------* - * Compare the 3 sections maxima, and favor small lag. * - *--------------------------------------------------------------------*/ - - if ( max1 * THRESHPIT < max2 ) { - max1 = max2; - p_max1 = p_max2; - } - - if ( max1 * THRESHPIT < max3 ) p_max1 = p_max3; - - return (p_max1); -} - -/** - * Find the lag that has maximum correlation - * - * @param signal input : Signal to compute the open loop pitch - * signal[-142:-1] should be known. - * @param signal_offset input : signal offset - * @param l_frame input : Length of frame to compute pitch - * @param lagmax input : maximum lag - * @param lagmin input : minimum lag - * @param cor_max input : normalized correlation of selected lag - * @return lag found - */ -private static int lag_max( - float[] signal, - int signal_offset, - int l_frame, - int lagmax, - int lagmin, - FloatReference cor_max -) -{ - float FLT_MIN_G729 = Ld8k.FLT_MIN_G729; - - int i, j; - int p, p1; - float max, t0; - int p_max = 0; - - max = FLT_MIN_G729; - - for (i = lagmax; i >= lagmin; i--) { - p = signal_offset; - p1 = signal_offset - i; - t0 = 0.0f; - - for (j=0; j= max) { - max = t0; - p_max = i; - } - } - - /* compute energy */ - - t0 = 0.01f; /* to avoid division by zero */ - p = signal_offset - p_max; - for(i=0; i= max) - { - max = corr[corr_offset + i]; - lag = i; - } - } - - /* If first subframe and lag > 84 do not search fractionnal pitch */ - - if( (i_subfr == 0) && (lag > 84) ) - { - pit_frac.value = 0; - return(lag); - } - - /* test the fractions around lag and choose the one which maximizes - the interpolated normalized correlation */ - corr_offset += lag; - max = interpol_3(corr, corr_offset, -2); - frac = -2; - - for (i = -1; i <= 2; i++) - { - corr_int = interpol_3(corr, corr_offset, i); - if(corr_int > max) - { - max = corr_int; - frac = i; - } - } - - /* limit the fraction value in the interval [-1,0,1] */ - - if (frac == -2) - { - frac = 1; - lag -= 1; - } - if (frac == 2) - { - frac = -1; - lag += 1; - } - - pit_frac.value = frac; - - return lag; -} - -/** - * Find the normalized correlation between the target vector and - * the filtered past excitation. - * - * @param exc input : excitation buffer - * @param exc_offset input : excitation buffer offset - * @param xn input : target vector - * @param h input : imp response of synth and weighting flt - * @param l_subfr input : Length of frame to compute pitch - * @param t_min input : minimum value of searched range - * @param t_max input : maximum value of search range - * @param corr_norm output: normalized correlation (correlation - * between target and filtered excitation divided - * by the square root of energy of filtered - * excitation) - * @param corr_norm_offset input: normalized correlation offset - */ -private static void norm_corr( - float[] exc, - int exc_offset, - float xn[], - float h[], - int l_subfr, - int t_min, - int t_max, - float corr_norm[], - int corr_norm_offset -) -{ - int L_SUBFR = Ld8k.L_SUBFR; - - int i, j, k; - float[] excf = new float[L_SUBFR]; /* filtered past excitation */ - float alp, s, norm; - - k = exc_offset -t_min; - - /* compute the filtered excitation for the first delay t_min */ - - Filter.convolve(exc, k, h, excf, l_subfr); - - /* loop for every possible period */ - - for (i = t_min; i <= t_max; i++) - { - /* Compute 1/sqrt(energie of excf[]) */ - - alp = 0.01f; - for (j = 0; j < l_subfr; j++) - alp += excf[j]*excf[j]; - - norm = inv_sqrt(alp); - - - /* Compute correlation between xn[] and excf[] */ - - s = 0.0f; - for (j = 0; j < l_subfr; j++) s += xn[j]*excf[j]; - - - /* Normalize correlation = correlation * (1/sqrt(energie)) */ - - corr_norm[corr_norm_offset + i] = s*norm; - - /* modify the filtered excitation excf[] for the next iteration */ - - if (i != t_max) - { - k--; - for (j = l_subfr-1; j > 0; j--) - excf[j] = excf[j-1] + exc[k]*h[j]; - excf[0] = exc[k]; - } - } -} - -/** - * Compute adaptive codebook gain and compute , -2 - * - * @param xn input : target vector - * @param y1 input : filtered adaptive codebook vector - * @param g_coeff output: and -2 - * @param l_subfr input : vector dimension - * @return pitch gain - */ -static float g_pitch( - float xn[], - float y1[], - float g_coeff[], - int l_subfr -) -{ - float GAIN_PIT_MAX = Ld8k.GAIN_PIT_MAX; - - float xy, yy, gain; - int i; - - xy = 0.0f; - for (i = 0; i < l_subfr; i++) { - xy += xn[i] * y1[i]; - } - yy = 0.01f; - for (i = 0; i < l_subfr; i++) { - yy += y1[i] * y1[i]; /* energy of filtered excitation */ - } - g_coeff[0] = yy; - g_coeff[1] = -2.0f*xy +0.01f; - - /* find pitch gain and bound it by [0,1.2] */ - - gain = xy/yy; - - if (gain<0.0f) gain = 0.0f; - if (gain>GAIN_PIT_MAX) gain = GAIN_PIT_MAX; - - return gain; -} - -/** - * Function enc_lag3() - * Encoding of fractional pitch lag with 1/3 resolution. - *
- * The pitch range for the first subframe is divided as follows:
- *   19 1/3  to   84 2/3   resolution 1/3
- *   85      to   143      resolution 1
- *
- * The period in the first subframe is encoded with 8 bits.
- * For the range with fractions:
- *   index = (T-19)*3 + frac - 1;   where T=[19..85] and frac=[-1,0,1]
- * and for the integer only range
- *   index = (T - 85) + 197;        where T=[86..143]
- *----------------------------------------------------------------------
- * For the second subframe a resolution of 1/3 is always used, and the
- * search range is relative to the lag in the first subframe.
- * If t0 is the lag in the first subframe then
- *  t_min=t0-5   and  t_max=t0+4   and  the range is given by
- *       t_min - 2/3   to  t_max + 2/3
- *
- * The period in the 2nd subframe is encoded with 5 bits:
- *   index = (T-(t_min-1))*3 + frac - 1;    where T[t_min-1 .. t_max+1]
- * 
- * - * @param T0 input : Pitch delay - * @param T0_frac input : Fractional pitch delay - * @param T0_min in/out: Minimum search delay - * @param T0_max in/out: Maximum search delay - * @param pit_min input : Minimum pitch delay - * @param pit_max input : Maximum pitch delay - * @param pit_flag input : Flag for 1st subframe - * @return Return index of encoding - */ -static int enc_lag3( - int T0, - int T0_frac, - IntReference T0_min, - IntReference T0_max, - int pit_min, - int pit_max, - int pit_flag -) -{ - int index; - int _T0_min = T0_min.value, _T0_max = T0_max.value; - - if (pit_flag == 0) /* if 1st subframe */ - { - /* encode pitch delay (with fraction) */ - - if (T0 <= 85) - index = T0*3 - 58 + T0_frac; - else - index = T0 + 112; - - /* find T0_min and T0_max for second subframe */ - - _T0_min = T0 - 5; - if (_T0_min < pit_min) _T0_min = pit_min; - _T0_max = _T0_min + 9; - if (_T0_max > pit_max) - { - _T0_max = pit_max; - _T0_min = _T0_max - 9; - } - } - - else /* second subframe */ - { - index = T0 - _T0_min; - index = index*3 + 2 + T0_frac; - } - T0_min.value = _T0_min; - T0_max.value = _T0_max; - return index; -} - -/** - * For interpolating the normalized correlation - * - * @param x input : function to be interpolated - * @param x_offset input : function offset - * @param frac input : fraction value to evaluate - * @return interpolated value - */ -private static float interpol_3( - float[] x, - int x_offset, - int frac -) -{ - int L_INTER4 = Ld8k.L_INTER4; - int UP_SAMP = Ld8k.UP_SAMP; - float[] inter_3 = TabLd8k.inter_3; - - int i; - float s; - int x1, x2, c1, c2; - - if (frac < 0) { - frac += UP_SAMP; - x_offset--; - } - x1 = x_offset; - x2 = x_offset + 1; - c1 = frac; - c2 = UP_SAMP-frac; - - s = 0.0f; - for(i=0; i< L_INTER4; i++, c1+=UP_SAMP, c2+=UP_SAMP) - { - s+= x[x1] * inter_3[c1] + x[x2] * inter_3[c2]; - x1--; - x2++; - } - - return s; -} - -/** - * Compute y = 1 / sqrt(x) - * - * @param x input : value of x - * @return output: 1/sqrt(x) - */ -private static float inv_sqrt( - float x -) -{ - return (1.0f / (float)Math.sqrt((double)x) ); -} -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/PostPro.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/PostPro.java deleted file mode 100644 index 5c9c99e1a..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/PostPro.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * Post-processing of output speech. - * 2nd order high pass filter with cut off frequency at 100 Hz. - * Designed with SPPACK efi command -40 dB att, 0.25 ri. - * - * Algorithm: - *
- *  y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2]
- *                   + a[1]*y[i-1] + a[2]*y[i-2];
- *
- *     b[3] = {0.93980581E+00, -0.18795834E+01,  0.93980581E+00};
- *     a[3] = {0.10000000E+01, +0.19330735E+01, -0.93589199E+00};
- * 
- * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class PostPro -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : POST_PRO.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -/** - * High-pass fir memory - */ -private float x0, x1; - -/** - * High-pass iir memory - */ -private float y1, y2; - -/** - * Init Post Process. - */ -void init_post_process() -{ - x0 = x1 = 0.0f; - y2 = y1 = 0.0f; -} - -/** - * Post Process - * - * @param signal (i/o) : signal - * @param lg (i) : lenght of signal - */ -void post_process( - float signal[], - int lg -) -{ - float[] a100 = TabLd8k.a100; - float[] b100 = TabLd8k.b100; - - int i; - float x2; - float y0; - - for(i=0; iSIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * Post - filtering : short term + long term. - * Floating point computation. - *
- *      Short term postfilter :
- *      Hst(z) = Hst0(z) Hst1(z)
- *      Hst0(z) = 1/g0 A(gamma2)(z) / A(gamma1)(z)
- *      if {hi} = i.r. filter A(gamma2)/A(gamma1) (truncated)
- *      g0 = SUM(|hi|) if > 1
- *      g0 = 1. else
- *      Hst1(z) = 1/(1+ |mu|) (1 + mu z-1)
- *      with mu = 1st parcor calculated on {hi}
-
- *      Long term postfilter :
- *      harmonic postfilter :   H0(z) = gl * (1 + b * z-p)
- *      b = gamma_g * gain_ltp
- *      gl = 1 / 1 + b
- *      copmuation of delay on A(gamma2)(z) s(z)
- *      sub optimal research
- *      1. search best integer delay
- *      2. search around integer sub multiples (3 val. / sub mult)
- *      3. search around integer with fractionnal delays (1/8)
- * 
- * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Postfil - extends Ld8k -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : POSTFIL.C - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - -/* Static arrays and variables */ -/** - * s.t. numerator coeff. - */ -private final float[] apond2 = new float[LONG_H_ST]; - -/** - * s.t. postfilter memory - */ -private final float[] mem_stp = new float[M]; - -/** - * null memory to compute h_st - */ -private final float[] mem_zero = new float[M]; - -/** - * A(gamma2) residual - */ -private final float[] res2 = new float[SIZ_RES2]; - -/* Static pointers */ -private int res2_ptr; -private float[] ptr_mem_stp; -private int ptr_mem_stp_offset; - -/** - * for gain adjustment - */ -private float gain_prec; - -/** - * Initialize postfilter functions - */ -void init_post_filter() -{ - int i; - - /* Initialize arrays and pointers */ - - /* A(gamma2) residual */ - for(i=0; iLONG_H_ST-1] with zeroes */ - for(i=MP1; i 0 delay - */ -int post( - int t0, - float[] signal_ptr, - int signal_ptr_offset, - float[] coeff, - int coeff_offset, - float[] sig_out, - int sig_out_offset -) -{ - int vo; /* output: voicing decision 0 = uv, > 0 delay */ - - float[] apond1 = new float[MP1]; /* s.t. denominator coeff. */ - float[] sig_ltp = new float[L_SUBFRP1]; /* H0 output signal */ - int sig_ltp_ptr; - float parcor0; - - /* Compute weighted LPC coefficients */ - Lpcfunc.weight_az(coeff, coeff_offset, GAMMA1_PST, M, apond1); - Lpcfunc.weight_az(coeff, coeff_offset, GAMMA2_PST, M, apond2); - - /* Compute A(gamma2) residual */ - Filter.residu(apond2, 0, signal_ptr, signal_ptr_offset, res2, res2_ptr, L_SUBFR); - - /* Harmonic filtering */ - sig_ltp_ptr = 1; - vo = pst_ltp(t0, res2, res2_ptr, sig_ltp, sig_ltp_ptr); - - /* Save last output of 1/A(gamma1) */ - /* (from preceding subframe) */ - sig_ltp[0] = ptr_mem_stp[ptr_mem_stp_offset]; - - /* Control short term pst filter gain and compute parcor0 */ - parcor0 = calc_st_filt(apond2, apond1, sig_ltp, sig_ltp_ptr); - - /* 1/A(gamma1) filtering, mem_stp is updated */ - Filter.syn_filt(apond1, 0, sig_ltp, sig_ltp_ptr, sig_ltp, sig_ltp_ptr, L_SUBFR, mem_stp, 0, 1); - - /* (1 + mu z-1) tilt filtering */ - filt_mu(sig_ltp, sig_out, sig_out_offset, parcor0); - - /* gain control */ - gain_prec = scale_st(signal_ptr, signal_ptr_offset, sig_out, sig_out_offset, gain_prec); - - /* Update for next frame */ - Util.copy(res2, L_SUBFR, res2, MEM_RES2); - - return vo; -} - -/** - * Harmonic postfilter - * - * @param t0 input : pitch delay given by coder - * @param ptr_sig_in input : postfilter input filter (residu2) - * @param ptr_sig_in_offset input : postfilter input filter offset - * @param ptr_sig_pst0 output: harmonic postfilter output - * @param ptr_sig_pst0_offset input: harmonic postfilter offset - * @return voicing decision 0 = uv, > 0 delay - */ -private int pst_ltp( - int t0, - float[] ptr_sig_in, - int ptr_sig_in_offset, - float[] ptr_sig_pst0, - int ptr_sig_pst0_offset -) -{ - int vo; - -/* Declare variables */ - int ltpdel, phase; - float num_gltp, den_gltp; - float num2_gltp, den2_gltp; - float gain_plt; - float[] y_up = new float[SIZ_Y_UP]; - float[] ptr_y_up; - int ptr_y_up_offset; - int off_yup; - - /* Sub optimal delay search */ - IntReference _ltpdel = new IntReference(); - IntReference _phase = new IntReference(); - FloatReference _num_gltp = new FloatReference(); - FloatReference _den_gltp = new FloatReference(); - IntReference _off_yup = new IntReference(); - search_del(t0, ptr_sig_in, ptr_sig_in_offset, _ltpdel, _phase, _num_gltp, _den_gltp, - y_up, _off_yup); - ltpdel = _ltpdel.value; - phase = _phase.value; - num_gltp = _num_gltp.value; - den_gltp = _den_gltp.value; - off_yup = _off_yup.value; - - vo = ltpdel; - - if(num_gltp == 0.f) { - Util.copy(ptr_sig_in, ptr_sig_in_offset, ptr_sig_pst0, ptr_sig_pst0_offset, L_SUBFR); - } - else { - - if(phase == 0) { - ptr_y_up = ptr_sig_in; - ptr_y_up_offset = ptr_sig_in_offset - ltpdel; - } - - else { - /* Filtering with long filter */ - FloatReference _num2_gltp = new FloatReference(); - FloatReference _den2_gltp = new FloatReference(); - compute_ltp_l(ptr_sig_in, ptr_sig_in_offset, ltpdel, phase, ptr_sig_pst0, ptr_sig_pst0_offset, - _num2_gltp, _den2_gltp); - num2_gltp = _num2_gltp.value; - den2_gltp = _den2_gltp.value; - - if(select_ltp(num_gltp, den_gltp, num2_gltp, den2_gltp) == 1) { - - /* select short filter */ - ptr_y_up = y_up; - ptr_y_up_offset = ((phase-1) * L_SUBFRP1 + off_yup); - } - else { - /* select long filter */ - num_gltp = num2_gltp; - den_gltp = den2_gltp; - ptr_y_up = ptr_sig_pst0; - ptr_y_up_offset = ptr_sig_pst0_offset; - } - } - - if(num_gltp > den_gltp) { - /* beta bounded to 1 */ - gain_plt = MIN_GPLT; - } - else { - gain_plt = den_gltp / (den_gltp + GAMMA_G * num_gltp); - } - - /* filtering by H0(z) (harmonic filter) */ - filt_plt(ptr_sig_in, ptr_sig_in_offset, ptr_y_up, ptr_y_up_offset, ptr_sig_pst0, ptr_sig_pst0_offset, gain_plt); - } - return vo; -} - -/** - * Computes best (shortest) integer LTP delay + fine search - * - * @param t0 input : pitch delay given by coder - * @param ptr_sig_in input : input signal (with delay line) - * @param ptr_sig_in_offset input : input signal offset - * @param ltpdel output: delay = *ltpdel - *phase / f_up - * @param phase output: phase - * @param num_gltp output: numerator of LTP gain - * @param den_gltp output: denominator of LTP gain - * @param y_up - * @param off_yup - */ -private void search_del( - int t0, - float[] ptr_sig_in, - int ptr_sig_in_offset, - IntReference ltpdel, - IntReference phase, - FloatReference num_gltp, - FloatReference den_gltp, - float[] y_up, - IntReference off_yup -) -{ - float[] tab_hup_s = TabLd8k.tab_hup_s; - - /* pointers on tables of constants */ - int ptr_h; - - /* Variables and local arrays */ - float[] tab_den0 = new float[F_UP_PST-1], tab_den1 = new float[F_UP_PST-1]; - int ptr_den0, ptr_den1; - int ptr_sig_past, ptr_sig_past0; - int ptr1; - - int i, n, ioff, i_max; - float ener, num, numsq, den0, den1; - float den_int, num_int; - float den_max, num_max, numsq_max; - int phi_max; - int lambda, phi; - float temp0, temp1; - int ptr_y_up; - - - /* Compute current signal energy */ - ener = 0.f; - for(i=0; i num_int) { - i_max = i; - num_int = num; - } - ptr_sig_past--; - } - if(num_int <= 0.f) { - num_gltp.value = 0.f; - den_gltp.value = 1.f; - ltpdel.value = 0; - phase.value = 0; - return; - } - - /* Calculates denominator for lambda_max */ - lambda += i_max; - ptr_sig_past = ptr_sig_in_offset - lambda; - den_int=0.f; - for(n=0; nMath.abs(y_up[ptr_y_up + L_SUBFR])) { - if(den0 > den_max) { - den_max = den0; - } - } - else { - if(den1 > den_max) { - den_max = den1; - } - } - ptr_y_up += L_SUBFRP1; - ptr_h += LH2_S; - } - if(den_max < 0.1f ) { - num_gltp.value = 0.f; - den_gltp.value = 1.f; - ltpdel.value = 0; - phase.value = 0; - return; - } - /* Computation of the numerators */ - /* and selection of best num*num/den */ - /* for non null phases */ - - /* Initialize with null phase */ - num_max = num_int; - den_max = den_int; - numsq_max = num_max * num_max; - phi_max = 0; - ioff = 1; - - ptr_den0 = 0; - ptr_den1 = 0; - ptr_y_up = 0; - - /* if den_max = 0 : will be selected and declared unvoiced */ - /* if num!=0 & den=0 : will be selected and declared unvoiced */ - /* degenerated seldom cases, switch off LT is OK */ - - /* Loop on phase */ - for(phi=1; phi temp1) { - num_max = num; - numsq_max = numsq; - den_max = den0; - ioff = 0; - phi_max = phi; - } - - /* computes num for lambda_max - phi/F_UP_PST */ - ptr_y_up++; - num = 0.f; - for(n = 0; n temp1) { - num_max = num; - numsq_max = numsq; - den_max = den1; - ioff = 1; - phi_max = phi; - } - ptr_y_up += L_SUBFR; - } - - /* test if normalised crit0[iopt] > THRESCRIT */ - - if((num_max == 0.f) || (den_max <= 0.1f)) { - num_gltp.value = 0.f; - den_gltp.value = 1.f; - ltpdel.value = 0; - phase.value = 0; - return; - } - - /* comparison num * num */ - /* with ener * den x THRESCRIT */ - temp1 = den_max * ener * THRESCRIT; - if(numsq_max >= temp1) { - ltpdel.value = lambda + 1 - ioff; - off_yup.value = ioff; - phase.value = phi_max; - num_gltp.value = num_max; - den_gltp.value = den_max; - } - else { - num_gltp.value = 0.f; - den_gltp.value = 1.f; - ltpdel.value = 0; - phase.value = 0; - } -} - -/** - * Ltp postfilter - * - * @param s_in input : input signal with past - * @param s_in_offset input : input signal offset - * @param s_ltp input : filtered signal with gain 1 - * @param s_ltp_offset input : filtered signal offset - * @param s_out output: output signal - * @param s_out_offset input: output signal offset - * @param gain_plt input : filter gain - */ -private void filt_plt( - float[] s_in, - int s_in_offset, - float[] s_ltp, - int s_ltp_offset, - float[] s_out, - int s_out_offset, - float gain_plt -) -{ - - /* Local variables */ - int n; - float temp; - float gain_plt_1; - - gain_plt_1 = 1.f - gain_plt; - - for(n=0; n num1 * num1 * den2) { - return(2); - } - else { - return(1); - } -} - -/** - * Computes impulse response of A(gamma2) / A(gamma1). - * controls gain : computation of energy impulse response as - * SUMn (abs (h[n])) and computes parcor0 - * - * @param apond2 input : coefficients of numerator - * @param apond1 input : coefficients of denominator - * @param sig_ltp_ptr in/out: input of 1/A(gamma1) : scaled by 1/g0 - * @param sig_ltp_ptr_offset input : input of 1/A(gamma1) ... offset - * @return 1st parcor calcul. on composed filter - */ -private float calc_st_filt( - float[] apond2, - float[] apond1, - float[] sig_ltp_ptr, - int sig_ltp_ptr_offset -) -{ - float[] h = new float[LONG_H_ST]; - float parcor0; /* output: 1st parcor calcul. on composed filter */ - float g0, temp; - - /* computes impulse response of apond1 / apond2 */ - Filter.syn_filt(apond1, 0, apond2, 0, h, 0, LONG_H_ST, mem_zero, 0, 0); - - /* computes 1st parcor */ - parcor0 = calc_rc0_h(h); - - /* computes gain g0 */ - g0 = 0.f; - for(int i=0; i 1.f) { - temp = 1.f/g0; - for(int i=sig_ltp_ptr_offset, toIndex = sig_ltp_ptr_offset + L_SUBFR; i 0.f) { - mu = parcor0 * GAMMA3_PLUS; - } - else { - mu = parcor0 * GAMMA3_MINUS; - } - ga = 1.f / (1.f - Math.abs(mu)); - - ptrs = 0; /* points on sig_in(-1) */ - for(n=0; nSIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * Preprocessing of input speech. - * - 2nd order high pass filter with cut off frequency at 140 Hz. - * - * 2nd order high pass filter with cut off frequency at 140 Hz. - * Designed with SPPACK efi command -40 dB att, 0.25 ri. - * - * Algorithm: - *
- *  y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2]
- *                   + a[1]*y[i-1] + a[2]*y[i-2];
- *
- *     b[3] = {0.92727435E+00, -0.18544941E+01, 0.92727435E+00};
- *     a[3] = {0.10000000E+01, 0.19059465E+01, -0.91140240E+00};
- * 
- * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class PreProc -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : PRE_PROC.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -/** - * High-pass fir memory - */ -private float x0, x1; - -/** - * High-pass iir memory - */ -private float y1, y2; - -/** - * Init Pre Process - */ -void init_pre_process() -{ - x0 = x1 = 0.0f; - y2 = y1 = 0.0f; -} - -/** - * Pre Process - * - * @param signal (i/o) : signal - * @param signal_offset (input) : signal offset - * @param lg (i) : length of signal - */ -void pre_process( - float[] signal, - int signal_offset, - int lg -) -{ - float[] a140 = TabLd8k.a140; - float[] b140 = TabLd8k.b140; - - float x2; - float y0; - - for(int i=signal_offset, toIndex=lg+signal_offset; iSIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class PredLt3 -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : PRED_LT3.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -/** - * Compute the result of long term prediction with fractional - * interpolation of resolution 1/3. - * - * On return exc[0..L_subfr-1] contains the interpolated signal - * (adaptive codebook excitation) - * - * @param exc in/out: excitation vector, exc[0:l_sub-1] = out - * @param exc_offset input: excitation vector offset - * @param t0 input : pitch lag - * @param frac input : Fraction of pitch lag (-1, 0, 1) / 3 - * @param l_subfr input : length of subframe. - */ -static void pred_lt_3( - float[] exc, - int exc_offset, - int t0, - int frac, - int l_subfr -) -{ - int L_INTER10 = Ld8k.L_INTER10; - int UP_SAMP = Ld8k.UP_SAMP; - float[] inter_3l = TabLd8k.inter_3l; - - int i, j, k; - float s; - int x0, x1, x2, c1, c2; - - x0 = exc_offset - t0; - - frac = -frac; - if (frac < 0) { - frac += UP_SAMP; - x0--; - } - - for (j=0; jSIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Pwf -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : PWF.C - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - - -private int smooth = 1; -private final float[/* 2 */] lar_old = {0.0f, 0.0f}; - -/** - * Adaptive bandwidth expansion for perceptual weighting filter - * - * @param gamma1 output: gamma1 value - * @param gamma2 output: gamma2 value - * @param lsfint input : Interpolated lsf vector : 1st subframe - * @param lsfnew input : lsf vector : 2nd subframe - * @param r_c input : Reflection coefficients - */ -void perc_var( - float[] gamma1, - float[] gamma2, - float[] lsfint, - float[] lsfnew, - float[] r_c -) -{ - float ALPHA = Ld8k.ALPHA; - float BETA = Ld8k.BETA; - float GAMMA1_0 = Ld8k.GAMMA1_0; - float GAMMA1_1 = Ld8k.GAMMA1_1; - float GAMMA2_0_H = Ld8k.GAMMA2_0_H; - float GAMMA2_0_L = Ld8k.GAMMA2_0_L; - float GAMMA2_1 = Ld8k.GAMMA2_1; - int M = Ld8k.M; - float THRESH_H1 = Ld8k.THRESH_H1; - float THRESH_H2 = Ld8k.THRESH_H2; - float THRESH_L1 = Ld8k.THRESH_L1; - float THRESH_L2 = Ld8k.THRESH_L2; - - float[] lar = new float[4]; - float[] lsf; - float critlar0, critlar1; - float d_min, temp; - int i, k; - - - float[] lar_new = lar; - int lar_new_offset = 2; - - /* reflection coefficients --> lar */ - for (i=0; i<2; i++) - lar_new[lar_new_offset + i] = (float)Math.log10( (double)( ( 1.0f + r_c[i]) / (1.0f - r_c[i]))); - - /* Interpolation of lar for the 1st subframe */ - for (i=0; i<2; i++) { - lar[i] = 0.5f * (lar_new[lar_new_offset + i] + lar_old[i]); - lar_old[i] = lar_new[lar_new_offset + i]; - } - - for (k=0; k<2; k++) { /* LOOP : gamma2 for 1st to 2nd subframes */ - - /* ----------------------------------------------------- */ - /* First criterion based on the first two lars */ - /* */ - /* smooth == 1 ==> gamma2 is set to 0.6 */ - /* gamma1 is set to 0.94 */ - /* */ - /* smooth == 0 ==> gamma2 can vary from 0.4 to 0.7 */ - /* (gamma2 = -6.0 dmin + 1.0) */ - /* gamma1 is set to 0.98 */ - /* ----------------------------------------------------- */ - critlar0 = lar[2*k]; - critlar1 = lar[2*k+1]; - - if (smooth != 0) { - if ((critlar0 THRESH_H1)) smooth = 0; - } - else { - if ((critlar0 > THRESH_L2)||(critlar1 < THRESH_H2)) smooth = 1; - } - - if (smooth == 0) { - /* ------------------------------------------------------ */ - /* Second criterion based on the minimum distance between */ - /* two successives lsfs */ - /* ------------------------------------------------------ */ - gamma1[k] = GAMMA1_0; - if (k == 0) lsf = lsfint; - else lsf = lsfnew; - d_min = lsf[1] - lsf[0]; - for (i=1; i GAMMA2_0_H) gamma2[k] = GAMMA2_0_H; - if (gamma2[k] < GAMMA2_0_L) gamma2[k] = GAMMA2_0_L; - } - else { - gamma1[k] = GAMMA1_1; - gamma2[k] = GAMMA2_1;; - } - } -} -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/QuaGain.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/QuaGain.java deleted file mode 100644 index 3f7407f78..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/QuaGain.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class QuaGain -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : QUA_GAIN.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - - -/* gain quantizer routines */ - -private final float[/* 4 */] past_qua_en={-14.0f,-14.0f,-14.0f,-14.0f}; - -/** - * Quantization of pitch and codebook gains - * - * @param code input : fixed codebook vector - * @param g_coeff input : correlation factors - * @param l_subfr input : fcb vector length - * @param gain_pit output: quantized acb gain - * @param gain_code output: quantized fcb gain - * @param tameflag input : flag set to 1 if taming is needed - * @return quantizer index - */ -int qua_gain( - float code[], - float[] g_coeff, - int l_subfr, - FloatReference gain_pit, - FloatReference gain_code, - int tameflag -) -{ - float FLT_MAX_G729 = Ld8k.FLT_MAX_G729; - float GP0999 = Ld8k.GP0999; - float GPCLIP2 = Ld8k.GPCLIP2; - int NCAN1 = Ld8k.NCAN1; - int NCAN2 = Ld8k.NCAN2; - int NCODE2 = Ld8k.NCODE2; - float[][] gbk1 = TabLd8k.gbk1; - float[][] gbk2 = TabLd8k.gbk2; - int[] map1 = TabLd8k.map1; - int[] map2 = TabLd8k.map2; - - /* - * MA prediction is performed on the innovation energy (in dB with mean * - * removed). * - * An initial predicted gain, g_0, is first determined and the correction * - * factor alpha = gain / g_0 is quantized. * - * The pitch gain and the correction factor are vector quantized and the * - * mean-squared weighted error criterion is used in the quantizer search. * - * CS Codebook , fast pre-selection version * - */ - - int i,j, index1 = 0, index2 = 0; - int cand1,cand2 ; - float gcode0 ; - float dist, dist_min, g_pitch, g_code; - float[] best_gain = new float[2]; - float tmp; - - /*---------------------------------------------------* - *- energy due to innovation -* - *- predicted energy -* - *- predicted codebook gain => gcode0[exp_gcode0] -* - *---------------------------------------------------*/ - - gcode0 = Gainpred.gain_predict( past_qua_en, code, l_subfr); - - /*-- pre-selection --*/ - tmp = -1.f/(4.f*g_coeff[0]*g_coeff[2]-g_coeff[4]*g_coeff[4]) ; - best_gain[0] = (2.f*g_coeff[2]*g_coeff[1]-g_coeff[3]*g_coeff[4])*tmp ; - best_gain[1] = (2.f*g_coeff[0]*g_coeff[3]-g_coeff[1]*g_coeff[4])*tmp ; - - if (tameflag == 1){ - if(best_gain[0]> GPCLIP2) best_gain[0] = GPCLIP2; - } - /*----------------------------------------------* - * - presearch for gain codebook - * - *----------------------------------------------*/ - - IntReference cand1Ref = new IntReference(); - IntReference cand2Ref = new IntReference(); - gbk_presel(best_gain,cand1Ref,cand2Ref,gcode0) ; - cand1 = cand1Ref.value; - cand2 = cand2Ref.value; - - /*-- selection --*/ - dist_min = FLT_MAX_G729; - if(tameflag == 1) { - for (i=0;i0.0f){ - /* pre select codebook #1 */ - _cand1 = 0 ; - do{ - if(y>thr1[_cand1]*gcode0) (_cand1)++ ; - else break ; - } while((_cand1)<(NCODE1-NCAN1)) ; - /* pre select codebook #2 */ - _cand2 = 0 ; - do{ - if(x>thr2[_cand2]*gcode0) (_cand2)++ ; - else break ; - } while((_cand2)<(NCODE2-NCAN2)) ; - } - else{ - /* pre select codebook #1 */ - _cand1 = 0 ; - do{ - if(ySIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * Functions related to the quantization of LSP's. - * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class QuaLsp -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : QUA_LSP.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -/* static memory */ -/** - * previous LSP vector - */ -private final float[][] freq_prev = new float[Ld8k.MA_NP][Ld8k.M]; - -/** - * previous LSP vector(init) - */ -private static final float[/* M */] FREQ_PREV_RESET = { - 0.285599f, 0.571199f, 0.856798f, 1.142397f, 1.427997f, - 1.713596f, 1.999195f, 2.284795f, 2.570394f, 2.855993f -}; /* PI*(float)(j+1)/(float)(M+1) */ - -/** - * @param lsp (i) : Unquantized LSP - * @param lsp_q (o) : Quantized LSP - * @param ana (o) : indexes - */ -void qua_lsp( - float lsp[], - float lsp_q[], - int ana[] -) -{ - int M = Ld8k.M; - - int i; - float[] lsf = new float[M], lsf_q = new float[M]; /* domain 0.0<= lsf 0.0f) wegt[0] = 1.0f; - else wegt[0] = tmp * tmp * 10.f + 1.0f; - - for ( i=1; i 0.0f) wegt[i] = 1.0f; - else wegt[i] = tmp * tmp * 10.f + 1.0f; - } - - tmp = PI92 - flsp[M-2] - 1.0f; - if (tmp > 0.0f) wegt[M-1] = 1.0f; - else wegt[M-1] = tmp * tmp * 10.f + 1.0f; - - wegt[4] *= CONST12; - wegt[5] *= CONST12; -} - -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/TabLd8k.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/TabLd8k.java deleted file mode 100644 index f21e69639..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/TabLd8k.java +++ /dev/null @@ -1,2626 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class TabLd8k -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : TAB_LD8K.H - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - -u---------------------------------------------------------------------- -*/ - -/* - File : TAB_LD8K.C - Used for the floating point version of G.729 main body - (not for G.729A) -*/ - -static final float[/* L_WINDOW */] hamwindow = { -0.08000000f, -0.08005703f, -0.08022812f, -0.08051321f, -0.08091225f, -0.08142514f, -0.08205172f, -0.08279188f, -0.08364540f, -0.08461212f, -0.08569173f, -0.08688401f, -0.08818865f, -0.08960532f, -0.09113365f, -0.09277334f, -0.09452391f, -0.09638494f, -0.09835598f, -0.10043652f, -0.10262608f, -0.10492408f, -0.10732999f, -0.10984316f, -0.11246302f, -0.11518890f, -0.11802010f, -0.12095598f, -0.12399574f, -0.12713866f, -0.13038395f, -0.13373083f, -0.13717847f, -0.14072597f, -0.14437246f, -0.14811710f, -0.15195890f, -0.15589692f, -0.15993017f, -0.16405767f, -0.16827843f, -0.17259133f, -0.17699537f, -0.18148938f, -0.18607232f, -0.19074300f, -0.19550033f, -0.20034306f, -0.20527001f, -0.21027996f, -0.21537170f, -0.22054392f, -0.22579536f, -0.23112471f, -0.23653066f, -0.24201185f, -0.24756692f, -0.25319457f, -0.25889328f, -0.26466170f, -0.27049842f, -0.27640197f, -0.28237087f, -0.28840363f, -0.29449883f, -0.30065489f, -0.30687031f, -0.31314352f, -0.31947297f, -0.32585713f, -0.33229437f, -0.33878314f, -0.34532180f, -0.35190874f, -0.35854232f, -0.36522087f, -0.37194279f, -0.37870640f, -0.38550997f, -0.39235184f, -0.39923036f, -0.40614375f, -0.41309035f, -0.42006844f, -0.42707625f, -0.43411207f, -0.44117412f, -0.44826069f, -0.45537004f, -0.46250033f, -0.46964988f, -0.47681686f, -0.48399949f, -0.49119604f, -0.49840465f, -0.50562358f, -0.51285106f, -0.52008528f, -0.52732444f, -0.53456670f, -0.54181033f, -0.54905349f, -0.55629444f, -0.56353134f, -0.57076240f, -0.57798582f, -0.58519983f, -0.59240264f, -0.59959245f, -0.60676748f, -0.61392599f, -0.62106609f, -0.62818617f, -0.63528436f, -0.64235890f, -0.64940804f, -0.65643007f, -0.66342324f, -0.67038584f, -0.67731601f, -0.68421221f, -0.69107264f, -0.69789559f, -0.70467937f, -0.71142232f, -0.71812278f, -0.72477907f, -0.73138952f, -0.73795253f, -0.74446648f, -0.75092971f, -0.75734061f, -0.76369762f, -0.76999915f, -0.77624369f, -0.78242958f, -0.78855544f, -0.79461962f, -0.80062068f, -0.80655706f, -0.81242740f, -0.81823015f, -0.82396388f, -0.82962728f, -0.83521879f, -0.84073710f, -0.84618086f, -0.85154873f, -0.85683930f, -0.86205131f, -0.86718345f, -0.87223446f, -0.87720311f, -0.88208807f, -0.88688827f, -0.89160240f, -0.89622939f, -0.90076804f, -0.90521723f, -0.90957582f, -0.91384280f, -0.91801709f, -0.92209762f, -0.92608339f, -0.92997342f, -0.93376678f, -0.93746245f, -0.94105959f, -0.94455731f, -0.94795465f, -0.95125085f, -0.95444512f, -0.95753652f, -0.96052444f, -0.96340811f, -0.96618676f, -0.96885973f, -0.97142631f, -0.97388595f, -0.97623801f, -0.97848189f, -0.98061699f, -0.98264289f, -0.98455900f, -0.98636484f, -0.98806006f, -0.98964417f, -0.99111670f, -0.99247742f, -0.99372596f, -0.99486196f, -0.99588519f, -0.99679530f, -0.99759221f, -0.99827564f, -0.99884540f, -0.99930143f, -0.99964350f, -0.99987161f, -0.99998569f, -1.00000000f, -0.99921930f, -0.99687845f, -0.99298108f, -0.98753333f, -0.98054361f, -0.97202289f, -0.96198452f, -0.95044410f, -0.93741965f, -0.92293155f, -0.90700239f, -0.88965708f, -0.87092263f, -0.85082841f, -0.82940567f, -0.80668795f, -0.78271067f, -0.75751126f, -0.73112911f, -0.70360541f, -0.67498308f, -0.64530689f, -0.61462307f, -0.58297962f, -0.55042595f, -0.51701277f, -0.48279238f, -0.44781810f, -0.41214463f, -0.37582767f, -0.33892387f, -0.30149087f, -0.26358715f, -0.22527184f, -0.18660481f, -0.14764643f, -0.10845750f, -0.06909923f, -0.02963307f -}; - -static final float[/* M */] lwindow = { -0.99879038f, -0.99546894f, -0.98995779f, -0.98229335f, -0.97252620f, -0.96072035f, -0.94695264f, -0.93131180f, -0.91389754f, -0.89481964f -}; - -static final float[/* GRID_POINTS+1 */] grid = { -0.9997559f, -0.9986295f, -0.9945219f, -0.9876884f, -0.9781476f, -0.9659258f, -0.9510565f, -0.9335804f, -0.9135454f, -0.8910065f, -0.8660254f, -0.8386706f, -0.8090170f, -0.7771460f, -0.7431448f, -0.7071068f, -0.6691306f, -0.6293204f, -0.5877852f, -0.5446391f, -0.5000000f, -0.4539905f, -0.4067366f, -0.3583679f, -0.3090170f, -0.2588190f, -0.2079117f, -0.1564345f, -0.1045285f, -0.0523360f, -0.0000000f, --0.0523360f, --0.1045285f, --0.1564345f, --0.2079117f, --0.2588190f, --0.3090170f, --0.3583679f, --0.4067366f, --0.4539905f, --0.5000000f, --0.5446391f, --0.5877852f, --0.6293204f, --0.6691306f, --0.7071068f, --0.7431448f, --0.7771460f, --0.8090170f, --0.8386706f, --0.8660254f, --0.8910065f, --0.9135454f, --0.9335804f, --0.9510565f, --0.9659258f, --0.9781476f, --0.9876884f, --0.9945219f, --0.9986295f, --0.9997559f -}; - -/*First Stage Codebook */ -static final float[/* NC0 */][/* M */] lspcb1 = { -{0.1814f, -0.2647f, -0.4580f, -1.1077f, -1.4813f, -1.7022f, -2.1953f, -2.3405f, -2.5867f, -2.6636f}, - -{0.2113f, -0.3223f, -0.4212f, -0.5946f, -0.7479f, -0.9615f, -1.9097f, -2.1750f, -2.4773f, -2.6737f}, - -{0.1915f, -0.2755f, -0.3770f, -0.5950f, -1.3505f, -1.6349f, -2.2348f, -2.3552f, -2.5768f, -2.6540f}, - -{0.2116f, -0.3067f, -0.4099f, -0.5748f, -0.8518f, -1.2569f, -2.0782f, -2.1920f, -2.3371f, -2.4842f}, - -{0.2129f, -0.2974f, -0.4039f, -1.0659f, -1.2735f, -1.4658f, -1.9061f, -2.0312f, -2.6074f, -2.6750f}, - -{0.2181f, -0.2893f, -0.4117f, -0.5519f, -0.8295f, -1.5825f, -2.1575f, -2.3179f, -2.5458f, -2.6417f}, - -{0.1991f, -0.2971f, -0.4104f, -0.7725f, -1.3073f, -1.4665f, -1.6208f, -1.6973f, -2.3732f, -2.5743f}, - -{0.1818f, -0.2886f, -0.4018f, -0.7630f, -1.1264f, -1.2699f, -1.6899f, -1.8650f, -2.1633f, -2.6186f}, - -{0.2282f, -0.3093f, -0.4243f, -0.5329f, -1.1173f, -1.7717f, -1.9420f, -2.0780f, -2.5160f, -2.6137f}, - -{0.2528f, -0.3693f, -0.5290f, -0.7146f, -0.9528f, -1.1269f, -1.2936f, -1.9589f, -2.4548f, -2.6653f}, - -{0.2332f, -0.3263f, -0.4174f, -0.5202f, -1.3633f, -1.8447f, -2.0236f, -2.1474f, -2.3572f, -2.4738f}, - -{0.1393f, -0.2216f, -0.3204f, -0.5644f, -0.7929f, -1.1705f, -1.7051f, -2.0054f, -2.3623f, -2.5985f}, - -{0.2677f, -0.3871f, -0.5746f, -0.7091f, -1.3311f, -1.5260f, -1.7288f, -1.9122f, -2.5787f, -2.6598f}, - -{0.1570f, -0.2328f, -0.3111f, -0.4216f, -1.1688f, -1.4605f, -1.9505f, -2.1173f, -2.4038f, -2.7460f}, - -{0.2346f, -0.3321f, -0.5621f, -0.8160f, -1.4042f, -1.5860f, -1.7518f, -1.8631f, -2.0749f, -2.5380f}, - -{0.2505f, -0.3368f, -0.4758f, -0.6405f, -0.8104f, -1.2533f, -1.9329f, -2.0526f, -2.2155f, -2.6459f}, - -{0.2196f, -0.3049f, -0.6857f, -1.3976f, -1.6100f, -1.7958f, -2.0813f, -2.2211f, -2.4789f, -2.5857f}, - -{0.1232f, -0.2011f, -0.3527f, -0.6969f, -1.1647f, -1.5081f, -1.8593f, -2.2576f, -2.5594f, -2.6896f}, - -{0.3682f, -0.4632f, -0.6600f, -0.9118f, -1.5245f, -1.7071f, -1.8712f, -1.9939f, -2.4356f, -2.5380f}, - -{0.2690f, -0.3711f, -0.4635f, -0.6644f, -1.4633f, -1.6495f, -1.8227f, -1.9983f, -2.1797f, -2.2954f}, - -{0.3555f, -0.5240f, -0.9751f, -1.1685f, -1.4114f, -1.6168f, -1.7769f, -2.0178f, -2.4420f, -2.5724f}, - -{0.3493f, -0.4404f, -0.7231f, -0.8587f, -1.1272f, -1.4715f, -1.6760f, -2.2042f, -2.4735f, -2.5604f}, - -{0.3747f, -0.5263f, -0.7284f, -0.8994f, -1.4017f, -1.5502f, -1.7468f, -1.9816f, -2.2380f, -2.3404f}, - -{0.2972f, -0.4470f, -0.5941f, -0.7078f, -1.2675f, -1.4310f, -1.5930f, -1.9126f, -2.3026f, -2.4208f}, - -{0.2467f, -0.3180f, -0.4712f, -1.1281f, -1.6206f, -1.7876f, -1.9544f, -2.0873f, -2.3521f, -2.4721f}, - -{0.2292f, -0.3430f, -0.4383f, -0.5747f, -1.3497f, -1.5187f, -1.9070f, -2.0958f, -2.2902f, -2.4301f}, - -{0.2573f, -0.3508f, -0.4484f, -0.7079f, -1.6577f, -1.7929f, -1.9456f, -2.0847f, -2.3060f, -2.4208f}, - -{0.1968f, -0.2789f, -0.3594f, -0.4361f, -1.0034f, -1.7040f, -1.9439f, -2.1044f, -2.2696f, -2.4558f}, - -{0.2955f, -0.3853f, -0.7986f, -1.2470f, -1.4723f, -1.6522f, -1.8684f, -2.0084f, -2.2849f, -2.4268f}, - -{0.2036f, -0.3189f, -0.4314f, -0.6393f, -1.2834f, -1.4278f, -1.5796f, -2.0506f, -2.2044f, -2.3656f}, - -{0.2916f, -0.3684f, -0.5907f, -1.1394f, -1.3933f, -1.5540f, -1.8341f, -1.9835f, -2.1301f, -2.2800f}, - -{0.2289f, -0.3402f, -0.5166f, -0.7716f, -1.0614f, -1.2389f, -1.4386f, -2.0769f, -2.2715f, -2.4366f}, - -{0.0829f, -0.1723f, -0.5682f, -0.9773f, -1.3973f, -1.6174f, -1.9242f, -2.2128f, -2.4855f, -2.6327f}, - -{0.2244f, -0.3169f, -0.4368f, -0.5625f, -0.6897f, -1.3763f, -1.7524f, -1.9393f, -2.5121f, -2.6556f}, - -{0.1591f, -0.2387f, -0.2924f, -0.4056f, -1.4677f, -1.6802f, -1.9389f, -2.2067f, -2.4635f, -2.5919f}, - -{0.1756f, -0.2566f, -0.3251f, -0.4227f, -1.0167f, -1.2649f, -1.6801f, -2.1055f, -2.4088f, -2.7276f}, - -{0.1050f, -0.2325f, -0.7445f, -0.9491f, -1.1982f, -1.4658f, -1.8093f, -2.0397f, -2.4155f, -2.5797f}, - -{0.2043f, -0.3324f, -0.4522f, -0.7477f, -0.9361f, -1.1533f, -1.6703f, -1.7631f, -2.5071f, -2.6528f}, - -{0.1522f, -0.2258f, -0.3543f, -0.5504f, -0.8815f, -1.5516f, -1.8110f, -1.9915f, -2.3603f, -2.7735f}, - -{0.1862f, -0.2759f, -0.4715f, -0.6908f, -0.8963f, -1.4341f, -1.6322f, -1.7630f, -2.2027f, -2.6043f}, - -{0.1460f, -0.2254f, -0.3790f, -0.8622f, -1.3394f, -1.5754f, -1.8084f, -2.0798f, -2.4319f, -2.7632f}, - -{0.2621f, -0.3792f, -0.5463f, -0.7948f, -1.0043f, -1.1921f, -1.3409f, -1.4845f, -2.3159f, -2.6002f}, - -{0.1935f, -0.2937f, -0.3656f, -0.4927f, -1.4015f, -1.6086f, -1.7724f, -1.8837f, -2.4374f, -2.5971f}, - -{0.2171f, -0.3282f, -0.4412f, -0.5713f, -1.1554f, -1.3506f, -1.5227f, -1.9923f, -2.4100f, -2.5391f}, - -{0.2274f, -0.3157f, -0.4263f, -0.8202f, -1.4293f, -1.5884f, -1.7535f, -1.9688f, -2.3939f, -2.4934f}, - -{0.1704f, -0.2633f, -0.3259f, -0.4134f, -1.2948f, -1.4802f, -1.6619f, -2.0393f, -2.3165f, -2.6083f}, - -{0.1763f, -0.2585f, -0.4012f, -0.7609f, -1.1503f, -1.5847f, -1.8309f, -1.9352f, -2.0982f, -2.6681f}, - -{0.2447f, -0.3535f, -0.4618f, -0.5979f, -0.7530f, -0.8908f, -1.5393f, -2.0075f, -2.3557f, -2.6203f}, - -{0.1826f, -0.3496f, -0.7764f, -0.9888f, -1.3915f, -1.7421f, -1.9412f, -2.1620f, -2.4999f, -2.6931f}, - -{0.3033f, -0.3802f, -0.6981f, -0.8664f, -1.0254f, -1.5401f, -1.7180f, -1.8124f, -2.5068f, -2.6119f}, - -{0.2960f, -0.4001f, -0.6465f, -0.7672f, -1.3782f, -1.5751f, -1.9559f, -2.1373f, -2.3601f, -2.4760f}, - -{0.3132f, -0.4613f, -0.6544f, -0.8532f, -1.0721f, -1.2730f, -1.7566f, -1.9217f, -2.1693f, -2.6531f}, - -{0.3329f, -0.4131f, -0.8073f, -1.1297f, -1.2869f, -1.4937f, -1.7885f, -1.9150f, -2.4505f, -2.5760f}, - -{0.2340f, -0.3605f, -0.7659f, -0.9874f, -1.1854f, -1.3337f, -1.5128f, -2.0062f, -2.4427f, -2.5859f}, - -{0.4131f, -0.5330f, -0.6530f, -0.9360f, -1.3648f, -1.5388f, -1.6994f, -1.8707f, -2.4294f, -2.5335f}, - -{0.3754f, -0.5229f, -0.7265f, -0.9301f, -1.1724f, -1.3440f, -1.5118f, -1.7098f, -2.5218f, -2.6242f}, - -{0.2138f, -0.2998f, -0.6283f, -1.2166f, -1.4187f, -1.6084f, -1.7992f, -2.0106f, -2.5377f, -2.6558f}, - -{0.1761f, -0.2672f, -0.4065f, -0.8317f, -1.0900f, -1.4814f, -1.7672f, -1.8685f, -2.3969f, -2.5079f}, - -{0.2801f, -0.3535f, -0.4969f, -0.9809f, -1.4934f, -1.6378f, -1.8021f, -2.1200f, -2.3135f, -2.4034f}, - -{0.2365f, -0.3246f, -0.5618f, -0.8176f, -1.1073f, -1.5702f, -1.7331f, -1.8592f, -1.9589f, -2.3044f}, - -{0.2529f, -0.3251f, -0.5147f, -1.1530f, -1.3291f, -1.5005f, -1.7028f, -1.8200f, -2.3482f, -2.4831f}, - -{0.2125f, -0.3041f, -0.4259f, -0.9935f, -1.1788f, -1.3615f, -1.6121f, -1.7930f, -2.5509f, -2.6742f}, - -{0.2685f, -0.3518f, -0.5707f, -1.0410f, -1.2270f, -1.3927f, -1.7622f, -1.8876f, -2.0985f, -2.5144f}, - -{0.2373f, -0.3648f, -0.5099f, -0.7373f, -0.9129f, -1.0421f, -1.7312f, -1.8984f, -2.1512f, -2.6342f}, - -{0.2229f, -0.3876f, -0.8621f, -1.1986f, -1.5655f, -1.8861f, -2.2376f, -2.4239f, -2.6648f, -2.7359f}, - -{0.3009f, -0.3719f, -0.5887f, -0.7297f, -0.9395f, -1.8797f, -2.0423f, -2.1541f, -2.5132f, -2.6026f}, - -{0.3114f, -0.4142f, -0.6476f, -0.8448f, -1.2495f, -1.7192f, -2.2148f, -2.3432f, -2.5246f, -2.6046f}, - -{0.3666f, -0.4638f, -0.6496f, -0.7858f, -0.9667f, -1.4213f, -1.9300f, -2.0564f, -2.2119f, -2.3170f}, - -{0.4218f, -0.5075f, -0.8348f, -1.0009f, -1.2057f, -1.5032f, -1.9416f, -2.0540f, -2.4352f, -2.5504f}, - -{0.3726f, -0.4602f, -0.5971f, -0.7093f, -0.8517f, -1.2361f, -1.8052f, -1.9520f, -2.4137f, -2.5518f}, - -{0.4482f, -0.5318f, -0.7114f, -0.8542f, -1.0328f, -1.4751f, -1.7278f, -1.8237f, -2.3496f, -2.4931f}, - -{0.3316f, -0.4498f, -0.6404f, -0.8162f, -1.0332f, -1.2209f, -1.5130f, -1.7250f, -1.9715f, -2.4141f}, - -{0.2375f, -0.3221f, -0.5042f, -0.9760f, -1.7503f, -1.9014f, -2.0822f, -2.2225f, -2.4689f, -2.5632f}, - -{0.2813f, -0.3575f, -0.5032f, -0.5889f, -0.6885f, -1.6040f, -1.9318f, -2.0677f, -2.4546f, -2.5701f}, - -{0.2198f, -0.3072f, -0.4090f, -0.6371f, -1.6365f, -1.9468f, -2.1507f, -2.2633f, -2.5063f, -2.5943f}, - -{0.1754f, -0.2716f, -0.3361f, -0.5550f, -1.1789f, -1.3728f, -1.8527f, -1.9919f, -2.1349f, -2.3359f}, - -{0.2832f, -0.3540f, -0.6080f, -0.8467f, -1.0259f, -1.6467f, -1.8987f, -1.9875f, -2.4744f, -2.5527f}, - -{0.2670f, -0.3564f, -0.5628f, -0.7172f, -0.9021f, -1.5328f, -1.7131f, -2.0501f, -2.5633f, -2.6574f}, - -{0.2729f, -0.3569f, -0.6252f, -0.7641f, -0.9887f, -1.6589f, -1.8726f, -1.9947f, -2.1884f, -2.4609f}, - -{0.2155f, -0.3221f, -0.4580f, -0.6995f, -0.9623f, -1.2339f, -1.6642f, -1.8823f, -2.0518f, -2.2674f}, - -{0.4224f, -0.7009f, -1.1714f, -1.4334f, -1.7595f, -1.9629f, -2.2185f, -2.3304f, -2.5446f, -2.6369f}, - -{0.4560f, -0.5403f, -0.7568f, -0.8989f, -1.1292f, -1.7687f, -1.9575f, -2.0784f, -2.4260f, -2.5484f}, - -{0.4299f, -0.5833f, -0.8408f, -1.0596f, -1.5524f, -1.7484f, -1.9471f, -2.2034f, -2.4617f, -2.5812f}, - -{0.2614f, -0.3624f, -0.8381f, -0.9829f, -1.2220f, -1.6064f, -1.8083f, -1.9362f, -2.1397f, -2.2773f}, - -{0.5064f, -0.7481f, -1.1021f, -1.3271f, -1.5486f, -1.7096f, -1.9503f, -2.1006f, -2.3911f, -2.5141f}, - -{0.5375f, -0.6552f, -0.8099f, -1.0219f, -1.2407f, -1.4160f, -1.8266f, -1.9936f, -2.1951f, -2.2911f}, - -{0.4994f, -0.6575f, -0.8365f, -1.0706f, -1.4116f, -1.6224f, -1.9200f, -2.0667f, -2.3262f, -2.4539f}, - -{0.3353f, -0.4426f, -0.6469f, -0.9161f, -1.2528f, -1.3956f, -1.6080f, -1.8909f, -2.0600f, -2.1380f}, - -{0.2745f, -0.4341f, -1.0424f, -1.2928f, -1.5461f, -1.7940f, -2.0161f, -2.1758f, -2.4742f, -2.5937f}, - -{0.1562f, -0.2393f, -0.4786f, -0.9513f, -1.2395f, -1.8010f, -2.0320f, -2.2143f, -2.5243f, -2.6204f}, - -{0.2979f, -0.4242f, -0.8224f, -1.0564f, -1.4881f, -1.7808f, -2.0898f, -2.1882f, -2.3328f, -2.4389f}, - -{0.2294f, -0.3070f, -0.5490f, -0.9244f, -1.2229f, -1.8248f, -1.9704f, -2.0627f, -2.2458f, -2.3653f}, - -{0.3423f, -0.4502f, -0.9144f, -1.2313f, -1.3694f, -1.5517f, -1.9907f, -2.1326f, -2.4509f, -2.5789f}, - -{0.2470f, -0.3275f, -0.4729f, -1.0093f, -1.2519f, -1.4216f, -1.8540f, -2.0877f, -2.3151f, -2.4156f}, - -{0.3447f, -0.4401f, -0.7099f, -1.0493f, -1.2312f, -1.4001f, -2.0225f, -2.1317f, -2.2894f, -2.4263f}, - -{0.3481f, -0.4494f, -0.6446f, -0.9336f, -1.1198f, -1.2620f, -1.8264f, -1.9712f, -2.1435f, -2.2552f}, - -{0.1646f, -0.3229f, -0.7112f, -1.0725f, -1.2964f, -1.5663f, -1.9843f, -2.2363f, -2.5798f, -2.7572f}, - -{0.2614f, -0.3707f, -0.5241f, -0.7425f, -0.9269f, -1.2976f, -2.0945f, -2.2014f, -2.6204f, -2.6959f}, - -{0.1963f, -0.2900f, -0.4131f, -0.8397f, -1.2171f, -1.3705f, -2.0665f, -2.1546f, -2.4640f, -2.5782f}, - -{0.3387f, -0.4415f, -0.6121f, -0.8005f, -0.9507f, -1.0937f, -2.0836f, -2.2342f, -2.3849f, -2.5076f}, - -{0.2362f, -0.5876f, -0.7574f, -0.8804f, -1.0961f, -1.4240f, -1.9519f, -2.1742f, -2.4935f, -2.6493f}, - -{0.2793f, -0.4282f, -0.6149f, -0.8352f, -1.0106f, -1.1766f, -1.8392f, -2.0119f, -2.6433f, -2.7117f}, - -{0.3603f, -0.4604f, -0.5955f, -0.9251f, -1.1006f, -1.2572f, -1.7688f, -1.8607f, -2.4687f, -2.5623f}, - -{0.3975f, -0.5849f, -0.8059f, -0.9182f, -1.0552f, -1.1850f, -1.6356f, -1.9627f, -2.3318f, -2.4719f}, - -{0.2231f, -0.3192f, -0.4256f, -0.7373f, -1.4831f, -1.6874f, -1.9765f, -2.1097f, -2.6152f, -2.6906f}, - -{0.1221f, -0.2081f, -0.3665f, -0.7734f, -1.0341f, -1.2818f, -1.8162f, -2.0727f, -2.4446f, -2.7377f}, - -{0.2010f, -0.2791f, -0.3796f, -0.8845f, -1.4030f, -1.5615f, -2.0538f, -2.1567f, -2.3171f, -2.4686f}, - -{0.2086f, -0.3053f, -0.4047f, -0.8224f, -1.0656f, -1.2115f, -1.9641f, -2.0871f, -2.2430f, -2.4313f}, - -{0.3203f, -0.4285f, -0.5467f, -0.6891f, -1.2039f, -1.3569f, -1.8578f, -2.2055f, -2.3906f, -2.4881f}, - -{0.3074f, -0.4192f, -0.5772f, -0.7799f, -0.9866f, -1.1335f, -1.6068f, -2.2441f, -2.4194f, -2.5089f}, - -{0.2108f, -0.2910f, -0.4993f, -0.7695f, -0.9528f, -1.5681f, -1.7838f, -2.1495f, -2.3522f, -2.4636f}, - -{0.3492f, -0.4560f, -0.5906f, -0.7379f, -0.8855f, -1.0257f, -1.7128f, -1.9997f, -2.2019f, -2.3694f}, - -{0.5185f, -0.7316f, -0.9708f, -1.1954f, -1.5066f, -1.7887f, -2.1396f, -2.2918f, -2.5429f, -2.6489f}, - -{0.4276f, -0.4946f, -0.6934f, -0.8308f, -0.9944f, -1.4582f, -2.0324f, -2.1294f, -2.4891f, -2.6324f}, - -{0.3847f, -0.5973f, -0.7202f, -0.8787f, -1.3938f, -1.5959f, -1.8463f, -2.1574f, -2.5050f, -2.6687f}, - -{0.4835f, -0.5919f, -0.7235f, -0.8862f, -1.0756f, -1.2853f, -1.9118f, -2.0215f, -2.2213f, -2.4638f}, - -{0.5492f, -0.8062f, -0.9810f, -1.1293f, -1.3189f, -1.5415f, -1.9385f, -2.1378f, -2.4439f, -2.5691f}, - -{0.5190f, -0.6764f, -0.8123f, -1.0154f, -1.2085f, -1.4266f, -1.8433f, -2.0866f, -2.5113f, -2.6474f}, - -{0.4602f, -0.6503f, -0.9602f, -1.1427f, -1.3043f, -1.4427f, -1.6676f, -1.8758f, -2.2868f, -2.4271f}, - -{0.3764f, -0.4845f, -0.7627f, -0.9914f, -1.1961f, -1.3421f, -1.5129f, -1.6707f, -2.1836f, -2.3322f}, - -{0.3334f, -0.5701f, -0.8622f, -1.1232f, -1.3851f, -1.6767f, -2.0600f, -2.2946f, -2.5375f, -2.7295f}, - -{0.1449f, -0.2719f, -0.5783f, -0.8807f, -1.1746f, -1.5422f, -1.8804f, -2.1934f, -2.4734f, -2.8728f}, - -{0.2333f, -0.3024f, -0.4780f, -1.2327f, -1.4180f, -1.5815f, -1.9804f, -2.0921f, -2.3524f, -2.5304f}, - -{0.2154f, -0.3075f, -0.4746f, -0.8477f, -1.1170f, -1.5369f, -1.9847f, -2.0733f, -2.1880f, -2.2504f}, - -{0.1709f, -0.4486f, -0.8705f, -1.0643f, -1.3047f, -1.5269f, -1.9175f, -2.1621f, -2.4073f, -2.5718f}, - -{0.2835f, -0.3752f, -0.5234f, -0.9898f, -1.1484f, -1.2974f, -1.9363f, -2.0378f, -2.4065f, -2.6214f}, - -{0.3211f, -0.4077f, -0.5809f, -1.0206f, -1.2542f, -1.3835f, -1.5723f, -2.1209f, -2.3464f, -2.4336f}, - -{0.2101f, -0.3146f, -0.6779f, -0.8783f, -1.0561f, -1.3045f, -1.8395f, -2.0695f, -2.2831f, -2.4328f} -}; - -/*Second Stage Codebook*/ -static final float[/* NC1 */][/* M */] lspcb2 = { -{-0.0532f, --0.0995f, --0.0906f, -0.1261f, --0.0633f, -0.0711f, --0.1467f, -0.1012f, -0.0106f, -0.0470f}, - -{-0.1017f, --0.1088f, -0.0566f, --0.0010f, --0.1528f, -0.1771f, -0.0089f, --0.0282f, -0.1055f, -0.0808f}, - -{-0.1247f, -0.0283f, --0.0374f, -0.0393f, --0.0269f, --0.0200f, --0.0643f, --0.0921f, --0.1994f, -0.0327f}, - -{0.0070f, --0.0242f, --0.0415f, --0.0041f, --0.1793f, -0.0700f, -0.0972f, --0.0207f, --0.0771f, -0.0997f}, - -{0.0209f, --0.0428f, -0.0359f, -0.2027f, -0.0554f, -0.0634f, -0.0356f, -0.0195f, --0.0782f, --0.1583f}, - -{-0.0856f, --0.1028f, --0.0071f, -0.1160f, -0.1089f, -0.1892f, -0.0874f, -0.0644f, --0.0872f, --0.0236f}, - -{0.0713f, -0.0039f, --0.0353f, -0.0435f, --0.0407f, --0.0558f, -0.0748f, --0.0346f, --0.1686f, --0.0905f}, - -{-0.0134f, --0.0987f, -0.0283f, -0.0095f, --0.0107f, --0.0420f, -0.1638f, -0.1328f, --0.0799f, --0.0695f}, - -{-0.1049f, -0.1510f, -0.0672f, -0.1043f, -0.0872f, --0.0663f, --0.2139f, --0.0239f, --0.0120f, --0.0338f}, - -{-0.1071f, --0.1165f, --0.1524f, --0.0365f, -0.0260f, --0.0288f, --0.0889f, -0.1159f, -0.1852f, -0.1093f}, - -{-0.0094f, -0.0420f, --0.0758f, -0.0932f, -0.0505f, -0.0614f, --0.0443f, --0.1172f, --0.0590f, -0.1693f}, - -{-0.0384f, --0.0375f, --0.0313f, --0.1539f, --0.0524f, -0.0550f, --0.0569f, --0.0133f, -0.1233f, -0.2714f}, - -{0.0869f, -0.0847f, -0.0637f, -0.0794f, -0.1594f, --0.0035f, --0.0462f, -0.0909f, --0.1227f, -0.0294f}, - -{-0.0137f, --0.0332f, --0.0611f, -0.1156f, -0.2116f, -0.0332f, --0.0019f, -0.1110f, --0.0317f, -0.2061f}, - -{0.0703f, --0.0013f, --0.0572f, --0.0243f, -0.1345f, --0.1235f, -0.0710f, --0.0065f, --0.0912f, -0.1072f}, - -{0.0178f, --0.0349f, --0.1563f, --0.0487f, -0.0044f, --0.0609f, --0.1682f, -0.0023f, --0.0542f, -0.1811f}, - -{-0.1384f, --0.1020f, -0.1649f, -0.1568f, --0.0116f, -0.1240f, --0.0271f, -0.0541f, -0.0455f, --0.0433f}, - -{-0.1782f, --0.1511f, -0.0509f, --0.0261f, -0.0570f, -0.0817f, -0.0805f, -0.2003f, -0.1138f, -0.0653f}, - -{-0.0019f, -0.0081f, -0.0572f, -0.1245f, --0.0914f, -0.1691f, --0.0223f, --0.1108f, --0.0881f, --0.0320f}, - -{-0.0413f, -0.0181f, -0.1764f, -0.0092f, --0.0928f, -0.0695f, -0.1523f, -0.0412f, -0.0508f, --0.0148f}, - -{0.0476f, -0.0292f, -0.1915f, -0.1198f, -0.0139f, -0.0451f, --0.1225f, --0.0619f, --0.0717f, --0.1104f}, - -{-0.0382f, --0.0120f, -0.1159f, -0.0039f, -0.1348f, -0.0088f, --0.0173f, -0.1789f, -0.0078f, --0.0959f}, - -{0.1376f, -0.0713f, -0.1020f, -0.0339f, --0.1415f, -0.0254f, -0.0368f, --0.1077f, -0.0143f, --0.0494f}, - -{0.0658f, --0.0140f, -0.1046f, --0.0603f, -0.0273f, --0.1114f, -0.0761f, --0.0093f, -0.0338f, --0.0538f}, - -{0.2683f, -0.2853f, -0.1549f, -0.0819f, -0.0372f, --0.0327f, --0.0642f, -0.0172f, -0.1077f, --0.0170f}, - -{-0.1949f, -0.0672f, -0.0978f, --0.0557f, --0.0069f, --0.0851f, -0.1057f, -0.1294f, -0.0505f, -0.0545f}, - -{0.1409f, -0.0724f, --0.0094f, -0.1511f, --0.0039f, -0.0710f, --0.1266f, --0.1093f, -0.0817f, -0.0363f}, - -{0.0485f, -0.0682f, -0.0248f, --0.0974f, --0.1122f, -0.0004f, -0.0845f, --0.0357f, -0.1282f, -0.0955f}, - -{0.0408f, -0.1801f, -0.0772f, --0.0098f, -0.0059f, --0.1296f, --0.0591f, -0.0443f, --0.0729f, --0.1041f}, - -{-0.0666f, --0.0403f, --0.0524f, --0.0831f, -0.1384f, --0.1443f, --0.0909f, -0.1636f, -0.0320f, -0.0077f}, - -{0.1612f, -0.1010f, --0.0486f, --0.0704f, -0.0417f, --0.0945f, --0.0590f, --0.1523f, --0.0086f, -0.0120f}, - -{-0.0199f, -0.0823f, --0.0014f, --0.1082f, -0.0649f, --0.1374f, --0.0324f, --0.0296f, -0.0885f, -0.1141f} -}; - -/*MA prediction coef. */ -static final float fg[/* MODE */][/* MA_NP */][/* M */] = { -{{0.2570f, -0.2780f, -0.2800f, -0.2736f, -0.2757f, -0.2764f, -0.2675f, -0.2678f, -0.2779f, -0.2647f}, - -{0.2142f, -0.2194f, -0.2331f, -0.2230f, -0.2272f, -0.2252f, -0.2148f, -0.2123f, -0.2115f, -0.2096f}, - -{0.1670f, -0.1523f, -0.1567f, -0.1580f, -0.1601f, -0.1569f, -0.1589f, -0.1555f, -0.1474f, -0.1571f}, - -{0.1238f, -0.0925f, -0.0798f, -0.0923f, -0.0890f, -0.0828f, -0.1010f, -0.0988f, -0.0872f, -0.1060f}, -}, - -{{0.2360f, -0.2405f, -0.2499f, -0.2495f, -0.2517f, -0.2591f, -0.2636f, -0.2625f, -0.2551f, -0.2310f}, - -{0.1285f, -0.0925f, -0.0779f, -0.1060f, -0.1183f, -0.1176f, -0.1277f, -0.1268f, -0.1193f, -0.1211f}, - -{0.0981f, -0.0589f, -0.0401f, -0.0654f, -0.0761f, -0.0728f, -0.0841f, -0.0826f, -0.0776f, -0.0891f}, - -{0.0923f, -0.0486f, -0.0287f, -0.0498f, -0.0526f, -0.0482f, -0.0621f, -0.0636f, -0.0584f, -0.0794f}, -}, - -}; - -/*present MA prediction coef.*/ -static final float[/* MODE */][/* M */] fg_sum = { -{0.2380000054836f, -0.2578000128269f, -0.2504000067711f, -0.2531000375748f, -0.2480000108480f, -0.2587000429630f, -0.2577999532223f, -0.2656000256538f, -0.2760000228882f, -0.2625999450684f}, - -{0.4451000094414f, -0.5595000386238f, -0.6034000515938f, -0.5292999744415f, -0.5012999176979f, -0.5023000240326f, -0.4625000357628f, -0.4645000100136f, -0.4895999729633f, -0.4793999791145f} -}; - -/*inverse coef. */ -static final float[/* MODE */][/* M */] fg_sum_inv = { -{4.2016806602478f, -3.8789758682251f, -3.9936101436615f, -3.9510068893433f, -4.0322580337524f, -3.8654806613922f, -3.8789765834808f, -3.7650599479675f, -3.6231880187988f, -3.8080739974976f}, - -{2.2466859817505f, -1.7873100042343f, -1.6572753190994f, -1.8892878293991f, -1.9948137998581f, -1.9908419847488f, -2.1621620655060f, -2.1528525352478f, -2.0424838066101f, -2.0859408378601f} -}; - -static final float[/* FIR_SIZE_ANA */] inter_3 = { -0.900839f, -0.760084f, -0.424082f, -0.084078f, --0.105570f, --0.121120f, --0.047624f, -0.016285f, -0.031217f, -0.015738f, -0.000000f, --0.005925f, -0.000000f -}; - -static final float[/* FIR_SIZE_SYN */] inter_3l = { -0.898517f, -0.769271f, -0.448635f, -0.095915f, --0.134333f, --0.178528f, --0.084919f, -0.036952f, -0.095533f, -0.068936f, --0.000000f, --0.050404f, --0.050835f, --0.014169f, -0.023083f, -0.033543f, -0.016774f, --0.007466f, --0.019340f, --0.013755f, -0.000000f, -0.009400f, -0.009029f, -0.002381f, --0.003658f, --0.005027f, --0.002405f, -0.001050f, -0.002780f, -0.002145f, -0.000000f -}; - -static final float[/* 4 */] pred = { -0.68f, -0.58f, -0.34f, -0.19f -}; - -static final float[/* 2 */][/* 2 */] coef = { -{31.134575f, -1.612322f}, - -{0.481389f, -0.053056f} -}; - -static final float[/* NCODE1-NCAN1 */] thr1 = { -0.659681f, -0.755274f, -1.207205f, -1.987740f -}; - -static final float[/* NCODE2-NCAN2 */] thr2 = { -0.429912f, -0.494045f, -0.618737f, -0.650676f, -0.717949f, -0.770050f, -0.850628f, -0.932089f -}; - -static final float[/* NCODE1 */][/* 2 */] gbk1 = { -{0.000010f, -0.185084f}, - -{0.094719f, -0.296035f}, - -{0.111779f, -0.613122f}, - -{0.003516f, -0.659780f}, - -{0.117258f, -1.134277f}, - -{0.197901f, -1.214512f}, - -{0.021772f, -1.801288f}, - -{0.163457f, -3.315700f} -}; - -static final float[/* NCODE2*/][/* 2 */] gbk2 = { -{0.050466f, -0.244769f}, - -{0.121711f, -0.000010f}, - -{0.313871f, -0.072357f}, - -{0.375977f, -0.292399f}, - -{0.493870f, -0.593410f}, - -{0.556641f, -0.064087f}, - -{0.645363f, -0.362118f}, - -{0.706138f, -0.146110f}, - -{0.809357f, -0.397579f}, - -{0.866379f, -0.199087f}, - -{0.923602f, -0.599938f}, - -{0.925376f, -1.742757f}, - -{0.942028f, -0.029027f}, - -{0.983459f, -0.414166f}, - -{1.055892f, -0.227186f}, - -{1.158039f, -0.724592f} -}; - -static final float[/* SIZ_TAB_HUP_S */] tab_hup_s = { --0.005772f, -0.087669f, -0.965882f, --0.048753f, --0.014793f, -0.214886f, -0.868791f, --0.065537f, --0.028507f, -0.374334f, -0.723418f, --0.060834f, --0.045567f, -0.550847f, -0.550847f, --0.045567f, --0.060834f, -0.723418f, -0.374334f, --0.028507f, --0.065537f, -0.868791f, -0.214886f, --0.014793f, --0.048753f, -0.965882f, -0.087669f, --0.005772f -}; - -static final float[/* SIZ_TAB_HUP_L */] tab_hup_l = { --0.001246f, -0.002200f, --0.004791f, -0.009621f, --0.017685f, -0.031212f, --0.057225f, -0.135470f, -0.973955f, --0.103495f, -0.048663f, --0.027090f, -0.015280f, --0.008160f, -0.003961f, --0.001827f, --0.002388f, -0.004479f, --0.009715f, -0.019261f, --0.035118f, -0.061945f, --0.115187f, -0.294161f, -0.898322f, --0.170283f, -0.083211f, --0.046645f, -0.026210f, --0.013854f, -0.006641f, --0.003099f, --0.003277f, -0.006456f, --0.013906f, -0.027229f, --0.049283f, -0.086990f, --0.164590f, -0.464041f, -0.780309f, --0.199879f, -0.100795f, --0.056792f, -0.031761f, --0.016606f, -0.007866f, --0.003740f, --0.003770f, -0.007714f, --0.016462f, -0.031849f, --0.057272f, -0.101294f, --0.195755f, -0.630993f, -0.630993f, --0.195755f, -0.101294f, --0.057272f, -0.031849f, --0.016462f, -0.007714f, --0.003770f, --0.003740f, -0.007866f, --0.016606f, -0.031761f, --0.056792f, -0.100795f, --0.199879f, -0.780309f, -0.464041f, --0.164590f, -0.086990f, --0.049283f, -0.027229f, --0.013906f, -0.006456f, --0.003277f, --0.003099f, -0.006641f, --0.013854f, -0.026210f, --0.046645f, -0.083211f, --0.170283f, -0.898322f, -0.294161f, --0.115187f, -0.061945f, --0.035118f, -0.019261f, --0.009715f, -0.004479f, --0.002388f, --0.001827f, -0.003961f, --0.008160f, -0.015280f, --0.027090f, -0.048663f, --0.103495f, -0.973955f, -0.135470f, --0.057225f, -0.031212f, --0.017685f, -0.009621f, --0.004791f, -0.002200f, --0.001246f -}; - -static final int[/* NCODE1 */] map1 = { - 5, 1, 4, 7, 3, 0, 6, 2}; - -static final int[/* NCODE2 */] map2 = { - 4, 6, 0, 2,12,14, 8,10,15,11, 9,13, 7, 3, 1, 5}; - -static final int[/* NCODE1 */] imap1 = { - 5, 1, 7, 4, 2, 0, 6, 3}; -static final int[/* NCODE2 */] imap2 = { - 2,14, 3,13, 0,15, 1,12, 6,10, 7, 9, 4,11, 5, 8}; - -static final int[/* PRM_SIZE */] bitsno = {1+Ld8k.NC0_B, /* MA + 1st stage */ - Ld8k.NC1_B*2, /* 2nd stage */ - 8,1, 13,4, 7, /* first subframe */ - 5, 13,4, 7}; /* second subframe */ - -/* filter coefficients (fc = 140 Hz) */ -static final float[/* 3 */] b140 = {0.92727435E+00f, -0.18544941E+01f, 0.92727435E+00f}; -static final float[/* 3 */] a140 = {1.00000000E+00f, 0.19059465E+01f, -0.91140240E+00f}; - -/* filter coefficients (fc = 100 Hz ) */ -static final float[/* 3 */] b100 = {0.93980581E+00f, -0.18795834E+01f, 0.93980581E+00f}; -static final float[/* 3 */] a100 = {1.00000000E+00f, 0.19330735E+01f, -0.93589199E+00f}; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Taming.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Taming.java deleted file mode 100644 index 07c1c8fdb..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Taming.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -/** - * Taming functions. - * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Taming -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : TAMING.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -private final float[] exc_err = new float[4]; - -void init_exc_err() -{ - int i; - for(i=0; i<4; i++) exc_err[i] = 1.0f; -} - -/** - * Computes the accumulated potential error in the - * adaptive codebook contribution - * - * @param t0 (i) integer part of pitch delay - * @param t0_frac (i) fractional part of pitch delay - * @return flag set to 1 if taming is necessary - */ -int test_err( -int t0, -int t0_frac -) -{ - float INV_L_SUBFR = Ld8k.INV_L_SUBFR; - int L_INTER10 = Ld8k.L_INTER10; - int L_SUBFR = Ld8k.L_SUBFR; - float THRESH_ERR = Ld8k.THRESH_ERR; - - int i, t1, zone1, zone2, flag; - float maxloc; - - t1 = (t0_frac > 0) ? (t0+1) : t0; - - i = t1 - L_SUBFR - L_INTER10; - if(i < 0) i = 0; - zone1 = (int) ( (float)i * INV_L_SUBFR); - - i = t1 + L_INTER10 - 2; - zone2 = (int)( (float)i * INV_L_SUBFR); - - maxloc = -1.0f; - flag = 0 ; - for(i=zone2; i>=zone1; i--) { - if(exc_err[i] > maxloc) maxloc = exc_err[i]; - } - if(maxloc > THRESH_ERR) { - flag = 1; - } - return(flag); -} - -/** - * Maintains the memory used to compute the error - * function due to an adaptive codebook mismatch between encoder and - * decoder - * - * @param gain_pit (i) pitch gain - * @param t0 (i) integer part of pitch delay - */ -void update_exc_err( - float gain_pit, - int t0 -) -{ - float INV_L_SUBFR = Ld8k.INV_L_SUBFR; - int L_SUBFR = Ld8k.L_SUBFR; - - int i, zone1, zone2, n; - float worst, temp; - - worst = (float)-1.; - - n = t0- L_SUBFR; - if(n < 0) { - temp = 1.0f + gain_pit * exc_err[0]; - if(temp > worst) worst = temp; - temp = 1.0f + gain_pit * temp; - if(temp > worst) worst = temp; - } - - else { - zone1 = (int) ((float)n * INV_L_SUBFR); - - i = t0 - 1; - zone2 = (int)((float)i * INV_L_SUBFR); - - for(i = zone1; i <= zone2; i++) { - temp = 1.0f + gain_pit * exc_err[i]; - if(temp > worst) worst = temp; - } - } - - for(i=3; i>=1; i--) exc_err[i] = exc_err[i-1]; - exc_err[0] = worst; -} - -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Util.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Util.java deleted file mode 100644 index 173a12ccf..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/g729/Util.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -/* - * WARNING: The use of G.729 may require a license fee and/or royalty fee in - * some countries and is licensed by - * SIPRO Lab Telecom. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.g729; - -import java.io.*; - -/** - * Auxiliary functions. - * - * @author Lubomir Marinov (translation of ITU-T C source code to Java) - */ -class Util -{ - -/* ITU-T G.729 Software Package Release 2 (November 2006) */ -/* - ITU-T G.729 Annex C - Reference C code for floating point - implementation of G.729 - Version 1.01 of 15.September.98 -*/ - -/* ----------------------------------------------------------------------- - COPYRIGHT NOTICE ----------------------------------------------------------------------- - ITU-T G.729 Annex C ANSI C source code - Copyright (C) 1998, AT&T, France Telecom, NTT, University of - Sherbrooke. All rights reserved. - ----------------------------------------------------------------------- -*/ - -/* - File : UTIL.C - Used for the floating point version of both - G.729 main body and G.729A -*/ - -/** - * Assigns the value zero to element of the specified array of floats. - * The number of components set to zero equal to the length argument. - * - * @param x (o) : vector to clear - * @param L (i) : length of vector - */ -static void set_zero( - float x[], - int L -) -{ - set_zero(x, 0, L); -} - -/** - * Assigns the value zero to element of the specified array of floats. - * The number of components set to zero equal to the length argument. - * The components at positions offset through offset+length-1 in the - * array are set to zero. - * - * @param x (o) : vector to clear - * @param offset (i) : offset of vector - * @param length (i) : length of vector - */ -static void set_zero(float[] x, int offset, int length) -{ - for (int i = offset, toIndex = offset + length; i < toIndex; i++) - x[i] = 0.0f; -} - -/** - * Copies an array from the specified x array, to the specified y array. - * The number of components copied is equal to the length argument. - * - * @param x (i) : input vector - * @param y (o) : output vector - * @param L (i) : vector length - */ -static void copy( - float x[], - float y[], - int L -) -{ - copy(x, 0, y, L); -} - -/** - * Copies an array from the specified source array, - * beginning at the specified destination array. - * A subsequence of array components are copied from the source array referenced - * by x to the destination array referenced by y. - * The number of components copied is equal to the length argument. - * The components at positions x_offset through x_offset+length-1 in the source - * array are copied into positions 0 through length-1, - * respectively, of the destination array. - * - * @param x (i) : input vector - * @param x_offset (i) : input vector offset - * @param y (o) : output vector - * @param L (i) : vector length - */ -static void copy(float[] x, int x_offset, float[] y, int L) -{ - copy(x, x_offset, y, 0, L); -} - -/** - * Copies an array from the specified source array, - * beginning at the specified position, - * to the specified position of the destination array. - * A subsequence of array components are copied from the source array referenced - * by x to the destination array referenced by y. - * The number of components copied is equal to the length argument. - * The components at positions x_offset through x_offset+length-1 in the source - * array are copied into positions y_offset through y_offset+length-1, - * respectively, of the destination array. - * - * @param x (i) : input vector - * @param x_offset (i) : input vector offset - * @param y (o) : output vector - * @param y_offset (i) : output vector offset - * @param L (i) : vector length - */ -static void copy(float[] x, int x_offset, float[] y, int y_offset, int L) -{ - int i; - - for (i = 0; i < L; i++) - y[y_offset + i] = x[x_offset + i]; -} - -/* Random generator */ -private static short seed = 21845; - -/** - * Return random short. - * - * @return random short - */ -static short random_g729() -{ - seed = (short) (seed * 31821L + 13849L); - - return(seed); -} - -/** - * Write data in fp - * - * @param data - * @param length - * @param fp - * @throws java.io.IOException - */ -static void fwrite(short[] data, int length, OutputStream fp) - throws IOException -{ - byte[] bytes = new byte[2]; - - for (int i = 0; i < length; i++) - { - int value = data[i]; - bytes[0] = (byte) (value & 0xFF); - bytes[1] = (byte) (value >> 8); - fp.write(bytes); - } -} - -/** - * Read data from fp. - * - * @param data - * @param length - * @param fp - * @return length of resulting data array - * @throws java.io.IOException - */ -static int fread(short[] data, int length, InputStream fp) - throws IOException -{ - byte[] bytes = new byte[2]; - int readLength = 0; - - for (int i = 0; i < length; i++) - { - if (fp.read(bytes) != 2) - break; - data[i] = (short) ((bytes[1] << 8) | (bytes[0] & 0x00FF)); - readLength++; - } - return readLength; -} -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/DePacketizer.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/DePacketizer.java deleted file mode 100644 index c56885dfe..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/DePacketizer.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.gsm; - -import javax.media.*; -import javax.media.format.*; - -import net.sf.fmj.media.*; - -/** - * - * DePacketizer for GSM/RTP. Doesn't have to do much, just copies input - * to output. Uses buffer-swapping observed in debugging - * and seen in other open-source DePacketizer implementations. - * @author Martin Harvan - * @author Damian Minkov - */ -public class DePacketizer - extends AbstractDePacketizer -{ - @Override - public String getName() - { - return "GSM DePacketizer"; - } - - /** - * Constructs a new DePacketizer. - */ - public DePacketizer() - { - super(); - this.inputFormats = new Format[] { - new AudioFormat( - AudioFormat.GSM_RTP, - 8000, - 8, - 1, - Format.NOT_SPECIFIED, - AudioFormat.SIGNED, - 264, - Format.NOT_SPECIFIED, - Format.byteArray)}; - } - - // TODO: move to base class? - protected Format[] outputFormats = new Format[] { - new AudioFormat( - AudioFormat.GSM, - 8000, - 8, - 1, - -1, - AudioFormat.SIGNED, - 264, - -1.0, - Format.byteArray)}; - - @Override - public Format[] getSupportedOutputFormats(Format input) - { - if (input == null) - return outputFormats; - else - { - if (!(input instanceof AudioFormat)) - { - return new Format[] {null}; - } - final AudioFormat inputCast = (AudioFormat) input; - if (!inputCast.getEncoding().equals(AudioFormat.GSM_RTP)) - { - return new Format[] {null}; - } - final AudioFormat result = - new AudioFormat( - AudioFormat.GSM, - inputCast.getSampleRate(), - inputCast.getSampleSizeInBits(), - inputCast.getChannels(), - inputCast.getEndian(), - inputCast.getSigned(), - inputCast.getFrameSizeInBits(), - inputCast.getFrameRate(), - inputCast.getDataType()); - - return new Format[] {result}; - } - } - - @Override - public void open() - { - } - - @Override - public void close() - { - } - - @Override - public Format setInputFormat(Format f) - { - return super.setInputFormat(f); - } - - @Override - public Format setOutputFormat(Format f) - { - return super.setOutputFormat(f); - } - - -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/Decoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/Decoder.java deleted file mode 100644 index 94090b273..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/Decoder.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.gsm; - -import javax.media.*; -import javax.media.format.*; - -import net.sf.fmj.media.*; - -/** - * GSM to PCM java decoder. - * Decodes GSM frame (33 bytes long) into 160 16-bit PCM samples (320 bytes). - * - * @author Martin Harvan - * @author Damian Minkov - */ -public class Decoder - extends AbstractCodec -{ - private Buffer innerBuffer = new Buffer(); - private static final int PCM_BYTES = 320; - private static final int GSM_BYTES = 33; - private int innerDataLength = 0; - - byte[] innerContent; - - @Override - public String getName() - { - return "GSM Decoder"; - } - - /** - * Constructs a new Decoder. - */ - public Decoder() - { - super(); - this.inputFormats = new Format[] - { - new AudioFormat( - AudioFormat.GSM, - 8000, - 8, - 1, - Format.NOT_SPECIFIED, - AudioFormat.SIGNED, - 264, - Format.NOT_SPECIFIED, - Format.byteArray) - }; - } - - // TODO: move to base class? - protected Format[] outputFormats = new Format[] - { - new AudioFormat( - AudioFormat.LINEAR, - 8000, - 16, - 1, - Format.NOT_SPECIFIED, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - Format.byteArray) - }; - - @Override - public Format setOutputFormat(Format format) - { - if (!(format instanceof AudioFormat)) - return null; - - final AudioFormat audioFormat = (AudioFormat) format; - return super.setOutputFormat( - AudioFormatCompleter.complete(audioFormat)); - } - - @Override - public Format[] getSupportedOutputFormats(Format input) - { - if (input == null) - return outputFormats; - else - { - if (!(input instanceof AudioFormat)) - { - return new Format[]{null}; - } - - final AudioFormat inputCast = (AudioFormat) input; - if (!inputCast.getEncoding().equals(AudioFormat.GSM) - || (inputCast.getSampleSizeInBits() != 8 - && inputCast.getSampleSizeInBits() != Format.NOT_SPECIFIED) - || (inputCast.getChannels() != 1 - && inputCast.getChannels() != Format.NOT_SPECIFIED) - || (inputCast.getSigned() != AudioFormat.SIGNED - && inputCast.getSigned() != Format.NOT_SPECIFIED) - || (inputCast.getFrameSizeInBits() != 264 - && inputCast.getFrameSizeInBits() != Format.NOT_SPECIFIED) - || (inputCast.getDataType() != null - && inputCast.getDataType() != Format.byteArray)) - { - return new Format[] {null}; - } - - final AudioFormat result = new AudioFormat( - AudioFormat.LINEAR, - inputCast.getSampleRate(), - 16, - 1, - inputCast.getEndian(), - AudioFormat.SIGNED, - 16, - Format.NOT_SPECIFIED, - Format.byteArray); - - return new Format[]{result}; - } - } - - @Override - public void open() - { - - } - - @Override - public void close() - { - - } - - private static final boolean TRACE = false; - - @Override - public int process(Buffer inputBuffer, Buffer outputBuffer) - { - byte [] inputContent=new byte[inputBuffer.getLength()]; - - System.arraycopy( - inputBuffer.getData(), - inputBuffer.getOffset(), - inputContent, - 0, - inputContent.length); - - - byte[] mergedContent = - mergeArrays((byte[]) innerBuffer.getData(), inputContent); - innerBuffer.setData(mergedContent); - innerBuffer.setLength(mergedContent.length); - innerDataLength = innerBuffer.getLength(); - - if (TRACE) dump("input ", inputBuffer); - - if (!checkInputBuffer(inputBuffer)) - { - return BUFFER_PROCESSED_FAILED; - } - - if (isEOM(inputBuffer)) - { - propagateEOM(outputBuffer); - return BUFFER_PROCESSED_OK; - } - - if (TRACE) dump("input ", inputBuffer); - - if (!checkInputBuffer(inputBuffer)) - { - return BUFFER_PROCESSED_FAILED; - } - - if (isEOM(inputBuffer)) { - propagateEOM(outputBuffer); - return BUFFER_PROCESSED_OK; - } - - final int result; - byte[] outputBufferData = (byte[]) outputBuffer.getData(); - - if (outputBufferData == null - || outputBufferData.length < - PCM_BYTES * innerBuffer.getLength() / GSM_BYTES) - { - outputBufferData = new byte[ - PCM_BYTES * (innerBuffer.getLength() / GSM_BYTES)]; - outputBuffer.setData(outputBufferData); - } - - if (innerBuffer.getLength() < GSM_BYTES) - { - result = OUTPUT_BUFFER_NOT_FILLED; - } else - { - final boolean bigEndian = - ((AudioFormat) outputFormat).getEndian() - == AudioFormat.BIG_ENDIAN; - - outputBufferData = new byte[ - PCM_BYTES * (innerBuffer.getLength() / GSM_BYTES)]; - outputBuffer.setData(outputBufferData); - outputBuffer.setLength( - PCM_BYTES * (innerBuffer.getLength() / GSM_BYTES)); - - GSMDecoderUtil.gsmDecode( - bigEndian, - (byte[]) innerBuffer.getData(), - inputBuffer.getOffset(), - innerBuffer.getLength(), - outputBufferData); - - outputBuffer.setFormat(outputFormat); - result = BUFFER_PROCESSED_OK; - byte[] temp = new byte[ - innerDataLength - (innerDataLength / GSM_BYTES) * GSM_BYTES]; - innerContent = (byte[]) innerBuffer.getData(); - System.arraycopy( - innerContent, - (innerDataLength / GSM_BYTES) * GSM_BYTES, - temp, - 0, - temp.length); - outputBuffer.setOffset(0); - - innerBuffer.setLength(temp.length); - innerBuffer.setData(temp); - } - - if (TRACE) - { - dump("input ", inputBuffer); - dump("output", outputBuffer); - } - return result; - } - - private byte[] mergeArrays(byte[] arr1, byte[] arr2) - { - if (arr1 == null) return arr2; - if (arr2 == null) return arr1; - byte[] merged = new byte[arr1.length + arr2.length]; - System.arraycopy(arr1, 0, merged, 0, arr1.length); - System.arraycopy(arr2, 0, merged, arr1.length, arr2.length); - return merged; - } - - @Override - public Format setInputFormat(Format arg0) - { - // TODO: force sample size, etc - return super.setInputFormat(arg0); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/Encoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/Encoder.java deleted file mode 100644 index fff44b246..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/Encoder.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.gsm; - -import net.sf.fmj.media.*; - -import javax.media.*; -import javax.media.Format; -import javax.media.format.*; - -/** - * GSM encoder Codec. Encodes 160 16-bit PCM samples into array of - * 33 bytes (GSM frame). - * - * @author Martin Harvan - * @author Damian Minkov - */ -public class Encoder - extends AbstractCodec -{ - private Buffer innerBuffer = new Buffer(); - private static final int PCM_BYTES = 320; - private static final int GSM_BYTES = 33; - private int innerDataLength = 0; - byte[] innerContent; - - @Override - public String getName() - { - return "GSM Encoder"; - } - - /** - * Constructs a new Encoder. - */ - public Encoder() - { - super(); - this.inputFormats = new Format[]{ - new AudioFormat( - AudioFormat.LINEAR, - 8000, - 16, - 1, - AudioFormat.BIG_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - Format.byteArray) - }; - - } - - // TODO: move to base class? - protected Format[] outputFormats = new Format[]{ - new AudioFormat( - AudioFormat.GSM, - 8000, - 8, - 1, - Format.NOT_SPECIFIED, - AudioFormat.SIGNED, - 264, - Format.NOT_SPECIFIED, - Format.byteArray)}; - - @Override - public Format[] getSupportedOutputFormats(Format input) - { - if (input == null) - { - return outputFormats; - } else - { - if (!(input instanceof AudioFormat)) - { - return new Format[]{null}; - } - final AudioFormat inputCast = (AudioFormat) input; - final AudioFormat result = new AudioFormat( - AudioFormat.GSM, - inputCast.getSampleRate(), - 8, - 1, - inputCast.getEndian(), - AudioFormat.SIGNED, - 264, - inputCast.getFrameRate(), - Format.byteArray); - - return new Format[]{result}; - } - } - - @Override - public void open() - { - } - - @Override - public void close() - { - } - - private static final boolean TRACE = false; - - @Override - public int process(Buffer inputBuffer, Buffer outputBuffer) - { - byte [] inputContent=new byte[inputBuffer.getLength()]; - - System.arraycopy( - inputBuffer.getData(), - inputBuffer.getOffset(), - inputContent, - 0, - inputContent.length); - - byte[] mergedContent = mergeArrays( - (byte[]) innerBuffer.getData(), inputContent); - innerBuffer.setData(mergedContent); - innerBuffer.setLength(mergedContent.length); - innerDataLength = innerBuffer.getLength(); - - if (TRACE) dump("input ", inputBuffer); - - if (!checkInputBuffer(inputBuffer)) - { - return BUFFER_PROCESSED_FAILED; - } - - if (isEOM(inputBuffer)) - { - propagateEOM(outputBuffer); - return BUFFER_PROCESSED_OK; - } - - final int result; - byte[] outputBufferData = (byte[]) outputBuffer.getData(); - - if (outputBufferData == null - || outputBufferData.length < - GSM_BYTES * innerDataLength / PCM_BYTES) - { - outputBufferData = new byte[ - GSM_BYTES * (innerDataLength / PCM_BYTES)]; - outputBuffer.setData(outputBufferData); - } - - if (innerDataLength < PCM_BYTES) - { - result = OUTPUT_BUFFER_NOT_FILLED; - System.out.println("Not filled"); - } else - { - final boolean bigEndian = ((AudioFormat) outputFormat).getEndian() - == AudioFormat.BIG_ENDIAN; - - outputBufferData = new byte[ - GSM_BYTES * (innerDataLength / PCM_BYTES)]; - outputBuffer.setData(outputBufferData); - outputBuffer.setLength(GSM_BYTES * (innerDataLength / PCM_BYTES)); - - GSMEncoderUtil.gsmEncode( - bigEndian, - (byte[])innerBuffer.getData(), - innerBuffer.getOffset(), - innerDataLength, - outputBufferData); - - outputBuffer.setFormat(outputFormat); - outputBuffer.setData(outputBufferData); - result = BUFFER_PROCESSED_OK; - byte[] temp = new byte[ - innerDataLength - (innerDataLength / PCM_BYTES) * PCM_BYTES]; - innerContent = (byte[]) innerBuffer.getData(); - System.arraycopy( - innerContent, - (innerDataLength / PCM_BYTES) * PCM_BYTES, - temp, - 0, - temp.length); - - outputBuffer.setOffset(0); - innerBuffer.setLength(temp.length); - innerBuffer.setData(temp); - } - - if (TRACE) - { - dump("input ", inputBuffer); - dump("output", outputBuffer); - } - return result; - } - - private byte[] mergeArrays(byte[] arr1, byte[] arr2) - { - if (arr1 == null) return arr2; - if (arr2 == null) return arr1; - byte[] merged = new byte[arr1.length + arr2.length]; - System.arraycopy(arr1, 0, merged, 0, arr1.length); - System.arraycopy(arr2, 0, merged, arr1.length, arr2.length); - return merged; - } - - - @Override - public Format setInputFormat(Format f) - { - //TODO: force sample size, etc - return super.setInputFormat(f); - } - - @Override - public Format setOutputFormat(Format f) - { - return super.setOutputFormat(f); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/GSMDecoderUtil.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/GSMDecoderUtil.java deleted file mode 100644 index 56eb32f0b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/GSMDecoderUtil.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.gsm; - -import org.rubycoder.gsm.*; - - -/** - * GSMDecoderUtil class - * - * @author Martin Harvan - * @author Damian Minkov - */ -public class GSMDecoderUtil -{ - private static GSMDecoder decoder = new GSMDecoder(); - private static final int GSM_BYTES = 33; - private static final int PCM_INTS = 160; - private static final int PCM_BYTES = 320; - - /** - * Decode GSM data. - * - * @param bigEndian if the data are in big endian format - * @param data the GSM data - * @param offset offset - * @param length length of the data - * @param decoded decoded data array - */ - public static void gsmDecode(boolean bigEndian, - byte[] data, - int offset, - int length, - byte[] decoded) - { - for (int i = 0; i < length / GSM_BYTES; i++) - { - int[] output = new int[PCM_INTS]; - byte[] input = new byte[GSM_BYTES]; - System.arraycopy(data, i * GSM_BYTES, input, 0, GSM_BYTES); - try - { - decoder.decode(input, output); - } catch (InvalidGSMFrameException e) - { - e.printStackTrace(); - } - for (int j = 0; j < PCM_INTS; j++) - { - int index = j << 1; - if (bigEndian) - { - decoded[index + i * PCM_BYTES] - = (byte) ((output[j] & 0xff00) >> 8); - decoded[++index + (i * PCM_BYTES)] - = (byte) ((output[j] & 0x00ff)); - } else - { - decoded[index + i * PCM_BYTES] - = (byte) ((output[j] & 0x00ff)); - decoded[++index + (i * PCM_BYTES)] - = (byte) ((output[j] & 0xff00) >> 8); - } - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/GSMEncoderUtil.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/GSMEncoderUtil.java deleted file mode 100644 index 701094602..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/GSMEncoderUtil.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.gsm; - -import org.rubycoder.gsm.*; - -/** - * GSMEncoderUtil class - * - * @author Martin Harvan - * @author Damian Minkov - */ -public class GSMEncoderUtil { - - private static GSMEncoder encoder = new GSMEncoder(); - /** - * number of bytes in GSM frame - */ - private static final int GSM_BYTES = 33; - - /** - * number of PCM bytes needed to encode - */ - private static final int PCM_BYTES = 320; - - /** - * number of PCM ints needed to encode - */ - private static final int PCM_INTS = 160; - - /** - * Encode data to GSM. - * - * @param bigEndian if the data is in big endian format - * @param data data to encode - * @param offset offset - * @param length length of data - * @param decoded array of encoded data. - */ - public static void gsmEncode( - boolean bigEndian, - byte[] data, - int offset, - int length, - byte[] decoded) - { - for (int i = offset; i < length / PCM_BYTES; i++) - { - int[] input = new int[PCM_INTS]; - byte[] output = new byte[GSM_BYTES]; - - for (int j = 0; j < PCM_INTS; j++) { - int index = j << 1; - - input[j] = data[i * PCM_BYTES + index++]; - - input[j] <<= 8; - input[j] |= data[i * PCM_BYTES + index++] & 0xFF; - } - encoder.encode(output, input); - System.arraycopy(output, 0, decoded, i * GSM_BYTES, GSM_BYTES); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/Packetizer.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/Packetizer.java deleted file mode 100644 index 5e34d4b47..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/gsm/Packetizer.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.gsm; - -import javax.media.*; -import javax.media.format.*; - -import net.sf.fmj.media.*; - -/** - * GSM/RTP packetizer Codec. - * - * @author Martin Harvan - * @author Damian Minkov - */ -public class Packetizer - extends AbstractPacketizer -{ - private static final int PACKET_SIZE = 33; - - @Override - public String getName() - { - return "GSM Packetizer"; - } - - /** - * Constructs a new Packetizer. - */ - public Packetizer() - { - super(); - this.inputFormats = new Format[]{ - new AudioFormat( - AudioFormat.GSM, - 8000, - 8, - 1, - Format.NOT_SPECIFIED, - AudioFormat.SIGNED, - 264, - Format.NOT_SPECIFIED, - Format.byteArray)}; - } - - // TODO: move to base class? - protected Format[] outputFormats = new Format[]{ - new AudioFormat( - AudioFormat.GSM_RTP, - 8000, - 8, - 1, - Format.NOT_SPECIFIED, - AudioFormat.SIGNED, - 264, - Format.NOT_SPECIFIED, - Format.byteArray)}; - - @Override - public Format[] getSupportedOutputFormats(Format input) - { - if (input == null) - return outputFormats; - else - { - if (!(input instanceof AudioFormat)) - { - return new Format[]{null}; - } - final AudioFormat inputCast = (AudioFormat) input; - if (!inputCast.getEncoding().equals(AudioFormat.GSM) - || (inputCast.getSampleSizeInBits() != 8 - && inputCast.getSampleSizeInBits() != Format.NOT_SPECIFIED) - || (inputCast.getChannels() != 1 - && inputCast.getChannels() != Format.NOT_SPECIFIED) - || (inputCast.getFrameSizeInBits() != 264 - && inputCast.getFrameSizeInBits() != Format.NOT_SPECIFIED) - ) - { - return new Format[]{null}; - } - final AudioFormat result = - new AudioFormat( - AudioFormat.GSM_RTP, - inputCast.getSampleRate(), - 8, - 1, - inputCast.getEndian(), - inputCast.getSigned(), - 264, - inputCast.getFrameRate(), - inputCast.getDataType()); - - return new Format[]{result}; - } - } - - @Override - public void open() - { - setPacketSize(PACKET_SIZE); - } - - @Override - public void close() - { - } - - @Override - public Format setInputFormat(Format f) - { - return super.setInputFormat(f); - } - - @Override - public Format setOutputFormat(Format f) - { - return super.setOutputFormat(f); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/JavaDecoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/JavaDecoder.java deleted file mode 100644 index 1943b9c8c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/JavaDecoder.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.ilbc; - -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; - -/** - * Implements an iLBC decoder and RTP depacketizer as a {@link Codec}. - * - * @author Damian Minkov - * @author Lyubomir Marinov - */ -public class JavaDecoder - extends AbstractCodecExt -{ - - /** - * The ilbc_decoder adapted to Codec by this instance. - */ - private ilbc_decoder dec; - - /** - * The input length in bytes with which {@link #dec} has been initialized. - */ - private int inputLength; - - /** - * List of offsets for a "more than one" iLBC frame per RTP packet. - */ - private List offsets = new ArrayList(); - - /** - * Initializes a new iLBC JavaDecoder instance. - */ - public JavaDecoder() - { - super( - "iLBC Decoder", - AudioFormat.class, - new Format[] { new AudioFormat(AudioFormat.LINEAR) }); - - inputFormats - = new Format[] - { - new AudioFormat( - Constants.ILBC_RTP, - 8000, - 16, - 1, - Format.NOT_SPECIFIED /* endian */, - Format.NOT_SPECIFIED /* signed */) - }; - - addControl( - new com.sun.media.controls.SilenceSuppressionAdapter( - this, - false, - false)); - } - - /** - * Implements {@link AbstractCodecExt#doClose()}. - * - * @see AbstractCodecExt#doClose() - */ - protected void doClose() - { - dec = null; - inputLength = 0; - } - - /** - * Implements {@link AbstractCodecExt#doOpen()}. - * - * @see AbstractCodecExt#doOpen() - */ - protected void doOpen() - { - } - - /** - * Implements {@link AbstractCodecExt#doProcess(Buffer, Buffer)}. - * - * @param inputBuffer - * @param outputBuffer - * @return - * @see AbstractCodecExt#doProcess(Buffer, Buffer) - */ - protected int doProcess(Buffer inputBuffer, Buffer outputBuffer) - { - byte[] input = (byte[]) inputBuffer.getData(); - int inputLength = inputBuffer.getLength(); - - if(offsets.size() == 0 && - ((inputLength > ilbc_constants.NO_OF_BYTES_20MS && - inputLength != ilbc_constants.NO_OF_BYTES_30MS) || - inputLength > ilbc_constants.NO_OF_BYTES_30MS)) - { - int nb = 0; - int len = 0; - - if((inputLength % ilbc_constants.NO_OF_BYTES_20MS) == 0) - { - nb = (inputLength % ilbc_constants.NO_OF_BYTES_20MS); - len = ilbc_constants.NO_OF_BYTES_20MS; - } - else if((inputLength % ilbc_constants.NO_OF_BYTES_30MS) == 0) - { - nb = (inputLength % ilbc_constants.NO_OF_BYTES_30MS); - len = ilbc_constants.NO_OF_BYTES_30MS; - } - - if (this.inputLength != len) - initDec(len); - - for(int i = 0 ; i < nb ; i++) - { - offsets.add(new Integer(inputLength + (i * len))); - } - } - else - if (this.inputLength != inputLength) - initDec(inputLength); - - int outputLength = dec.ULP_inst.blockl * 2; - byte[] output = validateByteArraySize(outputBuffer, outputLength); - int outputOffset = 0; - - int offsetToAdd = 0; - - if(offsets.size() > 0) - offsetToAdd = offsets.remove(0).intValue(); - - dec.decode( - output, outputOffset, - input, inputBuffer.getOffset() + offsetToAdd, - (short) 1); - - updateOutput( - outputBuffer, - getOutputFormat(), outputLength, outputOffset); - int flags = BUFFER_PROCESSED_OK; - - if(offsets.size() > 0) - { - flags |= INPUT_BUFFER_NOT_CONSUMED; - } - - return flags; - } - - @Override - protected Format[] getMatchingOutputFormats(Format inputFormat) - { - AudioFormat inputAudioFormat = (AudioFormat) inputFormat; - - return - new AudioFormat[] - { - new AudioFormat( - AudioFormat.LINEAR, - inputAudioFormat.getSampleRate(), - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED) - }; - } - - /** - * Initializes {@link #dec} so that it processes a specific number of bytes - * as input. - * - * @param inputLength the number of bytes of input to be processed by - * {@link #dec} - */ - private void initDec(int inputLength) - { - int mode; - - switch (inputLength) - { - case ilbc_constants.NO_OF_BYTES_20MS: - mode = 20; - break; - case ilbc_constants.NO_OF_BYTES_30MS: - mode = 30; - break; - default: - throw new IllegalArgumentException("inputLength"); - } - - dec = new ilbc_decoder(mode, 1); - this.inputLength = inputLength; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/JavaEncoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/JavaEncoder.java deleted file mode 100644 index 6e50fd48c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/JavaEncoder.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.ilbc; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; - -/** - * Implements an iLBC encoder and RTP packetizer as a {@link Codec}. - * - * @author Damian Minkov - * @author Lyubomir Marinov - */ -public class JavaEncoder - extends AbstractCodecExt -{ - /** - * The ilbc_encoder adapted to Codec by this instance. - */ - private ilbc_encoder enc; - - /** - * The input length in bytes with which {@link #enc} has been initialized. - */ - private int inputLength; - - /** - * The output length in bytes with which {@link #enc} has been initialized. - */ - private int outputLength; - - /** - * The input from previous calls to {@link #doProcess(Buffer, Buffer)} which - * has not been consumed yet. - */ - private byte[] prevInput; - - /** - * The number of bytes in {@link #prevInput} which have not been consumed - * yet. - */ - private int prevInputLength; - - /** - * The duration an output Buffer produced by this Codec. - */ - private int duration = 0; - - /** - * Initializes a new iLBC JavaEncoder instance. - */ - public JavaEncoder() - { - super( - "iLBC Encoder", - AudioFormat.class, - new Format[] - { - new AudioFormat( - Constants.ILBC_RTP, - 8000, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED) - }); - - inputFormats - = new Format[] - { - new AudioFormat( - AudioFormat.LINEAR, - 8000, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED) - }; - - addControl( - new com.sun.media.controls.SilenceSuppressionAdapter( - this, - false, - false)); - } - - /** - * Implements {@link AbstractCodecExt#doClose()}. - * - * @see AbstractCodecExt#doClose() - */ - protected void doClose() - { - enc = null; - outputLength = 0; - inputLength = 0; - prevInput = null; - prevInputLength = 0; - duration = 0; - } - - /** - * Implements {@link AbstractCodecExt#doOpen()}. - * - * @see AbstractCodecExt#doOpen() - */ - protected void doOpen() - { - int mode = Constants.ILBC_MODE; - - enc = new ilbc_encoder(mode); - - switch (mode) - { - case 20: - outputLength = ilbc_constants.NO_OF_BYTES_20MS; - break; - case 30: - outputLength = ilbc_constants.NO_OF_BYTES_30MS; - break; - default: - throw new IllegalStateException("mode"); - } - /* mode is 20 or 30 ms, duration must be in nanoseconds */ - duration = mode * 1000000; - inputLength = enc.ULP_inst.blockl * 2; - prevInput = new byte[inputLength]; - prevInputLength = 0; - } - - /** - * Get the output format. - * - * @return output format - * @see net.sf.fmj.media.AbstractCodec#getOutputFormat() - */ - @Override - public Format getOutputFormat() - { - Format outputFormat = super.getOutputFormat(); - - if ((outputFormat != null) - && (outputFormat.getClass() == AudioFormat.class)) - { - AudioFormat outputAudioFormat = (AudioFormat) outputFormat; - - outputFormat = setOutputFormat( - new AudioFormat( - outputAudioFormat.getEncoding(), - outputAudioFormat.getSampleRate(), - outputAudioFormat.getSampleSizeInBits(), - outputAudioFormat.getChannels(), - outputAudioFormat.getEndian(), - outputAudioFormat.getSigned(), - outputAudioFormat.getFrameSizeInBits(), - outputAudioFormat.getFrameRate(), - outputAudioFormat.getDataType()) - { - private static final long serialVersionUID = 0L; - - @Override - public long computeDuration(long length) - { - return JavaEncoder.this.duration; - } - }); - } - return outputFormat; - } - - /** - * Implements {@link AbstractCodecExt#doProcess(Buffer, Buffer)}. - * - * @param inputBuffer - * @param outputBuffer - * @return - * @see AbstractCodecExt#doProcess(Buffer, Buffer) - */ - protected int doProcess(Buffer inputBuffer, Buffer outputBuffer) - { - int inputLength = inputBuffer.getLength(); - byte[] input = (byte[]) inputBuffer.getData(); - int inputOffset = inputBuffer.getOffset(); - - if ((prevInputLength != 0) || (inputLength < this.inputLength)) - { - int bytesToCopy = this.inputLength - prevInputLength; - - if (bytesToCopy > inputLength) - bytesToCopy = inputLength; - System.arraycopy( - input, inputOffset, - prevInput, prevInputLength, - bytesToCopy); - prevInputLength += bytesToCopy; - - inputBuffer.setLength(inputLength - bytesToCopy); - inputBuffer.setOffset(inputOffset + bytesToCopy); - - inputLength = prevInputLength; - input = prevInput; - inputOffset = 0; - } - else - { - inputBuffer.setLength(inputLength - this.inputLength); - inputBuffer.setOffset(inputOffset + this.inputLength); - } - - int ret; - - if (inputLength >= this.inputLength) - { - /* - * If we are about to encode from prevInput, we already have - * prevInputLength taken into consideration by using prevInput in - * the first place and we have to make sure that we will not use the - * same prevInput more than once. - */ - prevInputLength = 0; - - int outputOffset = 0; - byte[] output - = validateByteArraySize( - outputBuffer, - outputOffset + outputLength); - - enc.encode(output, outputOffset, input, inputOffset); - - updateOutput( - outputBuffer, - getOutputFormat(), outputLength, outputOffset); - outputBuffer.setDuration(duration); - ret = BUFFER_PROCESSED_OK; - } - else - ret = OUTPUT_BUFFER_NOT_FILLED; - - if (inputBuffer.getLength() > 0) - ret |= INPUT_BUFFER_NOT_CONSUMED; - return ret; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/bitpack.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/bitpack.java deleted file mode 100644 index 92b17e6f5..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/bitpack.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.ilbc; - -/** - * @author Jean Lorchat - */ -class bitpack { - - int firstpart; - int rest; - - public bitpack() { - firstpart = 0; - rest = 0; - } - - public bitpack(int fp, int r) { - firstpart = fp; - rest = r; - } - - public int get_firstpart() { - return firstpart; - } - - public void set_firstpart(int fp) { - firstpart = fp; - } - - public int get_rest() { - return rest; - } - - public void set_rest(int r) { - rest = r; - } - -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/bitstream.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/bitstream.java deleted file mode 100644 index 0eb7fe0be..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/bitstream.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.ilbc; - -/** - * - * @author Jean Lorchat - * @author Lyubomir Marinov - */ -class bitstream { - - int bitcount; - - int pos; - - final byte [] buffer; - - /** - * The offset in {@link #buffer} of the first octet of this - * bitstream. - */ - final int buffer_off; - - /** - * The length in {@link #buffer} which is available to octets of this - * bitstream. - */ - final int buffer_len; - private int buffer_pos; - - public bitstream(byte[] buffer, int offset, int length) - { - pos = 0; - - this.buffer = buffer; - buffer_off = offset; - buffer_len = length; - - buffer_pos = buffer_off; - bitcount = 0; - } - - /*----------------------------------------------------------------* - * splitting an integer into first most significant bits and - * remaining least significant bits - *---------------------------------------------------------------*/ - - public bitpack packsplit( - int index, /* (i) the value to split */ - int bitno_firstpart, /* (i) number of bits in most - significant part */ - int bitno_total) /* (i) number of bits in full range - of value */ - { - int bitno_rest = bitno_total - bitno_firstpart; - bitpack rval = new bitpack (); - - int fp = index >>> bitno_rest; - - rval.set_firstpart(fp); - // *firstpart = *index>>(bitno_rest); - rval.set_rest(index - (rval.get_firstpart() << bitno_rest)); - // *rest = *index-(*firstpart<<(bitno_rest)); - return rval; - } - - /*----------------------------------------------------------------* - * combining a value corresponding to msb's with a value - * corresponding to lsb's - *---------------------------------------------------------------*/ - - int packcombine( - int index, /* (i/o) the msb value in the - combined value out */ - int rest, /* (i) the lsb value */ - int bitno_rest /* (i) the number of bits in the - lsb part */ - ){ - index = index << bitno_rest; - index += rest; - return index; - } - - /*----------------------------------------------------------------* - * packing of bits into bitstream, i.e., vector of bytes - *---------------------------------------------------------------*/ - - void dopack( -// unsigned char **bitstream, /* (i/o) on entrance pointer to -// place in bitstream to pack -// new data, on exit pointer -// to place in bitstream to -// pack future data */ - int index, /* (i) the value to pack */ - int bitno /* (i) the number of bits that the - value will fit within */ - ){ - int posLeft; - - // System.out.println("packing " + bitno + " bits (" + index + "), total packed : " + (bitcount+bitno) + " bits to date"); - bitcount += bitno; - - // System.out.println("packing tag " + index + " of length " + bitno + "bits from byte " + buffer_pos + "/" + buffer.length + " at " + pos + "th bit"); - - /* Clear the bits before starting in a new byte */ - - if (pos == 0) { - buffer[buffer_pos] = 0; - } - - while (bitno > 0) { - - /* Jump to the next byte if end of this byte is reached*/ - - if (pos == 8) { - pos = 0; - buffer_pos++; - buffer[buffer_pos] = 0; - } - - posLeft = 8 - pos; - - /* Insert index into the bitstream */ - - if (bitno <= posLeft) { - buffer[buffer_pos] |= (byte) (index << (posLeft - bitno)); - pos += bitno; - bitno = 0; - } else { - buffer[buffer_pos] |= (byte) (index >>> (bitno - posLeft)); - - pos = 8; - index -= ((index >>> (bitno - posLeft)) << (bitno - posLeft)); - - bitno -= posLeft; - } - } - } - - /*----------------------------------------------------------------* - * unpacking of bits from bitstream, i.e., vector of bytes - *---------------------------------------------------------------*/ - - public int unpack( - int bitno /* (i) number of bits used to - represent the value */ - ) - { - int BitsLeft; - int index=0; - - while (bitno > 0) { - - /* move forward in bitstream when the end of the - byte is reached */ - - if (pos == 8) { - pos = 0; - buffer_pos++; - } - - BitsLeft = 8 - pos; - - /* Extract bits to index */ - - if (BitsLeft >= bitno) { - index += ((((buffer[buffer_pos]) << (pos)) & 0xFF) >>> (8 - bitno)); - pos += bitno; - bitno = 0; - } else { - - if ((8 - bitno) > 0) { - index+=((((buffer[buffer_pos]) << (pos)) & 0xFF) >>> (8 - bitno)); - pos=8; - } else { - index+=(((buffer[buffer_pos] << pos) & 0xFF) << (bitno - 8)); - pos=8; - } - bitno -= BitsLeft; - } - } - - return index; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/ilbc_common.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/ilbc_common.java deleted file mode 100644 index 0774e4d10..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/ilbc_common.java +++ /dev/null @@ -1,722 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.ilbc; - -/** - * @author Jean Lorchat - */ -class ilbc_common { - - /*----------------------------------------------------------------* - * check for stability of lsf coefficients - *---------------------------------------------------------------*/ - - public static int LSF_check( /* (o) 1 for stable lsf vectors and 0 for - nonstable ones */ - float lsf[], /* (i) a table of lsf vectors */ - int dim, /* (i) the dimension of each lsf vector */ - int NoAn) /* (i) the number of lsf vectors in the - table */ - { - int k,n,m, Nit=2, change=0,pos; - float eps=(float)0.039; /* 50 Hz */ - float eps2=(float)0.0195; - float maxlsf=(float)3.14; /* 4000 Hz */ - float minlsf=(float)0.01; /* 0 Hz */ - - /* LSF separation check*/ - - for (n=0; nmaxlsf) { - lsf[pos]=maxlsf; - change=1; - } - } - } - } - - return change; - } - - /*----------------------------------------------------------------* - * decoding of the start state - *---------------------------------------------------------------*/ - - public static void StateConstructW( - int idxForMax, /* (i) 6-bit index for the quantization of - max amplitude */ - int idxVec[], /* (i) vector of quantization indexes */ - float syntDenum[], /* (i) synthesis filter denumerator */ - int syntDenum_idx, - float out[], /* (o) the decoded state vector */ - int out_idx, - int len /* (i) length of a state vector */ - ){ - float maxVal; - float [] tmpbuf = new float[ilbc_constants.LPC_FILTERORDER+2*ilbc_constants.STATE_LEN]; - //, *tmp, - int tmp; - float [] numerator = new float[ilbc_constants.LPC_FILTERORDER+1]; - float [] foutbuf = new float[ilbc_constants.LPC_FILTERORDER+2*ilbc_constants.STATE_LEN]; - //, *fout; - int fout; - int k,tmpi; - - /* decoding of the maximum value */ - - maxVal = ilbc_constants.state_frgqTbl[idxForMax]; - //System.out.println("idxForMax : " + idxForMax + "maxVal : " + maxVal); - maxVal = (float)Math.pow(10,maxVal) / 4.5f; - //System.out.println("maxVal : " + maxVal); - - /* initialization of buffers and coefficients */ - - for (int li = 0; li < ilbc_constants.LPC_FILTERORDER; li++) { - tmpbuf[li] = 0.0f; - foutbuf[li] = 0.0f; - } - // memset(tmpbuf, 0, LPC_FILTERORDER*sizeof(float)); - // memset(foutbuf, 0, LPC_FILTERORDER*sizeof(float)); - - for (k=0; k < ilbc_constants.LPC_FILTERORDER; k++) { - numerator[k]=syntDenum[syntDenum_idx + ilbc_constants.LPC_FILTERORDER - k]; - //System.out.println("numerator-" + k + " = " + numerator[k] + " (( " + syntDenum[syntDenum_idx + ilbc_constants.LPC_FILTERORDER - k]); - } - - numerator[ilbc_constants.LPC_FILTERORDER]=syntDenum[syntDenum_idx]; - // tmp = &tmpbuf[LPC_FILTERORDER]; - tmp = ilbc_constants.LPC_FILTERORDER; - // fout = &foutbuf[LPC_FILTERORDER]; - fout = ilbc_constants.LPC_FILTERORDER; - - /* decoding of the sample values */ - - // for (int li = 0; li < idxVec.length; li++) - //System.out.println("idxVec["+li+"] = " + idxVec[li]); - - for (k=0; k= 0.5)){ - - - if (freq[0] <= 0.0f) { - freq[0] = (float)0.022; - } - - - if (freq[ilbc_constants.LPC_FILTERORDER - 1] >= 0.5) { - freq[ilbc_constants.LPC_FILTERORDER - 1] = (float)0.499; - } - - hlp = (freq[ilbc_constants.LPC_FILTERORDER - 1] - freq[0]) / - (float) (ilbc_constants.LPC_FILTERORDER - 1); - - for (i=1; i < ilbc_constants.LPC_FILTERORDER; i++) { - freq[i] = freq[i - 1] + hlp; - } - } - - for (int li = 0; li < ilbc_constants.LPC_HALFORDER; li++) { - a1[li] = 0.0f; - a2[li] = 0.0f; - b1[li] = 0.0f; - b2[li] = 0.0f; - } -// memset(a1, 0, LPC_HALFORDER*sizeof(float)); -// memset(a2, 0, LPC_HALFORDER*sizeof(float)); -// memset(b1, 0, LPC_HALFORDER*sizeof(float)); -// memset(b2, 0, LPC_HALFORDER*sizeof(float)); - for (int li = 0; li < ilbc_constants.LPC_HALFORDER + 1; li++) { - a[li] = 0.0f; - b[li] = 0.0f; - } -// memset(a, 0, (LPC_HALFORDER+1)*sizeof(float)); -// memset(b, 0, (LPC_HALFORDER+1)*sizeof(float)); - - /* p[i] and q[i] compute cos(2*pi*omega_{2j}) and - cos(2*pi*omega_{2j-1} in eqs. 4.2.2.2-1 and 4.2.2.2-2. - Note that for this code p[i] specifies the coefficients - used in .Q_A(z) while q[i] specifies the coefficients used - in .P_A(z) */ - - for (i = 0; i < ilbc_constants.LPC_HALFORDER; i++) { - p[i] = (float)Math.cos(ilbc_constants.TWO_PI * freq[2 * i]); - q[i] = (float)Math.cos(ilbc_constants.TWO_PI * freq[2 * i + 1]); - } - - a[0] = 0.25f; - b[0] = 0.25f; - - for (i= 0; i < ilbc_constants.LPC_HALFORDER; i++) { - a[i + 1] = a[i] - 2 * p[i] * a1[i] + a2[i]; - b[i + 1] = b[i] - 2 * q[i] * b1[i] + b2[i]; - a2[i] = a1[i]; - a1[i] = a[i]; - b2[i] = b1[i]; - b1[i] = b[i]; - } - - for (j=0; j < ilbc_constants.LPC_FILTERORDER; j++) { - - if (j == 0) { - a[0] = 0.25f; - b[0] = -0.25f; - } else { - a[0] = b[0] = 0.0f; - } - - for (i=0; i < ilbc_constants.LPC_HALFORDER; i++) { - a[i + 1] = a[i] - 2 * p[i] * a1[i] + a2[i]; - b[i + 1] = b[i] - 2 * q[i] * b1[i] + b2[i]; - a2[i] = a1[i]; - a1[i] = a[i]; - b2[i] = b1[i]; - b1[i] = b[i]; - } - - a_coef[j + 1] = 2 * (a[ilbc_constants.LPC_HALFORDER] + - b[ilbc_constants.LPC_HALFORDER]); - } - - a_coef[0] = 1.0f; - } - - /*----------------------------------------------------------------* - * Construct decoded vector from codebook and gains. - *---------------------------------------------------------------*/ - - /*----------------------------------------------------------------* - * interpolation between vectors - *---------------------------------------------------------------*/ - - public static void interpolate( - float out[], /* (o) the interpolated vector */ - float in1[], /* (i) the first vector for the - interpolation */ - float in2[], /* (i) the second vector for the - interpolation */ - int in2_idx, - float coef, /* (i) interpolation weights */ - int length) /* (i) length of all vectors */ - { - int i; - float invcoef; - - invcoef = 1.0f - coef; - for (i = 0; i < length; i++) { - out[i] = coef * in1[i] + invcoef * in2[i + in2_idx]; - // System.out.println("out["+i+"] devient " + out[i] + ", par " + - // coef + " * " + in1[i] + " + " + invcoef + " * " + in2[i + in2_idx]); - } - } - - /*----------------------------------------------------------------* - * lpc bandwidth expansion - *---------------------------------------------------------------*/ - - public static void bwexpand( - float out[], /* (o) the bandwidth expanded lpc - coefficients */ - int out_idx, - float in[], /* (i) the lpc coefficients before bandwidth - expansion */ - float coef, /* (i) the bandwidth expansion factor */ - int length) /* (i) the length of lpc coefficient vectors */ - { - int i; - float chirp; - - chirp = coef; - - out[out_idx] = in[0]; - for (i = 1; i < length; i++) { - out[i + out_idx] = chirp * in[i]; - chirp *= coef; - } - } - - public static void getCBvec( - float cbvec[], /* (o) Constructed codebook vector */ - float mem[], /* (i) Codebook buffer */ - int mem_idx, - int index, /* (i) Codebook index */ - int lMem, /* (i) Length of codebook buffer */ - int cbveclen) /* (i) Codebook vector length */ - { - int j, k, n, memInd, sFilt; - float [] tmpbuf = new float[ilbc_constants.CB_MEML]; - int base_size; - int ilow, ihigh; - float alfa, alfa1; - - /* Determine size of codebook sections */ - - base_size=lMem-cbveclen+1; - - if (cbveclen==ilbc_constants.SUBL) { - base_size+=cbveclen/2; - } - - /* No filter -> First codebook section */ - - if (index 1) { - gain[1] = gaindequant(gain_index[gain_index_idx + 1], - Math.abs(gain[0]), 16); - } - if (nStages > 2) { - gain[2] = gaindequant(gain_index[gain_index_idx + 2], - Math.abs(gain[1]), 8); - } - - /* codebook vector construction and construction of - total vector */ - - getCBvec(cbvec, mem, mem_idx, index[index_idx + 0], lMem, veclen); - for (j=0;j 1) { - for (k=1; k " + (pi - Out_idx)); - Out[po] -= a[pa] * Out[pi]; -// System.out.println("Pour un resultat de " + Out[po]); - pa++; - pi--; - } - for (j=i+1; j < ilbc_constants.LPC_FILTERORDER+1; j++) { - // *po-=(*pa++)*(*pm--); -// System.out.println("2 Soustraction a " + Out[po] + " de " + a[pa] + " * " + mem[pm]); - Out[po] -= a[pa] * mem[pm]; -// System.out.println("Pour un resultat de " + Out[po]); - pa++; - pm--; - } - po++; - } - - /* Filter last part where the state is entirely in - the output vector */ - - for (i = ilbc_constants.LPC_FILTERORDER; i < len; i++) { - // pi=&Out[i-1]; - pi = Out_idx + i - 1; - // pa=&a[1]; - pa = a_idx + 1; - for (j=1; j < ilbc_constants.LPC_FILTERORDER+1; j++) { - // *po-=(*pa++)*(*pi--); -// System.out.println("3 Soustraction a " + Out[po] + " de " + a[pa] + " * " + Out[pi]); - Out[po] -= a[pa] * Out[pi]; -// System.out.println("Pour un resultat de " + Out[po]); - pa++; - pi--; - } - po++; - } - - /* Update state vector */ - - System.arraycopy(Out, Out_idx + len - ilbc_constants.LPC_FILTERORDER, - mem, 0, ilbc_constants.LPC_FILTERORDER); -// memcpy(mem, &Out[len-LPC_FILTERORDER], -// LPC_FILTERORDER*sizeof(float)); - } - - /*---------------------------------------------------------------* - * interpolation of lsf coefficients for the decoder - *--------------------------------------------------------------*/ - - public void LSFinterpolate2a_dec( - float a[], /* (o) lpc coefficients for a sub-frame */ - float lsf1[], /* (i) first lsf coefficient vector */ - float lsf2[], /* (i) second lsf coefficient vector */ - int lsf2_idx, - float coef, /* (i) interpolation weight */ - int length /* (i) length of lsf vectors */ - ){ - float [] lsftmp = new float[ilbc_constants.LPC_FILTERORDER]; - - ilbc_common.interpolate(lsftmp, lsf1, lsf2, lsf2_idx, coef, length); - ilbc_common.lsf2a(a, lsftmp); - } - - /*---------------------------------------------------------------* - * obtain dequantized lsf coefficients from quantization index - *--------------------------------------------------------------*/ - - void SimplelsfDEQ( - float lsfdeq[], /* (o) dequantized lsf coefficients */ - int index[], /* (i) quantization index */ - int lpc_n /* (i) number of LPCs */ - ){ - int i, j, pos, cb_pos; - - /* decode first LSF */ - - pos = 0; - cb_pos = 0; - for (i = 0; i < ilbc_constants.LSF_NSPLIT; i++) { - for (j = 0; j < ilbc_constants.dim_lsfCbTbl[i]; j++) { - lsfdeq[pos + j] = ilbc_constants.lsfCbTbl[cb_pos + (int) - ((long)(index[i])*ilbc_constants.dim_lsfCbTbl[i] + j)]; - } - pos += ilbc_constants.dim_lsfCbTbl[i]; - cb_pos += ilbc_constants.size_lsfCbTbl[i]*ilbc_constants.dim_lsfCbTbl[i]; - } - - if (lpc_n>1) { - - /* decode last LSF */ - - pos = 0; - cb_pos = 0; - for (i = 0; i < ilbc_constants.LSF_NSPLIT; i++) { - for (j = 0; j < ilbc_constants.dim_lsfCbTbl[i]; j++) { - lsfdeq[ilbc_constants.LPC_FILTERORDER + pos + j] = - ilbc_constants.lsfCbTbl[cb_pos + (int) - ((long)(index[ilbc_constants.LSF_NSPLIT + i])* - ilbc_constants.dim_lsfCbTbl[i]) + j]; - } - pos += ilbc_constants.dim_lsfCbTbl[i]; - cb_pos += ilbc_constants.size_lsfCbTbl[i]*ilbc_constants.dim_lsfCbTbl[i]; - } - } - } - - /*----------------------------------------------------------------* - * obtain synthesis and weighting filters form lsf coefficients - *---------------------------------------------------------------*/ - - void DecoderInterpolateLSF( - float syntdenum[], /* (o) synthesis filter coefficients */ - float weightdenum[], /* (o) weighting denumerator - coefficients */ - float lsfdeq[], /* (i) dequantized lsf coefficients */ - int length) /* (i) length of lsf coefficient vector */ - { - int i, pos, lp_length; - float [] lp = new float[ilbc_constants.LPC_FILTERORDER + 1]; - int lsfdeq2; - - lsfdeq2 = length; -// lsfdeq2 = lsfdeq + length; - lp_length = length + 1; - - if (this.ULP_inst.mode==30) { - /* sub-frame 1: Interpolation between old and first */ - - LSFinterpolate2a_dec(lp, this.lsfdeqold, lsfdeq, 0, - ilbc_constants.lsf_weightTbl_30ms[0], length); - System.arraycopy(lp, 0, syntdenum, 0, lp_length); -// memcpy(syntdenum,lp,lp_length*sizeof(float)); - ilbc_common.bwexpand(weightdenum, 0, lp, ilbc_constants.LPC_CHIRP_WEIGHTDENUM, lp_length); - - /* sub-frames 2 to 6: interpolation between first - and last LSF */ - - pos = lp_length; - for (i = 1; i < 6; i++) { - LSFinterpolate2a_dec(lp, lsfdeq, lsfdeq, lsfdeq2, - ilbc_constants.lsf_weightTbl_30ms[i], length); - System.arraycopy(lp, 0, syntdenum, pos, lp_length); -// memcpy(syntdenum + pos,lp,lp_length*sizeof(float)); - ilbc_common.bwexpand(weightdenum, pos, lp, - ilbc_constants.LPC_CHIRP_WEIGHTDENUM, lp_length); - pos += lp_length; - } - } - else { - pos = 0; - for (i = 0; i < this.ULP_inst.nsub; i++) { - LSFinterpolate2a_dec(lp, this.lsfdeqold, - lsfdeq, 0, ilbc_constants.lsf_weightTbl_20ms[i], length); - System.arraycopy(lp, 0, syntdenum, pos, lp_length); -// memcpy(syntdenum+pos,lp,lp_length*sizeof(float)); - ilbc_common.bwexpand(weightdenum, pos, lp, ilbc_constants.LPC_CHIRP_WEIGHTDENUM, - lp_length); - pos += lp_length; - } - } - - /* update memory */ - - if (this.ULP_inst.mode==30) { - System.arraycopy(lsfdeq, lsfdeq2, this.lsfdeqold, 0, length); -// memcpy(iLBCdec_inst->lsfdeqold, lsfdeq2, length*sizeof(float)); - } else { - System.arraycopy(lsfdeq, 0, this.lsfdeqold, 0, length); -// memcpy(iLBCdec_inst->lsfdeqold, lsfdeq, length*sizeof(float)); - } - } - - - public void index_conv_dec(int index[]) /* (i/o) Codebook indexes */ - { - int k; - - for (k=1; k=44)&&(index[k]<108)) { - index[k]+=64; - } else if ((index[k]>=108)&&(index[k]<128)) { - index[k]+=128; - } else { - /* ERROR */ - } - } - } - - public void hpOutput( - float In[], /* (i) vector to filter */ - int len,/* (i) length of vector to filter */ - float Out[], /* (o) the resulting filtered vector */ - float mem[]) /* (i/o) the filter state */ - { - int i; - // float *pi, *po; - int pi, po; - - /* all-zero section*/ - -// pi = &In[0]; -// po = &Out[0]; - pi = 0; - po = 0; - - for (i=0; i dim1 ) { - hfl2=(dim1/2); - for (j=0; j= idatal) { - searchSegEndPos=idatal-ilbc_constants.ENH_BLOCKL-1; - } - corrdim=searchSegEndPos-searchSegStartPos+1; - - /* compute upsampled correlation (corr33) and find - location of max */ -// System.out.println("appel 1"); - mycorr1(corrVec, 0, idata, searchSegStartPos, - corrdim+ilbc_constants.ENH_BLOCKL-1, - idata,centerStartPos,ilbc_constants.ENH_BLOCKL); - enh_upsample(corrVecUps,corrVec,corrdim,ilbc_constants.ENH_FL0); - tloc=0; maxv=corrVecUps[0]; - for (i=1; imaxv) { - tloc=i; - maxv=corrVecUps[i]; - } - } - - /* make vector can be upsampled without ever running outside - bounds */ - - updStartPos= searchSegStartPos + - (float)tloc/(float)ilbc_constants.ENH_UPS0+1.0f; - tloc2=tloc/ilbc_constants.ENH_UPS0; - - if (tloc>tloc2*ilbc_constants.ENH_UPS0) { - tloc2++; - } - st=searchSegStartPos+tloc2-ilbc_constants.ENH_FL0; - - if (st<0) { - for (int li = 0; li < -st; li++) - vect[li] = 0.0f; -// memset(vect,0,-st*sizeof(float)); - System.arraycopy(idata, 0, vect, -st, (ilbc_constants.ENH_VECTL+st)); -// memcpy(&vect[-st],idata, (ilbc_constants.ENH_VECTL+st)*sizeof(float)); - } - else { - en=st+ilbc_constants.ENH_VECTL; - - if (en>idatal) { - System.arraycopy(idata, st, vect, 0, (ilbc_constants.ENH_VECTL-(en-idatal))); -// memcpy(vect, &idata[st], -// (ilbc_constants.ENH_VECTL-(en-idatal))*sizeof(float)); - for (int li = 0; li < en-idatal; li++) - vect[ilbc_constants.ENH_VECTL-(en-idatal)+li] = 0.0f; -// memset(&vect[ilbc_constants.ENH_VECTL-(en-idatal)], 0, -// (en-idatal)*sizeof(float)); - } - else { - System.arraycopy(idata, st, vect, 0, ilbc_constants.ENH_VECTL); -// memcpy(vect, &idata[st], ilbc_constants.ENH_VECTL*sizeof(float)); - } - } - fraction=tloc2*ilbc_constants.ENH_UPS0-tloc; - - /* compute the segment (this is actually a convolution) */ - -// System.out.println("appel 2"); -// System.out.println("longueur 1 : " + vect.length); -// System.out.println("distance 1 : " + 0); -// System.out.println("longueur 2 : " + ilbc_constants.polyphaserTbl.length); -// System.out.println("distance 2 : " + (2*ilbc_constants.ENH_FL0+1)*fraction); -// System.out.println("dimension 1 : " + ilbc_constants.ENH_VECTL); -// System.out.println("dimension 2 : " + (2 * ilbc_constants.ENH_FL0+1)); -// System.out.println("correlations de dimension " + seg.length); - mycorr1(seg, seg_idx, vect, 0, ilbc_constants.ENH_VECTL, - ilbc_constants.polyphaserTbl, - (2*ilbc_constants.ENH_FL0+1)*fraction, - 2*ilbc_constants.ENH_FL0+1); - - return updStartPos; - } - - /*----------------------------------------------------------------* - * find the smoothed output data - *---------------------------------------------------------------*/ - - public void smath( - float odata[], /* (o) smoothed output */ - int odata_idx, - float sseq[],/* (i) said second sequence of waveforms */ - int hl, /* (i) 2*hl+1 is sseq dimension */ - float alpha0)/* (i) max smoothing energy fraction */ - { - int i,k; - float w00,w10,w11,A,B,C,err,errs; - float [] surround = new float[ilbc_constants.BLOCKL_MAX]; /* shape contributed by other than - current */ - float [] wt = new float[2*ilbc_constants.ENH_HL+1]; /* waveform weighting to get - surround shape */ - float denom; - int psseq; - - /* create shape of contribution from all waveforms except the - current one */ - - for (i=1; i<=2*hl+1; i++) { - wt[i-1] = (float)0.5*(1 - (float)Math.cos(2*ilbc_constants.PI*i/(2*hl+2))); - } - wt[hl]=0.0f; /* for clarity, not used */ - for (i=0; i alpha0 * w00) { - if ( w00 < 1) { - w00=1; - } - denom = (w11*w00-w10*w10)/(w00*w00); - - if (denom > 0.0001f) { /* eliminates numerical problems - for if smooth */ - A = (float)Math.sqrt( (alpha0- alpha0*alpha0/4)/denom); - B = -alpha0/2 - A * w10/w00; - B = B+1; - } - else { /* essentially no difference between cycles; - smoothing not needed */ - A= 0.0f; - B= 1.0f; - } - - /* create smoothed sequence */ - - psseq=hl*ilbc_constants.ENH_BLOCKL; - for (i=0; i=0; q--) { - blockStartPos[q]=blockStartPos[q+1]-period[lagBlock[q+1]]; - lagBlock[q] = NearestNeighbor(plocs, - blockStartPos[q]+ - ilbc_constants.ENH_BLOCKL_HALF-period[lagBlock[q+1]], - periodl); - - - if (blockStartPos[q]-ilbc_constants.ENH_OVERHANG>=0) { - blockStartPos[q] = refiner(sseq,q*ilbc_constants.ENH_BLOCKL, idata, - idatal, centerStartPos, - blockStartPos[q], - period[lagBlock[q+1]]); - } else { - psseq=q*ilbc_constants.ENH_BLOCKL; -// psseq=sseq+q*ENH_BLOCKL; - for (int li = 0; li < ilbc_constants.ENH_BLOCKL; li++) - sseq[psseq+li] = 0.0f; -// memset(psseq, 0, ENH_BLOCKL*sizeof(float)); - } - } - - /* future */ - - for (i=0; i 0.0f) { - return (ftmp1*ftmp1/ftmp2); - } - else { - return 0.0f; - } - } - - /*----------------------------------------------------------------* - * interface for enhancer - *---------------------------------------------------------------*/ - - int enhancerInterface( - float out[], /* (o) enhanced signal */ - float in[]) /* (i) unenhanced signal */ - { - // float *enh_buf, *enh_period; (definis en global pour la classe) - int iblock, isample; - int lag=0, ilag, i, ioffset; - float cc, maxcc; - float ftmp1, ftmp2; - // float *inPtr, *enh_bufPtr1, *enh_bufPtr2; - int inPtr, enh_bufPtr1, enh_bufPtr2; - float [] plc_pred = new float[ilbc_constants.ENH_BLOCKL]; - - float [] lpState = new float[6]; - float [] downsampled = new float[(ilbc_constants.ENH_NBLOCKS*ilbc_constants.ENH_BLOCKL+120)/2]; - int inLen=ilbc_constants.ENH_NBLOCKS*ilbc_constants.ENH_BLOCKL+120; - int start, plc_blockl, inlag; - - // enh_buf=iLBCdec_inst->enh_buf; - // enh_period=iLBCdec_inst->enh_period; - - System.arraycopy(enh_buf, this.ULP_inst.blockl, - enh_buf, 0, - ilbc_constants.ENH_BUFL-this.ULP_inst.blockl); -// memmove(enh_buf, &enh_buf[iLBCdec_inst->blockl], -// (ENH_BUFL-iLBCdec_inst->blockl)*sizeof(float)); - - - System.arraycopy(in, 0, enh_buf, ilbc_constants.ENH_BUFL-this.ULP_inst.blockl, - this.ULP_inst.blockl); -// memcpy(&enh_buf[ENH_BUFL-this.ULP_inst.blockl], in, -// this.ULP_inst.blockl*sizeof(float)); - - if (this.ULP_inst.mode==30) - plc_blockl=ilbc_constants.ENH_BLOCKL; - else - plc_blockl=40; - - /* when 20 ms frame, move processing one block */ - ioffset=0; - if (this.ULP_inst.mode==20) ioffset=1; - - i=3-ioffset; - System.arraycopy(enh_period, i, enh_period, 0, ilbc_constants.ENH_NBLOCKS_TOT-i); -// memmove(enh_period, &enh_period[i], -// (ENH_NBLOCKS_TOT-i)*sizeof(float)); - - /* Set state information to the 6 samples right before - the samples to be downsampled. */ - - System.arraycopy(enh_buf, (ilbc_constants.ENH_NBLOCKS_EXTRA+ioffset)*ilbc_constants.ENH_BLOCKL-126, - lpState, 0, 6); -// memcpy(lpState, -// enh_buf+(ENH_NBLOCKS_EXTRA+ioffset)*ENH_BLOCKL-126, -// 6*sizeof(float)); - - /* Down sample a factor 2 to save computations */ - - DownSample(enh_buf, - (ilbc_constants.ENH_NBLOCKS_EXTRA+ioffset)*ilbc_constants.ENH_BLOCKL-120, - ilbc_constants.lpFilt_coefsTbl, inLen-ioffset*ilbc_constants.ENH_BLOCKL, - lpState, downsampled); - - /* Estimate the pitch in the down sampled domain. */ - for (iblock = 0; iblock maxcc) { - maxcc = cc; - lag = ilag; - } - } - - /* Store the estimated lag in the non-downsampled domain */ - enh_period[iblock+ilbc_constants.ENH_NBLOCKS_EXTRA+ioffset] = (float)lag*2; - - - } - - - /* PLC was performed on the previous packet */ - if (this.prev_enh_pl==1) { - - inlag=(int)enh_period[ilbc_constants.ENH_NBLOCKS_EXTRA+ioffset]; - - lag = inlag-1; - maxcc = xCorrCoef(in, 0, in, lag, plc_blockl); - for (ilag=inlag; ilag<=inlag+1; ilag++) { - cc = xCorrCoef(in, 0, in, ilag, plc_blockl); - if (cc > maxcc) { - maxcc = cc; - lag = ilag; - } - } - - enh_period[ilbc_constants.ENH_NBLOCKS_EXTRA+ioffset-1]=lag; - - /* compute new concealed residual for the old lookahead, - mix the forward PLC with a backward PLC from - the new frame */ - - // inPtr=&in[lag-1]; - inPtr = lag - 1; - - // enh_bufPtr1=&plc_pred[plc_blockl-1]; - enh_bufPtr1 = plc_blockl - 1; - - if (lag>plc_blockl) { - start=plc_blockl; - } else { - start=lag; - } - - for (isample = start; isample>0; isample--) { - // *enh_bufPtr1-- = *inPtr--; - plc_pred[enh_bufPtr1] = in[inPtr]; - enh_bufPtr1--; - inPtr--; - } - - // enh_bufPtr2=&enh_buf[ENH_BUFL-1-this.ULP_inst.blockl]; - enh_bufPtr2 = ilbc_constants.ENH_BUFL - 1 - this.ULP_inst.blockl; - for (isample = (plc_blockl-1-lag); isample>=0; isample--) { - // *enh_bufPtr1-- = *enh_bufPtr2--; - plc_pred[enh_bufPtr1] = enh_buf[enh_bufPtr2]; - enh_bufPtr1--; - enh_bufPtr2--; - } - - /* limit energy change */ - ftmp2=0.0f; - ftmp1=0.0f; - for (i=0;i 2.0f*ftmp2 && ftmp1 > 0.0) { - for (i=0;i 0.0f) { - cc[0] = ftmp1*ftmp1/ftmp2; - gc[0] = Math.abs(ftmp1 / ftmp2); - pm[0] = Math.abs(ftmp1) / - ((float)Math.sqrt(ftmp2)*(float)Math.sqrt(ftmp3)); - } - else { - cc[0] = 0.0f; - gc[0] = 0.0f; - pm[0] = 0.0f; - } - } - - public void doThePLC( - float PLCresidual[], /* (o) concealed residual */ - float PLClpc[], /* (o) concealed LP parameters */ - int PLI, /* (i) packet loss indicator - 0 - no PL, 1 = PL */ - float decresidual[], /* (i) decoded residual */ - float lpc[], /* (i) decoded LPC (only used for no PL) */ - int lpc_idx, - int inlag) /* (i) pitch lag */ - { - int lag = 20, randlag = 0; - float gain = 0.0f, maxcc = 0.0f; - float use_gain = 0.0f; - float gain_comp = 0.0f, maxcc_comp = 0.0f, per = 0.0f, max_per = 0.0f; - int i, pick, use_lag; - float ftmp, randvec[], pitchfact, energy; - float [] a_gain, a_comp, a_per; - - randvec = new float [ilbc_constants.BLOCKL_MAX]; - - a_gain = new float[1]; - a_comp = new float[1]; - a_per = new float[1]; - - /* Packet Loss */ - - if (PLI == 1) { - - this.consPLICount += 1; - - /* if previous frame not lost, - determine pitch pred. gain */ - - if (this.prevPLI != 1) { - - /* Search around the previous lag to find the - best pitch period */ - - lag=inlag-3; - - a_comp[0] = maxcc; - a_gain[0] = gain; - a_per[0] = max_per; - compCorr(a_comp, a_gain, a_per, - this.prevResidual, - lag, this.ULP_inst.blockl, 60); - maxcc = a_comp[0]; - gain = a_gain[0]; - max_per = a_per[0]; - - for (i=inlag-2;i<=inlag+3;i++) { - - a_comp[0] = maxcc_comp; - a_gain[0] = gain_comp; - a_per[0] = per; - compCorr(a_comp, a_gain, a_per, - this.prevResidual, - i, this.ULP_inst.blockl, 60); - maxcc_comp = a_comp[0]; - gain_comp = a_gain[0]; - per = a_per[0]; - - if (maxcc_comp>maxcc) { - maxcc=maxcc_comp; - gain=gain_comp; - lag=i; - max_per=per; - } - } - } - - /* previous frame lost, use recorded lag and periodicity */ - - else { - lag=this.prevLag; - max_per=this.per; - } - - /* downscaling */ - - use_gain=1.0f; - if (this.consPLICount*this.ULP_inst.blockl>320) - use_gain=0.9f; - else if (this.consPLICount*this.ULP_inst.blockl>2*320) - use_gain=0.7f; - else if (this.consPLICount*this.ULP_inst.blockl>3*320) - use_gain=0.5f; - else if (this.consPLICount*this.ULP_inst.blockl>4*320) - use_gain=0.0f; - - /* mix noise and pitch repeatition */ - ftmp=(float)Math.sqrt(max_per); - if (ftmp > 0.7f) - pitchfact=1.0f; - else if (ftmp>(float)0.4) - pitchfact=(ftmp-(float)0.4)/((float)0.7-(float)0.4); - else - pitchfact=0.0f; - - - /* avoid repetition of same pitch cycle */ - use_lag=lag; - if (lag<80) { - use_lag=2*lag; - } - - /* compute concealed residual */ - energy = 0.0f; - for (i=0; i 1)) { - System.out.println("\nERROR - Wrong mode - 0, 1 allowed\n"); - } - - /* do actual decoding of block */ - iLBC_decode(decblock, en_data, mode); - - /* convert to short */ - for (k = 0; k < this.ULP_inst.blockl; k++, decodedOffset += 2) { - dtmp=decblock[k]; -// System.out.println("on a eu : " + dtmp); - if (dtmp < ilbc_constants.MIN_SAMPLE) - dtmp = ilbc_constants.MIN_SAMPLE; - else if (dtmp > ilbc_constants.MAX_SAMPLE) - dtmp = ilbc_constants.MAX_SAMPLE; - - ArrayIOUtils.writeShort((short) dtmp, decoded, decodedOffset); - } - - return ((short) this.ULP_inst.blockl); - } - - /*----------------------------------------------------------------* - * frame residual decoder function (subrutine to iLBC_decode) - *---------------------------------------------------------------*/ - - public void Decode( - float decresidual[], /* (o) decoded residual frame */ - int start, /* (i) location of start - state */ - int idxForMax, /* (i) codebook index for the - maximum value */ - int idxVec[], /* (i) codebook indexes for the - samples in the start - state */ - float syntdenum[], /* (i) the decoded synthesis - filter coefficients */ - int cb_index[], /* (i) the indexes for the - adaptive codebook */ - int gain_index[], /* (i) the indexes for the - corresponding gains */ - int extra_cb_index[], /* (i) the indexes for the - adaptive codebook part - of start state */ - int extra_gain_index[], /* (i) the indexes for the - corresponding gains */ - int state_first) /* (i) 1 if non adaptive part - of start state comes - first 0 if that part - comes last */ - { - float [] reverseDecresidual = new float[ilbc_constants.BLOCKL_MAX]; - float [] mem = new float[ilbc_constants.CB_MEML]; - int k, meml_gotten, Nfor, Nback, i; - int diff, start_pos; - int subcount, subframe; - - diff = ilbc_constants.STATE_LEN - this.ULP_inst.state_short_len; - - if (state_first == 1) { - start_pos = (start-1) * ilbc_constants.SUBL; - } else { - start_pos = (start-1) * ilbc_constants.SUBL + diff; - } - - /* decode scalar part of start state */ - - ilbc_common.StateConstructW(idxForMax, idxVec, - syntdenum, (start-1)*(ilbc_constants.LPC_FILTERORDER+1), - decresidual, start_pos, this.ULP_inst.state_short_len); - - - if (state_first != 0) { /* put adaptive part in the end */ - - /* setup memory */ - - for (int li = 0; li < (ilbc_constants.CB_MEML-this.ULP_inst.state_short_len); li++) - mem[li] = 0.0f; -// memset(mem, 0, -// (CB_MEML-this.ULP_inst.state_short_len)*sizeof(float)); - System.arraycopy(decresidual, start_pos, - mem, ilbc_constants.CB_MEML - this.ULP_inst.state_short_len, - this.ULP_inst.state_short_len); -// memcpy(mem+CB_MEML-this.ULP_inst.state_short_len, -// decresidual+start_pos, -// this.ULP_inst.state_short_len*sizeof(float)); - - /* construct decoded vector */ - - ilbc_common.iCBConstruct(decresidual, start_pos+this.ULP_inst.state_short_len, - extra_cb_index, 0, extra_gain_index, 0, - mem, ilbc_constants.CB_MEML - ilbc_constants.stMemLTbl, - ilbc_constants.stMemLTbl, diff, ilbc_constants.CB_NSTAGES); - - } - else {/* put adaptive part in the beginning */ - - /* create reversed vectors for prediction */ - - for (k=0; k 0 ){ - - /* setup memory */ - - for (int li = 0; li < ilbc_constants.CB_MEML - ilbc_constants.STATE_LEN; li++) - mem[li] = 0.0f; - // memset(mem, 0, (CB_MEML-STATE_LEN)*sizeof(float)); - System.arraycopy(decresidual, (start - 1) * ilbc_constants.SUBL, - mem, ilbc_constants.CB_MEML - ilbc_constants.STATE_LEN, - ilbc_constants.STATE_LEN); - // memcpy(mem+CB_MEML-STATE_LEN, decresidual+(start-1)*SUBL, - // STATE_LEN*sizeof(float)); - - /* loop over sub-frames to encode */ - - for (subframe=0; subframe 0 ) { - - /* setup memory */ - - meml_gotten = ilbc_constants.SUBL*(this.ULP_inst.nsub+1-start); - - if ( meml_gotten > ilbc_constants.CB_MEML ) { - meml_gotten = ilbc_constants.CB_MEML; - } - for (k=0; k 0) { /* the data are good */ - - /* decode data */ - - // pbytes=bytes; - // pos=0; - - /* Set everything to zero before decoding */ - - for (k=0; k maxcc) { - maxcc = cc; - lag = ilag; - } - } - this.last_lag = lag; - - /* copy data and run synthesis filter */ - - System.arraycopy(decresidual, 0, data, 0, this.ULP_inst.blockl); -// memcpy(data, decresidual, -// this.ULP_inst.blockl*sizeof(float)); -// System.out.println("runs 5"); - for (i=0; i < this.ULP_inst.nsub; i++) { - syntFilter(data, i * ilbc_constants.SUBL, - syntdenum, i * (ilbc_constants.LPC_FILTERORDER + 1), - ilbc_constants.SUBL, this.syntMem); - } - - } - - /* high pass filtering on output if desired, otherwise - copy to out */ - - hpOutput(data, this.ULP_inst.blockl, decblock, this.hpomem); - - /* memcpy(decblock,data,iLBCdec_inst->blockl*sizeof(float));*/ - - System.arraycopy(syntdenum, 0, this.old_syntdenum, 0, - this.ULP_inst.nsub * (ilbc_constants.LPC_FILTERORDER+1)); -// memcpy(this.old_syntdenum, syntdenum, -// this.ULP_inst.nsub*(LPC_FILTERORDER+1)*sizeof(float)); - - this.prev_enh_pl=0; - - if (mode==0) { /* PLC was used */ - this.prev_enh_pl=1; - } - } - - - public ilbc_decoder(int init_mode, int init_enhancer) - { - ULP_inst = new ilbc_ulp(init_mode); - /* properties to initialize : */ - syntMem = new float[ilbc_constants.LPC_FILTERORDER]; - prevLpc = new float[ilbc_constants.LPC_FILTERORDER+1]; - prevResidual = new float[ilbc_constants.NSUB_MAX*ilbc_constants.SUBL]; - old_syntdenum = new float[(ilbc_constants.LPC_FILTERORDER + 1) * ilbc_constants.NSUB_MAX]; - hpomem = new float[4]; - enh_buf = new float[ilbc_constants.ENH_BUFL]; - enh_period = new float[ilbc_constants.ENH_NBLOCKS_TOT]; - lsfdeqold = new float[ilbc_constants.LPC_FILTERORDER]; - - for (int li = 0; li < syntMem.length; li++) - syntMem[li] = 0.0f; - - System.arraycopy(ilbc_constants.lsfmeanTbl, 0, lsfdeqold, 0, - ilbc_constants.LPC_FILTERORDER); -// for (int li = 0; li < lsfdeqold.length; li++) -// lsfdeqold[li] = 0.0f; - - for (int li = 0; li < old_syntdenum.length; li++) - old_syntdenum[li] = 0.0f; - - for (int li = 0; li < ilbc_constants.NSUB_MAX; li++) - old_syntdenum[li * (ilbc_constants.LPC_FILTERORDER + 1)] = 1.0f; - - last_lag = 20; - prevLag = 120; - per = 0.0f; - consPLICount = 0; - prevPLI = 0; - prevLpc[0] = 1.0f; - for (int li = 1; li < prevLpc.length; li++) - prevLpc[li] = 0.0f; - for (int li = 0; li < prevResidual.length; li++) - prevResidual[li] = 0.0f; - seed = 777; - - for (int li = 0; li < hpomem.length; li++) - hpomem[li] = 0.0f; - - use_enhancer = init_enhancer; - for (int li = 0; li < enh_buf.length; li++) - enh_buf[li] = 0.0f; - for (int li = 0; li < ilbc_constants.ENH_NBLOCKS_TOT; li++) - enh_period[li] = 40.0f; - prev_enh_pl = 0; - } -} - diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/ilbc_encoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/ilbc_encoder.java deleted file mode 100644 index e207ba3fe..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ilbc/ilbc_encoder.java +++ /dev/null @@ -1,2340 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.ilbc; - -import net.java.sip.communicator.impl.neomedia.*; - -/** - * Implements an iLBC encoder. - * - * @author Jean Lorchat - * @author Lyubomir Marinov - */ -class ilbc_encoder { - /* encoding mode, either 20 or 30 ms */ - int mode; - - /* analysis filter state */ - float anaMem[];//LPC_FILTERORDER]; - - /* old lsf parameters for interpolation */ - float lsfold[]; //LPC_FILTERORDER]; - float lsfdeqold[]; //LPC_FILTERORDER]; - - /* signal buffer for LP analysis */ - float lpc_buffer[]; //LPC_LOOKBACK + BLOCKL_MAX]; - - /* state of input HP filter */ - float hpimem[]; //4]; - - ilbc_ulp ULP_inst = null; - - /** - * @param syntDenum Currently not used - */ - /* encoder methods start here */ - - /*----------------------------------------------------------------* - * predictive noise shaping encoding of scaled start state - * (subrutine for StateSearchW) - *---------------------------------------------------------------*/ - - void AbsQuantW( - float in[], /* (i) vector to encode */ - int in_idx, - float syntDenum[], /* (i) denominator of synthesis filter */ - int syntDenum_idx, - float weightDenum[], /* (i) denominator of weighting filter */ - int weightDenum_idx, - int out[], /* (o) vector of quantizer indexes */ - int len, /* (i) length of vector to encode and - vector of quantizer indexes */ - int state_first /* (i) position of start state in the - 80 vec */ - ){ - // float *syntOut; - int syntOut; - float [] syntOutBuf = new float[ilbc_constants.LPC_FILTERORDER + - ilbc_constants.STATE_SHORT_LEN_30MS]; - float toQ; - int n; - int [] index = new int[1]; - - /* initialization of buffer for filtering */ - - for (int li = 0; li < ilbc_constants.LPC_FILTERORDER; li++) { - syntOutBuf[li] = 0.0f; - } - // memset(syntOutBuf, 0, LPC_FILTERORDER*sizeof(float)); - - /* initialization of pointer for filtering */ - - // syntOut = &syntOutBuf[LPC_FILTERORDER]; - - syntOut = ilbc_constants.LPC_FILTERORDER; - - /* synthesis and weighting filters on input */ - - if (state_first != 0) { - ilbc_common.AllPoleFilter (in, in_idx, weightDenum, weightDenum_idx, - ilbc_constants.SUBL, ilbc_constants.LPC_FILTERORDER); - } else { - ilbc_common.AllPoleFilter (in, in_idx, weightDenum, weightDenum_idx, - this.ULP_inst.state_short_len - ilbc_constants.SUBL, - ilbc_constants.LPC_FILTERORDER); - } - - /* encoding loop */ - - for (n=0; n maxVal*maxVal){ - maxVal = foutbuf[fout+k]; - } - } - maxVal=Math.abs(maxVal); - - /* encoding of the maximum amplitude value */ - - if (maxVal < 10.0f) { - maxVal = 10.0f; - } - // log10 is since 1.5 - //maxVal = (float)Math.log10(maxVal); - maxVal = (float)(Math.log(maxVal)/Math.log(10)); - sort_sq(idxForMax, 0, maxVal, ilbc_constants.state_frgqTbl, 64); - - /* decoding of the maximum amplitude representation value, - and corresponding scaling of start state */ - - maxVal = ilbc_constants.state_frgqTbl[idxForMax[0]]; - qmax = (float)Math.pow(10,maxVal); - scal = 4.5f / qmax; - for (k=0; k= 0.5)){ - - if (step_idx == (ilbc_constants.LSF_NUMBER_OF_STEPS - 1)){ - - if (Math.abs(hlp5) >= Math.abs(olds[old])) { - //System.out.println("acces index " + freq_idx + lsp_index); - freq[freq_idx+lsp_index] = omega - step; - } else { - //System.out.println("acces index " + freq_idx + lsp_index); - freq[freq_idx+lsp_index] = omega; - } - - if ((olds[old]) >= 0.0f){ - olds[old] = -1.0f * ilbc_constants.DOUBLE_MAX; - } else { - olds[old] = ilbc_constants.DOUBLE_MAX; - } - - omega = old_omega; - step_idx = 0; - - step_idx = ilbc_constants.LSF_NUMBER_OF_STEPS; - } else { - - if (step_idx == 0) { - old_omega = omega; - } - - step_idx++; - omega -= steps[step_idx]; - - /* Go back one grid step */ - - step = steps[step_idx]; - } - } else { - - /* increment omega until they are of different sign, - and we know there is at least one root between omega - and old_omega */ - olds[old] = hlp5; - omega += step; - } - } - } - - for (i = 0; i < ilbc_constants.LPC_FILTERORDER; i++) { - //System.out.println("acces index " + freq_idx + i); - freq[freq_idx+i] = freq[freq_idx+i] * ilbc_constants.TWO_PI; - } - } - - /*----------------------------------------------------------------* - * lpc analysis (subrutine to LPCencode) - *---------------------------------------------------------------*/ - - void SimpleAnalysis( - float lsf[], /* (o) lsf coefficients */ - float data[]) /* (i) new data vector */ - { - int k, is; - float [] temp = new float[ilbc_constants.BLOCKL_MAX]; - float [] lp = new float[ilbc_constants.LPC_FILTERORDER + 1]; - float [] lp2 = new float[ilbc_constants.LPC_FILTERORDER + 1]; - float [] r = new float[ilbc_constants.LPC_FILTERORDER + 1]; - - is=ilbc_constants.LPC_LOOKBACK+ilbc_constants.BLOCKL_MAX-this.ULP_inst.blockl; - // System.out.println("copie 1"); -// System.out.println("\nInformations de copie : \nbuffer source : " + data.length + " octets\n"+ -// "buffer cible : " + this.lpc_buffer.length + "octets\n" + -// " offset : " + is + "octets\n" + -// "longueur de la copie : " + this.ULP_inst.blockl); - System.arraycopy(data, 0, this.lpc_buffer, is, this.ULP_inst.blockl); -// memcpy(iLBCenc_inst->lpc_buffer+is,data,iLBCenc_inst->blockl*sizeof(float)); - - /* No lookahead, last window is asymmetric */ - - for (k = 0; k < this.ULP_inst.lpc_n; k++) { - - is = ilbc_constants.LPC_LOOKBACK; - - if (k < (this.ULP_inst.lpc_n - 1)) { - window(temp, ilbc_constants.lpc_winTbl, this.lpc_buffer, 0, - ilbc_constants.BLOCKL_MAX); - } else { - window(temp, ilbc_constants.lpc_asymwinTbl, - this.lpc_buffer, is, ilbc_constants.BLOCKL_MAX); - } - - autocorr(r, temp, ilbc_constants.BLOCKL_MAX, ilbc_constants.LPC_FILTERORDER); - window(r, r, ilbc_constants.lpc_lagwinTbl, 0, ilbc_constants.LPC_FILTERORDER + 1); - - levdurb(lp, temp, r, ilbc_constants.LPC_FILTERORDER); - ilbc_common.bwexpand(lp2, 0, lp, ilbc_constants.LPC_CHIRP_SYNTDENUM, - ilbc_constants.LPC_FILTERORDER+1); - - a2lsf(lsf, k * ilbc_constants.LPC_FILTERORDER, lp2); - } - is=ilbc_constants.LPC_LOOKBACK+ilbc_constants.BLOCKL_MAX-this.ULP_inst.blockl; -// System.out.println("copie 2"); - System.arraycopy(this.lpc_buffer, ilbc_constants.LPC_LOOKBACK + ilbc_constants.BLOCKL_MAX - is, - this.lpc_buffer, 0, is); -// memmove(iLBCenc_inst->lpc_buffer, -// iLBCenc_inst->lpc_buffer+LPC_LOOKBACK+BLOCKL_MAX-is, -// is*sizeof(float)); - } - - /*----------------------------------------------------------------* - * lsf interpolator and conversion from lsf to a coefficients - * (subrutine to SimpleInterpolateLSF) - *---------------------------------------------------------------*/ - - void LSFinterpolate2a_enc( - float a[], /* (o) lpc coefficients */ - float lsf1[],/* (i) first set of lsf coefficients */ - float lsf2[],/* (i) second set of lsf coefficients */ - int lsf2_idx, - float coef, /* (i) weighting coefficient to use between - lsf1 and lsf2 */ - long length /* (i) length of coefficient vectors */ - ){ - float [] lsftmp = new float[ilbc_constants.LPC_FILTERORDER]; - - ilbc_common.interpolate(lsftmp, lsf1, lsf2, lsf2_idx, coef, ((int)length)); - ilbc_common.lsf2a(a, lsftmp); - } - - /*----------------------------------------------------------------* - * lsf interpolator (subrutine to LPCencode) - *---------------------------------------------------------------*/ - - void SimpleInterpolateLSF( - float syntdenum[], /* (o) the synthesis filter denominator - resulting from the quantized - interpolated lsf */ - float weightdenum[], /* (o) the weighting filter denominator - resulting from the unquantized - interpolated lsf */ - float lsf[], /* (i) the unquantized lsf coefficients */ - float lsfdeq[], /* (i) the dequantized lsf coefficients */ - float lsfold[], /* (i) the unquantized lsf coefficients of - the previous signal frame */ - float lsfdeqold[], /* (i) the dequantized lsf coefficients of - the previous signal frame */ - int length) /* (i) should equate LPC_FILTERORDER */ - { - int i, pos, lp_length; - float [] lp = new float[ilbc_constants.LPC_FILTERORDER + 1]; - int lsf2, lsfdeq2; - - lsf2 = length; - lsfdeq2 = length; -// lsf2 = lsf + length; -// lsfdeq2 = lsfdeq + length; - lp_length = length + 1; - - if (this.ULP_inst.mode==30) { - /* sub-frame 1: Interpolation between old and first - - set of lsf coefficients */ - - LSFinterpolate2a_enc(lp, lsfdeqold, lsfdeq, 0, - ilbc_constants.lsf_weightTbl_30ms[0], length); - System.arraycopy(lp, 0, syntdenum, 0, lp_length); - // memcpy(syntdenum,lp,lp_length*sizeof(float)); - LSFinterpolate2a_enc(lp, lsfold, lsf, 0, - ilbc_constants.lsf_weightTbl_30ms[0], length); - ilbc_common.bwexpand(weightdenum, 0, lp, - ilbc_constants.LPC_CHIRP_WEIGHTDENUM, - lp_length); - - /* sub-frame 2 to 6: Interpolation between first - and second set of lsf coefficients */ - - pos = lp_length; - for (i = 1; i < this.ULP_inst.nsub; i++) { - LSFinterpolate2a_enc(lp, lsfdeq, lsfdeq, lsfdeq2, - ilbc_constants.lsf_weightTbl_30ms[i], length); - System.arraycopy(lp, 0, syntdenum, pos, lp_length); - // memcpy(syntdenum + pos,lp,lp_length*sizeof(float)); - - LSFinterpolate2a_enc(lp, lsf, lsf, lsf2, - ilbc_constants.lsf_weightTbl_30ms[i], length); - ilbc_common.bwexpand(weightdenum, pos, lp, - ilbc_constants.LPC_CHIRP_WEIGHTDENUM, lp_length); - pos += lp_length; - } - } - else { - pos = 0; - for (i = 0; i < this.ULP_inst.nsub; i++) { - //System.out.println("ici ?"); - LSFinterpolate2a_enc(lp, lsfdeqold, lsfdeq, 0, - ilbc_constants.lsf_weightTbl_20ms[i], length); - //System.out.println("ici !"); - System.arraycopy(lp, 0, syntdenum, pos, lp_length); - for (int li = 0; li < lp_length; li++) - //System.out.println("interpolate syntdenum [" + (li+pos) +"] is worth " + syntdenum[li+pos]); - // memcpy(syntdenum+pos,lp,lp_length*sizeof(float)); - LSFinterpolate2a_enc(lp, lsfold, lsf, 0, - ilbc_constants.lsf_weightTbl_20ms[i], length); - ilbc_common.bwexpand(weightdenum, pos, lp, - ilbc_constants.LPC_CHIRP_WEIGHTDENUM, lp_length); - pos += lp_length; - } - } - - /* update memory */ - - if (this.ULP_inst.mode==30) { - System.arraycopy(lsf, lsf2, lsfold, 0, length); -// memcpy(lsfold, lsf2, length*sizeof(float)); - System.arraycopy(lsfdeq, lsfdeq2, lsfdeqold, 0, length); -// memcpy(lsfdeqold, lsfdeq2, length*sizeof(float)); - } - else { - System.arraycopy(lsf, 0, lsfold, 0, length); -// memcpy(lsfold, lsf, length*sizeof(float)); - System.arraycopy(lsfdeq, 0, lsfdeqold, 0, length); -// memcpy(lsfdeqold, lsfdeq, length*sizeof(float)); - - } - } - - /*----------------------------------------------------------------* - * lsf quantizer (subrutine to LPCencode) - *---------------------------------------------------------------*/ - - void SimplelsfQ( - float lsfdeq[], /* (o) dequantized lsf coefficients - (dimension FILTERORDER) */ - int index[], /* (o) quantization index */ - float lsf[], /* (i) the lsf coefficient vector to be - quantized (dimension FILTERORDER ) */ - int lpc_n /* (i) number of lsf sets to quantize */ - ){ - /* Quantize first LSF with memoryless split VQ */ - SplitVQ(lsfdeq, 0, index, 0, lsf, 0, ilbc_constants.lsfCbTbl, - ilbc_constants.LSF_NSPLIT, ilbc_constants.dim_lsfCbTbl, - ilbc_constants.size_lsfCbTbl); - - if (lpc_n==2) { - /* Quantize second LSF with memoryless split VQ */ - SplitVQ(lsfdeq, ilbc_constants.LPC_FILTERORDER, - index, ilbc_constants.LSF_NSPLIT, - lsf, ilbc_constants.LPC_FILTERORDER, - ilbc_constants.lsfCbTbl, - ilbc_constants.LSF_NSPLIT, - ilbc_constants.dim_lsfCbTbl, - ilbc_constants.size_lsfCbTbl); - } - } - - /*----------------------------------------------------------------* - * lpc encoder - *---------------------------------------------------------------*/ - - void LPCencode( - float syntdenum[], /* (i/o) synthesis filter coefficients - before/after encoding */ - float weightdenum[], /* (i/o) weighting denumerator - coefficients before/after - encoding */ - int lsf_index[], /* (o) lsf quantization index */ - float data[]) /* (i) lsf coefficients to quantize */ - { - float [] lsf = new float[ilbc_constants.LPC_FILTERORDER * ilbc_constants.LPC_N_MAX]; - float [] lsfdeq= new float[ilbc_constants.LPC_FILTERORDER * ilbc_constants.LPC_N_MAX]; - - SimpleAnalysis(lsf, data); - // for (int li = 0; li < ilbc_constants.LPC_FILTERORDER * ilbc_constants.LPC_N_MAX; li++) - // System.out.println("postSA n-" + li + " is worth " + lsf[li]); - // for (int li = 0; li < ilbc_constants.BLOCKL_MAX; li++) - // System.out.println("data postSA n-" + li + " is worth " + data[li]); - SimplelsfQ(lsfdeq, lsf_index, lsf, this.ULP_inst.lpc_n); - // for (int li = 0; li < ilbc_constants.LPC_FILTERORDER * ilbc_constants.LPC_N_MAX; li++) - // System.out.println("postSlsfQ n-" + li + " is worth " + lsfdeq[li]); - // for (int li = 0; li < lsf_index.length; li++) - // System.out.println("index postSlsfQ n-" + li + " is worth " + lsf_index[li]); - - ilbc_common.LSF_check(lsfdeq, ilbc_constants.LPC_FILTERORDER, this.ULP_inst.lpc_n); - //System.out.println("check gives " + change); - SimpleInterpolateLSF(syntdenum, weightdenum, - lsf, lsfdeq, this.lsfold, - this.lsfdeqold, ilbc_constants.LPC_FILTERORDER); - // for (int li = 0; li < syntdenum.length; li++) - // System.out.println("syntdenum[" + li +"] is worth " + syntdenum[li]); - } - - public void iCBSearch( - int index[], /* (o) Codebook indices */ - int index_idx, - int gain_index[],/* (o) Gain quantization indices */ - int gain_index_idx, - - float intarget[],/* (i) Target vector for encoding */ - int intarget_idx, - float mem[], /* (i) Buffer for codebook construction */ - int mem_idx, - int lMem, /* (i) Length of buffer */ - int lTarget, /* (i) Length of vector */ - int nStages, /* (i) Number of codebook stages */ - float weightDenum[], /* (i) weighting filter coefficients */ - int weightDenum_idx, - float weightState[], /* (i) weighting filter state */ - int block) /* (i) the sub-block number */ - { - int i, j, icount, stage, best_index, range, counter; - float max_measure, gain, measure, crossDot, ftmp; - float [] gains = new float[ilbc_constants.CB_NSTAGES]; - float [] target = new float[ilbc_constants.SUBL]; - int base_index, sInd, eInd, base_size; - int sIndAug=0, eIndAug=0; - float [] buf = new float[ilbc_constants.CB_MEML+ilbc_constants.SUBL+2*ilbc_constants.LPC_FILTERORDER]; - float [] invenergy = new float[ilbc_constants.CB_EXPAND*128]; - float [] energy = new float[ilbc_constants.CB_EXPAND*128]; - // float *pp, *ppi=0, *ppo=0, *ppe=0; - int pp, ppi = 0, ppo = 0, ppe = 0; - float [] ppt; - float [] cbvectors = new float[ilbc_constants.CB_MEML]; - float tene, cene; - float [] cvec = new float[ilbc_constants.SUBL]; - float [] aug_vec = new float[ilbc_constants.SUBL]; - - float [] a = new float[1]; - int [] b = new int[1]; - float [] c = new float[1]; - - for (int li = 0; li < ilbc_constants.SUBL; li++) - cvec[li] = 0.0f; - // memset(cvec,0,SUBL*sizeof(float)); - - /* Determine size of codebook sections */ - - base_size=lMem-lTarget+1; - - if (lTarget == ilbc_constants.SUBL) { - base_size=lMem-lTarget+1+lTarget/2; - } - - /* setup buffer for weighting */ - - System.arraycopy(weightState, 0, buf, 0, ilbc_constants.LPC_FILTERORDER); -// memcpy(buf,weightState,sizeof(float)*LPC_FILTERORDER); - System.arraycopy(mem, mem_idx, buf, ilbc_constants.LPC_FILTERORDER, lMem); -// memcpy(buf+LPC_FILTERORDER,mem,lMem*sizeof(float)); - System.arraycopy(intarget, intarget_idx, buf, ilbc_constants.LPC_FILTERORDER+lMem, lTarget); -// memcpy(buf+LPC_FILTERORDER+lMem,intarget,lTarget*sizeof(float)); - - //System.out.println("beginning of mem"); -// for (int li = 0; li < lMem; li++) -// System.out.println("mem[" + li + "] = " + mem[li+mem_idx]); -// System.out.println("end of mem"); - - -// System.out.println("plages : [0-" + ilbc_constants.LPC_FILTERORDER + -// "], puis [" + ilbc_constants.LPC_FILTERORDER + "-" + (ilbc_constants.LPC_FILTERORDER + lMem) + -// "], puis [" + (ilbc_constants.LPC_FILTERORDER + lMem) + -// "-" + (ilbc_constants.LPC_FILTERORDER + lMem + lTarget) + "]"); - -// System.out.println("beginning of buffer"); - -// for (int li = 0; li < buf.length; li++) -// System.out.println("buffer[" + li + "] = " + buf[li]); - -// System.out.println("end of buffer"); - /* weighting */ - - ilbc_common.AllPoleFilter(buf, ilbc_constants.LPC_FILTERORDER, weightDenum, weightDenum_idx, - lMem+lTarget, ilbc_constants.LPC_FILTERORDER); - - /* Construct the codebook and target needed */ - - System.arraycopy(buf, ilbc_constants.LPC_FILTERORDER + lMem, target, 0, lTarget); - // memcpy(target, buf+LPC_FILTERORDER+lMem, lTarget*sizeof(float)); - - tene=0.0f; - - for (i=0; i 0.0f) { - invenergy[0] = 1.0f / (energy[ppe] + ilbc_constants.EPS); - } else { - invenergy[0] = 0.0f; - - } - ppe++; - - measure=-10000000.0f; - - if (crossDot > 0.0f) { - measure = crossDot*crossDot*invenergy[0]; - } - } - else { - measure = crossDot*crossDot*invenergy[0]; - } - - /* check if measure is better */ - ftmp = crossDot*invenergy[0]; - - if ((measure>max_measure) && (Math.abs(ftmp) < ilbc_constants.CB_MAXGAIN)) { - best_index = 0; - max_measure = measure; - gain = ftmp; - } - - /* loop over the main first codebook section, - full search */ - - for (icount=1; icount0.0f) { - invenergy[icount] = - 1.0f/(energy[icount]+ilbc_constants.EPS); - } else { - invenergy[icount] = 0.0f; - } - - measure=-10000000.0f; - - if (crossDot > 0.0f) { - measure = crossDot*crossDot*invenergy[icount]; - } - } - else { - measure = crossDot*crossDot*invenergy[icount]; - } - - /* check if measure is better */ - ftmp = crossDot*invenergy[icount]; - - if ((measure>max_measure) && (Math.abs(ftmp) < ilbc_constants.CB_MAXGAIN)) { - best_index = icount; - max_measure = measure; - gain = ftmp; - } - } - - /* Loop over augmented part in the first codebook - * section, full search. - * The vectors are interpolated. - */ - - if (lTarget == ilbc_constants.SUBL) { - - /* Search for best possible cb vector and - compute the CB-vectors' energy. */ - a[0] = max_measure; - b[0] = best_index; - c[0] = gain; - searchAugmentedCB(20, 39, stage, base_size-lTarget/2, - target, buf, ilbc_constants.LPC_FILTERORDER+lMem, - a, b, c, energy, invenergy); - max_measure = a[0]; - best_index = b[0]; - gain = c[0]; - } - - /* set search range for following codebook sections */ - - // System.out.println("best index : " + best_index); - - base_index = best_index; - - /* unrestricted search */ - - if (ilbc_constants.CB_RESRANGE == -1) { - // System.out.println("on met a 0"); - sInd = 0; - eInd = range - 1; - sIndAug = 20; - eIndAug = 39; - } - - /* restricted search around best index from first - codebook section */ - - else { - /* Initialize search indices */ - sIndAug=0; - eIndAug=0; - sInd=base_index-ilbc_constants.CB_RESRANGE/2; - // System.out.println("on met a " + base_index + " - " + ilbc_constants.CB_RESRANGE/2 + " = " + sInd); - eInd=sInd+ilbc_constants.CB_RESRANGE; - - if (lTarget==ilbc_constants.SUBL) { - - if (sInd<0) { - - sIndAug = 40 + sInd; - eIndAug = 39; - // System.out.println("On met encore a 0"); - sInd=0; - - } else if ( base_index < (base_size-20) ) { - - if (eInd > range) { - sInd -= (eInd-range); - // System.out.println("on retire " + eInd + " - " + range + " pour arriver a " + sInd); - eInd = range; - } - } else { /* base_index >= (base_size-20) */ - - if (sInd < (base_size-20)) { - sIndAug = 20; - sInd = 0; - // System.out.println("on remet encore a 0"); - eInd = 0; - eIndAug = 19 + ilbc_constants.CB_RESRANGE; - - if(eIndAug > 39) { - eInd = eIndAug-39; - eIndAug = 39; - } - } else { - sIndAug = 20 + sInd - (base_size-20); - eIndAug = 39; - sInd = 0; - // System.out.println("on remetz4 a zero"); - eInd = ilbc_constants.CB_RESRANGE - (eIndAug-sIndAug+1); - } - } - - } else { /* lTarget = 22 or 23 */ - - if (sInd < 0) { - eInd -= sInd; - - sInd = 0; - // System.out.println("on remet x5 a zero"); - } - - if(eInd > range) { - sInd -= (eInd - range); - // System.out.println("on retire " + eInd + " - " + range + " pour arriver a " + sInd); - eInd = range; - } - } - } - - /* search of higher codebook section */ - - /* index search range */ - counter = sInd; - // System.out.println("on ajoute " + base_size + " pour arriver a " + sInd); - sInd += base_size; - eInd += base_size; - - - if (stage==0) { - // ppe = energy+base_size; - ppe = base_size; - energy[ppe]=0.0f; - - pp=lMem-lTarget; - // pp=cbvectors+lMem-lTarget; - for (j=0; j0.0f) { - invenergy[icount] = 1.0f/(energy[icount]+ilbc_constants.EPS); - } else { - invenergy[icount] = 0.0f; - } - - if (stage==0) { - - measure = -10000000.0f; - - if (crossDot > 0.0f) { - measure = crossDot*crossDot* - invenergy[icount]; - } - } - else { - measure = crossDot*crossDot*invenergy[icount]; - } - - /* check if measure is better */ - ftmp = crossDot*invenergy[icount]; - - if ((measure > max_measure) && (Math.abs(ftmp) ilbc_constants.CB_MAXGAIN) { - gain = ilbc_constants.CB_MAXGAIN; - } - gain = ilbc_common.gainquant(gain, 1.0f, 32, gain_index, gain_index_idx + stage); - } - else { - if (stage==1) { - gain = ilbc_common.gainquant(gain, Math.abs(gains[stage-1]), - 16, gain_index, gain_index_idx + stage); - } else { - gain = ilbc_common.gainquant(gain, Math.abs(gains[stage-1]), - 8, gain_index, gain_index_idx + stage); - } - } - - /* Extract the best (according to measure) - codebook vector */ - - if (lTarget==(ilbc_constants.STATE_LEN - this.ULP_inst.state_short_len)) { - - if (index[index_idx+stage]=108)&&(index[k]<172)) { - index[k]-=64; - } else if (index[k]>=236) { - index[k]-=128; - } else { - /* ERROR */ - } - } - } - - public void hpInput( - float In[], /* (i) vector to filter */ - int len, /* (i) length of vector to filter */ - float Out[], /* (o) the resulting filtered vector */ - float mem[]) /* (i/o) the filter state */ - { - int i; - // float *pi, *po; - int pi, po; - - /* all-zero section*/ - - // pi = &In[0]; - pi = 0; - // po = &Out[0]; - po = 0; - - for (i=0; i0.0f) { - invenergy[tmpIndex] = 1.0f/(energy[tmpIndex] + ilbc_constants.EPS); - } else { - invenergy[tmpIndex] = 0.0f; - } - - if (stage==0) { - measure = -10000000.0f; - - if (crossDot > 0.0f) { - measure = crossDot*crossDot*invenergy[tmpIndex]; - } - } - else { - measure = crossDot*crossDot*invenergy[tmpIndex]; - } - - /* check if measure is better */ - ftmp = crossDot*invenergy[tmpIndex]; - - // System.out.println("on compare " + measure + " et " + max_measure[0]); - // System.out.println("ainsi que " + Math.abs(ftmp) + " et " + ilbc_constants.CB_MAXGAIN); - - if ((measure>max_measure[0]) && (Math.abs(ftmp) < ilbc_constants.CB_MAXGAIN)) { - // System.out.println("new best index at " + tmpIndex + ", where icount = " + icount); - best_index[0] = tmpIndex; - max_measure[0] = measure; - gain[0] = ftmp; - } - } - } - - /*----------------------------------------------------------------* - * Recreate a specific codebook vector from the augmented part. - * - *----------------------------------------------------------------*/ - - private void createAugmentedVec(int index, float buffer[], int buffer_idx, float cbVec[]) - { - int ilow, j; - int pp, ppo, ppi; - float alfa, alfa1, weighted; - - ilow = index - 5; - - /* copy the first noninterpolated part */ - - pp = buffer_idx - index; - System.arraycopy(buffer, pp, cbVec, 0, index); - // memcpy(cbVec,pp,sizeof(float)*index); - - /* interpolation */ - - alfa1 = (float)0.2; - alfa = 0.0f; - // ppo = buffer-5; - ppo = buffer_idx - 5; - // ppi = buffer-index-5; - ppi = buffer_idx - index - 5; - for (j=ilow; jno_of_bytes); - } - - // public int encode(short encoded_data[], short data[]) - // { - // for (int i = 0; i < encoded_data.length; i ++) { - // data[i%data.length] = encoded_data[i]; - // } - - // if (mode == 20) - // return ilbc_constants.BLOCKL_20MS; - // else - // return ilbc_constants.BLOCKL_30MS; - // } - public int encode( - byte[] encoded, int encodedOffset, - byte[] decoded, int decodedOffset) - { - float block[] = new float [this.ULP_inst.blockl]; - bitstream en_data - = new bitstream(encoded, encodedOffset, this.ULP_inst.no_of_bytes); - // char en_data[] = new char [this.ULP_inst.no_of_bytes]; - int k; - - /* convert signal to float */ - for (k = 0; k < this.ULP_inst.blockl; k++, decodedOffset += 2) - block[k] = ArrayIOUtils.readShort(decoded, decodedOffset); - - // for (int li = 0; li < block.length; li++) - // System.out.println("block " + li + " : " + block[li]); - - /* do the actual encoding */ - - iLBC_encode(en_data, block); - - return this.ULP_inst.no_of_bytes; - - } - - public void iLBC_encode( - bitstream bytes, /* (o) encoded data bits iLBC */ - float block[]) /* (o) speech vector to encode */ - { - int start; - int [] idxForMax = new int[1]; - int n, k, meml_gotten, Nfor, Nback, i; - // unsigned char *pbytes; - int diff, start_pos, state_first; - float en1, en2; - int index, ulp; - // int [] firstpart = new int[1]; - int firstpart; - int subcount, subframe; - - float [] data = new float[ilbc_constants.BLOCKL_MAX]; - float [] residual = new float[ilbc_constants.BLOCKL_MAX]; - float [] reverseResidual = new float[ilbc_constants.BLOCKL_MAX]; - - int [] idxVec = new int[ilbc_constants.STATE_LEN]; - float [] reverseDecresidual = new float[ilbc_constants.BLOCKL_MAX]; - float [] mem = new float[ilbc_constants.CB_MEML]; - - int [] gain_index = new int[ilbc_constants.CB_NSTAGES*ilbc_constants.NASUB_MAX]; - int [] extra_gain_index = new int[ilbc_constants.CB_NSTAGES]; - int [] cb_index = new int[ilbc_constants.CB_NSTAGES*ilbc_constants.NASUB_MAX]; - int [] extra_cb_index = new int[ilbc_constants.CB_NSTAGES]; - int [] lsf_i = new int[ilbc_constants.LSF_NSPLIT*ilbc_constants.LPC_N_MAX]; - - float [] weightState = new float[ilbc_constants.LPC_FILTERORDER]; - float [] syntdenum = new float[ilbc_constants.NSUB_MAX*(ilbc_constants.LPC_FILTERORDER+1)]; - float [] weightdenum = new float[ilbc_constants.NSUB_MAX*(ilbc_constants.LPC_FILTERORDER+1)]; - float [] decresidual = new float[ilbc_constants.BLOCKL_MAX]; - - bitpack pack; - - /* high pass filtering of input signal if such is not done - prior to calling this function */ - - // System.out.println("Data prior to hpinput call"); - // for (int li = 0; li < data.length; li++) - // System.out.println("index : " + li + " and value " + data[li]); - // System.out.println("Mem prior to hpinput call"); - // for (int li = 0; li < this.hpimem.length; li++) - // System.out.println("index : " + li + " and value " + this.hpimem[li]); - hpInput(block, this.ULP_inst.blockl, data, this.hpimem); - // System.out.println("Data after hpinput call"); - // for (int li = 0; li < data.length; li++) - // System.out.println("index : " + li + " and value " + data[li]); - // System.out.println("Mem after hpinput call"); - // for (int li = 0; li < this.hpimem.length; li++) - // System.out.println("index : " + li + " and value " + this.hpimem[li]); - - - /* otherwise simply copy */ - - /*memcpy(data,block,iLBCenc_inst->blockl*sizeof(float));*/ - - /* LPC of hp filtered input data */ - - LPCencode(syntdenum, weightdenum, lsf_i, data); - - // for (int li = 0; li < ilbc_constants.NSUB_MAX*(ilbc_constants.LPC_FILTERORDER+1); li++) - // System.out.println("postLPC n-" + li + " is worth " + syntdenum[li] + ", " + weightdenum[li]); - - /* inverse filter to get residual */ - - for (n = 0; n < this.ULP_inst.nsub; n++) { - anaFilter(data, n*ilbc_constants.SUBL, syntdenum, n*(ilbc_constants.LPC_FILTERORDER+1), - ilbc_constants.SUBL, residual, n*ilbc_constants.SUBL, this.anaMem); - } - - // for (int li = 0; li < ilbc_constants.BLOCKL_MAX; li++) - // System.out.println("block residual n-" + li + " is worth " + residual[li]); - - /* find state location */ - - start = FrameClassify(residual); - - /* check if state should be in first or last part of the - two subframes */ - - diff = ilbc_constants.STATE_LEN - this.ULP_inst.state_short_len; - en1 = 0; - index = (start-1)*ilbc_constants.SUBL; - for (i = 0; i < this.ULP_inst.state_short_len; i++) { - en1 += residual[index+i]*residual[index+i]; - } - en2 = 0; - index = (start-1)*ilbc_constants.SUBL+diff; - for (i = 0; i < this.ULP_inst.state_short_len; i++) { - en2 += residual[index+i]*residual[index+i]; - } - - - if (en1 > en2) { - state_first = 1; - start_pos = (start-1)*ilbc_constants.SUBL; - } else { - state_first = 0; - start_pos = (start-1)*ilbc_constants.SUBL + diff; - } - - /* scalar quantization of state */ - - StateSearchW(residual, start_pos, - syntdenum, (start-1)*(ilbc_constants.LPC_FILTERORDER+1), - weightdenum, (start-1)*(ilbc_constants.LPC_FILTERORDER+1), - idxForMax, idxVec, this.ULP_inst.state_short_len, state_first); - - ilbc_common.StateConstructW(idxForMax[0], idxVec, - syntdenum, (start-1)*(ilbc_constants.LPC_FILTERORDER+1), - decresidual, start_pos, this.ULP_inst.state_short_len); - - /* predictive quantization in state */ - - if (state_first != 0) { /* put adaptive part in the end */ - - /* setup memory */ - for (int li = 0; li < ilbc_constants.CB_MEML-this.ULP_inst.state_short_len; li++) - mem[li] = 0.0f; - System.arraycopy(decresidual, start_pos, - mem, ilbc_constants.CB_MEML-this.ULP_inst.state_short_len, - this.ULP_inst.state_short_len); - // memcpy(mem+ilbc_constants.CB_MEML-this.ULP_inst.state_short_len, - // decresidual+start_pos, - // this.ULP_inst.state_short_len*sizeof(float)); - for (int li = 0; li < ilbc_constants.LPC_FILTERORDER; li++) - weightState[li] = 0.0f; - // memset(weightState, 0, ilbc_constants.LPC_FILTERORDER*sizeof(float)); - - /* encode sub-frames */ - - iCBSearch(extra_cb_index, 0, extra_gain_index, 0, - residual, start_pos+this.ULP_inst.state_short_len, - mem, ilbc_constants.CB_MEML-ilbc_constants.stMemLTbl, - ilbc_constants.stMemLTbl, diff, ilbc_constants.CB_NSTAGES, - weightdenum, start*(ilbc_constants.LPC_FILTERORDER+1), - weightState, 0); - - /* construct decoded vector */ - - ilbc_common.iCBConstruct(decresidual, start_pos+this.ULP_inst.state_short_len, - extra_cb_index, 0, extra_gain_index, 0, - mem, ilbc_constants.CB_MEML-ilbc_constants.stMemLTbl, - ilbc_constants.stMemLTbl, diff, ilbc_constants.CB_NSTAGES); - - } - else { /* put adaptive part in the beginning */ - - /* create reversed vectors for prediction */ - - for (k=0; k 0 ) { - - /* setup memory */ - - for (int li = 0; li < (ilbc_constants.CB_MEML-ilbc_constants.STATE_LEN); li++) - mem[li] = 0.0f; - // memset(mem, 0, (ilbc_constants.CB_MEML-ilbc_constants.STATE_LEN)*sizeof(float)); - System.arraycopy(decresidual, (start-1)*ilbc_constants.SUBL, - mem, ilbc_constants.CB_MEML-ilbc_constants.STATE_LEN, - ilbc_constants.STATE_LEN); - // memcpy(mem+ilbc_constants.CB_MEML-ilbc_constants.STATE_LEN, - // decresidual+(start-1)*ilbc_constants.SUBL, - // ilbc_constants.STATE_LEN*sizeof(float)); - for (int li = 0; li < ilbc_constants.LPC_FILTERORDER; li++) - weightState[li] = 0.0f; - // memset(weightState, 0, ilbc_constants.LPC_FILTERORDER*sizeof(float)); - - /* loop over sub-frames to encode */ - - for (subframe=0; subframe 0 ) { - - /* create reverse order vectors */ - - for (n=0; n ilbc_constants.CB_MEML ) { - meml_gotten=ilbc_constants.CB_MEML; - } - for (k=0; kULP_inst=&ULP_20msTbl; - System.arraycopy(ilbc_constants.lsf_bits_20ms, 0, lsf_bits, 0, 6); - System.arraycopy(ilbc_constants.start_bits_20ms, 0, start_bits, 0, ilbc_constants.start_bits_20ms.length); - System.arraycopy(ilbc_constants.startfirst_bits_20ms, 0, startfirst_bits, 0, ilbc_constants.startfirst_bits_20ms.length); - System.arraycopy(ilbc_constants.scale_bits_20ms, 0, scale_bits, 0, ilbc_constants.scale_bits_20ms.length); - System.arraycopy(ilbc_constants.state_bits_20ms, 0, state_bits, 0, ilbc_constants.state_bits_20ms.length); - System.arraycopy(ilbc_constants.extra_cb_index_20ms, 0, extra_cb_index, 0, ilbc_constants.CB_NSTAGES); - System.arraycopy(ilbc_constants.extra_cb_gain_20ms, 0, extra_cb_gain, 0, ilbc_constants.CB_NSTAGES); - System.arraycopy(ilbc_constants.cb_index_20ms, 0, cb_index, 0, ilbc_constants.NSUB_20MS); - System.arraycopy(ilbc_constants.cb_gain_20ms, 0, cb_gain, 0, ilbc_constants.NSUB_20MS); - } - else if (mode == 30) - { - blockl = ilbc_constants.BLOCKL_30MS; - nsub = ilbc_constants.NSUB_30MS; - nasub = ilbc_constants.NASUB_30MS; - lpc_n = ilbc_constants.LPC_N_30MS; - no_of_bytes = ilbc_constants.NO_OF_BYTES_30MS; - no_of_words = ilbc_constants.NO_OF_WORDS_30MS; - state_short_len = ilbc_constants.STATE_SHORT_LEN_30MS; - /* ULP init */ - // ULP_inst=&ULP_30msTbl; - System.arraycopy(ilbc_constants.lsf_bits_30ms, 0, lsf_bits, 0, 6); - System.arraycopy(ilbc_constants.start_bits_30ms, 0, start_bits, 0, ilbc_constants.start_bits_30ms.length); - System.arraycopy(ilbc_constants.startfirst_bits_30ms, 0, startfirst_bits, 0, ilbc_constants.startfirst_bits_30ms.length); - System.arraycopy(ilbc_constants.scale_bits_30ms, 0, scale_bits, 0, ilbc_constants.scale_bits_30ms.length); - System.arraycopy(ilbc_constants.state_bits_30ms, 0, state_bits, 0, ilbc_constants.state_bits_30ms.length); - System.arraycopy(ilbc_constants.extra_cb_index_30ms, 0, extra_cb_index, 0, ilbc_constants.CB_NSTAGES); - System.arraycopy(ilbc_constants.extra_cb_gain_30ms, 0, extra_cb_gain, 0, ilbc_constants.CB_NSTAGES); - // System.out.println("nsubmax vaut: " + NSUB_MAX + " vs " + NSUB_30MS + ", alors que la taille de la table est: " + cb_index_30ms.length + " vs " + cb_index.length); - System.arraycopy(ilbc_constants.cb_index_30ms, 0, cb_index, 0, ilbc_constants.NSUB_30MS); - System.arraycopy(ilbc_constants.cb_gain_30ms, 0, cb_gain, 0, ilbc_constants.NSUB_30MS); - } - - // for (int i = 0; i < NSUB_MAX; i++) { - // for (int j = 0; j < CB_NSTAGES; j++) { - // for (int k = 0; k < ULP_CLASSES+2; k++) { - // System.out.print(" " + cb_gain[i][j][k]); - // } - // System.out.print(" | "); - // } - // System.out.println(""); - // } - } -} - diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/mp3/JNIEncoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/mp3/JNIEncoder.java deleted file mode 100644 index d4adfe817..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/mp3/JNIEncoder.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.mp3; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.util.*; -import net.sf.fmj.media.*; - -/** - * Implements a MP3 encoder using the native FFmpeg library. - * - * @author Lyubomir Marinov - */ -public class JNIEncoder - extends AbstractCodecExt -{ - /** - * The Logger used by the JNIEncoder class and its - * instances for logging output. - */ - private static final Logger logger = Logger.getLogger(JNIEncoder.class); - - /** - * The list of Formats of audio data supported as input by - * JNIEncoder instances. - */ - private static final Format[] SUPPORTED_INPUT_FORMATS - = new Format[] - { - new AudioFormat( - AudioFormat.LINEAR, - /* sampleRate */ Format.NOT_SPECIFIED, - 16, - /* channels */ Format.NOT_SPECIFIED, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - /* frameSizeInBits */ Format.NOT_SPECIFIED, - /* frameRate */ Format.NOT_SPECIFIED, - Format.byteArray) - }; - - /** - * The list of Formats of audio data supported as output by - * JNIEncoder instances. - */ - private static final Format[] SUPPORTED_OUTPUT_FORMATS - = new Format[] { new AudioFormat(AudioFormat.MPEGLAYER3) }; - - static - { - if (FFmpeg.avcodec_find_encoder(FFmpeg.CODEC_ID_MP3) == 0) - { - throw new RuntimeException( - "Could not find FFmpeg encoder CODEC_ID_MP3"); - } - } - - /** - * The AVCodecContext which performs the actual encoding and which - * is the native counterpart of this open JNIEncoder. - */ - private long avctx; - - /** - * The number of bytes of audio data to be encoded with a single call to - * {@link FFmpeg#avcodec_encode_audio(long, byte[], int, int, byte[], int)} - * based on the frame_size of {@link #avctx}. - */ - private int frameSizeInBytes; - - /** - * The audio data which was given to this JNIEncoder in a previous - * call to {@link #doProcess(Buffer, Buffer)} but was less than - * {@link #frameSizeInBytes} in length and was thus left to be prepended to - * the audio data in a next call to doProcess. - */ - private byte[] prevInput; - - /** - * The length of the valid audio data in {@link #prevInput}. - */ - private int prevInputLength; - - /** - * Initializes a new JNIEncoder instance. - */ - public JNIEncoder() - { - super("MP3 JNI Encoder", AudioFormat.class, SUPPORTED_OUTPUT_FORMATS); - - inputFormats = SUPPORTED_INPUT_FORMATS; - } - - /** - * Implements {@link AbstractCodecExt#doClose()}. - * - * @see AbstractCodecExt#doClose() - */ - protected synchronized void doClose() - { - if (avctx != 0) - { - FFmpeg.avcodec_close(avctx); - FFmpeg.av_free(avctx); - avctx = 0; - } - - prevInput = null; - prevInputLength = 0; - } - - /** - * Opens this Codec and acquires the resources that it needs to - * operate. A call to {@link PlugIn#open()} on this instance will result in - * a call to doOpen only if {@link AbstractCodec#opened} is - * false. All required input and/or output formats are assumed to - * have been set on this Codec before doOpen is called. - * - * @throws ResourceUnavailableException if any of the resources that this - * Codec needs to operate cannot be acquired - * @see AbstractCodecExt#doOpen() - */ - protected synchronized void doOpen() - throws ResourceUnavailableException - { - long encoder = FFmpeg.avcodec_find_encoder(FFmpeg.CODEC_ID_MP3); - - if (encoder == 0) - { - throw new ResourceUnavailableException( - "Could not find FFmpeg encoder CODEC_ID_MP3"); - } - - avctx = FFmpeg.avcodec_alloc_context(); - if (avctx == 0) - { - throw new ResourceUnavailableException( - "Could not allocate AVCodecContext" - + " for FFmpeg encoder CODEC_ID_MP3"); - } - - int avcodec_open = -1; - - try - { - AudioFormat inputFormat = (AudioFormat) getInputFormat(); - int channels = inputFormat.getChannels(); - int sampleRate = (int) inputFormat.getSampleRate(); - - if (channels == Format.NOT_SPECIFIED) - channels = 1; - - FFmpeg.avcodeccontext_set_bit_rate(avctx, 128000); - FFmpeg.avcodeccontext_set_channels(avctx, channels); - - // FIXME - try - { - FFmpeg.avcodeccontext_set_sample_fmt(avctx, - FFmpeg.AV_SAMPLE_FMT_S16); - } - catch (UnsatisfiedLinkError ule) - { - logger.warn("The FFmpeg JNI library is out-of-date."); - } - - if (sampleRate != Format.NOT_SPECIFIED) - FFmpeg.avcodeccontext_set_sample_rate(avctx, sampleRate); - - avcodec_open = FFmpeg.avcodec_open(avctx, encoder); - - frameSizeInBytes - = FFmpeg.avcodeccontext_get_frame_size(avctx) - * (inputFormat.getSampleSizeInBits() / 8) - * channels; - } - finally - { - if (avcodec_open < 0) - { - FFmpeg.av_free(avctx); - avctx = 0; - } - } - if (avctx == 0) - { - throw new ResourceUnavailableException( - "Could not open FFmpeg encoder CODEC_ID_MP3"); - } - } - - /** - * Implements {@link AbstractCodecExt#doProcess(Buffer, Buffer)}. - * - * @param inputBuffer - * @param outputBuffer - * @see AbstractCodecExt#doProcess(Buffer, Buffer) - */ - protected synchronized int doProcess( - Buffer inputBuffer, - Buffer outputBuffer) - { - byte[] input = (byte[]) inputBuffer.getData(); - int inputLength = inputBuffer.getLength(); - int inputOffset = inputBuffer.getOffset(); - - if ((prevInputLength > 0) || (inputLength < frameSizeInBytes)) - { - int newPrevInputLength - = Math.min(frameSizeInBytes - prevInputLength, inputLength); - - if (newPrevInputLength > 0) - { - if (prevInput == null) - { - prevInput = new byte[frameSizeInBytes]; - prevInputLength = 0; - } - - System.arraycopy( - input, inputOffset, - prevInput, prevInputLength, - newPrevInputLength); - - inputBuffer.setLength(inputLength - newPrevInputLength); - inputBuffer.setOffset(inputOffset + newPrevInputLength); - - prevInputLength += newPrevInputLength; - if (prevInputLength == frameSizeInBytes) - { - input = prevInput; - inputLength = prevInputLength; - inputOffset = 0; - - prevInputLength = 0; - } - else - return OUTPUT_BUFFER_NOT_FILLED; - } - } - else - { - inputBuffer.setLength(inputLength - frameSizeInBytes); - inputBuffer.setOffset(inputOffset + frameSizeInBytes); - } - - Object outputData = outputBuffer.getData(); - byte[] output - = (outputData instanceof byte[]) ? (byte[]) outputData : null; - int outputOffset = outputBuffer.getOffset(); - int minOutputLength - = Math.max(FFmpeg.FF_MIN_BUFFER_SIZE, inputLength); - - if ((output == null) - || ((output.length - outputOffset) < minOutputLength)) - { - output = new byte[minOutputLength]; - outputBuffer.setData(output); - outputOffset = 0; - outputBuffer.setOffset(outputOffset); - } - - int outputLength - = FFmpeg.avcodec_encode_audio( - avctx, - output, outputOffset, output.length - outputOffset, - input, inputOffset); - - if (outputLength < 0) - return BUFFER_PROCESSED_FAILED; - else - { - outputBuffer.setLength(outputLength); - - if (inputBuffer.getLength() > 0) - return BUFFER_PROCESSED_OK | INPUT_BUFFER_NOT_CONSUMED; - else - return BUFFER_PROCESSED_OK; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/JavaDecoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/JavaDecoder.java deleted file mode 100644 index b42d460a3..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/JavaDecoder.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; - -/** - * Implements the SILK decoder as an FMJ/JMF Codec. - * - * @author Dingxin Xu - */ -public class JavaDecoder - extends AbstractCodecExt -{ - /** - * The duration of a frame in milliseconds as defined by the SILK standard. - */ - static final int FRAME_DURATION = 20; - - /** - * The maximum number of frames encoded into a single payload as defined by - * the SILK standard. - */ - private static final int MAX_FRAMES_PER_PAYLOAD = 5; - /** - * The list of Formats of audio data supported as input by - * JavaDecoder instances. - */ - private static final Format[] SUPPORTED_INPUT_FORMATS - = JavaEncoder.SUPPORTED_OUTPUT_FORMATS; - - /** - * The list of Formats of audio data supported as output by - * JavaDecoder instances. - */ - private static final Format[] SUPPORTED_OUTPUT_FORMATS - = JavaEncoder.SUPPORTED_INPUT_FORMATS; - - /** - * The SILK decoder control (structure). - */ - private SKP_SILK_SDK_DecControlStruct decControl; - - /** - * The SILK decoder state. - */ - private SKP_Silk_decoder_state decState; - - /** - * The length of an output frame as determined by {@link #FRAME_DURATION} - * and the inputFormat of this JavaDecoder. - */ - private short frameLength; - - /** - * The number of frames decoded from the last input Buffer which - * has not been consumed yet. - */ - private int framesPerPayload; - - /** - * The length of an output frame as reported by - * {@link Silk_dec_API#SKP_Silk_SDK_Decode(Object, SKP_SILK_SDK_DecControlStruct, int, byte[], int, int, short[], int, short[])}. - */ - private final short[] outputLength = new short[1]; - - /** - * Initializes a new JavaDecoder instance. - */ - public JavaDecoder() - { - super("SILK Decoder", AudioFormat.class, SUPPORTED_OUTPUT_FORMATS); - - inputFormats = SUPPORTED_INPUT_FORMATS; - } - - protected void doClose() - { - decState = null; - decControl = null; - } - - protected void doOpen() - throws ResourceUnavailableException - { - decState = new SKP_Silk_decoder_state(); - if (Silk_dec_API.SKP_Silk_SDK_InitDecoder(decState) != 0) - throw - new ResourceUnavailableException( - "Silk_dec_API.SKP_Silk_SDK_InitDecoder"); - - AudioFormat inputFormat = (AudioFormat) getInputFormat(); - double sampleRate = inputFormat.getSampleRate(); - int channels = inputFormat.getChannels(); - - decControl = new SKP_SILK_SDK_DecControlStruct(); - decControl.API_sampleRate = (int) sampleRate; - - frameLength = (short) ((FRAME_DURATION * sampleRate * channels) / 1000); - } - - protected int doProcess(Buffer inputBuffer, Buffer outputBuffer) - { - byte[] inputData = (byte[]) inputBuffer.getData(); - int inputOffset = inputBuffer.getOffset(); - int inputLength = inputBuffer.getLength(); - - short[] outputData = validateShortArraySize(outputBuffer, frameLength); - int outputOffset = 0; - - int processed; - - outputLength[0] = frameLength; - if (Silk_dec_API.SKP_Silk_SDK_Decode( - decState, decControl, - 0, - inputData, inputOffset, inputLength, - outputData, outputOffset, outputLength) - == 0) - { - outputBuffer.setDuration(FRAME_DURATION * 1000000); - outputBuffer.setLength(outputLength[0]); - outputBuffer.setOffset(outputOffset); - - if (decControl.moreInternalDecoderFrames == 0) - processed = BUFFER_PROCESSED_OK; - else - { - framesPerPayload++; - processed - = (framesPerPayload >= MAX_FRAMES_PER_PAYLOAD) - ? BUFFER_PROCESSED_OK - : INPUT_BUFFER_NOT_CONSUMED; - } - } - else - processed = BUFFER_PROCESSED_FAILED; - - if ((processed & INPUT_BUFFER_NOT_CONSUMED) - != INPUT_BUFFER_NOT_CONSUMED) - framesPerPayload = 0; - - return processed; - } - - /** - * Get the output formats matching a specific input format. - * - * @param inputFormat the input format to get the matching output formats of - * @return the output formats matching the specified input format - * @see AbstractCodecExt#getMatchingOutputFormats(Format) - */ - @Override - protected Format[] getMatchingOutputFormats(Format inputFormat) - { - return - JavaEncoder.getMatchingOutputFormats( - inputFormat, - SUPPORTED_INPUT_FORMATS, - SUPPORTED_OUTPUT_FORMATS); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/JavaEncoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/JavaEncoder.java deleted file mode 100644 index 79c8e83d6..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/JavaEncoder.java +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; - -/** - * Implements the SILK encoder as an FMJ/JMF Codec. - * - * @author Dingxin Xu - */ -public class JavaEncoder - extends AbstractCodecExt -{ - private static final int BITRATE = 40000; - - private static final int COMPLEXITY = 2; - - /** - * The maximum number of output payload bytes per input frame. Equals peak - * bitrate of 100 kbps. - */ - private static final int MAX_BYTES_PER_FRAME = 250; - - private static final int PACKET_LOSS_PERCENTAGE = 0; - - /** - * The list of Formats of audio data supported as input by - * JavaEncoder instances. - */ - static final Format[] SUPPORTED_INPUT_FORMATS; - - /** - * The list of Formats of audio data supported as output by - * JavaEncoder instances. - */ - static final Format[] SUPPORTED_OUTPUT_FORMATS; - - /** - * The list of sample rates of audio data supported as input and output by - * JavaEncoder instances. - */ - private static final double[] SUPPORTED_SAMPLE_RATES - = new double[] { 8000, 12000, 16000, 24000 }; - - private static final boolean USE_DTX = false; - - private static final boolean USE_IN_BAND_FEC = false; - - /** - * The duration an output Buffer produced by this Codec - * in nanosecond. - */ - private int duration = JavaDecoder.FRAME_DURATION * 1000000; - - static - { - int supportedCount = SUPPORTED_SAMPLE_RATES.length; - - SUPPORTED_INPUT_FORMATS = new Format[supportedCount]; - SUPPORTED_OUTPUT_FORMATS = new Format[supportedCount]; - for (int i = 0; i < supportedCount; i++) - { - double supportedSampleRate = SUPPORTED_SAMPLE_RATES[i]; - - SUPPORTED_INPUT_FORMATS[i] - = new AudioFormat( - AudioFormat.LINEAR, - supportedSampleRate, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED /* frameSizeInBits */, - Format.NOT_SPECIFIED /* frameRate */, - Format.shortArray); - SUPPORTED_OUTPUT_FORMATS[i] - = new AudioFormat( - Constants.SILK_RTP, - supportedSampleRate, - Format.NOT_SPECIFIED /* sampleSizeInBits */, - 1, - Format.NOT_SPECIFIED /* endian */, - Format.NOT_SPECIFIED /* signed */, - Format.NOT_SPECIFIED /* frameSizeInBits */, - Format.NOT_SPECIFIED /* frameRate */, - Format.byteArray); - } - } - - /** - * The SILK encoder control (structure). - */ - private SKP_SILK_SDK_EncControlStruct encControl; - - /** - * The SILK encoder state. - */ - private SKP_Silk_encoder_state_FLP encState; - - /** - * The length of an output payload as reported by - * {@link Silk_enc_API#SKP_Silk_SDK_Encode(Object, SKP_SILK_SDK_EncControlStruct, short[], int, int, byte[], int, short[])}. - */ - private final short[] outputLength = new short[1]; - - /** - * Initializes a new JavaEncoder instance. - */ - public JavaEncoder() - { - super("SILK Encoder", AudioFormat.class, SUPPORTED_OUTPUT_FORMATS); - - inputFormats = SUPPORTED_INPUT_FORMATS; - } - - protected void doClose() - { - encState = null; - encControl = null; - } - - protected void doOpen() - throws ResourceUnavailableException - { - encState = new SKP_Silk_encoder_state_FLP(); - encControl = new SKP_SILK_SDK_EncControlStruct(); - if (Silk_enc_API.SKP_Silk_SDK_InitEncoder(encState, encControl) != 0) - throw - new ResourceUnavailableException( - "Silk_enc_API.SKP_Silk_SDK_InitEncoder"); - - AudioFormat inputFormat = (AudioFormat) getInputFormat(); - double sampleRate = inputFormat.getSampleRate(); - int channels = inputFormat.getChannels(); - - encControl.API_sampleRate = (int) sampleRate; - encControl.bitRate = BITRATE; - encControl.complexity = COMPLEXITY; - encControl.maxInternalSampleRate = encControl.API_sampleRate; - encControl.packetLossPercentage = PACKET_LOSS_PERCENTAGE; - encControl.packetSize - = (int) - ((JavaDecoder.FRAME_DURATION * sampleRate * channels) / 1000); - encControl.useDTX = USE_DTX ? 1 : 0; - encControl.useInBandFEC = USE_IN_BAND_FEC ? 1 : 0; - } - - protected int doProcess(Buffer inputBuffer, Buffer outputBuffer) - { - short[] inputData = (short[]) inputBuffer.getData(); - int inputLength = inputBuffer.getLength(); - int inputOffset = inputBuffer.getOffset(); - - if (inputLength > encControl.packetSize) - inputLength = encControl.packetSize; - - byte[] outputData - = validateByteArraySize(outputBuffer, MAX_BYTES_PER_FRAME); - int outputOffset = 0; - - int processed; - - outputLength[0] = MAX_BYTES_PER_FRAME; - if (Silk_enc_API.SKP_Silk_SDK_Encode( - encState, encControl, - inputData, inputOffset, inputLength, - outputData, outputOffset, outputLength) - == 0) - { - outputBuffer.setLength(outputLength[0]); - outputBuffer.setOffset(outputOffset); - processed = BUFFER_PROCESSED_OK; - } - else - processed = BUFFER_PROCESSED_FAILED; - - inputBuffer.setLength(inputBuffer.getLength() - inputLength); - inputBuffer.setOffset(inputBuffer.getOffset() + inputLength); - - if (processed != BUFFER_PROCESSED_FAILED) - { - if(processed == BUFFER_PROCESSED_OK) - { - updateOutput( - outputBuffer, - getOutputFormat(), outputBuffer.getLength(), - outputBuffer.getOffset()); - outputBuffer.setDuration(duration); - } - - if (inputBuffer.getLength() > 0) - processed |= INPUT_BUFFER_NOT_CONSUMED; - } - - return processed; - } - - /** - * Get the output formats matching a specific input format. - * - * @param inputFormat the input format to get the matching output formats of - * @return the output formats matching the specified input format - * @see AbstractCodecExt#getMatchingOutputFormats(Format) - */ - @Override - protected Format[] getMatchingOutputFormats(Format inputFormat) - { - return - getMatchingOutputFormats( - inputFormat, - SUPPORTED_INPUT_FORMATS, - SUPPORTED_OUTPUT_FORMATS); - } - - static Format[] getMatchingOutputFormats( - Format inputFormat, - Format[] supportedInputFormats, - Format[] supportedOutputFormats) - { - if (inputFormat == null) - return supportedOutputFormats; - else - { - Format matchingInputFormat - = matches(inputFormat, supportedInputFormats); - - if (matchingInputFormat == null) - return new Format[0]; - else - { - AudioFormat matchingInputAudioFormat - = (AudioFormat) matchingInputFormat.intersects(inputFormat); - Format outputFormat - = new AudioFormat( - null /* encoding */, - matchingInputAudioFormat.getSampleRate(), - Format.NOT_SPECIFIED /* sampleSizeInBits */, - Format.NOT_SPECIFIED /* channels */, - Format.NOT_SPECIFIED /* endian */, - Format.NOT_SPECIFIED /* signed */, - Format.NOT_SPECIFIED /* frameSizeInBits */, - Format.NOT_SPECIFIED /* frameRate */, - null /* dataType */); - Format matchingOutputFormat - = matches(outputFormat, supportedOutputFormats); - - if (matchingOutputFormat == null) - return new Format[0]; - else - return - new Format[] - { - matchingOutputFormat.intersects(outputFormat) - }; - } - } - } - - /** - * Get the output format. - * - * @return output format - * @see net.sf.fmj.media.AbstractCodec#getOutputFormat() - */ - @Override - public Format getOutputFormat() - { - Format outputFormat = super.getOutputFormat(); - - if ((outputFormat != null) - && (outputFormat.getClass() == AudioFormat.class)) - { - AudioFormat outputAudioFormat = (AudioFormat) outputFormat; - - outputFormat = setOutputFormat( - new AudioFormat( - outputAudioFormat.getEncoding(), - outputAudioFormat.getSampleRate(), - outputAudioFormat.getSampleSizeInBits(), - outputAudioFormat.getChannels(), - outputAudioFormat.getEndian(), - outputAudioFormat.getSigned(), - outputAudioFormat.getFrameSizeInBits(), - outputAudioFormat.getFrameRate(), - outputAudioFormat.getDataType()) - { - private static final long serialVersionUID = 0L; - - @Override - public long computeDuration(long length) - { - return JavaEncoder.this.duration; - } - }); - } - return outputFormat; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_A2NLSF.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_A2NLSF.java deleted file mode 100644 index 258ef0d34..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_A2NLSF.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -class Silk_A2NLSF_constants -{ - /* Number of binary divisions, when not in low complexity mode */ - static final int BIN_DIV_STEPS_A2NLSF_FIX = 2; /* must be no higher than 16 - log2( LSF_COS_TAB_SZ_FIX ) */ - static final int QPoly = 16; - static final int MAX_ITERATIONS_A2NLSF_FIX = 50; - - /* Flag for using 2x as many cosine sampling points, reduces the risk of missing a root */ - static final int OVERSAMPLE_COSINE_TABLE = 0; -} - -/** - * Conversion between prediction filter coefficients and NLSFs. - * Requires the order to be an even number. - * A piecewise linear approximation maps LSF <-> cos(LSF). - * Therefore the result is not accurate NLSFs, but the two. - * function are accurate inverses of each other. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_A2NLSF - extends Silk_A2NLSF_constants -{ - /** - * Helper function for A2NLSF(..). - * Transforms polynomials from cos(n*f) to cos(f)^n. - * @param p Polynomial - * @param dd Polynomial order (= filter order / 2 ) - */ - static void SKP_Silk_A2NLSF_trans_poly( - int[] p, /* I/O Polynomial */ - final int dd /* I Polynomial order (= filter order / 2 ) */ - ) - { - int k, n; - - for( k = 2; k <= dd; k++ ) - { - for( n = dd; n > k; n-- ) - { - p[ n - 2 ] -= p[ n ]; - } - p[ k - 2 ] -= p[ k ] << 1 ; - } - } - - /** - * Helper function for A2NLSF(..). - * Polynomial evaluation. - * @param p Polynomial, QPoly - * @param x Evaluation point, Q12 - * @param dd Order - * @return return the polynomial evaluation, in QPoly - */ - static int SKP_Silk_A2NLSF_eval_poly( /* return the polynomial evaluation, in QPoly */ - int[] p, /* I Polynomial, QPoly */ - final int x, /* I Evaluation point, Q12 */ - final int dd /* I Order */ - ) - { - int n; - int x_Q16, y32; - - y32 = p[ dd ]; /* QPoly */ - x_Q16 = x << 4; - for( n = dd - 1; n >= 0; n-- ) - { - y32 = Silk_macros.SKP_SMLAWW( p[ n ], y32, x_Q16 ); /* QPoly */ - } - return y32; - } - - static void SKP_Silk_A2NLSF_init( - int[] a_Q16, - int[] P, - int[] Q, - final int dd - ) - { - int k; - - /* Convert filter coefs to even and odd polynomials */ - P[dd] = 1 << QPoly; - Q[dd] = 1 << QPoly; - for( k = 0; k < dd; k++ ) - { - if( QPoly < 16 ) - { - P[ k ] = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( -a_Q16[ dd - k - 1 ] - a_Q16[ dd + k ], 16 - QPoly ); /* QPoly */ - Q[ k ] = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( -a_Q16[ dd - k - 1 ] + a_Q16[ dd + k ], 16 - QPoly ); /* QPoly */ - } - else if( QPoly == 16 ) - { - P[ k ] = -a_Q16[ dd - k - 1 ] - a_Q16[ dd + k ]; // QPoly - Q[ k ] = -a_Q16[ dd - k - 1 ] + a_Q16[ dd + k ]; // QPoly - } - else - { - P[ k ] = ( -a_Q16[ dd - k - 1 ] - a_Q16[ dd + k ] ) << ( QPoly - 16 ); /* QPoly */ - Q[ k ] = ( -a_Q16[ dd - k - 1 ] + a_Q16[ dd + k ] ) << ( QPoly - 16 ); /* QPoly */ - } - } - - /* Divide out zeros as we have that for even filter orders, */ - /* z = 1 is always a root in Q, and */ - /* z = -1 is always a root in P */ - for( k = dd; k > 0; k-- ) - { - P[ k - 1 ] -= P[ k ]; - Q[ k - 1 ] += Q[ k ]; - } - - /* Transform polynomials from cos(n*f) to cos(f)^n */ - SKP_Silk_A2NLSF_trans_poly( P, dd ); - SKP_Silk_A2NLSF_trans_poly( Q, dd ); - } - - /** - * Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients. - * If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. - * @param NLSF Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] - * @param a_Q16 Monic whitening filter coefficients in Q16 [d] - * @param d Filter order (must be even) - */ - static void SKP_Silk_A2NLSF( - int[] NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */ - int[] a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */ - final int d /* I Filter order (must be even) */ - ) - { - int i, k, m, dd, root_ix, ffrac; - int xlo, xhi, xmid; - int ylo, yhi, ymid; - int nom, den; - int[] P = new int[ Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC / 2 + 1 ]; - int[] Q = new int[ Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC / 2 + 1 ]; - int[][] PQ = new int[ 2 ][ ]; - int[] p; - - /* Store pointers to array */ - PQ[ 0 ] = P; - PQ[ 1 ] = Q; - - dd = d >> 1; - - SKP_Silk_A2NLSF_init( a_Q16, P, Q, dd ); - - /* Find roots, alternating between P and Q */ - p = P; /* Pointer to polynomial */ - - xlo = Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ 0 ]; // Q12 - ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd ); - - if( ylo < 0 ) - { - /* Set the first NLSF to zero and move on to the next */ - NLSF[ 0 ] = 0; - p = Q; /* Pointer to polynomial */ - ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd ); - root_ix = 1; /* Index of current root */ - } - else - { - root_ix = 0; /* Index of current root */ - } - k = 1; /* Loop counter */ - i = 0; /* Counter for bandwidth expansions applied */ - while( true ) - { - /* Evaluate polynomial */ - if(OVERSAMPLE_COSINE_TABLE!=0) - { - xhi = Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ k >> 1 ] + - ( ( Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ ( k + 1 ) >> 1 ] - - Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ k >> 1 ] ) >> 1 ); /* Q12 */ - } - else - { - xhi = Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ k ]; /* Q12 */ - } - - yhi = SKP_Silk_A2NLSF_eval_poly( p, xhi, dd ); - - /* Detect zero crossing */ - if( ( ylo <= 0 && yhi >= 0 ) || ( ylo >= 0 && yhi <= 0 ) ) - { - /* Binary division */ - if(OVERSAMPLE_COSINE_TABLE!=0) - ffrac = -128; - else - ffrac = -256; - - for( m = 0; m < BIN_DIV_STEPS_A2NLSF_FIX; m++ ) - { - /* Evaluate polynomial */ - xmid = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( xlo + xhi, 1 ); - ymid = SKP_Silk_A2NLSF_eval_poly( p, xmid, dd ); - - /* Detect zero crossing */ - if( ( ylo <= 0 && ymid >= 0 ) || ( ylo >= 0 && ymid <= 0 ) ) - { - /* Reduce frequency */ - xhi = xmid; - yhi = ymid; - } - else - { - /* Increase frequency */ - xlo = xmid; - ylo = ymid; - if(OVERSAMPLE_COSINE_TABLE!=0) - ffrac = ffrac + (64>>m); - else - ffrac = ffrac + (128>>m); - } - } - - /* Interpolate */ - if( Math.abs( ylo ) < 65536 ) - { - /* Avoid dividing by zero */ - den = ylo - yhi; - nom = ( ylo << ( 8 - BIN_DIV_STEPS_A2NLSF_FIX ) ) + ( den >> 1 ); - if( den != 0 ) - { - ffrac += nom / den; - } - } - else - { - /* No risk of dividing by zero because abs(ylo - yhi) >= abs(ylo) >= 65536 */ - ffrac += ylo / ( ( ylo - yhi ) >> ( 8 - BIN_DIV_STEPS_A2NLSF_FIX ) ); - } - if(OVERSAMPLE_COSINE_TABLE!=0) - NLSF[ root_ix ] = Math.min( ( k << 7 ) + ffrac, Silk_typedef.SKP_int16_MAX ); - else - NLSF[ root_ix ] = Math.min( ( k << 8 ) + ffrac, Silk_typedef.SKP_int16_MAX ); - - assert( NLSF[ root_ix ] >= 0 ); - assert( NLSF[ root_ix ] <= 32767 ); - - root_ix++; /* Next root */ - if( root_ix >= d ) - { - /* Found all roots */ - break; - } - /* Alternate pointer to polynomial */ - p = PQ[ root_ix & 1 ]; - - /* Evaluate polynomial */ - if(OVERSAMPLE_COSINE_TABLE!=0) - xlo = Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] + - ( ( Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ k >> 1 ] - - Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] ) >> 1 ); // Q12 - else - xlo = Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ k - 1 ]; // Q12 - - ylo = ( 1 - ( root_ix & 2 ) ) << 12; - } - else - { - /* Increment loop counter */ - k++; - xlo = xhi; - ylo = yhi; - - if (OVERSAMPLE_COSINE_TABLE != 0) - { - if( k > 2 * Silk_SigProc_FIX.LSF_COS_TAB_SZ_FIX ) - { - i++; - if( i > MAX_ITERATIONS_A2NLSF_FIX ) - { - /* Set NLSFs to white spectrum and exit */ - NLSF[ 0 ] = ( 1 << 15 ) / ( d + 1 ); - for( k = 1; k < d; k++ ) - { - NLSF[ k ] = Silk_macros.SKP_SMULBB( k + 1, NLSF[ 0 ] ); - } - return; - } - - /* Error: Apply progressively more bandwidth expansion and run again */ - Silk_bwexpander_32.SKP_Silk_bwexpander_32( a_Q16, d, 65536 - Silk_macros.SKP_SMULBB( 66, i ) ); // 66_Q16 = 0.001 - - SKP_Silk_A2NLSF_init( a_Q16, P, Q, dd ); - p = P; /* Pointer to polynomial */ - xlo = Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ 0 ]; // Q12 - ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd ); - if( ylo < 0 ) - { - /* Set the first NLSF to zero and move on to the next */ - NLSF[ 0 ] = 0; - p = Q; /* Pointer to polynomial */ - ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd ); - root_ix = 1; /* Index of current root */ - } - else - { - root_ix = 0; /* Index of current root */ - } - k = 1; /* Reset loop counter */ - } - } - else - { - if( k > Silk_SigProc_FIX.LSF_COS_TAB_SZ_FIX ) - { - i++; - if( i > MAX_ITERATIONS_A2NLSF_FIX ) - { - /* Set NLSFs to white spectrum and exit */ - NLSF[ 0 ] = ( 1 << 15 ) / ( d + 1 ); - for( k = 1; k < d; k++ ) - { - NLSF[ k ] = Silk_macros.SKP_SMULBB( k + 1, NLSF[ 0 ] ); - } - return; - } - - /* Error: Apply progressively more bandwidth expansion and run again */ - Silk_bwexpander_32.SKP_Silk_bwexpander_32( a_Q16, d, 65536 - Silk_macros.SKP_SMULBB( 66, i ) ); // 66_Q16 = 0.001 - - SKP_Silk_A2NLSF_init( a_Q16, P, Q, dd ); - p = P; /* Pointer to polynomial */ - xlo = Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ 0 ]; // Q12 - ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd ); - if( ylo < 0 ) - { - /* Set the first NLSF to zero and move on to the next */ - NLSF[ 0 ] = 0; - p = Q; /* Pointer to polynomial */ - ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd ); - root_ix = 1; /* Index of current root */ - } - else - { - root_ix = 0; /* Index of current root */ - } - k = 1; /* Reset loop counter */ - } - } - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_CNG.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_CNG.java deleted file mode 100644 index afb65fcc9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_CNG.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * SILK CNG. - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_CNG -{ - /** - * Generates excitation for CNG LPC synthesis. - * @param residual CNG residual signal Q0. - * @param residual_offset offset of the valid data. - * @param exc_buf_Q10 Random samples buffer Q10. - * @param exc_buf_Q10_offset offset of the valid data. - * @param Gain_Q16 Gain to apply - * @param length Length - * @param rand_seed Seed to random index generator - * - */ - static void SKP_Silk_CNG_exc( - short residual[], /* O CNG residual signal Q0 */ - int residual_offset, - int exc_buf_Q10[], /* I Random samples buffer Q10 */ - int exc_buf_Q10_offset, - int Gain_Q16, /* I Gain to apply */ - int length, /* I Length */ - int[] rand_seed /* I/O Seed to random index generator */ - ) - { - int seed; - int i, idx, exc_mask; - - exc_mask = Silk_define.CNG_BUF_MASK_MAX; - while( exc_mask > length ) { - exc_mask = ( exc_mask >> 1 ); - } - - seed = rand_seed[0]; - - for( i = 0; i < length; i++ ) { - seed = Silk_SigProc_FIX.SKP_RAND( seed ); - idx = ( ( seed >> 24 ) & exc_mask ); - Silk_typedef.SKP_assert( idx >= 0 ); - Silk_typedef.SKP_assert( idx <= Silk_define.CNG_BUF_MASK_MAX ); - residual[ residual_offset+i ] = ( short )Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( Silk_macros.SKP_SMULWW( exc_buf_Q10[ idx ], Gain_Q16 ), 10 ) ); - } - rand_seed[0] = seed; - } - - /** - * Reset CNG. - * @param psDec Decoder state. - */ - static void SKP_Silk_CNG_Reset( - SKP_Silk_decoder_state psDec /* I/O Decoder state */ - ) - { - int i, NLSF_step_Q15, NLSF_acc_Q15; - - NLSF_step_Q15 = ( Silk_typedef.SKP_int16_MAX / (psDec.LPC_order + 1) ); - NLSF_acc_Q15 = 0; - for( i = 0; i < psDec.LPC_order; i++ ) { - NLSF_acc_Q15 += NLSF_step_Q15; - psDec.sCNG.CNG_smth_NLSF_Q15[ i ] = NLSF_acc_Q15; - } - psDec.sCNG.CNG_smth_Gain_Q16 = 0; - psDec.sCNG.rand_seed = 3176576; - } - - /** - * Updates CNG estimate, and applies the CNG when packet was lost. - * @param psDec Decoder state. - * @param psDecCtrl Decoder control. - * @param signal Signal. - * @param signal_offset offset of the valid data. - * @param length Length of residual. - */ - static void SKP_Silk_CNG( - SKP_Silk_decoder_state psDec, /* I/O Decoder state */ - SKP_Silk_decoder_control psDecCtrl, /* I/O Decoder control */ - short signal[], /* I/O Signal */ - int signal_offset, - int length /* I Length of residual */ - ) - { - int i, subfr; - int tmp_32, Gain_Q26, max_Gain_Q16; - short[] LPC_buf = new short[Silk_define.MAX_LPC_ORDER]; - short[] CNG_sig = new short[Silk_define.MAX_FRAME_LENGTH]; - - SKP_Silk_CNG_struct psCNG; - - psCNG = psDec.sCNG; - - if( psDec.fs_kHz != psCNG.fs_kHz ) { - /* Reset state */ - SKP_Silk_CNG_Reset( psDec ); - - psCNG.fs_kHz = psDec.fs_kHz; - } - if( psDec.lossCnt == 0 && psDec.vadFlag == Silk_define.NO_VOICE_ACTIVITY ) { - /* Update CNG parameters */ - - /* Smoothing of LSF's */ - for( i = 0; i < psDec.LPC_order; i++ ) { - psCNG.CNG_smth_NLSF_Q15[ i ] += Silk_macros.SKP_SMULWB( psDec.prevNLSF_Q15[ i ] - psCNG.CNG_smth_NLSF_Q15[ i ], Silk_define.CNG_NLSF_SMTH_Q16 ); - } - /* Find the subframe with the highest gain */ - max_Gain_Q16 = 0; - subfr = 0; - for( i = 0; i < Silk_define.NB_SUBFR; i++ ) { - if( psDecCtrl.Gains_Q16[ i ] > max_Gain_Q16 ) { - max_Gain_Q16 = psDecCtrl.Gains_Q16[ i ]; - subfr = i; - } - } - /* Update CNG excitation buffer with excitation from this subframe */ - System.arraycopy(psCNG.CNG_exc_buf_Q10, 0, psCNG.CNG_exc_buf_Q10, psDec.subfr_length, ( Silk_define.NB_SUBFR - 1 ) * psDec.subfr_length); - System.arraycopy(psDec.exc_Q10, subfr * psDec.subfr_length , psCNG.CNG_exc_buf_Q10, 0, psDec.subfr_length); - /* Smooth gains */ - for( i = 0; i < Silk_define.NB_SUBFR; i++ ) { - psCNG.CNG_smth_Gain_Q16 += Silk_macros.SKP_SMULWB( psDecCtrl.Gains_Q16[ i ] - psCNG.CNG_smth_Gain_Q16, Silk_define.CNG_GAIN_SMTH_Q16 ); - } - } - - /* Add CNG when packet is lost and / or when low speech activity */ - if( psDec.lossCnt != 0 ) {//|| psDec.vadFlag == NO_VOICE_ACTIVITY ) { - - /* Generate CNG excitation */ - int[] psCNG_rand_seed_ptr = new int[1]; - psCNG_rand_seed_ptr[0] = psCNG.rand_seed; - - SKP_Silk_CNG_exc( CNG_sig, 0, psCNG.CNG_exc_buf_Q10, 0, - psCNG.CNG_smth_Gain_Q16, length, psCNG_rand_seed_ptr ); - psCNG.rand_seed = psCNG_rand_seed_ptr[0]; - - /* Convert CNG NLSF to filter representation */ - Silk_NLSF2A_stable.SKP_Silk_NLSF2A_stable( LPC_buf, psCNG.CNG_smth_NLSF_Q15, psDec.LPC_order ); - - Gain_Q26 = 1 << 26; /* 1.0 */ - - /* Generate CNG signal, by synthesis filtering */ - if( psDec.LPC_order == 16 ) { - Silk_LPC_synthesis_order16.SKP_Silk_LPC_synthesis_order16( CNG_sig, LPC_buf, - Gain_Q26, psCNG.CNG_synth_state, CNG_sig, length ); - } else { - Silk_LPC_synthesis_filter.SKP_Silk_LPC_synthesis_filter( CNG_sig, LPC_buf, - Gain_Q26, psCNG.CNG_synth_state, CNG_sig, length, psDec.LPC_order ); - } - /* Mix with signal */ - for( i = 0; i < length; i++ ) { - tmp_32 = signal[ signal_offset + i ] + CNG_sig[ i ]; - signal[ signal_offset+i ] = (short) Silk_SigProc_FIX.SKP_SAT16( tmp_32 ); - } - } else { - Arrays.fill(psCNG.CNG_synth_state,0, psDec.LPC_order,0); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_HP_variable_cutoff_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_HP_variable_cutoff_FLP.java deleted file mode 100644 index aae0775a3..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_HP_variable_cutoff_FLP.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_HP_variable_cutoff_FLP -{ - /** - * TODO: TEST - */ - static int frame_cnt = 0; - /** - * High-pass filter with cutoff frequency adaptation based on pitch lag statistics. - * @param psEnc Encoder state FLP - * @param psEncCtrl Encoder control FLP - * @param out High-pass filtered output signal - * @param out_offset offset of valid data. - * @param in Input signal - * @param in_offset offset of valid data. - */ - static void SKP_Silk_HP_variable_cutoff_FLP( - SKP_Silk_encoder_state_FLP psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP psEncCtrl, /* I/O Encoder control FLP */ - short[] out, /* O High-pass filtered output signal */ - int out_offset, - short[] in, /* I Input signal */ - int in_offset - ) - { - float pitch_freq_Hz, pitch_freq_log, quality, delta_freq, smth_coef, Fc, r; - int[] B_Q28 = new int[ 3 ], A_Q28 = new int[ 2 ]; - - /*********************************************/ - /* Estimate low end of pitch frequency range */ - /*********************************************/ - if( psEnc.sCmn.prev_sigtype == Silk_define.SIG_TYPE_VOICED ) - { - - /* Difference, in log domain */ - pitch_freq_Hz = 1e3f * psEnc.sCmn.fs_kHz / psEnc.sCmn.prevLag; - pitch_freq_log = Silk_main_FLP.SKP_Silk_log2( pitch_freq_Hz ); - - /* Adjustment based on quality */ - quality = psEncCtrl.input_quality_bands[ 0 ]; - pitch_freq_log -= quality * quality * ( pitch_freq_log - Silk_main_FLP.SKP_Silk_log2( Silk_define_FLP.VARIABLE_HP_MIN_FREQ ) ); - pitch_freq_log += 0.5f * ( 0.6f - quality ); - - delta_freq = pitch_freq_log - psEnc.variable_HP_smth1; - if( delta_freq < 0.0 ) - { - /* Less smoothing for decreasing pitch frequency, to track something close to the minimum */ - delta_freq *= 3.0f; - } - - /* Limit delta, to reduce impact of outliers */ - delta_freq = Silk_SigProc_FLP.SKP_LIMIT_float( delta_freq, -Silk_define_FLP.VARIABLE_HP_MAX_DELTA_FREQ, Silk_define_FLP.VARIABLE_HP_MAX_DELTA_FREQ ); - - /* Update smoother */ - smth_coef = Silk_define_FLP.VARIABLE_HP_SMTH_COEF1 * psEnc.speech_activity; - psEnc.variable_HP_smth1 += smth_coef * delta_freq; - } - - /* Second smoother */ - psEnc.variable_HP_smth2 += Silk_define_FLP.VARIABLE_HP_SMTH_COEF2 * ( psEnc.variable_HP_smth1 - psEnc.variable_HP_smth2 ); - - /* Convert from log scale to Hertz */ - psEncCtrl.pitch_freq_low_Hz = ( float )Math.pow( 2.0, psEnc.variable_HP_smth2 ); - - /* Limit frequency range */ - psEncCtrl.pitch_freq_low_Hz = Silk_SigProc_FLP.SKP_LIMIT_float( psEncCtrl.pitch_freq_low_Hz, Silk_define_FLP.VARIABLE_HP_MIN_FREQ, Silk_define_FLP.VARIABLE_HP_MAX_FREQ ); - - /*******************************/ - /* Compute filter coefficients */ - /*******************************/ - /* Compute cut-off frequency, in radians */ - Fc = ( float )( 0.45f * 2.0f * 3.14159265359 * psEncCtrl.pitch_freq_low_Hz / ( 1e3f * psEnc.sCmn.fs_kHz ) ); - - /* 2nd order ARMA coefficients */ - r = 1.0f - 0.92f * Fc; - - /* b = r * [1; -2; 1]; */ - /* a = [1; -2 * r * (1 - 0.5 * Fc^2); r^2]; */ - B_Q28[ 0 ] = Silk_SigProc_FLP.SKP_float2int( ( 1 << 28 ) * r ); - B_Q28[ 1 ] = Silk_SigProc_FLP.SKP_float2int( ( 1 << 28 ) * -2.0f * r ); - B_Q28[ 2 ] = B_Q28[ 0 ]; - A_Q28[ 0 ] = Silk_SigProc_FLP.SKP_float2int( ( 1 << 28 ) * -2.0f * r * ( 1.0f - 0.5f * Fc * Fc ) ); - A_Q28[ 1 ] = Silk_SigProc_FLP.SKP_float2int( ( 1 << 28 ) * r * r ); - - /********************/ - /* High-pass filter */ - /********************/ - -// /*TEST****************************************************************************/ -// /** -// * test for B_Q28 -// */ -// int[] b_q28 = B_Q28; -// String b_q28_filename = "D:/gsoc/b_q28/b_q28"; -// b_q28_filename += frame_cnt; -// DataInputStream b_q28_datain = null; -// try -// { -// b_q28_datain = new DataInputStream( -// new FileInputStream( -// new File(b_q28_filename))); -// byte[] buffer = new byte[4]; -// for(int ii = 0; ii < b_q28.length; ii++ ) -// { -// try -// { -// -// int res = b_q28_datain.read(buffer); -// if(res != buffer.length) -// { -// throw new IOException("Unexpected End of Stream"); -// } -// b_q28[ii] = ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).getInt(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// finally -// { -// if(b_q28_datain != null) -// { -// try -// { -// b_q28_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -//// frame_cnt++; -///*TEST END****************************************************************************/ -// -///*TEST****************************************************************************/ -// /** -// * test for psEnc.x_buf -// */ -// int[] a_q28 = A_Q28; -// String a_q28_filename = "D:/gsoc/a_q28/a_q28"; -// a_q28_filename += frame_cnt; -// DataInputStream a_q28_datain = null; -// try -// { -// a_q28_datain = new DataInputStream( -// new FileInputStream( -// new File(a_q28_filename))); -// byte[] buffer = new byte[4]; -// for(int ii = 0; ii < a_q28.length; ii++ ) -// { -// try -// { -// -// int res = a_q28_datain.read(buffer); -// if(res != buffer.length) -// { -// throw new IOException("Unexpected End of Stream"); -// } -// a_q28[ii] = ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).getInt(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// finally -// { -// if(a_q28_datain != null) -// { -// try -// { -// a_q28_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -//// frame_cnt++; -///*TEST END****************************************************************************/ -// -// /*TEST****************************************************************************/ -// /** -// * test for psEnc.sCmn.In_HP_State -// */ -// int[] in_hp_state = psEnc.sCmn.In_HP_State; -// String in_hp_state_filename = "D:/gsoc/in_hp_state/in_hp_state"; -// in_hp_state_filename += frame_cnt; -// DataInputStream in_hp_state_datain = null; -// try -// { -// in_hp_state_datain = new DataInputStream( -// new FileInputStream( -// new File(in_hp_state_filename))); -// byte[] buffer = new byte[4]; -// for(int ii = 0; ii < in_hp_state.length; ii++ ) -// { -// try -// { -// -// int res = in_hp_state_datain.read(buffer); -// if(res != buffer.length) -// { -// throw new IOException("Unexpected End of Stream"); -// } -// in_hp_state[ii] = ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).getInt(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// finally -// { -// if(in_hp_state_datain != null) -// { -// try -// { -// in_hp_state_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -//// frame_cnt++; -///*TEST END****************************************************************************/ - -// /*TEST****************************************************************************/ -// /** -// * test for in -// */ -// short[] in_test = in; -// String in_test_filename = "D:/gsoc/in_test/in_test"; -// in_test_filename += frame_cnt; -// DataInputStream in_test_datain = null; -// try -// { -// in_test_datain = new DataInputStream( -// new FileInputStream( -// new File(in_test_filename))); -// byte[] buffer = new byte[2]; -// for(int ii = 0; ii < in_test.length; ii++ ) -// { -// try -// { -// -// int res = in_test_datain.read(buffer); -// if(res != buffer.length) -// { -// throw new IOException("Unexpected End of Stream"); -// } -// in_test[ii] = ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).getShort(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// finally -// { -// if(in_test_datain != null) -// { -// try -// { -// in_test_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// frame_cnt++; -///*TEST END****************************************************************************/ - - Silk_biquad_alt.SKP_Silk_biquad_alt( in,in_offset, B_Q28, A_Q28, psEnc.sCmn.In_HP_State, out,out_offset, psEnc.sCmn.frame_length ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_Inlines.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_Inlines.java deleted file mode 100644 index ad77e31be..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_Inlines.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -class Silk_Inlines_constants -{ - static final int SKP_SIN_APPROX_CONST0 = 1073735400; - static final int SKP_SIN_APPROX_CONST1 = -82778932; - static final int SKP_SIN_APPROX_CONST2 = 1059577; - static final int SKP_SIN_APPROX_CONST3 = -5013; -} - -public class Silk_Inlines - extends Silk_Inlines_constants -{ - /** - * count leading zeros of long. - * @param in. input - * @return - */ - static int SKP_Silk_CLZ64(long in) - { - return Long.numberOfLeadingZeros(in); - } - - /** - * get number of leading zeros and fractional part (the bits right after the leading one). - * @param in - * @param lz - * @param frac_Q7 - */ - static void SKP_Silk_CLZ_FRAC(int in, /* I: input */ - int[] lz, /* O: number of leading zeros */ - int[] frac_Q7) /* O: the 7 bits right after the leading one */ - { - int lzeros = Integer.numberOfLeadingZeros(in); - - lz[0] = lzeros; - frac_Q7[0] = Silk_SigProc_FIX.SKP_ROR32(in, 24 - lzeros) & 0x7f; - } - - /** - * Approximation of square root - * Accuracy: < +/- 10% for output values > 15 - < +/- 2.5% for output values > 120 - * @param x - * @return - */ - static int SKP_Silk_SQRT_APPROX(int x) - { - int y; - int[] lz = new int[1], frac_Q7 = new int[1]; - - if( x <= 0 ) - { - return 0; - } - - SKP_Silk_CLZ_FRAC(x, lz, frac_Q7); - - if( (lz[0] & 1) != 0 ) - { - y = 32768; - } - else - { - y = 46214; /* 46214 = sqrt(2) * 32768 */ - } - - /* get scaling right */ - y >>= (lz[0]>>1); - - /* increment using fractional part of input */ - y = Silk_macros.SKP_SMLAWB(y, y, Silk_macros.SKP_SMULBB(213, frac_Q7[0])); - - return y; - } - - /** - * returns the number of left shifts before overflow for a 16 bit - * number (ITU definition with norm(0)=0). - * @param a - * @return - */ - static int SKP_Silk_norm16(short a) - { - int a32; - - /* if ((a == 0) || (a == SKP_int16_MIN)) return(0); */ - if ((a << 1) == 0) - return(0); - - a32 = a; - /* if (a32 < 0) a32 = -a32 - 1; */ - a32 ^= (a32>>31); - - return Integer.numberOfLeadingZeros(a32) - 17; - } - - /** - * returns the number of left shifts before overflow for a 32 bit - * number (ITU definition with norm(0)=0) - * @param a - * @return - */ - static int SKP_Silk_norm32(int a) - { - - /* if ((a == 0) || (a == Interger.MIN_VALUE)) return(0); */ - if ((a << 1) == 0) - return(0); - - /* if (a < 0) a = -a - 1; */ - a ^= (a>>31); - - return Integer.numberOfLeadingZeros(a) - 1; - } - - /** - * Divide two int32 values and return result as int32 in a given Q-domain. - * @param a32 numerator (Q0) - * @param b32 denominator (Q0) - * @param Qres Q-domain of result (>= 0) - * @return returns a good approximation of "(a32 << Qres) / b32" - */ - static int SKP_DIV32_varQ /* O returns a good approximation of "(a32 << Qres) / b32" */ - ( - final int a32, /* I numerator (Q0) */ - final int b32, /* I denominator (Q0) */ - final int Qres /* I Q-domain of result (>= 0) */ - ) - { - int a_headrm, b_headrm, lshift; - int b32_inv, a32_nrm, b32_nrm, result; - - assert( b32 != 0 ); - assert( Qres >= 0 ); - - /* Compute number of bits head room and normalize inputs */ - a_headrm = Integer.numberOfLeadingZeros( Math.abs(a32) ) - 1; - a32_nrm = a32<> 2) / (b32_nrm>>16) ; /* Q: 29 + 16 - b_headrm */ - - /* First approximation */ - result = Silk_macros.SKP_SMULWB(a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */ - - /* Compute residual by subtracting product of denominator and first approximation */ - a32_nrm -= Silk_SigProc_FIX.SKP_SMMUL(b32_nrm, result)<<3; /* Q: a_headrm */ - - /* Refinement */ - result = Silk_macros.SKP_SMLAWB(result, a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */ - - /* Convert to Qres domain */ - lshift = 29 + a_headrm - b_headrm - Qres; - if( lshift <= 0 ) - { - return Silk_SigProc_FIX.SKP_LSHIFT_SAT32(result, -lshift); - } - else - { - if( lshift < 32) - { - return result>>lshift; - } - else - { - /* Avoid undefined result */ - return 0; - } - } - } - - /** - * Invert int32 value and return result as int32 in a given Q-domain. - * @param b32 denominator (Q0) - * @param Qres Q-domain of result (> 0) - * @return returns a good approximation of "(1 << Qres) / b32" - */ - static int SKP_INVERSE32_varQ /* O returns a good approximation of "(1 << Qres) / b32" */ - ( - final int b32, /* I denominator (Q0) */ - final int Qres /* I Q-domain of result (> 0) */ - ) - { - int b_headrm, lshift; - int b32_inv, b32_nrm, err_Q32, result; - - assert( b32 != 0 ); - assert( Qres > 0 ); - - /* Compute number of bits head room and normalize input */ - b_headrm = Integer.numberOfLeadingZeros( Math.abs(b32) ) - 1; - b32_nrm = b32<> 2) / (b32_nrm>>16); /* Q: 29 + 16 - b_headrm */ - - /* First approximation */ - result = b32_inv<<16; /* Q: 61 - b_headrm */ - - /* Compute residual by subtracting product of denominator and first approximation from one */ - err_Q32 = -Silk_macros.SKP_SMULWB(b32_nrm, b32_inv)<<3; /* Q32 */ - - /* Refinement */ - result = Silk_macros.SKP_SMLAWW(result, err_Q32, b32_inv); /* Q: 61 - b_headrm */ - - /* Convert to Qres domain */ - lshift = 61 - b_headrm - Qres; - if( lshift <= 0 ) - { - return Silk_SigProc_FIX.SKP_LSHIFT_SAT32(result, -lshift); - } - else - { - if( lshift < 32) - { - return result>>lshift; - } - else - { - /* Avoid undefined result */ - return 0; - } - } - } - - /** - * Sine approximation; an input of 65536 corresponds to 2 * pi - * Uses polynomial expansion of the input to the power 0, 2, 4 and 6 - * The relative error is below 1e-5 - * - * @param x - * @return returns approximately 2^24 * sin(x * 2 * pi / 65536). - */ - static int SKP_Silk_SIN_APPROX_Q24( /* O returns approximately 2^24 * sin(x * 2 * pi / 65536) */ - int x) - { - int y_Q30; - - /* Keep only bottom 16 bits (the function repeats itself with period 65536) */ - x &= 65535; - - /* Split range in four quadrants */ - if( x <= 32768 ) - { - if( x < 16384 ) - { - /* Return cos(pi/2 - x) */ - x = 16384 - x; - } - else - { - /* Return cos(x - pi/2) */ - x -= 16384; - } - if( x < 1100 ) - { - /* Special case: high accuracy */ - return Silk_macros.SKP_SMLAWB( 1 << 24, x*x, -5053 ); - } - x = Silk_macros.SKP_SMULWB( x<<8 , x ); /* contains x^2 in Q20 */ - y_Q30 = Silk_macros.SKP_SMLAWB( SKP_SIN_APPROX_CONST2, x, SKP_SIN_APPROX_CONST3 ); - y_Q30 = Silk_macros.SKP_SMLAWW( SKP_SIN_APPROX_CONST1, x, y_Q30 ); - y_Q30 = Silk_macros.SKP_SMLAWW( SKP_SIN_APPROX_CONST0 + 66, x, y_Q30 ); - } - else - { - if( x < 49152 ) - { - /* Return -cos(3*pi/2 - x) */ - x = 49152 - x; - } - else - { - /* Return -cos(x - 3*pi/2) */ - x -= 49152; - } - if( x < 1100 ) - { - /* Special case: high accuracy */ - return Silk_macros.SKP_SMLAWB( -1 << 24, x*x , 5053 ); - } - x = Silk_macros.SKP_SMULWB( x<<8 , x ); /* contains x^2 in Q20 */ - y_Q30 = Silk_macros.SKP_SMLAWB( -SKP_SIN_APPROX_CONST2, x, -SKP_SIN_APPROX_CONST3 ); - y_Q30 = Silk_macros.SKP_SMLAWW( -SKP_SIN_APPROX_CONST1, x, y_Q30 ); - y_Q30 = Silk_macros.SKP_SMLAWW( -SKP_SIN_APPROX_CONST0, x, y_Q30 ); - } - return Silk_SigProc_FIX.SKP_RSHIFT_ROUND( y_Q30, 6 ); - } - - /** - * Cosine approximation; an input of 65536 corresponds to 2 * pi - * The relative error is below 1e-5 - * @param x - * @return returns approximately 2^24 * cos(x * 2 * pi / 65536). - */ - static int SKP_Silk_COS_APPROX_Q24( /* O returns approximately 2^24 * cos(x * 2 * pi / 65536) */ - int x) - { - return SKP_Silk_SIN_APPROX_Q24( x + 16384 ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LBRR_reset.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LBRR_reset.java deleted file mode 100644 index c8f0edcaf..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LBRR_reset.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_LBRR_reset -{ - /** - * Resets LBRR buffer, used if packet size changes. - * - * @param psEncC state - */ - static void SKP_Silk_LBRR_reset( - SKP_Silk_encoder_state psEncC /* I/O state */ - ) - { - int i; - - for( i = 0; i < Silk_define.MAX_LBRR_DELAY; i++ ) { - psEncC.LBRR_buffer[ i ].usage = Silk_define.SKP_SILK_NO_LBRR; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_analysis_filter_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_analysis_filter_FLP.java deleted file mode 100644 index 037c6e157..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_analysis_filter_FLP.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * LPC analysis filter - * NB! State is kept internally and the - * filter always starts with zero state - * first Order output samples are not set - * - * @author Jing Dai - * @author Dignxin Xu - */ -public class Silk_LPC_analysis_filter_FLP -{ - /** - * - * @param r_LPC LPC residual signal - * @param PredCoef LPC coefficients - * @param s Input signal - * @param s_offset offset of valid data. - * @param length Length of input signal - * @param Order LPC order - */ - static void SKP_Silk_LPC_analysis_filter_FLP( - float r_LPC[], /* O LPC residual signal */ - float PredCoef[], /* I LPC coefficients */ - float s[], /* I Input signal */ - int s_offset, - final int length, /* I Length of input signal */ - final int Order /* I LPC order */ - ) - { - assert( Order <= length ); - - switch( Order ) - { - case 8: - SKP_Silk_LPC_analysis_filter8_FLP( r_LPC, PredCoef, s, s_offset, length ); - break; - - case 10: - SKP_Silk_LPC_analysis_filter10_FLP( r_LPC, PredCoef, s, s_offset, length ); - break; - - case 12: - SKP_Silk_LPC_analysis_filter12_FLP( r_LPC, PredCoef, s, s_offset, length ); - break; - - case 16: - SKP_Silk_LPC_analysis_filter16_FLP( r_LPC, PredCoef, s, s_offset, length ); - break; - - default: - assert( false ); - break; - } - - /* Set first LPC Order samples to zero instead of undefined */ - for(int i=0; i 0; k-- ) { - /* Check for stability */ - if( ( Anew_QA[ k ] > A_LIMIT ) || ( Anew_QA[ k ] < -A_LIMIT ) ) { - return 1; - } - - /* Set RC equal to negated AR coef */ - rc_Q31 = -( Anew_QA[ k ] << (31 - QA) ); - - /* rc_mult1_Q30 range: [ 1 : 2^30-1 ] */ - rc_mult1_Q30 = ( Silk_typedef.SKP_int32_MAX >> 1 ) - Silk_SigProc_FIX.SKP_SMMUL( rc_Q31, rc_Q31 ); - Silk_typedef.SKP_assert( rc_mult1_Q30 > ( 1 << 15 ) ); /* reduce A_LIMIT if fails */ - Silk_typedef.SKP_assert( rc_mult1_Q30 < ( 1 << 30 ) ); - - /* rc_mult2_Q16 range: [ 2^16 : SKP_int32_MAX ] */ - rc_mult2_Q16 = Silk_Inlines.SKP_INVERSE32_varQ( rc_mult1_Q30, 46 ); /* 16 = 46 - 30 */ - - /* Update inverse gain */ - /* invGain_Q30 range: [ 0 : 2^30 ] */ - invGain_Q30[0] = ( Silk_SigProc_FIX.SKP_SMMUL( invGain_Q30[0], rc_mult1_Q30 ) << 2 ); - - Silk_typedef.SKP_assert( invGain_Q30[0] >= 0 ); - Silk_typedef.SKP_assert( invGain_Q30[0] <= ( 1 << 30 ) ); - - /* Swap pointers */ - Aold_QA = Anew_QA; - Anew_QA = Atmp_QA[ k & 1 ]; - - /* Update AR coefficient */ - headrm = Silk_macros.SKP_Silk_CLZ32( rc_mult2_Q16 ) - 1; - rc_mult2_Q16 = ( rc_mult2_Q16 << headrm ); /* Q: 16 + headrm */ - for( n = 0; n < k; n++ ) { - tmp_QA = Aold_QA[ n ] - ( Silk_SigProc_FIX.SKP_SMMUL( Aold_QA[ k - n - 1 ], rc_Q31 ) << 1 ); - Anew_QA[ n ] = ( Silk_SigProc_FIX.SKP_SMMUL( tmp_QA, rc_mult2_Q16 ) << (16 - headrm) ); - } - } - - /* Check for stability */ - if( ( Anew_QA[ 0 ] > A_LIMIT ) || ( Anew_QA[ 0 ] < -A_LIMIT ) ) { - return 1; - } - - /* Set RC equal to negated AR coef */ - rc_Q31 = -( Anew_QA[ 0 ] <<( 31 - QA )); - - /* Range: [ 1 : 2^30 ] */ - rc_mult1_Q30 = ( Silk_typedef.SKP_int32_MAX >> 1 ) - Silk_SigProc_FIX.SKP_SMMUL( rc_Q31, rc_Q31 ); - - /* Update inverse gain */ - /* Range: [ 0 : 2^30 ] */ - invGain_Q30[0] = ( Silk_SigProc_FIX.SKP_SMMUL( invGain_Q30[0], rc_mult1_Q30 ) << 2 ); - Silk_typedef.SKP_assert( invGain_Q30[0] >= 0 ); - Silk_typedef.SKP_assert( invGain_Q30[0] <= 1<<30 ); - - return 0; - } - - /** - * For input in Q13 domain. - * @param invGain_Q30 Inverse prediction gain, Q30 energy domain. - * @param A_Q13 Prediction coefficients, Q13 [order]. - * @param order Prediction order. - * @return Returns 1 if unstable, otherwise 0. - */ - static int SKP_Silk_LPC_inverse_pred_gain_Q13( /* O: Returns 1 if unstable, otherwise 0 */ - int []invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */ - short []A_Q13, /* I: Prediction coefficients, Q13 [order] */ - final int order /* I: Prediction order */ - ) - { - int k, n, headrm; - int rc_Q31, rc_mult1_Q30, rc_mult2_Q16; - int[][] Atmp_QA = new int[ 2 ][ Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC ]; - int tmp_QA; - - int []Aold_QA, Anew_QA; - - Anew_QA = Atmp_QA[ order & 1 ]; - /* Increase Q domain of the AR coefficients */ - for( k = 0; k < order; k++ ) { - Anew_QA[ k ] = ( A_Q13[ k ] <<( QA - 13 )); - } - - invGain_Q30[0] = ( 1 << 30 ); - for( k = order - 1; k > 0; k-- ) { - /* Check for stability */ - if( ( Anew_QA[ k ] > A_LIMIT ) || ( Anew_QA[ k ] < -A_LIMIT ) ) { - return 1; - } - - /* Set RC equal to negated AR coef */ - rc_Q31 = -( Anew_QA[ k ] <<(31 - QA) ); - - /* rc_mult1_Q30 range: [ 1 : 2^30-1 ] */ - rc_mult1_Q30 = ( Silk_typedef.SKP_int32_MAX >> 1 ) - Silk_SigProc_FIX.SKP_SMMUL( rc_Q31, rc_Q31 ); - assert( rc_mult1_Q30 > ( 1 << 15 ) ); /* reduce A_LIMIT if fails */ - assert( rc_mult1_Q30 < ( 1 << 30 ) ); - - /* rc_mult2_Q16 range: [ 2^16 : SKP_int32_MAX ] */ - rc_mult2_Q16 = Silk_Inlines.SKP_INVERSE32_varQ( rc_mult1_Q30, 46 ); /* 16 = 46 - 30 */ - - /* Update inverse gain */ - /* invGain_Q30 range: [ 0 : 2^30 ] */ - invGain_Q30[0] = ( Silk_SigProc_FIX.SKP_SMMUL(invGain_Q30[0], rc_mult1_Q30 ) << 2 ); - Silk_typedef.SKP_assert( invGain_Q30[0] >= 0 ); - Silk_typedef.SKP_assert( invGain_Q30[0] <= 1<<30 ); - - /* Swap pointers */ - Aold_QA = Anew_QA; - Anew_QA = Atmp_QA[ k & 1 ]; - - /* Update AR coefficient */ - headrm = Silk_macros.SKP_Silk_CLZ32( rc_mult2_Q16 ) - 1; - rc_mult2_Q16 = ( rc_mult2_Q16 << headrm ); /* Q: 16 + headrm */ - for( n = 0; n < k; n++ ) { - tmp_QA = Aold_QA[ n ] - ( Silk_SigProc_FIX.SKP_SMMUL( Aold_QA[ k - n - 1 ], rc_Q31 ) << 1 ); - Anew_QA[ n ] = ( Silk_SigProc_FIX.SKP_SMMUL( tmp_QA, rc_mult2_Q16 ) << (16 - headrm) ); - } - } - - /* Check for stability */ - if( ( Anew_QA[ 0 ] > A_LIMIT ) || ( Anew_QA[ 0 ] < -A_LIMIT ) ) { - return 1; - } - - /* Set RC equal to negated AR coef */ - rc_Q31 = -( Anew_QA[ 0 ] << (31 - QA )); - - /* Range: [ 1 : 2^30 ] */ - rc_mult1_Q30 = ( Silk_typedef.SKP_int32_MAX >> 1 ) - Silk_SigProc_FIX.SKP_SMMUL( rc_Q31, rc_Q31 ); - - /* Update inverse gain */ - /* Range: [ 0 : 2^30 ] */ - invGain_Q30[0] = ( Silk_SigProc_FIX.SKP_SMMUL( invGain_Q30[0], rc_mult1_Q30 ) << 2 ); - Silk_typedef.SKP_assert( invGain_Q30[0] >= 0 ); - Silk_typedef.SKP_assert( invGain_Q30[0] <= 1<<30 ); - - return 0; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_inv_pred_gain_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_inv_pred_gain_FLP.java deleted file mode 100644 index 470d95732..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_inv_pred_gain_FLP.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * compute inverse of LPC prediction gain, and - * test if LPC coefficients are stable (all poles within unit circle) - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_LPC_inv_pred_gain_FLP -{ - static final float RC_THRESHOLD = 0.9999f; - - /** - * compute inverse of LPC prediction gain, and - * test if LPC coefficients are stable (all poles within unit circle) - * this code is based on SKP_Silk_a2k_FLP(). - * @param invGain inverse prediction gain, energy domain - * @param A prediction coefficients [order] - * @param A_offset offset of valid data. - * @param order prediction order - * @return returns 1 if unstable, otherwise 0 - */ - static int SKP_Silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */ - float[] invGain, /* O: inverse prediction gain, energy domain */ - float[] A, /* I: prediction coefficients [order] */ - int A_offset, - int order /* I: prediction order */ - ) - { - int k, n; - double rc, rc_mult1, rc_mult2; - float[][] Atmp = new float[ 2 ][ Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC ]; - float[] Aold, Anew; - - Anew = Atmp[ order & 1 ]; - for(int i_djinn=0; i_djinn 0; k-- ) - { - rc = -Anew[ k ]; - if (rc > RC_THRESHOLD || rc < -RC_THRESHOLD) - { - return 1; - } - rc_mult1 = 1.0f - rc * rc; - rc_mult2 = 1.0f / rc_mult1; - invGain[0] *= (float)rc_mult1; - /* swap pointers */ - Aold = Anew; - Anew = Atmp[ k & 1 ]; - for( n = 0; n < k; n++ ) { - Anew[ n ] = (float)( ( Aold[ n ] - Aold[ k - n - 1 ] * rc ) * rc_mult2 ); - } - } - rc = -Anew[ 0 ]; - if ( rc > RC_THRESHOLD || rc < -RC_THRESHOLD ) { - return 1; - } - rc_mult1 = 1.0f - rc * rc; - invGain[0] *= (float)rc_mult1; - return 0; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_stabilize.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_stabilize.java deleted file mode 100644 index 1d9eed05f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_stabilize.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -public class Silk_LPC_stabilize -{ - - static final int LPC_STABILIZE_LPC_MAX_ABS_VALUE_Q16 =( ( Short.MAX_VALUE ) << 4 ); - - /** - * LPC stabilizer, for a single input data vector. - * @param a_Q12 stabilized LPC vector [L] - * @param a_Q16 LPC vector [L] - * @param bwe_Q16 Bandwidth expansion factor - * @param L Number of LPC parameters in the input vector - */ - static void SKP_Silk_LPC_stabilize( - short []a_Q12, /* O stabilized LPC vector [L] */ - int []a_Q16, /* I LPC vector [L] */ - final int bwe_Q16, /* I Bandwidth expansion factor */ - final int L /* I Number of LPC parameters in the input vector */ - ) - { - int maxabs, absval, sc_Q16; - int i, idx = 0; - int invGain_Q30=0; - - Silk_bwexpander_32.SKP_Silk_bwexpander_32( a_Q16, L, bwe_Q16 ); - - /***************************/ - /* Limit range of the LPCs */ - /***************************/ - /* Limit the maximum absolute value of the prediction coefficients */ - while( true ) { - /* Find maximum absolute value and its index */ - maxabs = Integer.MIN_VALUE; - for( i = 0; i < L; i++ ) { - absval = Math.abs( a_Q16[ i ] ); - if( absval > maxabs ) { - maxabs = absval; - idx = i; - } - } - - if( maxabs >= LPC_STABILIZE_LPC_MAX_ABS_VALUE_Q16 ) { - /* Reduce magnitude of prediction coefficients */ - sc_Q16 = ( Integer.MAX_VALUE / ( maxabs >> 4 ) ); - sc_Q16 = 65536 - sc_Q16; - sc_Q16 = ( sc_Q16 /(idx + 1) ); - sc_Q16 = 65536 - sc_Q16; - sc_Q16 = ( Silk_macros.SKP_SMULWB( sc_Q16, 32604 ) << 1 ); // 0.995 in Q16 - Silk_bwexpander_32.SKP_Silk_bwexpander_32( a_Q16, L, sc_Q16 ); - } else { - break; - } - } - - /* Convert to 16 bit Q12 */ - for( i = 0; i < L; i++ ) { - a_Q12[ i ] = (short)Silk_SigProc_FIX.SKP_RSHIFT_ROUND( a_Q16[ i ], 4 ); - } - - /**********************/ - /* Ensure stable LPCs */ - /**********************/ - int invGain_Q30_ptr[] = new int[1]; - invGain_Q30_ptr[0] = invGain_Q30; - while( Silk_LPC_inv_pred_gain.SKP_Silk_LPC_inverse_pred_gain( invGain_Q30_ptr, a_Q12, L ) == 1 ) { - invGain_Q30 = invGain_Q30_ptr[0]; - Silk_bwexpander.SKP_Silk_bwexpander( a_Q12, L, 65339 ); // 0.997 in Q16 - } - } - - /** - * - * @param a_QQ Stabilized LPC vector, Q(24-rshift) [L] - * @param a_Q24 LPC vector [L] - * @param QQ Q domain of output LPC vector - * @param L Number of LPC parameters in the input vector - */ - static void SKP_Silk_LPC_fit( - short []a_QQ, /* O Stabilized LPC vector, Q(24-rshift) [L] */ - int []a_Q24, /* I LPC vector [L] */ - final int QQ, /* I Q domain of output LPC vector */ - final int L /* I Number of LPC parameters in the input vector */ - ) - { - int i, rshift, idx = 0; - int maxabs, absval, sc_Q16; - - rshift = 24 - QQ; - - /***************************/ - /* Limit range of the LPCs */ - /***************************/ - /* Limit the maximum absolute value of the prediction coefficients */ - while( true ) { - /* Find maximum absolute value and its index */ - maxabs = Integer.MIN_VALUE; - for( i = 0; i < L; i++ ) { - absval = Math.abs( a_Q24[ i ] ); - if( absval > maxabs ) { - maxabs = absval; - idx = i; - } - } - - maxabs = ( maxabs >> rshift ); - if( maxabs >= Short.MAX_VALUE ) { - /* Reduce magnitude of prediction coefficients */ - maxabs = Math.min( maxabs, 98369 ); // ( SKP_int32_MAX / ( 65470 >> 2 ) ) + SKP_int16_MAX = 98369 - sc_Q16 = 65470 - ( ( (65470 >> 2) * (maxabs - Short.MAX_VALUE) ) / - Silk_SigProc_FIX.SKP_RSHIFT32(( maxabs * (idx + 1)), 2 ) ); - Silk_bwexpander_32.SKP_Silk_bwexpander_32( a_Q24, L, sc_Q16 ); - } else { - break; - } - } - - /* Convert to 16 bit Q(24-rshift) */ - assert( rshift > 0 ); - assert( rshift < 31 ); - for( i = 0; i < L; i++ ) { - a_QQ[ i ] = (short)Silk_SigProc_FIX.SKP_RSHIFT_ROUND( a_Q24[ i ], rshift ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_synthesis_filter.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_synthesis_filter.java deleted file mode 100644 index da836bbd5..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_synthesis_filter.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * even order AR filter. - * Coefficients are in Q12 - * - * @author Jing Dai - */ -public class Silk_LPC_synthesis_filter -{ - /** - * even order AR filter. - * @param in excitation signal - * @param A_Q12 AR coefficients [Order], between -8_Q0 and 8_Q0 - * @param Gain_Q26 gain - * @param S state vector [Order] - * @param out output signal - * @param len signal length - * @param Order filter order, must be even - */ - static void SKP_Silk_LPC_synthesis_filter - ( - short []in, /* I: excitation signal */ - short []A_Q12, /* I: AR coefficients [Order], between -8_Q0 and 8_Q0 */ - final int Gain_Q26, /* I: gain */ - int []S, /* I/O: state vector [Order] */ - short []out, /* O: output signal */ - final int len, /* I: signal length */ - final int Order /* I: filter order, must be even */ - ) - { - int k, j, idx; - int Order_half = ( Order >> 1 ); - int SA, SB, out32_Q10, out32; - - /* Order must be even */ - Silk_typedef.SKP_assert( 2 * Order_half == Order ); - - /* S[] values are in Q14 */ - for( k = 0; k < len; k++ ) { - SA = S[ Order - 1 ]; - out32_Q10 = 0; - for( j = 0; j < ( Order_half - 1 ); j++ ) { - idx = Silk_macros.SKP_SMULBB( 2, j ) + 1; - SB = S[ Order - 1 - idx ]; - S[ Order - 1 - idx ] = SA; - out32_Q10 = Silk_macros.SKP_SMLAWB( out32_Q10, SA, A_Q12[ ( j << 1 ) ] ); - out32_Q10 = Silk_macros.SKP_SMLAWB( out32_Q10, SB, A_Q12[ ( j << 1 ) + 1 ] ); - SA = S[ Order - 2 - idx ]; - S[ Order - 2 - idx ] = SB; - } - - /* unrolled loop: epilog */ - SB = S[ 0 ]; - S[ 0 ] = SA; - out32_Q10 = Silk_macros.SKP_SMLAWB( out32_Q10, SA, A_Q12[ Order - 2 ] ); - out32_Q10 = Silk_macros.SKP_SMLAWB( out32_Q10, SB, A_Q12[ Order - 1 ] ); - /* apply gain to excitation signal and add to prediction */ - out32_Q10 = Silk_macros.SKP_ADD_SAT32( out32_Q10, Silk_macros.SKP_SMULWB( Gain_Q26, in[ k ] ) ); - - /* scale to Q0 */ - out32 = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32_Q10, 10 ); - - /* saturate output */ - out[ k ] = ( short )Silk_SigProc_FIX.SKP_SAT16( out32 ); - - /* move result into delay line */ - S[ Order - 1 ] = Silk_SigProc_FIX.SKP_LSHIFT_SAT32( out32_Q10, 4 ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_synthesis_order16.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_synthesis_order16.java deleted file mode 100644 index 6223a77e4..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LPC_synthesis_order16.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * 16th order AR filter. - * Coefficients are in Q12. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_LPC_synthesis_order16 -{ - /** - * 16th order AR filter - * @param in excitation signal - * @param A_Q12 AR coefficients [16], between -8_Q0 and 8_Q0 - * @param Gain_Q26 gain - * @param S state vector [16] - * @param out output signal - * @param len signal length, must be multiple of 16 - */ - static void SKP_Silk_LPC_synthesis_order16 - ( - short []in, /* I: excitation signal */ - short []A_Q12, /* I: AR coefficients [16], between -8_Q0 and 8_Q0 */ - final int Gain_Q26, /* I: gain */ - int []S, /* I/O: state vector [16] */ - short []out, /* O: output signal */ - final int len /* I: signal length, must be multiple of 16 */ - ) - { - int k; - int SA, SB, out32_Q10, out32; - for( k = 0; k < len; k++ ) { - /* unrolled loop: prolog */ - /* multiply-add two prediction coefficients per iteration */ - SA = S[ 15 ]; - SB = S[ 14 ]; - S[ 14 ] = SA; - out32_Q10 = Silk_macros.SKP_SMULWB(SA, A_Q12[ 0 ]); - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 1 ] ); - SA = S[ 13 ]; - S[ 13 ] = SB; - - /* unrolled loop: main loop */ - SB = S[ 12 ]; - S[ 12 ] = SA; - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 2 ] ); - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 3 ] ); - SA = S[ 11 ]; - S[ 11 ] = SB; - - SB = S[ 10 ]; - S[ 10 ] = SA; - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 4 ] ); - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 5 ] ); - - SA = S[ 9 ]; - S[ 9 ] = SB; - - SB = S[ 8 ]; - S[ 8 ] = SA; - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 6 ] ); - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 7 ] ); - SA = S[ 7 ]; - S[ 7 ] = SB; - - SB = S[ 6 ]; - S[ 6 ] = SA; - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 8 ] ); - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 9 ] ); - - SA = S[ 5 ]; - S[ 5 ] = SB; - - SB = S[ 4 ]; - S[ 4 ] = SA; - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 10 ] ); - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 11 ] ); - - SA = S[ 3 ]; - S[ 3 ] = SB; - - SB = S[ 2 ]; - S[ 2 ] = SA; - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 12 ] ); - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 13 ] ); - SA = S[ 1 ]; - S[ 1 ] = SB; - - /* unrolled loop: epilog */ - SB = S[ 0 ]; - S[ 0 ] = SA; - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 14 ] ); - out32_Q10 = Silk_SigProc_FIX.SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 15 ] ); - - - /* unrolled loop: end */ - /* apply gain to excitation signal and add to prediction */ - out32_Q10 = Silk_macros.SKP_ADD_SAT32( out32_Q10, Silk_macros.SKP_SMULWB( Gain_Q26, in[ k ] ) ); - - /* scale to Q0 */ - out32 = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32_Q10, 10 ); - - /* saturate output */ - out[ k ] = ( short )Silk_SigProc_FIX.SKP_SAT16( out32 ); - - /* move result into delay line */ - S[ 15 ] = Silk_SigProc_FIX.SKP_LSHIFT_SAT32( out32_Q10, 4 ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LP_variable_cutoff.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LP_variable_cutoff.java deleted file mode 100644 index 841c1f4b7..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_LP_variable_cutoff.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Elliptic/Cauer filters designed with 0.1 dB passband ripple, - * 80 dB minimum stopband attenuation, and - * [0.95 : 0.15 : 0.35] normalized cut off frequencies. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_LP_variable_cutoff -{ - /** - * Helper function, that interpolates the filter taps. - * @param B_Q28 - * @param A_Q28 - * @param ind - * @param fac_Q16 - */ - static void SKP_Silk_LP_interpolate_filter_taps( - int[] B_Q28, - int[] A_Q28, - final int ind, - final int fac_Q16 - ) - { - int nb, na; - - if( ind < Silk_define.TRANSITION_INT_NUM - 1 ) - { - if( fac_Q16 > 0 ) - { - if( fac_Q16 == Silk_SigProc_FIX.SKP_SAT16( fac_Q16 ) ) - { /* fac_Q16 is in range of a 16-bit int */ - /* Piece-wise linear interpolation of B and A */ - for( nb = 0; nb < Silk_define.TRANSITION_NB; nb++ ) - { - B_Q28[ nb ] = Silk_macros.SKP_SMLAWB( - Silk_tables_other.SKP_Silk_Transition_LP_B_Q28[ ind ][ nb ], - Silk_tables_other.SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ] - - Silk_tables_other.SKP_Silk_Transition_LP_B_Q28[ ind ][ nb ], - fac_Q16 ); - } - for( na = 0; na < Silk_define.TRANSITION_NA; na++ ) - { - A_Q28[ na ] = Silk_macros.SKP_SMLAWB( - Silk_tables_other.SKP_Silk_Transition_LP_A_Q28[ ind ][ na ], - Silk_tables_other.SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ] - - Silk_tables_other.SKP_Silk_Transition_LP_A_Q28[ ind ][ na ], - fac_Q16 ); - } - } - else if( fac_Q16 == ( 1 << 15 ) ) - { /* Neither fac_Q16 nor ( ( 1 << 16 ) - fac_Q16 ) is in range of a 16-bit int */ - - /* Piece-wise linear interpolation of B and A */ - for( nb = 0; nb < Silk_define.TRANSITION_NB; nb++ ) - { - B_Q28[ nb ] = Silk_SigProc_FIX.SKP_RSHIFT( - Silk_tables_other.SKP_Silk_Transition_LP_B_Q28[ ind ][ nb ] + - Silk_tables_other.SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ], - 1 ); - } - for( na = 0; na < Silk_define.TRANSITION_NA; na++ ) - { - A_Q28[ na ] = Silk_SigProc_FIX.SKP_RSHIFT( - Silk_tables_other.SKP_Silk_Transition_LP_A_Q28[ ind ][ na ] + - Silk_tables_other.SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ], - 1 ); - } - } - else - { /* ( ( 1 << 16 ) - fac_Q16 ) is in range of a 16-bit int */ - - assert( ( ( 1 << 16 ) - fac_Q16 ) == Silk_SigProc_FIX.SKP_SAT16( ( ( 1 << 16 ) - fac_Q16) ) ); - /* Piece-wise linear interpolation of B and A */ - for( nb = 0; nb < Silk_define.TRANSITION_NB; nb++ ) - { - B_Q28[ nb ] = Silk_macros.SKP_SMLAWB( - Silk_tables_other.SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ], - Silk_tables_other.SKP_Silk_Transition_LP_B_Q28[ ind ][ nb ] - - Silk_tables_other.SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ], - ( 1 << 16 ) - fac_Q16 ); - } - for( na = 0; na < Silk_define.TRANSITION_NA; na++ ) - { - A_Q28[ na ] = Silk_macros.SKP_SMLAWB( - Silk_tables_other.SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ], - Silk_tables_other.SKP_Silk_Transition_LP_A_Q28[ ind ][ na ] - - Silk_tables_other.SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ], - ( 1 << 16 ) - fac_Q16 ); - } - } - } - else - { - for(int i_djinn=0; i_djinntransition_frame_no = 1; - * Deactivate by setting psEncC->transition_frame_no = 0; - * @param psLP LP filter state - * @param out Low-pass filtered output signal - * @param out_offset offset of valid data. - * @param in Input signal - * @param in_offset offset of valid data. - * @param frame_length Frame length - */ - static void SKP_Silk_LP_variable_cutoff( - SKP_Silk_LP_state psLP, /* I/O LP filter state */ - short[] out, /* O Low-pass filtered output signal */ - int out_offset, - short[] in, /* I Input signal */ - int in_offset, - final int frame_length /* I Frame length */ - ) - { - int[] B_Q28 = new int[ Silk_define.TRANSITION_NB ], A_Q28 = new int[ Silk_define.TRANSITION_NA ]; - int fac_Q16 = 0; - int ind = 0; - - assert( psLP.transition_frame_no >= 0 ); - assert( ( ( ( psLP.transition_frame_no <= Silk_define.TRANSITION_FRAMES_DOWN ) && ( psLP.mode == 0 ) ) || - ( ( psLP.transition_frame_no <= Silk_define.TRANSITION_FRAMES_UP ) && ( psLP.mode == 1 ) ) ) ); - - /* Interpolate filter coefficients if needed */ - if( psLP.transition_frame_no > 0 ) - { - if( psLP.mode == 0 ) - { - if( psLP.transition_frame_no < Silk_define.TRANSITION_FRAMES_DOWN ) - { - /* Calculate index and interpolation factor for interpolation */ - if( Silk_define.TRANSITION_INT_STEPS_DOWN == 32 ) - fac_Q16 = psLP.transition_frame_no << ( 16 - 5 ); - else - fac_Q16 = ( psLP.transition_frame_no << 16 ) / Silk_define.TRANSITION_INT_STEPS_DOWN ; - - ind = fac_Q16 >> 16; - fac_Q16 -= ind << 16; - - assert( ind >= 0 ); - assert( ind < Silk_define.TRANSITION_INT_NUM ); - - /* Interpolate filter coefficients */ - SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, ind, fac_Q16 ); - - /* Increment transition frame number for next frame */ - psLP.transition_frame_no++; - - } - else if( psLP.transition_frame_no == Silk_define.TRANSITION_FRAMES_DOWN ) - { - /* End of transition phase */ - SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, Silk_define.TRANSITION_INT_NUM - 1, 0 ); - } - } - else if( psLP.mode == 1 ) - { - if( psLP.transition_frame_no < Silk_define.TRANSITION_FRAMES_UP ) - { - /* Calculate index and interpolation factor for interpolation */ - if( Silk_define.TRANSITION_INT_STEPS_UP == 64 ) - fac_Q16 = ( Silk_define.TRANSITION_FRAMES_UP - psLP.transition_frame_no ) << ( 16 - 6 ); - else - fac_Q16 = ( ( Silk_define.TRANSITION_FRAMES_UP - psLP.transition_frame_no ) << 16 ) / Silk_define.TRANSITION_INT_STEPS_UP; - - ind = fac_Q16 >> 16; - fac_Q16 -= ind << 16; - - assert( ind >= 0 ); - assert( ind < Silk_define.TRANSITION_INT_NUM ); - - /* Interpolate filter coefficients */ - SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, ind, fac_Q16 ); - - /* Increment transition frame number for next frame */ - psLP.transition_frame_no++; - - } - else if( psLP.transition_frame_no == Silk_define.TRANSITION_FRAMES_UP ) - { - /* End of transition phase */ - SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, 0, 0 ); - } - } - } - - if( psLP.transition_frame_no > 0 ) - { - /* ARMA low-pass filtering */ - assert( Silk_define.TRANSITION_NB == 3 && Silk_define.TRANSITION_NA == 2 ); - Silk_biquad_alt.SKP_Silk_biquad_alt( in,in_offset, B_Q28, A_Q28, psLP.In_LP_State, out,out_offset, frame_length ); - } - else - { - /* Instead of using the filter, copy input directly to output */ - for(int i_djinn=0; i_djinn round_loss ? 0 : round_loss); - - - /* Only scale if first frame in packet 0% */ - if( psEnc.sCmn.nFramesInPayloadBuf == 0 ){ - - frames_per_packet = psEnc.sCmn.PacketSize_ms / Silk_define.FRAME_LENGTH_MS; - - round_loss += ( frames_per_packet - 1 ); -// thrld1 = LTPScaleThresholds[ Math.min( round_loss, NB_THRESHOLDS - 1 ) ]; -// thrld2 = LTPScaleThresholds[ Math.min( round_loss + 1, NB_THRESHOLDS - 1 ) ]; - thrld1 = LTPScaleThresholds[ round_loss < (NB_THRESHOLDS - 1) ? round_loss : (NB_THRESHOLDS - 1)]; - thrld2 = LTPScaleThresholds[ (round_loss + 1) < (NB_THRESHOLDS - 1) ? (round_loss + 1):(NB_THRESHOLDS - 1)]; - - - if( g_limit > thrld1 ) { - /* High Scaling */ - psEncCtrl.sCmn.LTP_scaleIndex = 2; - } else if( g_limit > thrld2 ) { - /* Middle Scaling */ - psEncCtrl.sCmn.LTP_scaleIndex = 1; - } - } - psEncCtrl.LTP_scale = Silk_tables_other.SKP_Silk_LTPScales_table_Q14[ psEncCtrl.sCmn.LTP_scaleIndex ] / 16384.0f; - - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_MA.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_MA.java deleted file mode 100644 index 35a5035d8..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_MA.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Variable order MA filter. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_MA -{ - /** - * Variable order MA filter. - * @param in input signal. - * @param in_offset offset of valid data. - * @param B MA coefficients, Q13 [order+1]. - * @param S state vector [order]. - * @param out output signal. - * @param out_offset offset of valid data. - * @param len signal length. - * @param order filter order. - */ - static void SKP_Silk_MA( - short[] in, /* I: input signal */ - int in_offset, - short[] B, /* I: MA coefficients, Q13 [order+1] */ - int[] S, /* I/O: state vector [order] */ - short[] out, /* O: output signal */ - int out_offset, - final int len, /* I: signal length */ - final int order /* I: filter order */ - ) - { - int k, d, in16; - int out32; - - for( k = 0; k < len; k++ ) { - in16 = in[ in_offset + k ]; - out32 = Silk_macros.SKP_SMLABB(S[0], in16, B[ 0 ]); - out32 = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32, 13 ); - - for( d = 1; d < order; d++ ) { - S[ d - 1 ] = Silk_macros.SKP_SMLABB( S[ d ], in16, B[ d ] ); - } - S[ order - 1 ] = Silk_macros.SKP_SMULBB( in16, B[ order ] ); - - /* Limit */ - out[ out_offset + k ] = (short)Silk_SigProc_FIX.SKP_SAT16( out32 ); - } - } - - /** - * Variable order MA prediction error filter. - * @param in Input signal. - * @param in_offset offset of valid data. - * @param B MA prediction coefficients, Q12 [order]. - * @param B_offset - * @param S State vector [order]. - * @param out Output signal. - * @param out_offset offset of valid data. - * @param len Signal length. - * @param order Filter order. - */ - static void SKP_Silk_MA_Prediction( - short[] in, /* I: Input signal */ - int in_offset, - short[] B, /* I: MA prediction coefficients, Q12 [order] */ - int B_offset, - int[] S, /* I/O: State vector [order] */ - short[] out, /* O: Output signal */ - int out_offset, - final int len, /* I: Signal length */ - final int order /* I: Filter order */ - ) - { - int k, d, in16; - int out32; - - for( k = 0; k < len; k++ ) { - in16 = in[ in_offset + k ]; - out32 = ( in16 << 12 ) - S[ 0 ]; - out32 = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32, 12 ); - - for( d = 0; d < order - 1; d++ ) { - S[ d ] = Silk_SigProc_FIX.SKP_SMLABB_ovflw( S[ d + 1 ], in16, B[ B_offset + d ] ); - } - S[ order - 1 ] = Silk_macros.SKP_SMULBB( in16, B[ B_offset + order - 1 ] ); - - /* Limit */ - out[ out_offset + k ] = (short)Silk_SigProc_FIX.SKP_SAT16( out32 ); - } - } - - /** - * - * @param in input signal. - * @param in_offset offset of valid data. - * @param B MA prediction coefficients, Q13 [order]. - * @param S state vector [order]. - * @param out output signal. - * @param out_offset offset of valid data. - * @param len signal length. - * @param order filter order. - */ - static void SKP_Silk_MA_Prediction_Q13( - short []in, /* I: input signal */ - int in_offset, - short []B, /* I: MA prediction coefficients, Q13 [order] */ - int []S, /* I/O: state vector [order] */ - short []out, /* O: output signal */ - int out_offset, - int len, /* I: signal length */ - int order /* I: filter order */ - ) - { - int k, d, in16; - int out32; - for( k = 0; k < len; k++ ) { - in16 = in[ in_offset + k ]; - out32 = ( in16 << 13 ) - S[ 0 ]; - out32 = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32, 13 ); - - for( d = 0; d < order - 1; d++ ) { - S[ d ] = Silk_macros.SKP_SMLABB( S[ d + 1 ], in16, B[ d ] ); - } - S[ order - 1 ] = Silk_macros.SKP_SMULBB( in16, B[ order - 1 ] ); - - /* Limit */ - out[ out_offset + k ] = ( short )Silk_SigProc_FIX.SKP_SAT16( out32 ); - } - } - - /** - * - * @param in Input signal. - * @param in_offset offset of valid data. - * @param B MA prediction coefficients, Q12 [order]. - * @param S State vector [order]. - * @param out Output signal. - * @param out_offset offset of valid data. - * @param len Signal length. - * @param Order Filter order. - */ - static void SKP_Silk_LPC_analysis_filter( - short []in, /* I: Input signal */ - int in_offset, - short []B, /* I: MA prediction coefficients, Q12 [order] */ - short []S, /* I/O: State vector [order] */ - short []out, /* O: Output signal */ - int out_offset, - final int len, /* I: Signal length */ - final int Order /* I: Filter order */ - ) - { - int k, j, idx, Order_half = ( Order >> 1 ); - int out32_Q12, out32; - short SA, SB; - /* Order must be even */ - Silk_typedef.SKP_assert( 2 * Order_half == Order ); - - /* S[] values are in Q0 */ - for( k = 0; k < len; k++ ) { - SA = S[ 0 ]; - out32_Q12 = 0; - for( j = 0; j < ( Order_half - 1 ); j++ ) { - idx = Silk_macros.SKP_SMULBB( 2, j ) + 1; - /* Multiply-add two prediction coefficients for each loop */ - SB = S[ idx ]; - S[ idx ] = SA; - out32_Q12 = Silk_macros.SKP_SMLABB( out32_Q12, SA, B[ idx - 1 ] ); - out32_Q12 = Silk_macros.SKP_SMLABB( out32_Q12, SB, B[ idx ] ); - SA = S[ idx + 1 ]; - S[ idx + 1 ] = SB; - } - - /* Unrolled loop: epilog */ - SB = S[ Order - 1 ]; - S[ Order - 1 ] = SA; - out32_Q12 = Silk_macros.SKP_SMLABB( out32_Q12, SA, B[ Order - 2 ] ); - out32_Q12 = Silk_macros.SKP_SMLABB( out32_Q12, SB, B[ Order - 1 ] ); - - /* Subtract prediction */ - out32_Q12 = Silk_macros.SKP_SUB_SAT32( ( in[ in_offset + k ] << 12 ), out32_Q12 ); - - /* Scale to Q0 */ - out32 = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32_Q12, 12 ); - - /* Saturate output */ - out[ out_offset + k ] = ( short )Silk_SigProc_FIX.SKP_SAT16( out32 ); - - /* Move input line */ - S[ 0 ] = in[ in_offset + k ]; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF2A.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF2A.java deleted file mode 100644 index 6ebf020d6..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF2A.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * conversion between prediction filter coefficients and LSFs - * order should be even - * a piecewise linear approximation maps LSF <-> cos(LSF) - * therefore the result is not accurate LSFs, but the two - * function are accurate inverses of each other. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_NLSF2A -{ - /** - * helper function for NLSF2A(..). - * @param out intermediate polynomial, Q20. - * @param cLSF vector of interleaved 2*cos(LSFs), Q20. - * @param cLSF_offset offset of valid data. - * @param dd polynomial order (= 1/2 * filter order). - */ - static void SKP_Silk_NLSF2A_find_poly( - int []out, /* o intermediate polynomial, Q20 */ - int []cLSF, /* i vector of interleaved 2*cos(LSFs), Q20 */ - int cLSF_offset, - int dd /* i polynomial order (= 1/2 * filter order) */ - ) - { - int k, n; - int ftmp; - - out[0] = ( 1 << 20 ); - out[1] = -cLSF[ cLSF_offset + 0]; - for( k = 1; k < dd; k++ ) { - ftmp = cLSF[cLSF_offset + 2*k]; // Q20 - int test = ftmp * out[k]; - long test2 = Silk_SigProc_FIX.SKP_SMULL(ftmp, out[k]); - - out[k+1] = ( out[k-1] << 1 ) - (int)Silk_SigProc_FIX.SKP_RSHIFT_ROUND64( Silk_SigProc_FIX.SKP_SMULL( ftmp , out[k] ), 20 ); - - for( n = k; n > 1; n-- ) { - out[n] += out[n-2] - (int)Silk_SigProc_FIX.SKP_RSHIFT_ROUND64( Silk_SigProc_FIX.SKP_SMULL( ftmp , out[n-1] ), 20 ); - } - out[1] -= ftmp; - } - } - - /** - * compute whitening filter coefficients from normalized line spectral frequencies. - * @param a monic whitening filter coefficients in Q12, [d]. - * @param NLSF normalized line spectral frequencies in Q15, [d]. - * @param d filter order (should be even). - */ - static void SKP_Silk_NLSF2A( - short []a, /* o monic whitening filter coefficients in Q12, [d] */ - int []NLSF, /* i normalized line spectral frequencies in Q15, [d] */ - final int d /* i filter order (should be even) */ - ) - { - int k, i, dd; - int[] cos_LSF_Q20=new int[Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC]; - - int[] P = new int[Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC/2+1]; - int[] Q = new int[Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC/2+1]; - - int Ptmp, Qtmp; - int f_int; - int f_frac; - int cos_val, delta; - int[] a_int32 = new int[Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC]; - - int maxabs, absval, idx=0, sc_Q16; - - Silk_typedef.SKP_assert(Silk_SigProc_FIX.LSF_COS_TAB_SZ_FIX == 128); - - /* convert LSFs to 2*cos(LSF(i)), using piecewise linear curve from table */ - for( k = 0; k < d; k++ ) { - Silk_typedef.SKP_assert(NLSF[k] >= 0 ); - Silk_typedef.SKP_assert(NLSF[k] <= 32767 ); - - /* f_int on a scale 0-127 (rounded down) */ - f_int = ( NLSF[k] >> (15 - 7) ); - - /* f_frac, range: 0..255 */ - f_frac = NLSF[k] - ( f_int << (15 - 7) ); - - - Silk_typedef.SKP_assert(f_int >= 0); - Silk_typedef.SKP_assert(f_int < Silk_SigProc_FIX.LSF_COS_TAB_SZ_FIX ); - - /* Read start and end value from table */ - cos_val = Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ f_int ]; /* Q12 */ - delta = Silk_LSF_cos_table.SKP_Silk_LSFCosTab_FIX_Q12[ f_int + 1 ] - cos_val; /* Q12, with a range of 0..200 */ - - /* Linear interpolation */ - cos_LSF_Q20[k] = ( cos_val << 8 ) + ( delta * f_frac ); /* Q20 */ - - } - - dd = ( d >> 1 ); - - /* generate even and odd polynomials using convolution */ - SKP_Silk_NLSF2A_find_poly( P, cos_LSF_Q20, 0, dd ); - SKP_Silk_NLSF2A_find_poly( Q, cos_LSF_Q20, 1, dd ); - - - /* convert even and odd polynomials to int Q12 filter coefs */ - for( k = 0; k < dd; k++ ) { - Ptmp = P[k+1] + P[k]; - Qtmp = Q[k+1] - Q[k]; - - /* the Ptmp and Qtmp values at this stage need to fit in int32 */ - - a_int32[k] = -Silk_SigProc_FIX.SKP_RSHIFT_ROUND( Ptmp + Qtmp, 9 ); /* Q20 -> Q12 */ - a_int32[d-k-1] = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( Qtmp - Ptmp, 9 ); /* Q20 -> Q12 */ - } - - /* Limit the maximum absolute value of the prediction coefficients */ - for( i = 0; i < 10; i++ ) { - /* Find maximum absolute value and its index */ - maxabs = 0; - for( k = 0; k < d; k++ ) { - absval = Silk_SigProc_FIX.SKP_abs( a_int32[k] ); - if( absval > maxabs ) { - maxabs = absval; - idx = k; - } - } - - if( maxabs > Silk_typedef.SKP_int16_MAX ) { - /* Reduce magnitude of prediction coefficients */ - maxabs = Silk_SigProc_FIX.SKP_min( maxabs, 98369 ); // ( SKP_int32_MAX / ( 65470 >> 2 ) ) + SKP_int16_MAX = 98369 - sc_Q16 = 65470 - ( ( (65470 >> 2) * (maxabs - Silk_typedef.SKP_int16_MAX) ) / - ( ( maxabs * (idx + 1)) >> 2 ) ); - Silk_bwexpander_32.SKP_Silk_bwexpander_32( a_int32, d, sc_Q16 ); - - } else { - break; - } - } - - /* Reached the last iteration */ - if( i == 10 ) { - Silk_typedef.SKP_assert(false); - for( k = 0; k < d; k++ ) { - a_int32[k] = Silk_SigProc_FIX.SKP_SAT16( a_int32[k] ); - } - } - - /* Return as SKP_int16 Q12 coefficients */ - for( k = 0; k < d; k++ ) { - a[k] = (short)a_int32[k]; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF2A_stable.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF2A_stable.java deleted file mode 100644 index c0a31ed7b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF2A_stable.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Convert NLSF parameters to stable AR prediction filter coefficients. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_NLSF2A_stable -{ - /** - * Convert NLSF parameters to stable AR prediction filter coefficients. - * @param pAR_Q12 Stabilized AR coefs [LPC_order]. - * @param pNLSF NLSF vector [LPC_order]. - * @param LPC_order LPC/LSF order. - */ - static void SKP_Silk_NLSF2A_stable( - short pAR_Q12[], /* O Stabilized AR coefs [LPC_order] */ - int pNLSF[], /* I NLSF vector [LPC_order] */ - final int LPC_order /* I LPC/LSF order */ - ) - { - int i; - int invGain_Q30; - int invGain_Q30_ptr[] = new int[1]; - Silk_NLSF2A.SKP_Silk_NLSF2A( pAR_Q12, pNLSF, LPC_order ); - - - /* Ensure stable LPCs */ - for( i = 0; i < Silk_define.MAX_LPC_STABILIZE_ITERATIONS; i++ ) { - if( Silk_LPC_inv_pred_gain.SKP_Silk_LPC_inverse_pred_gain( invGain_Q30_ptr, pAR_Q12, LPC_order ) == 1 ) { - invGain_Q30 = invGain_Q30_ptr[0]; - Silk_bwexpander.SKP_Silk_bwexpander( pAR_Q12, LPC_order, 65536 - Silk_macros.SKP_SMULBB( 66, i ) ); /* 66_Q16 = 0.001 */ - } else { - invGain_Q30 = invGain_Q30_ptr[0]; - break; - } - } - - /* Reached the last iteration */ - if( i == Silk_define.MAX_LPC_STABILIZE_ITERATIONS ) { - for( i = 0; i < LPC_order; i++ ) { - pAR_Q12[ i ] = 0; - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_MSVQ_decode.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_MSVQ_decode.java deleted file mode 100644 index 89ede58f2..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_MSVQ_decode.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * NLSF vector decoder. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_NLSF_MSVQ_decode -{ - /** - * NLSF vector decoder. - * @param pNLSF_Q15 decoded output vector [LPC_ORDER x 1]. - * @param psNLSF_CB NLSF codebook struct. - * @param NLSFIndices NLSF indices [nStages x 1]. - * @param LPC_order LPC order used. - */ - static void SKP_Silk_NLSF_MSVQ_decode( - int []pNLSF_Q15, /* O Pointer to decoded output vector [LPC_ORDER x 1] */ - SKP_Silk_NLSF_CB_struct psNLSF_CB, /* I Pointer to NLSF codebook struct */ - int []NLSFIndices, /* I Pointer to NLSF indices [nStages x 1] */ - final int LPC_order /* I LPC order used */ - ) - { - short[] pCB_element; - int pCB_element_offset; - int s; - int i; - - /* Check that each index is within valid range */ - Silk_typedef.SKP_assert( 0 <= NLSFIndices[ 0 ] && NLSFIndices[ 0 ] < psNLSF_CB.CBStages[ 0 ].nVectors ); - - /* Point to the first vector element */ - pCB_element = psNLSF_CB.CBStages[ 0 ].CB_NLSF_Q15; - pCB_element_offset = ( NLSFIndices[ 0 ] * LPC_order ); - - /* Initialize with the codebook vector from stage 0 */ - for( i = 0; i < LPC_order; i++ ) { - pNLSF_Q15[ i ] = pCB_element[ pCB_element_offset + i ]; - } - - for( s = 1; s < psNLSF_CB.nStages; s++ ) { - /* Check that each index is within valid range */ - Silk_typedef.SKP_assert( 0 <= NLSFIndices[ s ] && NLSFIndices[ s ] < psNLSF_CB.CBStages[ s ].nVectors ); - - if( LPC_order == 16 ) { - /* Point to the first vector element */ - pCB_element = psNLSF_CB.CBStages[ s ].CB_NLSF_Q15; - pCB_element_offset = ( NLSFIndices[ s ] << 4 ); - - /* Add the codebook vector from the current stage */ - pNLSF_Q15[ 0 ] += pCB_element[ pCB_element_offset + 0 ]; - pNLSF_Q15[ 1 ] += pCB_element[ pCB_element_offset + 1 ]; - pNLSF_Q15[ 2 ] += pCB_element[ pCB_element_offset + 2 ]; - pNLSF_Q15[ 3 ] += pCB_element[ pCB_element_offset + 3 ]; - pNLSF_Q15[ 4 ] += pCB_element[ pCB_element_offset + 4 ]; - pNLSF_Q15[ 5 ] += pCB_element[ pCB_element_offset + 5 ]; - pNLSF_Q15[ 6 ] += pCB_element[ pCB_element_offset + 6 ]; - pNLSF_Q15[ 7 ] += pCB_element[ pCB_element_offset + 7 ]; - pNLSF_Q15[ 8 ] += pCB_element[ pCB_element_offset + 8 ]; - pNLSF_Q15[ 9 ] += pCB_element[ pCB_element_offset + 9 ]; - pNLSF_Q15[ 10 ] += pCB_element[ pCB_element_offset + 10 ]; - pNLSF_Q15[ 11 ] += pCB_element[ pCB_element_offset + 11 ]; - pNLSF_Q15[ 12 ] += pCB_element[ pCB_element_offset + 12 ]; - pNLSF_Q15[ 13 ] += pCB_element[ pCB_element_offset + 13 ]; - pNLSF_Q15[ 14 ] += pCB_element[ pCB_element_offset + 14 ]; - pNLSF_Q15[ 15 ] += pCB_element[ pCB_element_offset + 15 ]; - } else { - /* Point to the first vector element */ - pCB_element = psNLSF_CB.CBStages[ s ].CB_NLSF_Q15; - pCB_element_offset = Silk_macros.SKP_SMULBB( NLSFIndices[ s ], LPC_order ); - - /* Add the codebook vector from the current stage */ - for( i = 0; i < LPC_order; i++ ) { - pNLSF_Q15[ i ] += pCB_element[ pCB_element_offset + i ]; - } - } - } - - /* NLSF stabilization */ - Silk_NLSF_stabilize.SKP_Silk_NLSF_stabilize( pNLSF_Q15, 0, psNLSF_CB.NDeltaMin_Q15, LPC_order ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_MSVQ_decode_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_MSVQ_decode_FLP.java deleted file mode 100644 index afa1c990d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_MSVQ_decode_FLP.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * NLSF vector decoder. - * - * @author Dingxin Xu - */ -public class Silk_NLSF_MSVQ_decode_FLP -{ - /** - * NLSF vector decoder. - * @param pNLSF - * @param psNLSF_CB_FLP - * @param NLSFIndices - * @param NLSFIndices_offset - * @param LPC_order - */ - static void SKP_Silk_NLSF_MSVQ_decode_FLP( - float []pNLSF, /* O Decoded output vector [ LPC_ORDER ] */ - final SKP_Silk_NLSF_CB_FLP psNLSF_CB_FLP, /* I NLSF codebook struct */ - final int []NLSFIndices, /* I NLSF indices [ nStages ] */ - int NLSFIndices_offset, - final int LPC_order /* I LPC order used */ - ) - { - float[] pCB_element; - int pCB_element_offset; - int s; - int i; - - - /* Check that each index is within valid range */ - assert( 0 <= NLSFIndices[ NLSFIndices_offset+0 ] && NLSFIndices[ NLSFIndices_offset+0 ] < psNLSF_CB_FLP.CBStages[ 0 ].nVectors ); - - /* Point to the first vector element */ - pCB_element = psNLSF_CB_FLP.CBStages[ 0 ].CB; - pCB_element_offset = ( NLSFIndices[ NLSFIndices_offset+0 ] * LPC_order ); - - /* Initialize with the codebook vector from stage 0 */ - System.arraycopy(pCB_element, pCB_element_offset, pNLSF, 0, LPC_order); - - for( s = 1; s < psNLSF_CB_FLP.nStages; s++ ) { - /* Check that each index is within valid range */ - assert( 0 <= NLSFIndices[ NLSFIndices_offset+s ] && NLSFIndices[ NLSFIndices_offset+s ] < psNLSF_CB_FLP.CBStages[ s ].nVectors ); - - if( LPC_order == 16 ) { - /* Point to the first vector element */ - pCB_element = psNLSF_CB_FLP.CBStages[ s ].CB; - pCB_element_offset = ( NLSFIndices[ NLSFIndices_offset+s ] << 4 ); - - /* Add the codebook vector from the current stage */ - pNLSF[ 0 ] += pCB_element[ pCB_element_offset+0 ]; - pNLSF[ 1 ] += pCB_element[ pCB_element_offset+1 ]; - pNLSF[ 2 ] += pCB_element[ pCB_element_offset+2 ]; - pNLSF[ 3 ] += pCB_element[ pCB_element_offset+3 ]; - pNLSF[ 4 ] += pCB_element[ pCB_element_offset+4 ]; - pNLSF[ 5 ] += pCB_element[ pCB_element_offset+5 ]; - pNLSF[ 6 ] += pCB_element[ pCB_element_offset+6 ]; - pNLSF[ 7 ] += pCB_element[ pCB_element_offset+7 ]; - pNLSF[ 8 ] += pCB_element[ pCB_element_offset+8 ]; - pNLSF[ 9 ] += pCB_element[ pCB_element_offset+9 ]; - pNLSF[ 10 ] += pCB_element[ pCB_element_offset+10 ]; - pNLSF[ 11 ] += pCB_element[ pCB_element_offset+11 ]; - pNLSF[ 12 ] += pCB_element[ pCB_element_offset+12 ]; - pNLSF[ 13 ] += pCB_element[ pCB_element_offset+13 ]; - pNLSF[ 14 ] += pCB_element[ pCB_element_offset+14 ]; - pNLSF[ 15 ] += pCB_element[ pCB_element_offset+15 ]; - } else { - /* Point to the first vector element */ - pCB_element = psNLSF_CB_FLP.CBStages[ s ].CB; - pCB_element_offset = NLSFIndices[ NLSFIndices_offset+s ] * LPC_order; - - /* Add the codebook vector from the current stage */ - for( i = 0; i < LPC_order; i++ ) { - pNLSF[ i ] += pCB_element[ pCB_element_offset+i ]; - } - } - } - - /* NLSF stabilization */ - Silk_wrappers_FLP.SKP_Silk_NLSF_stabilize_FLP( pNLSF, psNLSF_CB_FLP.NDeltaMin, LPC_order ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_MSVQ_encode_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_MSVQ_encode_FLP.java deleted file mode 100644 index 659aed30d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_MSVQ_encode_FLP.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * NLSF vector encoder. - * - * @author Dingxin Xu - */ -public class Silk_NLSF_MSVQ_encode_FLP -{ - /** - * NLSF vector encoder. - * @param NLSFIndices Codebook path vector [ CB_STAGES ] - * @param pNLSF Quantized NLSF vector [ LPC_ORDER ] - * @param psNLSF_CB_FLP Codebook object - * @param pNLSF_q_prev Prev. quantized NLSF vector [LPC_ORDER] - * @param pW NLSF weight vector [ LPC_ORDER ] - * @param NLSF_mu Rate weight for the RD optimization - * @param NLSF_mu_fluc_red Fluctuation reduction error weight - * @param NLSF_MSVQ_Survivors Max survivors from each stage - * @param LPC_order LPC order - * @param deactivate_fluc_red Deactivate fluctuation reduction - */ - static void SKP_Silk_NLSF_MSVQ_encode_FLP( - int []NLSFIndices, /* O Codebook path vector [ CB_STAGES ] */ - float []pNLSF, /* I/O Quantized NLSF vector [ LPC_ORDER ] */ - final SKP_Silk_NLSF_CB_FLP psNLSF_CB_FLP, /* I Codebook object */ - final float []pNLSF_q_prev, /* I Prev. quantized NLSF vector [LPC_ORDER] */ - final float []pW, /* I NLSF weight vector [ LPC_ORDER ] */ - final float NLSF_mu, /* I Rate weight for the RD optimization */ - final float NLSF_mu_fluc_red, /* I Fluctuation reduction error weight */ - final int NLSF_MSVQ_Survivors,/* I Max survivors from each stage */ - final int LPC_order, /* I LPC order */ - final int deactivate_fluc_red /* I Deactivate fluctuation reduction */ - ) - { - int i, s, k, cur_survivors, prev_survivors, input_index, cb_index, bestIndex; - float se, wsse, rateDistThreshold, bestRateDist; - float pNLSF_in[] = new float[ Silk_define.MAX_LPC_ORDER ]; - - float pRateDist[]; - float pRate[]; - float pRate_new[]; - int pTempIndices[]; - int pPath[]; - int pPath_new[]; - float pRes[]; - float pRes_new[]; - if(Silk_define.LOW_COMPLEXITY_ONLY == 1) - { - pRateDist = new float[Silk_define.NLSF_MSVQ_TREE_SEARCH_MAX_VECTORS_EVALUATED_LC_MODE()]; - pRate = new float[Silk_define.MAX_NLSF_MSVQ_SURVIVORS_LC_MODE ]; - pRate_new = new float[Silk_define.MAX_NLSF_MSVQ_SURVIVORS_LC_MODE ]; - pTempIndices = new int[Silk_define.MAX_NLSF_MSVQ_SURVIVORS_LC_MODE ]; - pPath = new int[Silk_define.MAX_NLSF_MSVQ_SURVIVORS_LC_MODE * Silk_define.NLSF_MSVQ_MAX_CB_STAGES]; - pPath_new = new int[Silk_define.MAX_NLSF_MSVQ_SURVIVORS_LC_MODE * Silk_define.NLSF_MSVQ_MAX_CB_STAGES]; - pRes = new float[Silk_define.MAX_NLSF_MSVQ_SURVIVORS_LC_MODE * Silk_define.MAX_LPC_ORDER ]; - pRes_new = new float[Silk_define.MAX_NLSF_MSVQ_SURVIVORS_LC_MODE * Silk_define.MAX_LPC_ORDER ]; - }else - { - pRateDist = new float[Silk_define.NLSF_MSVQ_TREE_SEARCH_MAX_VECTORS_EVALUATED() ]; - pRate = new float[Silk_define.MAX_NLSF_MSVQ_SURVIVORS ]; - pRate_new = new float[Silk_define.MAX_NLSF_MSVQ_SURVIVORS ]; - pTempIndices = new int[Silk_define.MAX_NLSF_MSVQ_SURVIVORS ]; - pPath = new int[Silk_define.MAX_NLSF_MSVQ_SURVIVORS * Silk_define.NLSF_MSVQ_MAX_CB_STAGES ]; - pPath_new = new int[Silk_define.MAX_NLSF_MSVQ_SURVIVORS * Silk_define.NLSF_MSVQ_MAX_CB_STAGES ]; - pRes = new float[Silk_define.MAX_NLSF_MSVQ_SURVIVORS * Silk_define.MAX_LPC_ORDER ]; - pRes_new = new float[Silk_define.MAX_NLSF_MSVQ_SURVIVORS * Silk_define.MAX_LPC_ORDER ]; - } - - float[] pConstFloat;int pConstFloat_offset; - float[] pFloat; int pFloat_offset; - int[] pConstInt; int pConstInt_offset; - int[] pInt; int pInt_offset; - float[] pCB_element;int pCB_element_offset; - SKP_Silk_NLSF_CBS_FLP pCurrentCBStage; - - assert( NLSF_MSVQ_Survivors <= Silk_define.MAX_NLSF_MSVQ_SURVIVORS ); - assert( ( Silk_define.LOW_COMPLEXITY_ONLY == 0 ) || ( NLSF_MSVQ_Survivors <= Silk_define.MAX_NLSF_MSVQ_SURVIVORS_LC_MODE ) ); - - cur_survivors = NLSF_MSVQ_Survivors; - - - - /* Copy the input vector */ - System.arraycopy(pNLSF, 0, pNLSF_in, 0, LPC_order); - - /****************************************************/ - /* Tree search for the multi-stage vector quantizer */ - /****************************************************/ - - /* Clear accumulated rates */ - Arrays.fill(pRate, 0, NLSF_MSVQ_Survivors, 0); - - /* Copy NLSFs into residual signal vector */ - System.arraycopy(pNLSF, 0, pRes, 0, LPC_order); - - /* Set first stage values */ - prev_survivors = 1; - - /* Loop over all stages */ - for( s = 0; s < psNLSF_CB_FLP.nStages; s++ ) { - - /* Set a pointer to the current stage codebook */ - pCurrentCBStage = psNLSF_CB_FLP.CBStages[ s ]; - - /* Calculate the number of survivors in the current stage */ - cur_survivors = Math.min( NLSF_MSVQ_Survivors, prev_survivors * pCurrentCBStage.nVectors ); - - if(Silk_define.NLSF_MSVQ_FLUCTUATION_REDUCTION == 0 ) { - /* Find a single best survivor in the last stage, if we */ - /* do not need candidates for fluctuation reduction */ - if( s == psNLSF_CB_FLP.nStages - 1 ) { - cur_survivors = 1; - } - } - /* Nearest neighbor clustering for multiple input data vectors */ - Silk_NLSF_VQ_rate_distortion_FLP.SKP_Silk_NLSF_VQ_rate_distortion_FLP( pRateDist, pCurrentCBStage, - pRes, pW, pRate, NLSF_mu, prev_survivors, LPC_order ); - - /* Sort the rate-distortion errors */ - Silk_sort_FLP.SKP_Silk_insertion_sort_increasing_FLP( pRateDist, 0, pTempIndices, prev_survivors * pCurrentCBStage.nVectors, cur_survivors ); - - /* Discard survivors with rate-distortion values too far above the best one */ - rateDistThreshold = Silk_define.NLSF_MSVQ_SURV_MAX_REL_RD * pRateDist[ 0 ]; - while( pRateDist[ cur_survivors - 1 ] > rateDistThreshold && cur_survivors > 1 ) { - cur_survivors--; - } - - /* Update accumulated codebook contributions for the 'cur_survivors' best codebook indices */ - for( k = 0; k < cur_survivors; k++ ) { - if( s > 0 ) { - /* Find the indices of the input and the codebook vector */ - if( pCurrentCBStage.nVectors == 8 ) { - input_index = ( pTempIndices[ k ] >> 3 ); - cb_index = pTempIndices[ k ] & 7; - } else { - input_index = pTempIndices[ k ] / pCurrentCBStage.nVectors; - cb_index = pTempIndices[ k ] - input_index * pCurrentCBStage.nVectors; - } - } else { - /* Find the indices of the input and the codebook vector */ - input_index = 0; - cb_index = pTempIndices[ k ]; - } - - /* Subtract new contribution from the previous residual vector for each of 'cur_survivors' */ - pConstFloat = pRes; - pConstFloat_offset = input_index * LPC_order; - pCB_element = pCurrentCBStage.CB; - pCB_element_offset = cb_index * LPC_order; - pFloat = pRes_new; - pFloat_offset = k * LPC_order; - for( i = 0; i < LPC_order; i++ ) { - pFloat[ pFloat_offset + i ] = pConstFloat[ pConstFloat_offset + i ] - pCB_element[ pCB_element_offset + i ]; - } - - /* Update accumulated rate for stage 1 to the current */ - pRate_new[ k ] = pRate[ input_index ] + pCurrentCBStage.Rates[ cb_index ]; - - /* Copy paths from previous matrix, starting with the best path */ - pConstInt = pPath; - pConstInt_offset = input_index * psNLSF_CB_FLP.nStages; - pInt = pPath_new; - pInt_offset = k * psNLSF_CB_FLP.nStages; - for( i = 0; i < s; i++ ) { - pInt[ pInt_offset + i ] = pConstInt[ pConstInt_offset + i ]; - } - /* Write the current stage indices for the 'cur_survivors' to the best path matrix */ - pInt[ pInt_offset + s ] = cb_index; - } - - if( s < psNLSF_CB_FLP.nStages - 1 ) { - /* Copy NLSF residual matrix for next stage */ - System.arraycopy(pRes_new, 0, pRes, 0, cur_survivors * LPC_order); - - /* Copy rate vector for next stage */ - System.arraycopy(pRate_new, 0, pRate, 0, cur_survivors); - - /* Copy best path matrix for next stage */ - System.arraycopy(pPath_new, 0, pPath, 0, cur_survivors * psNLSF_CB_FLP.nStages); - } - - prev_survivors = cur_survivors; - } - - /* (Preliminary) index of the best survivor, later to be decoded */ - bestIndex = 0; - - if (Silk_define.NLSF_MSVQ_FLUCTUATION_REDUCTION == 1) - { - /******************************/ - /* NLSF fluctuation reduction */ - /******************************/ - if( deactivate_fluc_red != 1 ) { - - /* Search among all survivors, now taking also weighted fluctuation errors into account */ - bestRateDist = Float.MAX_VALUE; - for( s = 0; s < cur_survivors; s++ ) { - /* Decode survivor to compare with previous quantized NLSF vector */ - Silk_NLSF_MSVQ_decode_FLP.SKP_Silk_NLSF_MSVQ_decode_FLP( pNLSF, psNLSF_CB_FLP, - pPath_new, s * psNLSF_CB_FLP.nStages, LPC_order ); - - /* Compare decoded NLSF vector with the previously quantized vector */ - wsse = 0; - for( i = 0; i < LPC_order; i += 2 ) { - /* Compute weighted squared quantization error for index i */ - se = pNLSF[ i ] - pNLSF_q_prev[ i ]; - wsse += pW[ i ] * se * se; - - /* Compute weighted squared quantization error for index i + 1 */ - se = pNLSF[ i + 1 ] - pNLSF_q_prev[ i + 1 ]; - wsse += pW[ i + 1 ] * se * se; - } - - /* Add the fluctuation reduction penalty to the rate distortion error */ - wsse = pRateDist[s] + wsse * NLSF_mu_fluc_red; - - /* Keep index of best survivor */ - if( wsse < bestRateDist ) { - bestRateDist = wsse; - bestIndex = s; - } - } - } - } - - /* Copy best path to output argument */ - System.arraycopy(pPath_new, bestIndex * psNLSF_CB_FLP.nStages, NLSFIndices, 0, psNLSF_CB_FLP.nStages); - - /* Decode and stabilize the best survivor */ - Silk_NLSF_MSVQ_decode_FLP.SKP_Silk_NLSF_MSVQ_decode_FLP( pNLSF, psNLSF_CB_FLP, NLSFIndices, 0, LPC_order ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_VQ_rate_distortion_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_VQ_rate_distortion_FLP.java deleted file mode 100644 index 49ba95df1..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_VQ_rate_distortion_FLP.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Rate-Distortion calculations for multiple input data vectors - * - * @author Dingxin Xu - */ -public class Silk_NLSF_VQ_rate_distortion_FLP -{ - /** - * Rate-Distortion calculations for multiple input data vectors. - * @param pRD Rate-distortion values [psNLSF_CBS_FLP->nVectors*N] - * @param psNLSF_CBS_FLP NLSF codebook stage struct - * @param in Input vectors to be quantized - * @param w Weight vector - * @param rate_acc Accumulated rates from previous stage - * @param mu Weight between weighted error and rate - * @param N Number of input vectors to be quantized - * @param LPC_order LPC order - */ - static void SKP_Silk_NLSF_VQ_rate_distortion_FLP( - float []pRD, /* O Rate-distortion values [psNLSF_CBS_FLP->nVectors*N] */ - final SKP_Silk_NLSF_CBS_FLP psNLSF_CBS_FLP, /* I NLSF codebook stage struct */ - final float []in, /* I Input vectors to be quantized */ - final float []w, /* I Weight vector */ - final float []rate_acc, /* I Accumulated rates from previous stage */ - final float mu, /* I Weight between weighted error and rate */ - final int N, /* I Number of input vectors to be quantized */ - final int LPC_order /* I LPC order */ - ) - { - float[] pRD_vec; - int pRD_vec_offset; - int i, n; - - /* Compute weighted quantization errors for all input vectors over one codebook stage */ - Silk_NLSF_VQ_sum_error_FLP.SKP_Silk_NLSF_VQ_sum_error_FLP( pRD, in, w, psNLSF_CBS_FLP.CB, - N, psNLSF_CBS_FLP.nVectors, LPC_order ); - - /* Loop over input vectors */ - pRD_vec = pRD; - pRD_vec_offset = 0; - for( n = 0; n < N; n++ ) { - /* Add rate cost to error for each codebook vector */ - for( i = 0; i < psNLSF_CBS_FLP.nVectors; i++ ) { - pRD_vec[ pRD_vec_offset + i ] += mu * ( rate_acc[n] + psNLSF_CBS_FLP.Rates[ i ] ); - } - pRD_vec_offset += psNLSF_CBS_FLP.nVectors; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_VQ_sum_error_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_VQ_sum_error_FLP.java deleted file mode 100644 index 1ef61a147..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_VQ_sum_error_FLP.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * compute weighted quantization errors for LPC_order element input vectors, over one codebook stage. - * - * @author Dingxin Xu - */ -public class Silk_NLSF_VQ_sum_error_FLP -{ - /** - * compute weighted quantization errors for LPC_order element input vectors, over one codebook stage. - * @param err Weighted quantization errors [ N * K ] - * @param in Input vectors [ N * LPC_order ] - * @param w Weighting vectors [ N * LPC_order ] - * @param pCB Codebook vectors [ K * LPC_order ] - * @param N Number of input vectors - * @param K Number of codebook vectors - * @param LPC_order pCB - */ - static void SKP_Silk_NLSF_VQ_sum_error_FLP( - float []err, /* O Weighted quantization errors [ N * K ] */ - final float []in, /* I Input vectors [ N * LPC_order ] */ - final float []w, /* I Weighting vectors [ N * LPC_order ] */ - final float []pCB, /* I Codebook vectors [ K * LPC_order ] */ - final int N, /* I Number of input vectors */ - final int K, /* I Number of codebook vectors */ - final int LPC_order /* I LPC order */ - ) - { - int i, n; - float diff, sum_error; - float Wcpy[] = new float[ Silk_define.MAX_LPC_ORDER ]; - float[] cb_vec; - int cb_vec_offset; - - /* Copy to local stack */ - System.arraycopy(w, 0, Wcpy, 0, LPC_order); - -//TODO: - float[] err_tmp = err; - int err_tmp_offset = 0; - float[] in_tmp = in; - int in_tmp_offset = 0; - if( LPC_order == 16 ) { - /* Loop over input vectors */ - for( n = 0; n < N; n++ ) { - /* Loop over codebook */ - cb_vec = pCB; - cb_vec_offset = 0; - for( i = 0; i < K; i++ ) { - /* Compute weighted squared quantization error */ - diff = in_tmp[in_tmp_offset+0 ] - cb_vec[ cb_vec_offset+0 ]; - sum_error = Wcpy[ 0 ] * diff * diff; - diff = in_tmp[in_tmp_offset+1 ] - cb_vec[ cb_vec_offset+1 ]; - sum_error += Wcpy[ 1 ] * diff * diff; - diff = in_tmp[in_tmp_offset+2 ] - cb_vec[ cb_vec_offset+2 ]; - sum_error += Wcpy[ 2 ] * diff * diff; - diff = in_tmp[in_tmp_offset+3 ] - cb_vec[ cb_vec_offset+3 ]; - sum_error += Wcpy[ 3 ] * diff * diff; - diff = in_tmp[in_tmp_offset+4 ] - cb_vec[ cb_vec_offset+4 ]; - sum_error += Wcpy[ 4 ] * diff * diff; - diff = in_tmp[in_tmp_offset+5 ] - cb_vec[ cb_vec_offset+5 ]; - sum_error += Wcpy[ 5 ] * diff * diff; - diff = in_tmp[in_tmp_offset+6 ] - cb_vec[ cb_vec_offset+6 ]; - sum_error += Wcpy[ 6 ] * diff * diff; - diff = in_tmp[in_tmp_offset+7 ] - cb_vec[ cb_vec_offset+7 ]; - sum_error += Wcpy[ 7 ] * diff * diff; - diff = in_tmp[in_tmp_offset+8 ] - cb_vec[ cb_vec_offset+8 ]; - sum_error += Wcpy[ 8 ] * diff * diff; - diff = in_tmp[in_tmp_offset+9 ] - cb_vec[ cb_vec_offset+9 ]; - sum_error += Wcpy[ 9 ] * diff * diff; - diff = in_tmp[in_tmp_offset+10 ] - cb_vec[ cb_vec_offset+10 ]; - sum_error += Wcpy[ 10 ] * diff * diff; - diff = in_tmp[in_tmp_offset+11 ] - cb_vec[ cb_vec_offset+11 ]; - sum_error += Wcpy[ 11 ] * diff * diff; - diff = in_tmp[in_tmp_offset+12 ] - cb_vec[ cb_vec_offset+12 ]; - sum_error += Wcpy[ 12 ] * diff * diff; - diff = in_tmp[in_tmp_offset+13 ] - cb_vec[ cb_vec_offset+13 ]; - sum_error += Wcpy[ 13 ] * diff * diff; - diff = in_tmp[in_tmp_offset+14 ] - cb_vec[ cb_vec_offset+14 ]; - sum_error += Wcpy[ 14 ] * diff * diff; - diff = in_tmp[in_tmp_offset+15 ] - cb_vec[ cb_vec_offset+15 ]; - sum_error += Wcpy[ 15 ] * diff * diff; - - err_tmp[ err_tmp_offset +i ] = sum_error; - cb_vec_offset += 16; - } - err_tmp_offset += K; - in_tmp_offset += 16; - } - } else { - assert( LPC_order == 10 ); - - /* Loop over input vectors */ - for( n = 0; n < N; n++ ) { - /* Loop over codebook */ - cb_vec = pCB; - cb_vec_offset = 0; - for( i = 0; i < K; i++ ) { - /* Compute weighted squared quantization error */ - diff = in_tmp[in_tmp_offset+0 ] - cb_vec[ cb_vec_offset+0 ]; - sum_error = Wcpy[ 0 ] * diff * diff; - diff = in_tmp[in_tmp_offset+1 ] - cb_vec[ cb_vec_offset+1 ]; - sum_error += Wcpy[ 1 ] * diff * diff; - diff = in_tmp[in_tmp_offset+2 ] - cb_vec[ cb_vec_offset+2 ]; - sum_error += Wcpy[ 2 ] * diff * diff; - diff = in_tmp[in_tmp_offset+3 ] - cb_vec[ cb_vec_offset+3 ]; - sum_error += Wcpy[ 3 ] * diff * diff; - diff = in_tmp[in_tmp_offset+4 ] - cb_vec[ cb_vec_offset+4 ]; - sum_error += Wcpy[ 4 ] * diff * diff; - diff = in_tmp[in_tmp_offset+5 ] - cb_vec[ cb_vec_offset+5 ]; - sum_error += Wcpy[ 5 ] * diff * diff; - diff = in_tmp[in_tmp_offset+6 ] - cb_vec[ cb_vec_offset+6 ]; - sum_error += Wcpy[ 6 ] * diff * diff; - diff = in_tmp[in_tmp_offset+7 ] - cb_vec[ cb_vec_offset+7 ]; - sum_error += Wcpy[ 7 ] * diff * diff; - diff = in_tmp[in_tmp_offset+8 ] - cb_vec[ cb_vec_offset+8 ]; - sum_error += Wcpy[ 8 ] * diff * diff; - diff = in_tmp[in_tmp_offset+9 ] - cb_vec[ cb_vec_offset+9 ]; - sum_error += Wcpy[ 9 ] * diff * diff; - - err_tmp[ err_tmp_offset + i ] = sum_error; - cb_vec_offset += 10; - } - err_tmp_offset += K; - in_tmp_offset += 10; - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_VQ_weights_laroia_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_VQ_weights_laroia_FLP.java deleted file mode 100644 index 9c16c502a..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_VQ_weights_laroia_FLP.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * R. Laroia, N. Phamdo and N. Farvardin, "Robust and Efficient Quantization of Speech LSP - * Parameters Using Structured Vector Quantization", Proc. IEEE Int. Conf. Acoust., Speech, - * Signal Processing, pp. 641-644, 1991. - * - * @author Dingxin Xu - */ -public class Silk_NLSF_VQ_weights_laroia_FLP -{ - static float MIN_NDELTA = ( 1e-6f / Silk_SigProc_FLP.PI ); - - /** - * Laroia low complexity NLSF weights. - * @param pXW Pointer to input vector weights [D x 1] - * @param pX Pointer to input vector [D x 1] - * @param D Input vector dimension - */ - static void SKP_Silk_NLSF_VQ_weights_laroia_FLP( - float []pXW, /* 0: Pointer to input vector weights [D x 1] */ - final float []pX, /* I: Pointer to input vector [D x 1] */ - final int D /* I: Input vector dimension */ - ) - { - int k; - float tmp1, tmp2; - - /* Safety checks */ - assert( D > 0 ); - assert( ( D & 1 ) == 0 ); - - /* First value */ - tmp1 = 1.0f / ( pX[ 0 ] > MIN_NDELTA ? pX[0]:MIN_NDELTA); - tmp2 = 1.0f / ((pX[ 1 ] - pX[ 0 ])>MIN_NDELTA ?(pX[ 1 ] - pX[ 0 ]):MIN_NDELTA); - pXW[ 0 ] = tmp1 + tmp2; - - /* Main loop */ - for( k = 1; k < D - 1; k += 2 ) { - tmp1 = 1.0f / ((pX[ k + 1 ] - pX[ k ])>MIN_NDELTA ? (pX[ k + 1 ] - pX[ k ]):MIN_NDELTA); - pXW[ k ] = tmp1 + tmp2; - - tmp2 = 1.0f / ((pX[ k + 2 ] - pX[ k + 1 ]) >MIN_NDELTA ?(pX[ k + 2 ] - pX[ k + 1 ]):MIN_NDELTA); - pXW[ k + 1 ] = tmp1 + tmp2; - } - - /* Last value */ - tmp1 = 1.0f / ( (1.0f - pX[ D - 1 ])> MIN_NDELTA ?(1.0f - pX[ D - 1 ]):MIN_NDELTA); - pXW[ D - 1 ] = tmp1 + tmp2; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_stabilize.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_stabilize.java deleted file mode 100644 index 60b17cd54..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NLSF_stabilize.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * NLSF stabilizer: - * - Moves NLSFs further apart if they are too close - * - Moves NLSFs away from borders if they are too close - * - High effort to achieve a modification with minimum Euclidean distance to input vector - * - Output are sorted NLSF coefficients - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_NLSF_stabilize -{ - /** - * Constant Definitions. - */ - static final int MAX_LOOPS = 20; - - /** - * NLSF stabilizer, for a single input data vector. - * @param NLSF_Q15 Unstable/stabilized normalized LSF vector in Q15 [L]. - * @param NLSF_Q15_offset offset of valid data. - * @param NDeltaMin_Q15 Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1]. - * @param L Number of NLSF parameters in the input vector. - */ - static void SKP_Silk_NLSF_stabilize( - int []NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */ - int NLSF_Q15_offset, - int []NDeltaMin_Q15, /* I: Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */ - final int L /* I: Number of NLSF parameters in the input vector */ - ) - { - int center_freq_Q15, diff_Q15, min_center_Q15, max_center_Q15; - int min_diff_Q15; - int loops; - int i, I=0, k; - - /* This is necessary to ensure an output within range of a SKP_int16 */ - Silk_typedef.SKP_assert( NDeltaMin_Q15[L] >= 1 ); - - for( loops = 0; loops < MAX_LOOPS; loops++ ) { - /**************************/ - /* Find smallest distance */ - /**************************/ - /* First element */ - min_diff_Q15 = NLSF_Q15[ NLSF_Q15_offset + 0] - NDeltaMin_Q15[0]; - I = 0; - /* Middle elements */ - for( i = 1; i <= L-1; i++ ) { - diff_Q15 = NLSF_Q15[ NLSF_Q15_offset + i] - ( NLSF_Q15[ NLSF_Q15_offset + i-1] + NDeltaMin_Q15[i] ); - if( diff_Q15 < min_diff_Q15 ) { - min_diff_Q15 = diff_Q15; - I = i; - } - } - /* Last element */ - diff_Q15 = (1<<15) - ( NLSF_Q15[ NLSF_Q15_offset + L-1] + NDeltaMin_Q15[L] ); - if( diff_Q15 < min_diff_Q15 ) { - min_diff_Q15 = diff_Q15; - I = L; - } - - /***************************************************/ - /* Now check if the smallest distance non-negative */ - /***************************************************/ - if (min_diff_Q15 >= 0) { - return; - } - - if( I == 0 ) { - /* Move away from lower limit */ - NLSF_Q15[ NLSF_Q15_offset + 0] = NDeltaMin_Q15[0]; - - } else if( I == L) { - /* Move away from higher limit */ - NLSF_Q15[ NLSF_Q15_offset + L-1] = (1<<15) - NDeltaMin_Q15[L]; - - } else { - /* Find the lower extreme for the location of the current center frequency */ - min_center_Q15 = 0; - for( k = 0; k < I; k++ ) { - min_center_Q15 += NDeltaMin_Q15[k]; - } - min_center_Q15 += ( NDeltaMin_Q15[I] >> 1 ); - - - /* Find the upper extreme for the location of the current center frequency */ - max_center_Q15 = (1<<15); - for( k = L; k > I; k-- ) { - max_center_Q15 -= NDeltaMin_Q15[k]; - } - max_center_Q15 -= ( NDeltaMin_Q15[I] - ( NDeltaMin_Q15[I] >> 1 ) ); - - /* Move apart, sorted by value, keeping the same center frequency */ - center_freq_Q15 = Silk_SigProc_FIX.SKP_LIMIT_32( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( NLSF_Q15[ NLSF_Q15_offset + I-1] + NLSF_Q15[ NLSF_Q15_offset + I], 1 ), - min_center_Q15, max_center_Q15 ); - NLSF_Q15[ NLSF_Q15_offset + I-1] = center_freq_Q15 - ( NDeltaMin_Q15[I] >> 1 ); - NLSF_Q15[ NLSF_Q15_offset + I] = NLSF_Q15[ NLSF_Q15_offset + I-1] + NDeltaMin_Q15[I]; - } - } - - /* Safe and simple fall back method, which is less ideal than the above */ - if( loops == MAX_LOOPS ) - { - /* Insertion sort (fast for already almost sorted arrays): */ - /* Best case: O(n) for an already sorted array */ - /* Worst case: O(n^2) for an inversely sorted array */ - Silk_sort.SKP_Silk_insertion_sort_increasing_all_values(NLSF_Q15, NLSF_Q15_offset + 0, L); - - /* First NLSF should be no less than NDeltaMin[0] */ - NLSF_Q15[ NLSF_Q15_offset + 0] = Silk_SigProc_FIX.SKP_max_int( NLSF_Q15[ NLSF_Q15_offset + 0], NDeltaMin_Q15[0] ); - - /* Keep delta_min distance between the NLSFs */ - for( i = 1; i < L; i++ ) - NLSF_Q15[ NLSF_Q15_offset + i] = Silk_SigProc_FIX.SKP_max_int( NLSF_Q15[ NLSF_Q15_offset + i], NLSF_Q15[ NLSF_Q15_offset + i-1] + NDeltaMin_Q15[i] ); - - /* Last NLSF should be no higher than 1 - NDeltaMin[L] */ - NLSF_Q15[ NLSF_Q15_offset + L-1] = Silk_SigProc_FIX.SKP_min_int( NLSF_Q15[ NLSF_Q15_offset + L-1], (1<<15) - NDeltaMin_Q15[L] ); - - /* Keep NDeltaMin distance between the NLSFs */ - for( i = L-2; i >= 0; i-- ) - NLSF_Q15[ NLSF_Q15_offset + i] = Silk_SigProc_FIX.SKP_min_int( NLSF_Q15[ NLSF_Q15_offset + i], NLSF_Q15[ NLSF_Q15_offset + i+1] - NDeltaMin_Q15[i+1] ); - } - } - - /** - * NLSF stabilizer, over multiple input column data vectors. - * @param NLSF_Q15 Unstable/stabilized normalized LSF vectors in Q15 [LxN]. - * @param NDeltaMin_Q15 Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1]. - * @param N Number of input vectors to be stabilized. - * @param L NLSF vector dimension. - */ - static void SKP_Silk_NLSF_stabilize_multi( - int []NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vectors in Q15 [LxN] */ - int []NDeltaMin_Q15, /* I: Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */ - final int N, /* I: Number of input vectors to be stabilized */ - final int L /* I: NLSF vector dimension */ - ) - { - int n; - - /* loop over input data */ - for( n = 0; n < N; n++ ) { - SKP_Silk_NLSF_stabilize( NLSF_Q15, n * L, NDeltaMin_Q15, L ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NSQ.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NSQ.java deleted file mode 100644 index bfc610370..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NSQ.java +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * - * @author Dingxin Xu - */ -public class Silk_NSQ -{ - /** - * - * @param psEncC Encoder State - * @param psEncCtrlC Encoder Control - * @param NSQ NSQ state - * @param x prefiltered input signal - * @param q quantized qulse signal - * @param LSFInterpFactor_Q2 LSF interpolation factor in Q2 - * @param PredCoef_Q12 Short term prediction coefficients - * @param LTPCoef_Q14 Long term prediction coefficients - * @param AR2_Q13 - * @param HarmShapeGain_Q14 - * @param Tilt_Q14 Spectral tilt - * @param LF_shp_Q14 - * @param Gains_Q16 - * @param Lambda_Q10 - * @param LTP_scale_Q14 LTP state scaling - */ - static void SKP_Silk_NSQ( - SKP_Silk_encoder_state psEncC, /* I/O Encoder State */ - SKP_Silk_encoder_control psEncCtrlC, /* I Encoder Control */ - SKP_Silk_nsq_state NSQ, /* I/O NSQ state */ - short x[], /* I prefiltered input signal */ - byte q[], /* O quantized qulse signal */ - int LSFInterpFactor_Q2, /* I LSF interpolation factor in Q2 */ - short PredCoef_Q12[], /* I Short term prediction coefficients */ - short LTPCoef_Q14[], /* I Long term prediction coefficients */ - short AR2_Q13[], /* I */ - int HarmShapeGain_Q14[],/* I */ - int Tilt_Q14[], /* I Spectral tilt */ - int LF_shp_Q14[], /* I */ - int Gains_Q16[], /* I */ - int Lambda_Q10, /* I */ - int LTP_scale_Q14 /* I LTP state scaling */ - ) - { - int k, lag, start_idx, subfr_length, LSF_interpolation_flag; - short []A_Q12; - short [] B_Q14; - short [] AR_shp_Q13; - int A_Q12_offset, B_Q14_offset, AR_shp_Q13_offset; - short []pxq; - int pxq_offset; - int sLTP_Q16[] = new int[ 2 * Silk_define.MAX_FRAME_LENGTH ]; - short sLTP[] = new short[ 2 * Silk_define.MAX_FRAME_LENGTH ]; - int HarmShapeFIRPacked_Q14; - int offset_Q10; - int FiltState[] = new int[ Silk_define.MAX_LPC_ORDER ]; - int x_sc_Q10[] = new int[ Silk_define.MAX_FRAME_LENGTH / Silk_define.NB_SUBFR ]; - - subfr_length = psEncC.frame_length / Silk_define.NB_SUBFR; - - NSQ.rand_seed = psEncCtrlC.Seed; - /* Set unvoiced lag to the previous one, overwrite later for voiced */ - lag = NSQ.lagPrev; - - assert( NSQ.prev_inv_gain_Q16 != 0 ); - - offset_Q10 = Silk_tables_other.SKP_Silk_Quantization_Offsets_Q10[ psEncCtrlC.sigtype ][ psEncCtrlC.QuantOffsetType ]; - - if( LSFInterpFactor_Q2 == ( 1 << 2 ) ) { - LSF_interpolation_flag = 0; - } else { - LSF_interpolation_flag = 1; - } - - /* Setup pointers to start of sub frame */ - NSQ.sLTP_shp_buf_idx = psEncC.frame_length; - NSQ.sLTP_buf_idx = psEncC.frame_length; - pxq = NSQ.xq; - pxq_offset = psEncC.frame_length; -//TODO: use a local copy of the parameter short x[], which is supposed to be input; - short[] x_tmp = x.clone(); - int x_tmp_offset = 0; -//TODO: use a local copy of the parameter byte[] q, which is supposed to be output; - byte[] q_tmp = q.clone(); - int q_tmp_offset = 0; - - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - A_Q12 = PredCoef_Q12; - A_Q12_offset = (( k >> 1 ) | ( 1 - LSF_interpolation_flag )) * Silk_define.MAX_LPC_ORDER; - B_Q14 = LTPCoef_Q14; - B_Q14_offset = k * Silk_define.LTP_ORDER; - AR_shp_Q13 = AR2_Q13; - AR_shp_Q13_offset = k * Silk_define.SHAPE_LPC_ORDER_MAX; - - /* Noise shape parameters */ - assert( HarmShapeGain_Q14[ k ] >= 0 ); - HarmShapeFIRPacked_Q14 = ( HarmShapeGain_Q14[ k ] >> 2 ); - HarmShapeFIRPacked_Q14 |= ( ( HarmShapeGain_Q14[ k ] >> 1 ) << 16 ); - - - if( psEncCtrlC.sigtype == Silk_define.SIG_TYPE_VOICED ) { - /* Voiced */ - lag = psEncCtrlC.pitchL[ k ]; - - NSQ.rewhite_flag = 0; - /* Re-whitening */ - if( ( k & ( 3 - ( LSF_interpolation_flag << 1 ) ) ) == 0 ) { - /* Rewhiten with new A coefs */ - - start_idx = psEncC.frame_length - lag - psEncC.predictLPCOrder - Silk_define.LTP_ORDER / 2; - start_idx = Silk_SigProc_FIX.SKP_LIMIT_int( start_idx, 0, psEncC.frame_length - psEncC.predictLPCOrder ); /* Limit */ - - Arrays.fill(FiltState, 0, psEncC.predictLPCOrder, 0); - Silk_MA.SKP_Silk_MA_Prediction( NSQ.xq, start_idx + k * ( psEncC.frame_length >> 2 ), - A_Q12, A_Q12_offset, FiltState, sLTP, start_idx, psEncC.frame_length - start_idx, psEncC.predictLPCOrder ); - - NSQ.rewhite_flag = 1; - NSQ.sLTP_buf_idx = psEncC.frame_length; - } - } - - SKP_Silk_nsq_scale_states( NSQ, x_tmp, x_tmp_offset, x_sc_Q10, psEncC.subfr_length, sLTP, - sLTP_Q16, k, LTP_scale_Q14, Gains_Q16, psEncCtrlC.pitchL ); - - - SKP_Silk_noise_shape_quantizer( NSQ, psEncCtrlC.sigtype, x_sc_Q10, q_tmp, q_tmp_offset, pxq, pxq_offset, - sLTP_Q16, A_Q12, A_Q12_offset, B_Q14, B_Q14_offset, - AR_shp_Q13, AR_shp_Q13_offset, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], Gains_Q16[ k ], Lambda_Q10, - offset_Q10, psEncC.subfr_length, psEncC.shapingLPCOrder, psEncC.predictLPCOrder - ); - - x_tmp_offset += psEncC.subfr_length; - q_tmp_offset += psEncC.subfr_length; - pxq_offset += psEncC.subfr_length; - } - - /* Save scalars for this layer */ - NSQ.sLF_AR_shp_Q12 = NSQ.sLF_AR_shp_Q12; - NSQ.prev_inv_gain_Q16 = NSQ.prev_inv_gain_Q16; - NSQ.lagPrev = psEncCtrlC.pitchL[ Silk_define.NB_SUBFR - 1 ]; - /* Save quantized speech and noise shaping signals */ - System.arraycopy(NSQ.xq, psEncC.frame_length, NSQ.xq, 0, psEncC.frame_length); - System.arraycopy(NSQ.sLTP_shp_Q10, psEncC.frame_length, NSQ.sLTP_shp_Q10, 0, psEncC.frame_length); - -//TODO: copy back the q_tmp to the output parameter q; - System.arraycopy(q_tmp, 0, q, 0, q.length); - } - - /** - * SKP_Silk_noise_shape_quantizer. - * @param NSQ NSQ state - * @param sigtype Signal type - * @param x_sc_Q10 - * @param q - * @param q_offset - * @param xq - * @param xq_offset - * @param sLTP_Q16 LTP state - * @param a_Q12 Short term prediction coefs - * @param a_Q12_offset - * @param b_Q14 Long term prediction coefs - * @param b_Q14_offset - * @param AR_shp_Q13 Noise shaping AR coefs - * @param AR_shp_Q13_offset - * @param lag Pitch lag - * @param HarmShapeFIRPacked_Q14 - * @param Tilt_Q14 Spectral tilt - * @param LF_shp_Q14 - * @param Gain_Q16 - * @param Lambda_Q10 - * @param offset_Q10 - * @param length Input length - * @param shapingLPCOrder Noise shaping AR filter order - * @param predictLPCOrder Prediction filter order - */ - static void SKP_Silk_noise_shape_quantizer( - SKP_Silk_nsq_state NSQ, /* I/O NSQ state */ - int sigtype, /* I Signal type */ - final int x_sc_Q10[], /* I */ - byte q[], /* O */ - int q_offset, - short xq[], /* O */ - int xq_offset, - int sLTP_Q16[], /* I/O LTP state */ - final short a_Q12[], /* I Short term prediction coefs */ - int a_Q12_offset, - final short b_Q14[], /* I Long term prediction coefs */ - int b_Q14_offset, - final short AR_shp_Q13[], /* I Noise shaping AR coefs */ - int AR_shp_Q13_offset, - int lag, /* I Pitch lag */ - int HarmShapeFIRPacked_Q14, /* I */ - int Tilt_Q14, /* I Spectral tilt */ - int LF_shp_Q14, /* I */ - int Gain_Q16, /* I */ - int Lambda_Q10, /* I */ - int offset_Q10, /* I */ - int length, /* I Input length */ - int shapingLPCOrder, /* I Noise shaping AR filter order */ - int predictLPCOrder /* I Prediction filter order */ - ) - { - int i, j; - int LTP_pred_Q14, LPC_pred_Q10, n_AR_Q10, n_LTP_Q14; - int n_LF_Q10, r_Q10, q_Q0, q_Q10; - int thr1_Q10, thr2_Q10, thr3_Q10; - int dither; - int exc_Q10, LPC_exc_Q10, xq_Q10; - int tmp, sLF_AR_shp_Q10; - int []psLPC_Q14; - int psLPC_Q14_offset; - int []shp_lag_ptr, pred_lag_ptr; - int shp_lag_ptr_offset, pred_lag_ptr_offset; - - shp_lag_ptr = NSQ.sLTP_shp_Q10; - shp_lag_ptr_offset = NSQ.sLTP_shp_buf_idx - lag + Silk_define.HARM_SHAPE_FIR_TAPS / 2; - pred_lag_ptr = sLTP_Q16; - pred_lag_ptr_offset = NSQ.sLTP_buf_idx - lag + Silk_define.LTP_ORDER / 2; - - /* Setup short term AR state */ - psLPC_Q14 = NSQ.sLPC_Q14; - psLPC_Q14_offset = Silk_define.MAX_LPC_ORDER - 1; - - /* Quantization thresholds */ - thr1_Q10 = ( -1536 - (Lambda_Q10 >> 1)); - thr2_Q10 = ( -512 - (Lambda_Q10 >> 1)); - thr2_Q10 = ( thr2_Q10 + (Silk_macros.SKP_SMULBB( offset_Q10, Lambda_Q10 ) >> 10 )); - thr3_Q10 = ( 512 + (Lambda_Q10 >> 1)); - - for( i = 0; i < length; i++ ) { - /* Generate dither */ - NSQ.rand_seed = Silk_SigProc_FIX.SKP_RAND( NSQ.rand_seed ); - - /* dither = rand_seed < 0 ? 0xFFFFFFFF : 0; */ - dither = ( NSQ.rand_seed >> 31 ); - - /* Short-term prediction */ - assert( ( predictLPCOrder & 1 ) == 0 ); /* check that order is even */ -// SKP_assert( ( (SKP_int64)a_Q12 & 3 ) == 0 ); /* check that array starts at 4-byte aligned address */ - assert( predictLPCOrder >= 10 ); /* check that unrolling works */ - /* Partially unrolled */ - LPC_pred_Q10 = Silk_macros.SKP_SMULWB( psLPC_Q14[ psLPC_Q14_offset+0 ], a_Q12[ a_Q12_offset+0 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-1 ], a_Q12[ a_Q12_offset+1 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-2 ], a_Q12[ a_Q12_offset+2 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-3 ], a_Q12[ a_Q12_offset+3 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-4 ], a_Q12[ a_Q12_offset+4 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-5 ], a_Q12[ a_Q12_offset+5 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-6 ], a_Q12[ a_Q12_offset+6 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-7 ], a_Q12[ a_Q12_offset+7 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-8 ], a_Q12[ a_Q12_offset+8 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-9 ], a_Q12[ a_Q12_offset+9 ] ); - - for( j = 10; j < predictLPCOrder; j ++ ) { - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-j ], a_Q12[ a_Q12_offset+j ] ); - } - /* Long-term prediction */ - if( sigtype == Silk_define.SIG_TYPE_VOICED ) { - /* Unrolled loop */ - LTP_pred_Q14 = Silk_macros.SKP_SMULWB( pred_lag_ptr[ pred_lag_ptr_offset +0 ], b_Q14[ b_Q14_offset+0 ] ); - LTP_pred_Q14 = Silk_macros.SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ pred_lag_ptr_offset -1 ], b_Q14[ b_Q14_offset+1 ] ); - LTP_pred_Q14 = Silk_macros.SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ pred_lag_ptr_offset -2 ], b_Q14[ b_Q14_offset+2 ] ); - LTP_pred_Q14 = Silk_macros.SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ pred_lag_ptr_offset -3 ], b_Q14[ b_Q14_offset+3 ] ); - LTP_pred_Q14 = Silk_macros.SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ pred_lag_ptr_offset -4 ], b_Q14[ b_Q14_offset+4 ] ); - pred_lag_ptr_offset++; - } else { - LTP_pred_Q14 = 0; - } - - /* Noise shape feedback */ - assert( ( shapingLPCOrder & 1 ) == 0 ); /* check that order is even */ -// SKP_assert( ( (SKP_int64)AR_shp_Q13 & 3 ) == 0 ); /* check that array starts at 4-byte aligned address */ - assert( shapingLPCOrder >= 12 ); /* check that unrolling works */ - /* Partially unrolled */ - n_AR_Q10 = Silk_macros.SKP_SMULWB( psLPC_Q14[ psLPC_Q14_offset+0 ], AR_shp_Q13[AR_shp_Q13_offset+0 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-1 ], AR_shp_Q13[AR_shp_Q13_offset+1 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-2 ], AR_shp_Q13[AR_shp_Q13_offset+2 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-3 ], AR_shp_Q13[AR_shp_Q13_offset+3 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-4 ], AR_shp_Q13[AR_shp_Q13_offset+4 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-5 ], AR_shp_Q13[AR_shp_Q13_offset+5 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-6 ], AR_shp_Q13[AR_shp_Q13_offset+6 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-7 ], AR_shp_Q13[AR_shp_Q13_offset+7 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-8 ], AR_shp_Q13[AR_shp_Q13_offset+8 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-9 ], AR_shp_Q13[AR_shp_Q13_offset+9 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-10 ], AR_shp_Q13[AR_shp_Q13_offset+10] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-11 ], AR_shp_Q13[AR_shp_Q13_offset+11] ); - - for( j = 12; j < shapingLPCOrder; j ++ ) { - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-j ], AR_shp_Q13[ AR_shp_Q13_offset+j ] ); - } - n_AR_Q10 = ( n_AR_Q10 >> 1 ); /* Q11 -> Q10 */ - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, NSQ.sLF_AR_shp_Q12, Tilt_Q14 ); - - n_LF_Q10 = ( Silk_macros.SKP_SMULWB( NSQ.sLTP_shp_Q10[ NSQ.sLTP_shp_buf_idx - 1 ], LF_shp_Q14 ) << 2 ); - n_LF_Q10 = Silk_macros.SKP_SMLAWT( n_LF_Q10, NSQ.sLF_AR_shp_Q12, LF_shp_Q14 ); - - assert( lag > 0 || sigtype == Silk_define.SIG_TYPE_UNVOICED ); - - /* Long-term shaping */ - if( lag > 0 ) { - /* Symmetric, packed FIR coefficients */ - n_LTP_Q14 = Silk_macros.SKP_SMULWB((shp_lag_ptr[ shp_lag_ptr_offset+0 ] + shp_lag_ptr[ shp_lag_ptr_offset-2 ] ), - HarmShapeFIRPacked_Q14 ); - n_LTP_Q14 = Silk_macros.SKP_SMLAWT(n_LTP_Q14, shp_lag_ptr[ shp_lag_ptr_offset-1 ],HarmShapeFIRPacked_Q14 ); - shp_lag_ptr_offset++; - n_LTP_Q14 = ( n_LTP_Q14 << 6 ); - } else { - n_LTP_Q14 = 0; - } - - /* Input minus prediction plus noise feedback */ - //r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP; - tmp = ( LTP_pred_Q14 - n_LTP_Q14 ); /* Add Q14 stuff */ - tmp = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( tmp, 4 ); /* round to Q10 */ - tmp = ( tmp + LPC_pred_Q10 ); /* add Q10 stuff */ - tmp = ( tmp - n_AR_Q10 ); /* subtract Q10 stuff */ - tmp = ( tmp - n_LF_Q10 ); /* subtract Q10 stuff */ - r_Q10 = ( x_sc_Q10[ i ] - tmp ); - - /* Flip sign depending on dither */ - r_Q10 = ( r_Q10 ^ dither ) - dither; - r_Q10 = ( r_Q10 - offset_Q10 ); - r_Q10 = Silk_SigProc_FIX.SKP_LIMIT_32( r_Q10, -64 << 10, 64 << 10 ); - - /* Quantize */ - if( r_Q10 < thr1_Q10 ) { - q_Q0 = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( ( r_Q10 + (Lambda_Q10 >> 1) ), 10 ); - q_Q10 = ( q_Q0 << 10 ); - } else if( r_Q10 < thr2_Q10 ) { - q_Q0 = -1; - q_Q10 = -1024; - } else if( r_Q10 > thr3_Q10 ) { - q_Q0 = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( ( r_Q10 - (Lambda_Q10 >> 1) ), 10 ); - q_Q10 = ( q_Q0 << 10 ); - } else { - q_Q0 = 0; - q_Q10 = 0; - } - q[ q_offset + i ] = ( byte)q_Q0; /* No saturation needed because max is 64 */ - - /* Excitation */ - exc_Q10 = ( q_Q10 + offset_Q10 ); - exc_Q10 = ( exc_Q10 ^ dither ) - dither; - - /* Add predictions */ - LPC_exc_Q10 = ( exc_Q10 + Silk_SigProc_FIX.SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 ) ); - xq_Q10 = ( LPC_exc_Q10 + LPC_pred_Q10 ); - - /* Scale XQ back to normal level before saving */ - xq[ xq_offset + i ] = ( short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( Silk_macros.SKP_SMULWW( xq_Q10, Gain_Q16 ), 10 ) ); - - - /* Update states */ - psLPC_Q14_offset++; - psLPC_Q14[psLPC_Q14_offset] = ( xq_Q10 << 4 ); - sLF_AR_shp_Q10 = ( xq_Q10 - n_AR_Q10 ); - NSQ.sLF_AR_shp_Q12 = ( sLF_AR_shp_Q10 << 2 ); - - NSQ.sLTP_shp_Q10[ NSQ.sLTP_shp_buf_idx ] = ( sLF_AR_shp_Q10 - n_LF_Q10 ); - sLTP_Q16[ NSQ.sLTP_buf_idx ] = ( LPC_exc_Q10 << 6 ); - NSQ.sLTP_shp_buf_idx++; - NSQ.sLTP_buf_idx++; - - /* Make dither dependent on quantized signal */ - NSQ.rand_seed += q[ q_offset + i ]; - } - /* Update LPC synth buffer */ - System.arraycopy(NSQ.sLPC_Q14, length, NSQ.sLPC_Q14, 0, Silk_define.MAX_LPC_ORDER); - } - - /** - * - * @param NSQ NSQ state - * @param x input in Q0 - * @param x_offset - * @param x_sc_Q10 input scaled with 1/Gain - * @param length length of input - * @param sLTP re-whitened LTP state in Q0 - * @param sLTP_Q16 LTP state matching scaled input - * @param subfr subframe number - * @param LTP_scale_Q14 - * @param Gains_Q16 - * @param pitchL - */ - static void SKP_Silk_nsq_scale_states( - SKP_Silk_nsq_state NSQ, /* I/O NSQ state */ - final short x[], /* I input in Q0 */ - int x_offset, - int x_sc_Q10[], /* O input scaled with 1/Gain */ - int length, /* I length of input */ - short sLTP[], /* I re-whitened LTP state in Q0 */ - int sLTP_Q16[], /* O LTP state matching scaled input */ - int subfr, /* I subframe number */ - final int LTP_scale_Q14, /* I */ - final int Gains_Q16[], /* I */ - final int pitchL[] /* I */ - ) - { - int i, scale_length, lag; - int inv_gain_Q16, gain_adj_Q16, inv_gain_Q32; - - inv_gain_Q16 = ( Integer.MAX_VALUE / ( Gains_Q16[ subfr ] >> 1) ); - inv_gain_Q16 = ( inv_gain_Q16 < Short.MAX_VALUE ? inv_gain_Q16:Short.MAX_VALUE ); - lag = pitchL[ subfr ]; - - /* After rewhitening the LTP state is un-scaled */ - if( NSQ.rewhite_flag !=0 ) { - inv_gain_Q32 = ( inv_gain_Q16 << 16 ); - if( subfr == 0 ) { - /* Do LTP downscaling */ - inv_gain_Q32 = ( Silk_macros.SKP_SMULWB( inv_gain_Q32, LTP_scale_Q14 ) << 2 ); - } - for( i = NSQ.sLTP_buf_idx - lag - Silk_define.LTP_ORDER / 2; i < NSQ.sLTP_buf_idx; i++ ) { - sLTP_Q16[ i ] = Silk_macros.SKP_SMULWB( inv_gain_Q32, sLTP[ i ] ); - } - } - - /* Prepare for Worst case. Next frame starts with max lag voiced */ - scale_length = length * Silk_define.NB_SUBFR; /* approx max lag */ - scale_length = scale_length - Silk_macros.SKP_SMULBB( Silk_define.NB_SUBFR - (subfr + 1), length ); /* subtract samples that will be too old in next frame */ - scale_length = Silk_SigProc_FIX.SKP_max_int( scale_length, lag + Silk_define.LTP_ORDER ); /* make sure to scale whole pitch period if voiced */ - - /* Adjust for changing gain */ - if( inv_gain_Q16 != NSQ.prev_inv_gain_Q16 ) { - gain_adj_Q16 = Silk_Inlines.SKP_DIV32_varQ( inv_gain_Q16, NSQ.prev_inv_gain_Q16, 16 ); - - for( i = NSQ.sLTP_shp_buf_idx - scale_length; i < NSQ.sLTP_shp_buf_idx; i++ ) { - NSQ.sLTP_shp_Q10[ i ] = Silk_macros.SKP_SMULWW( gain_adj_Q16, NSQ.sLTP_shp_Q10[ i ] ); - } - - /* Scale LTP predict state */ - if( NSQ.rewhite_flag == 0 ) { - for( i = NSQ.sLTP_buf_idx - lag - Silk_define.LTP_ORDER / 2; i < NSQ.sLTP_buf_idx; i++ ) { - sLTP_Q16[ i ] = Silk_macros.SKP_SMULWW( gain_adj_Q16, sLTP_Q16[ i ] ); - } - } - NSQ.sLF_AR_shp_Q12 = Silk_macros.SKP_SMULWW( gain_adj_Q16, NSQ.sLF_AR_shp_Q12 ); - - /* scale short term state */ - for( i = 0; i < Silk_define.MAX_LPC_ORDER; i++ ) { - NSQ.sLPC_Q14[ i ] = Silk_macros.SKP_SMULWW( gain_adj_Q16, NSQ.sLPC_Q14[ i ] ); - } - } - - /* Scale input */ - for( i = 0; i < length; i++ ) { - x_sc_Q10[ i ] = ( Silk_macros.SKP_SMULBB( x[ x_offset + i ], ( short )inv_gain_Q16 ) >> 6 ); - } - - /* save inv_gain */ - assert( inv_gain_Q16 != 0 ); - NSQ.prev_inv_gain_Q16 = inv_gain_Q16; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NSQ_del_dec.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NSQ_del_dec.java deleted file mode 100644 index 4a6c50956..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_NSQ_del_dec.java +++ /dev/null @@ -1,796 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * - * @author Dingxin Xu - */ -class NSQ_del_dec_struct -{ - int RandState[] = new int[ Silk_define.DECISION_DELAY ]; - int Q_Q10[] = new int[ Silk_define.DECISION_DELAY ]; - int Xq_Q10[] = new int[ Silk_define.DECISION_DELAY ]; - int Pred_Q16[] = new int[ Silk_define.DECISION_DELAY ]; - int Shape_Q10[] = new int[ Silk_define.DECISION_DELAY ]; - int Gain_Q16[] = new int[ Silk_define.DECISION_DELAY ]; - int sLPC_Q14[] = new int[ Silk_define.MAX_FRAME_LENGTH / Silk_define.NB_SUBFR + Silk_define.NSQ_LPC_BUF_LENGTH() ]; - int LF_AR_Q12; - int Seed; - int SeedInit; - int RD_Q10; - public void FieldsInit() - { - Arrays.fill(this.RandState, 0); - Arrays.fill(this.Q_Q10, 0); - Arrays.fill(this.Xq_Q10, 0); - Arrays.fill(this.Pred_Q16, 0); - Arrays.fill(this.Shape_Q10, 0); - Arrays.fill(this.Gain_Q16, 0); - Arrays.fill(this.sLPC_Q14, 0); - this.LF_AR_Q12 = 0; - this.Seed = 0; - this.SeedInit = 0; - this.RD_Q10 = 0; - } -} - -/** - * - * @author Dingxin Xu - */ -class NSQ_sample_struct implements Cloneable -{ - int Q_Q10; - int RD_Q10; - int xq_Q14; - int LF_AR_Q12; - int sLTP_shp_Q10; - int LPC_exc_Q16; - public Object clone() - { - NSQ_sample_struct clone = null; - try { - clone = (NSQ_sample_struct) super.clone(); - } catch (CloneNotSupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return clone; - } -} - -/** - * - * @author Dingxin Xu - */ -public class Silk_NSQ_del_dec -{ - static void SKP_Silk_NSQ_del_dec( - SKP_Silk_encoder_state psEncC, /* I/O Encoder State */ - SKP_Silk_encoder_control psEncCtrlC, /* I Encoder Control */ - SKP_Silk_nsq_state NSQ, /* I/O NSQ state */ - short x[], /* I Prefiltered input signal */ - byte q[], /* O Quantized pulse signal */ - int LSFInterpFactor_Q2, /* I LSF interpolation factor in Q2 */ - short PredCoef_Q12[], /* I Prediction coefs */ - short LTPCoef_Q14[], /* I LT prediction coefs */ - short AR2_Q13[], /* I */ - int HarmShapeGain_Q14[],/* I */ - int Tilt_Q14[], /* I Spectral tilt */ - int LF_shp_Q14[], /* I */ - int Gains_Q16[], /* I */ - int Lambda_Q10, /* I */ - int LTP_scale_Q14 /* I LTP state scaling */ - ) - { - int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr; - int last_smple_idx, smpl_buf_idx, decisionDelay, subfr_length; - short[] A_Q12; - short[] B_Q14; - short[] AR_shp_Q13; - int A_Q12_offset, B_Q14_offset, AR_shp_Q13_offset; - short[] pxq; - int pxq_offset; - int sLTP_Q16[] = new int[ 2 * Silk_define.MAX_FRAME_LENGTH ]; - short sLTP[] = new short[ 2 * Silk_define.MAX_FRAME_LENGTH ]; - int HarmShapeFIRPacked_Q14; - int offset_Q10; - int FiltState[] = new int[ Silk_define.MAX_LPC_ORDER ], RDmin_Q10; - int x_sc_Q10[] = new int[ Silk_define.MAX_FRAME_LENGTH / Silk_define.NB_SUBFR ]; - NSQ_del_dec_struct psDelDec[] = new NSQ_del_dec_struct[ Silk_define.DEL_DEC_STATES_MAX ]; - /* - * psDelDec is an array of references, which has to be created manually. - */ - { - for(int psDelDecIni_i=0; psDelDecIni_i> 1 ) | ( 1 - LSF_interpolation_flag ) ) * Silk_define.MAX_LPC_ORDER ; - B_Q14 = LTPCoef_Q14; - B_Q14_offset = k * Silk_define.LTP_ORDER; - AR_shp_Q13 = AR2_Q13; - AR_shp_Q13_offset = k * Silk_define.SHAPE_LPC_ORDER_MAX; - - NSQ.rewhite_flag = 0; - if( psEncCtrlC.sigtype == Silk_define.SIG_TYPE_VOICED ) { - /* Voiced */ - lag = psEncCtrlC.pitchL[ k ]; - - /* Re-whitening */ - if( ( k & ( 3 - ( LSF_interpolation_flag << 1 ) ) ) == 0 ) { - if( k == 2 ) { - /* RESET DELAYED DECISIONS */ - /* Find winner */ - RDmin_Q10 = psDelDec[ 0 ].RD_Q10; - Winner_ind = 0; - for( i = 1; i < psEncC.nStatesDelayedDecision; i++ ) { - if( psDelDec[ i ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psDelDec[ i ].RD_Q10; - Winner_ind = i; - } - } - for( i = 0; i < psEncC.nStatesDelayedDecision; i++ ) { - if( i != Winner_ind ) { - psDelDec[ i ].RD_Q10 += ( Integer.MAX_VALUE >> 4 ); - assert( psDelDec[ i ].RD_Q10 >= 0 ); - } - } - - /* Copy final part of signals from winner state to output and long-term filter states */ - psDD = psDelDec[ Winner_ind ]; - last_smple_idx = smpl_buf_idx + decisionDelay; - for( i = 0; i < decisionDelay; i++ ) { - last_smple_idx = ( last_smple_idx - 1 ) & Silk_define.DECISION_DELAY_MASK; -// q[ i - decisionDelay ] = ( SKP_int )SKP_RSHIFT( psDD.Q_Q10[ last_smple_idx ], 10 ); - q_tmp[ q_tmp_offset + i - decisionDelay ] = (byte) ( psDD.Q_Q10[ last_smple_idx ] >> 10 ); - -// pxq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( -// SKP_SMULWW( psDD.Xq_Q10[ last_smple_idx ], -// psDD.Gain_Q16[ last_smple_idx ] ), 10 ) ); - pxq[ pxq_offset + i - decisionDelay ] = (short) Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( - Silk_macros.SKP_SMULWW( psDD.Xq_Q10[ last_smple_idx ], - psDD.Gain_Q16[ last_smple_idx ] ), 10 ) ); - NSQ.sLTP_shp_Q10[ NSQ.sLTP_shp_buf_idx - decisionDelay + i ] = psDD.Shape_Q10[ last_smple_idx ]; - } - - subfr = 0; - } - - /* Rewhiten with new A coefs */ - start_idx = psEncC.frame_length - lag - psEncC.predictLPCOrder - Silk_define.LTP_ORDER / 2; - start_idx = Silk_SigProc_FIX.SKP_LIMIT_int( start_idx, 0, psEncC.frame_length - psEncC.predictLPCOrder ); - -// SKP_memset( FiltState, 0, psEncC.predictLPCOrder * sizeof( SKP_int32 ) ); - Arrays.fill(FiltState, 0, psEncC.predictLPCOrder, 0); - Silk_MA.SKP_Silk_MA_Prediction( NSQ.xq, start_idx + k * psEncC.subfr_length, - A_Q12, A_Q12_offset, FiltState, sLTP, start_idx, psEncC.frame_length - start_idx, psEncC.predictLPCOrder ); - - NSQ.sLTP_buf_idx = psEncC.frame_length; - NSQ.rewhite_flag = 1; - } - } - - /* Noise shape parameters */ - assert( HarmShapeGain_Q14[ k ] >= 0 ); - HarmShapeFIRPacked_Q14 = ( HarmShapeGain_Q14[ k ] >> 2 ); - HarmShapeFIRPacked_Q14 |= ( ( HarmShapeGain_Q14[ k ] >> 1 ) << 16 ); - - SKP_Silk_nsq_del_dec_scale_states( NSQ, psDelDec, x_tmp, x_tmp_offset, x_sc_Q10, - subfr_length, sLTP, sLTP_Q16, k, psEncC.nStatesDelayedDecision, smpl_buf_idx, - LTP_scale_Q14, Gains_Q16, psEncCtrlC.pitchL ); - - int smpl_buf_idx_ptr[] = new int[1]; - smpl_buf_idx_ptr[0] = smpl_buf_idx; - SKP_Silk_noise_shape_quantizer_del_dec( NSQ, psDelDec, psEncCtrlC.sigtype, x_sc_Q10, q_tmp, q_tmp_offset, pxq, pxq_offset, - sLTP_Q16, A_Q12, A_Q12_offset, B_Q14, B_Q14_offset, AR_shp_Q13, AR_shp_Q13_offset, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], - LF_shp_Q14[ k ], Gains_Q16[ k ], Lambda_Q10, offset_Q10, psEncC.subfr_length, subfr++, psEncC.shapingLPCOrder, psEncC.predictLPCOrder, - psEncC.nStatesDelayedDecision, smpl_buf_idx_ptr, decisionDelay ); - smpl_buf_idx = smpl_buf_idx_ptr[0]; - - x_tmp_offset += psEncC.subfr_length; - q_tmp_offset += psEncC.subfr_length; - pxq_offset += psEncC.subfr_length; - } - - /* Find winner */ - RDmin_Q10 = psDelDec[ 0 ].RD_Q10; - Winner_ind = 0; - for( k = 1; k < psEncC.nStatesDelayedDecision; k++ ) { - if( psDelDec[ k ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psDelDec[ k ].RD_Q10; - Winner_ind = k; - } - } - - /* Copy final part of signals from winner state to output and long-term filter states */ - psDD = psDelDec[ Winner_ind ]; - psEncCtrlC.Seed = psDD.SeedInit; - last_smple_idx = smpl_buf_idx + decisionDelay; - for( i = 0; i < decisionDelay; i++ ) { - last_smple_idx = ( last_smple_idx - 1 ) & Silk_define.DECISION_DELAY_MASK; - q_tmp[q_tmp_offset + i - decisionDelay] = ( byte )( psDD.Q_Q10[ last_smple_idx ] >> 10 ); - pxq[ pxq_offset + i - decisionDelay ] = ( short )Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( - Silk_macros.SKP_SMULWW( psDD.Xq_Q10[ last_smple_idx ], psDD.Gain_Q16[ last_smple_idx ] ), 10 ) ); - NSQ.sLTP_shp_Q10[ NSQ.sLTP_shp_buf_idx - decisionDelay + i ] = psDD.Shape_Q10[ last_smple_idx ]; - sLTP_Q16[ NSQ.sLTP_buf_idx - decisionDelay + i ] = psDD.Pred_Q16[ last_smple_idx ]; - - } -// SKP_memcpy( NSQ.sLPC_Q14, &psDD.sLPC_Q14[ psEncC.subfr_length ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) ); - System.arraycopy(psDD.sLPC_Q14, psEncC.subfr_length, NSQ.sLPC_Q14, 0, Silk_define.NSQ_LPC_BUF_LENGTH()); - - /* Update states */ - NSQ.sLF_AR_shp_Q12 = psDD.LF_AR_Q12; - NSQ.prev_inv_gain_Q16 = NSQ.prev_inv_gain_Q16; - NSQ.lagPrev = psEncCtrlC.pitchL[ Silk_define.NB_SUBFR - 1 ]; - - /* Save quantized speech and noise shaping signals */ -// SKP_memcpy( NSQ.xq, &NSQ.xq[ psEncC.frame_length ], psEncC.frame_length * sizeof( SKP_int16 ) ); -// SKP_memcpy( NSQ.sLTP_shp_Q10, &NSQ.sLTP_shp_Q10[ psEncC.frame_length ], psEncC.frame_length * sizeof( SKP_int32 ) ); - System.arraycopy(NSQ.xq, psEncC.frame_length, NSQ.xq, 0, psEncC.frame_length); - System.arraycopy(NSQ.sLTP_shp_Q10, psEncC.frame_length, NSQ.sLTP_shp_Q10, 0, psEncC.frame_length); -//TODO: copy back the q_tmp to the output parameter q; - System.arraycopy(q_tmp, 0, q, 0, q.length); - } - - /** - * Noise shape quantizer for one subframe. - * @param NSQ NSQ state - * @param psDelDec Delayed decision states - * @param sigtype Signal type - * @param x_Q10 - * @param q - * @param q_offset - * @param xq - * @param xq_offset - * @param sLTP_Q16 LTP filter state - * @param a_Q12 Short term prediction coefs - * @param a_Q12_offset - * @param b_Q14 Long term prediction coefs - * @param b_Q14_offset - * @param AR_shp_Q13 Noise shaping coefs - * @param AR_shp_Q13_offset - * @param lag Pitch lag - * @param HarmShapeFIRPacked_Q14 - * @param Tilt_Q14 Spectral tilt - * @param LF_shp_Q14 - * @param Gain_Q16 - * @param Lambda_Q10 - * @param offset_Q10 - * @param length Input length - * @param subfr Subframe number - * @param shapingLPCOrder Shaping LPC filter order - * @param predictLPCOrder Prediction LPC filter order - * @param nStatesDelayedDecision Number of states in decision tree - * @param smpl_buf_idx Index to newest samples in buffers - * @param decisionDelay - */ - static void SKP_Silk_noise_shape_quantizer_del_dec( - SKP_Silk_nsq_state NSQ, /* I/O NSQ state */ - NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - int sigtype, /* I Signal type */ - final int x_Q10[], /* I */ - byte q[], /* O */ - int q_offset, - short xq[], /* O */ - int xq_offset, - int sLTP_Q16[], /* I/O LTP filter state */ - final short a_Q12[], /* I Short term prediction coefs */ - int a_Q12_offset, - final short b_Q14[], /* I Long term prediction coefs */ - int b_Q14_offset, - final short AR_shp_Q13[], /* I Noise shaping coefs */ - int AR_shp_Q13_offset, - int lag, /* I Pitch lag */ - int HarmShapeFIRPacked_Q14, /* I */ - int Tilt_Q14, /* I Spectral tilt */ - int LF_shp_Q14, /* I */ - int Gain_Q16, /* I */ - int Lambda_Q10, /* I */ - int offset_Q10, /* I */ - int length, /* I Input length */ - int subfr, /* I Subframe number */ - int shapingLPCOrder, /* I Shaping LPC filter order */ - int predictLPCOrder, /* I Prediction LPC filter order */ - int nStatesDelayedDecision, /* I Number of states in decision tree */ - int []smpl_buf_idx, /* I Index to newest samples in buffers */ - int decisionDelay /* I */ - ) - { - int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx; - int Winner_rand_state; - int LTP_pred_Q14, LPC_pred_Q10, n_AR_Q10, n_LTP_Q14; - int n_LF_Q10; - int r_Q10, rr_Q20, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10; - int q1_Q10, q2_Q10; - int dither; - int exc_Q10, LPC_exc_Q10, xq_Q10; - int tmp, sLF_AR_shp_Q10; - int pred_lag_ptr[], shp_lag_ptr[]; - int pred_lag_ptr_offset, shp_lag_ptr_offset; - int []psLPC_Q14; int psLPC_Q14_offset; - NSQ_sample_struct psSampleState[][] = new NSQ_sample_struct[ Silk_define.DEL_DEC_STATES_MAX ][ 2 ]; - /* - * psSampleState is an two-dimension array of reference, which should be created manually. - */ - { - for(int Ini_i=0; Ini_i 0 ) { - /* Symmetric, packed FIR coefficients */ - n_LTP_Q14 = Silk_macros.SKP_SMULWB( ( shp_lag_ptr[ shp_lag_ptr_offset+0 ] + shp_lag_ptr[ shp_lag_ptr_offset-2 ] ), HarmShapeFIRPacked_Q14 ); - n_LTP_Q14 = Silk_macros.SKP_SMLAWT( n_LTP_Q14, shp_lag_ptr[ shp_lag_ptr_offset-1 ], HarmShapeFIRPacked_Q14 ); -// n_LTP_Q14 = SKP_LSHIFT( n_LTP_Q14, 6 ); - n_LTP_Q14 = ( n_LTP_Q14 << 6 ); - shp_lag_ptr_offset++; - } else { - n_LTP_Q14 = 0; - } - - for( k = 0; k < nStatesDelayedDecision; k++ ) { - /* Delayed decision state */ - psDD = psDelDec[ k ]; - - /* Sample state */ - psSS = psSampleState[ k ]; - - /* Generate dither */ - psDD.Seed = Silk_SigProc_FIX.SKP_RAND( psDD.Seed ); - - /* dither = rand_seed < 0 ? 0xFFFFFFFF : 0; */ -// dither = SKP_RSHIFT( psDD.Seed, 31 ); - dither = ( psDD.Seed >> 31 ); - - /* Pointer used in short term prediction and shaping */ - psLPC_Q14 = psDD.sLPC_Q14; - psLPC_Q14_offset = Silk_define.NSQ_LPC_BUF_LENGTH() - 1 + i; - /* Short-term prediction */ - assert( predictLPCOrder >= 10 ); /* check that unrolling works */ - assert( ( predictLPCOrder & 1 ) == 0 ); /* check that order is even */ -// SKP_assert( ( (SKP_int64)a_Q12 & 3 ) == 0 ); /* check that array starts at 4-byte aligned address */ - /* Partially unrolled */ - LPC_pred_Q10 = Silk_macros.SKP_SMULWB( psLPC_Q14[ psLPC_Q14_offset+0 ], a_Q12[ a_Q12_offset+0 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-1 ], a_Q12[ a_Q12_offset+1 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-2 ], a_Q12[ a_Q12_offset+2 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-3 ], a_Q12[ a_Q12_offset+3 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-4 ], a_Q12[ a_Q12_offset+4 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-5 ], a_Q12[ a_Q12_offset+5 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-6 ], a_Q12[ a_Q12_offset+6 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-7 ], a_Q12[ a_Q12_offset+7 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-8 ], a_Q12[ a_Q12_offset+8 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-9 ], a_Q12[ a_Q12_offset+9 ] ); - - for( j = 10; j < predictLPCOrder; j ++ ) { - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ psLPC_Q14_offset-j ], a_Q12[ a_Q12_offset+j]); - } - - /* Noise shape feedback */ - assert( ( shapingLPCOrder & 1 ) == 0 ); /* check that order is even */ -// assert( ( (SKP_int64)AR_shp_Q13 & 3 ) == 0 ); /* check that array starts at 4-byte aligned address */ - assert( shapingLPCOrder >= 12 ); /* check that unrolling works */ - /* Partially unrolled */ - n_AR_Q10 = Silk_macros.SKP_SMULWB( psLPC_Q14[ psLPC_Q14_offset+0 ], AR_shp_Q13[ AR_shp_Q13_offset+0 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-1 ], AR_shp_Q13[ AR_shp_Q13_offset+1 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-2 ], AR_shp_Q13[ AR_shp_Q13_offset+2 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-3 ], AR_shp_Q13[ AR_shp_Q13_offset+3 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-4 ], AR_shp_Q13[ AR_shp_Q13_offset+4 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-5 ], AR_shp_Q13[ AR_shp_Q13_offset+5 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-6 ], AR_shp_Q13[ AR_shp_Q13_offset+6 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-7 ], AR_shp_Q13[ AR_shp_Q13_offset+7 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-8 ], AR_shp_Q13[ AR_shp_Q13_offset+8 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-9 ], AR_shp_Q13[ AR_shp_Q13_offset+9 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-10 ],AR_shp_Q13[ AR_shp_Q13_offset+10 ] ); - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-11 ],AR_shp_Q13[ AR_shp_Q13_offset+11 ] ); - - for( j = 12; j < shapingLPCOrder; j ++ ) { - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ psLPC_Q14_offset-j ], AR_shp_Q13[ AR_shp_Q13_offset+j ] ); - } - -// n_AR_Q10 = SKP_RSHIFT( n_AR_Q10, 1 ); /* Q11 -> Q10 */ - n_AR_Q10 = ( n_AR_Q10 >> 1 ); /* Q11 -> Q10 */ - n_AR_Q10 = Silk_macros.SKP_SMLAWB( n_AR_Q10, psDD.LF_AR_Q12, Tilt_Q14 ); - - n_LF_Q10 = ( Silk_macros.SKP_SMULWB( psDD.Shape_Q10[ smpl_buf_idx[0] ], LF_shp_Q14 ) << 2 ); - n_LF_Q10 = Silk_macros.SKP_SMLAWT( n_LF_Q10, psDD.LF_AR_Q12, LF_shp_Q14 ); - - /* Input minus prediction plus noise feedback */ - /* r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP */ - tmp = ( LTP_pred_Q14 - n_LTP_Q14 ); /* Add Q14 stuff */ - tmp = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( tmp, 4 ); /* round to Q10 */ - tmp = ( tmp + LPC_pred_Q10 ); /* add Q10 stuff */ - tmp = ( tmp - n_AR_Q10 ); /* subtract Q10 stuff */ - tmp = ( tmp - n_LF_Q10 ); /* subtract Q10 stuff */ - r_Q10 = ( x_Q10[ i ] - tmp ); /* residual error Q10 */ - - /* Flip sign depending on dither */ - r_Q10 = ( r_Q10 ^ dither ) - dither; - r_Q10 = ( r_Q10 - offset_Q10 ); - r_Q10 = Silk_SigProc_FIX.SKP_LIMIT_32( r_Q10, -64 << 10, 64 << 10 ); - - /* Find two quantization level candidates and measure their rate-distortion */ - if( r_Q10 < -1536 ) { - q1_Q10 = ( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( r_Q10, 10 ) << 10 ); - r_Q10 = ( r_Q10 - q1_Q10 ); - rd1_Q10 = ( Silk_macros.SKP_SMLABB( ( -( q1_Q10 + offset_Q10 ) * Lambda_Q10 ), r_Q10, r_Q10 ) >> 10 ); - rd2_Q10 = ( rd1_Q10 + 1024 ); - rd2_Q10 = ( rd2_Q10 - Silk_SigProc_FIX.SKP_ADD_LSHIFT32( Lambda_Q10, r_Q10, 1 ) ); - q2_Q10 = ( q1_Q10 + 1024 ); - } else if( r_Q10 > 512 ) { - q1_Q10 = ( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( r_Q10, 10 ) << 10 ); - r_Q10 = ( r_Q10 - q1_Q10 ); - rd1_Q10 = ( Silk_macros.SKP_SMLABB( ( ( q1_Q10 + offset_Q10 ) * Lambda_Q10 ), r_Q10, r_Q10 ) >> 10 ); - rd2_Q10 = ( rd1_Q10 + 1024 ); - rd2_Q10 = ( rd2_Q10 - Silk_SigProc_FIX.SKP_SUB_LSHIFT32( Lambda_Q10, r_Q10, 1 ) ); - q2_Q10 = ( q1_Q10 - 1024 ); - } else { /* r_Q10 >= -1536 && q1_Q10 <= 512 */ - rr_Q20 = Silk_macros.SKP_SMULBB( offset_Q10, Lambda_Q10 ); - rd2_Q10 = ( Silk_macros.SKP_SMLABB( rr_Q20, r_Q10, r_Q10 ) >> 10 ); - rd1_Q10 = ( rd2_Q10 + 1024 ); - rd1_Q10 = ( rd1_Q10 + Silk_SigProc_FIX.SKP_SUB_RSHIFT32( Silk_SigProc_FIX.SKP_ADD_LSHIFT32( Lambda_Q10, r_Q10, 1 ), rr_Q20, 9 ) ); - q1_Q10 = -1024; - q2_Q10 = 0; - } - - if( rd1_Q10 < rd2_Q10 ) { - psSS[ 0 ].RD_Q10 = ( psDD.RD_Q10 + rd1_Q10 ); - psSS[ 1 ].RD_Q10 = ( psDD.RD_Q10 + rd2_Q10 ); - psSS[ 0 ].Q_Q10 = q1_Q10; - psSS[ 1 ].Q_Q10 = q2_Q10; - } else { - psSS[ 0 ].RD_Q10 = ( psDD.RD_Q10 + rd2_Q10 ); - psSS[ 1 ].RD_Q10 = ( psDD.RD_Q10 + rd1_Q10 ); - psSS[ 0 ].Q_Q10 = q2_Q10; - psSS[ 1 ].Q_Q10 = q1_Q10; - } - - /* Update states for best quantization */ - - /* Quantized excitation */ - exc_Q10 = ( offset_Q10 + psSS[ 0 ].Q_Q10 ); - exc_Q10 = ( exc_Q10 ^ dither ) - dither; - - /* Add predictions */ - LPC_exc_Q10 = exc_Q10 + Silk_SigProc_FIX.SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 ); - xq_Q10 = ( LPC_exc_Q10 + LPC_pred_Q10 ); - - /* Update states */ - sLF_AR_shp_Q10 = ( xq_Q10 - n_AR_Q10 ); - psSS[ 0 ].sLTP_shp_Q10 = ( sLF_AR_shp_Q10 - n_LF_Q10 ); - psSS[ 0 ].LF_AR_Q12 = ( sLF_AR_shp_Q10 << 2 ); - psSS[ 0 ].xq_Q14 = ( xq_Q10 << 4 ); - psSS[ 0 ].LPC_exc_Q16 = ( LPC_exc_Q10 << 6 ); - - /* Update states for second best quantization */ - - /* Quantized excitation */ - exc_Q10 = ( offset_Q10 + psSS[ 1 ].Q_Q10 ); - exc_Q10 = ( exc_Q10 ^ dither ) - dither; - - /* Add predictions */ - LPC_exc_Q10 = exc_Q10 + Silk_SigProc_FIX.SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 ); - xq_Q10 = ( LPC_exc_Q10 + LPC_pred_Q10 ); - - /* Update states */ - sLF_AR_shp_Q10 = ( xq_Q10 - n_AR_Q10 ); - psSS[ 1 ].sLTP_shp_Q10 = ( sLF_AR_shp_Q10 - n_LF_Q10 ); - psSS[ 1 ].LF_AR_Q12 = ( sLF_AR_shp_Q10 << 2 ); - psSS[ 1 ].xq_Q14 = ( xq_Q10 << 4 ); - psSS[ 1 ].LPC_exc_Q16 = ( LPC_exc_Q10 << 6 ); - } - - smpl_buf_idx[0] = ( smpl_buf_idx[0] - 1 ) & Silk_define.DECISION_DELAY_MASK; /* Index to newest samples */ - last_smple_idx = ( smpl_buf_idx[0] + decisionDelay ) & Silk_define.DECISION_DELAY_MASK; /* Index to decisionDelay old samples */ - - /* Find winner */ - RDmin_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; - Winner_ind = 0; - for( k = 1; k < nStatesDelayedDecision; k++ ) { - if( psSampleState[ k ][ 0 ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psSampleState[ k ][ 0 ].RD_Q10; - Winner_ind = k; - } - } - - /* Increase RD values of expired states */ - Winner_rand_state = psDelDec[ Winner_ind ].RandState[ last_smple_idx ]; - for( k = 0; k < nStatesDelayedDecision; k++ ) { - if( psDelDec[ k ].RandState[ last_smple_idx ] != Winner_rand_state ) { - psSampleState[ k ][ 0 ].RD_Q10 = ( psSampleState[ k ][ 0 ].RD_Q10 + ( Integer.MAX_VALUE >> 4 ) ); - psSampleState[ k ][ 1 ].RD_Q10 = ( psSampleState[ k ][ 1 ].RD_Q10 + ( Integer.MAX_VALUE >> 4 ) ); - assert( psSampleState[ k ][ 0 ].RD_Q10 >= 0 ); - } - } - - /* Find worst in first set and best in second set */ - RDmax_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; - RDmin_Q10 = psSampleState[ 0 ][ 1 ].RD_Q10; - RDmax_ind = 0; - RDmin_ind = 0; - for( k = 1; k < nStatesDelayedDecision; k++ ) { - /* find worst in first set */ - if( psSampleState[ k ][ 0 ].RD_Q10 > RDmax_Q10 ) { - RDmax_Q10 = psSampleState[ k ][ 0 ].RD_Q10; - RDmax_ind = k; - } - /* find best in second set */ - if( psSampleState[ k ][ 1 ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psSampleState[ k ][ 1 ].RD_Q10; - RDmin_ind = k; - } - } - - /* Replace a state if best from second set outperforms worst in first set */ - if( RDmin_Q10 < RDmax_Q10 ) { -// SKP_Silk_copy_del_dec_state( &psDelDec[ RDmax_ind ], &psDelDec[ RDmin_ind ], i ); - SKP_Silk_copy_del_dec_state( psDelDec[ RDmax_ind ], psDelDec[ RDmin_ind ], i ); -//TODO:how to copy a struct ??? -// SKP_memcpy( &psSampleState[ RDmax_ind ][ 0 ], &psSampleState[ RDmin_ind ][ 1 ], sizeof( NSQ_sample_struct ) ); - psSampleState[ RDmax_ind ][ 0 ] = (NSQ_sample_struct) psSampleState[ RDmin_ind ][ 1 ].clone(); - } - - /* Write samples from winner to output and long-term filter states */ - psDD = psDelDec[ Winner_ind ]; - if( subfr > 0 || i >= decisionDelay ) { - q[ q_offset + i - decisionDelay ] = ( byte )( psDD.Q_Q10[ last_smple_idx ] >> 10 ); - xq[ xq_offset + i - decisionDelay ] = ( short )Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( - Silk_macros.SKP_SMULWW( psDD.Xq_Q10[ last_smple_idx ], psDD.Gain_Q16[ last_smple_idx ] ), 10 ) ); - NSQ.sLTP_shp_Q10[ NSQ.sLTP_shp_buf_idx - decisionDelay ] = psDD.Shape_Q10[ last_smple_idx ]; - sLTP_Q16[ NSQ.sLTP_buf_idx - decisionDelay ] = psDD.Pred_Q16[ last_smple_idx ]; - } - NSQ.sLTP_shp_buf_idx++; - NSQ.sLTP_buf_idx++; - - /* Update states */ - for( k = 0; k < nStatesDelayedDecision; k++ ) { - psDD = psDelDec[ k ]; -//TODO: psSS is an array of reference rather than a reference. -// psSS = &psSampleState[ k ][ 0 ]; - psSS = psSampleState[ k ]; - psDD.LF_AR_Q12 = psSS[0].LF_AR_Q12; - psDD.sLPC_Q14[ Silk_define.NSQ_LPC_BUF_LENGTH() + i ] = psSS[0].xq_Q14; - psDD.Xq_Q10[ smpl_buf_idx[0] ] = ( psSS[0].xq_Q14 >> 4 ); - psDD.Q_Q10[ smpl_buf_idx[0] ] = psSS[0].Q_Q10; - psDD.Pred_Q16[ smpl_buf_idx[0] ] = psSS[0].LPC_exc_Q16; - psDD.Shape_Q10[ smpl_buf_idx[0] ] = psSS[0].sLTP_shp_Q10; - psDD.Seed = Silk_SigProc_FIX.SKP_ADD_RSHIFT32( psDD.Seed, psSS[0].Q_Q10, 10 ); - psDD.RandState[ smpl_buf_idx[0] ] = psDD.Seed; - psDD.RD_Q10 = psSS[0].RD_Q10; - psDD.Gain_Q16[ smpl_buf_idx[0] ] = Gain_Q16; - } - } - /* Update LPC states */ - for( k = 0; k < nStatesDelayedDecision; k++ ) { - psDD = psDelDec[ k ]; - System.arraycopy(psDD.sLPC_Q14, length, psDD.sLPC_Q14, 0, Silk_define.NSQ_LPC_BUF_LENGTH()); - } - } - - /** - * - * @param NSQ NSQ state - * @param psDelDec Delayed decision states - * @param x Input in Q0 - * @param x_offset offset of valid data. - * @param x_sc_Q10 nput scaled with 1/Gain in Q10 - * @param length Length of input - * @param sLTP Re-whitened LTP state in Q0 - * @param sLTP_Q16 LTP state matching scaled input - * @param subfr Subframe number - * @param nStatesDelayedDecision Number of del dec states - * @param smpl_buf_idx Index to newest samples in buffers - * @param LTP_scale_Q14 LTP state scaling - * @param Gains_Q16 - * @param pitchL Pitch lag - */ - static void SKP_Silk_nsq_del_dec_scale_states( - SKP_Silk_nsq_state NSQ, /* I/O NSQ state */ - NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - final short x[], /* I Input in Q0 */ - int x_offset, - int x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ - int length, /* I Length of input */ - short sLTP[], /* I Re-whitened LTP state in Q0 */ - int sLTP_Q16[], /* O LTP state matching scaled input */ - int subfr, /* I Subframe number */ - int nStatesDelayedDecision, /* I Number of del dec states */ - int smpl_buf_idx, /* I Index to newest samples in buffers */ - final int LTP_scale_Q14, /* I LTP state scaling */ - final int Gains_Q16[], /* I */ - final int pitchL[] /* I Pitch lag */ - ) - { - int i, k, scale_length, lag; - int inv_gain_Q16, gain_adj_Q16, inv_gain_Q32; - NSQ_del_dec_struct psDD; - - inv_gain_Q16 = ( Integer.MAX_VALUE / ( Gains_Q16[ subfr ] >> 1 ) ); - inv_gain_Q16 = ( inv_gain_Q16 < Short.MAX_VALUE ? inv_gain_Q16:Short.MAX_VALUE); - lag = pitchL[ subfr ]; - /* After rewhitening the LTP state is un-scaled. So scale with inv_gain_Q16 */ - if( NSQ.rewhite_flag != 0) { - inv_gain_Q32 = ( inv_gain_Q16 << 16 ); - if( subfr == 0 ) { - /* Do LTP downscaling */ - inv_gain_Q32 = ( Silk_macros.SKP_SMULWB( inv_gain_Q32, LTP_scale_Q14 ) << 2 ); - } - for( i = NSQ.sLTP_buf_idx - lag - Silk_define.LTP_ORDER / 2; i < NSQ.sLTP_buf_idx; i++ ) { - assert( i < Silk_define.MAX_FRAME_LENGTH ); - sLTP_Q16[ i ] = Silk_macros.SKP_SMULWB( inv_gain_Q32, sLTP[ i ] ); - } - } - - /* Adjust for changing gain */ - if( inv_gain_Q16 != NSQ.prev_inv_gain_Q16 ) { - gain_adj_Q16 = Silk_Inlines.SKP_DIV32_varQ( inv_gain_Q16, NSQ.prev_inv_gain_Q16, 16 ); - - for( k = 0; k < nStatesDelayedDecision; k++ ) { - psDD = psDelDec[ k ]; - - /* Scale scalar states */ - psDD.LF_AR_Q12 = Silk_macros.SKP_SMULWW( gain_adj_Q16, psDD.LF_AR_Q12 ); - - /* scale short term state */ - for( i = 0; i < Silk_define.NSQ_LPC_BUF_LENGTH(); i++ ) { - psDD.sLPC_Q14[ Silk_define.NSQ_LPC_BUF_LENGTH() - i - 1 ] = Silk_macros.SKP_SMULWW( gain_adj_Q16, - psDD.sLPC_Q14[ Silk_define.NSQ_LPC_BUF_LENGTH() - i - 1 ] ); - } - for( i = 0; i < Silk_define.DECISION_DELAY; i++ ) { - psDD.Pred_Q16[ i ] = Silk_macros.SKP_SMULWW( gain_adj_Q16, psDD.Pred_Q16[ i ] ); - psDD.Shape_Q10[ i ] = Silk_macros.SKP_SMULWW( gain_adj_Q16, psDD.Shape_Q10[ i ] ); - } - } - - /* Scale long term shaping state */ - - /* Calculate length to be scaled, Worst case: Next frame is voiced with max lag */ - scale_length = length * Silk_define.NB_SUBFR; /* aprox max lag */ - scale_length = scale_length - Silk_macros.SKP_SMULBB( Silk_define.NB_SUBFR - ( subfr + 1 ), length ); /* subtract samples that will be too old in next frame */ - scale_length = Math.max( scale_length, lag + Silk_define.LTP_ORDER ); /* make sure to scale whole pitch period if voiced */ - - for( i = NSQ.sLTP_shp_buf_idx - scale_length; i < NSQ.sLTP_shp_buf_idx; i++ ) { - NSQ.sLTP_shp_Q10[ i ] = Silk_macros.SKP_SMULWW( gain_adj_Q16, NSQ.sLTP_shp_Q10[ i ] ); - } - - /* Scale LTP predict state */ - if( NSQ.rewhite_flag == 0 ) { - for( i = NSQ.sLTP_buf_idx - lag - Silk_define.LTP_ORDER / 2; i < NSQ.sLTP_buf_idx; i++ ) { - sLTP_Q16[ i ] = Silk_macros.SKP_SMULWW( gain_adj_Q16, sLTP_Q16[ i ] ); - } - } - } - - /* Scale input */ - for( i = 0; i < length; i++ ) { - x_sc_Q10[ i ] = (Silk_macros.SKP_SMULBB( x[ x_offset + i ], ( short )inv_gain_Q16 ) >> 6 ); - } - - /* save inv_gain */ - assert( inv_gain_Q16 != 0 ); - NSQ.prev_inv_gain_Q16 = inv_gain_Q16; - } - - /** - * - * @param DD_dst Dst del dec state - * @param DD_src Src del dec state - * @param LPC_state_idx Index to LPC buffer - */ - static void SKP_Silk_copy_del_dec_state( - NSQ_del_dec_struct DD_dst, /* I Dst del dec state */ - NSQ_del_dec_struct DD_src, /* I Src del dec state */ - int LPC_state_idx /* I Index to LPC buffer */ - ) - { - System.arraycopy(DD_src.RandState, 0, DD_dst.RandState, 0, Silk_define.DECISION_DELAY); - System.arraycopy(DD_src.Q_Q10, 0, DD_dst.Q_Q10, 0, Silk_define.DECISION_DELAY); - System.arraycopy(DD_src.Pred_Q16, 0, DD_dst.Pred_Q16, 0, Silk_define.DECISION_DELAY); - System.arraycopy(DD_src.Shape_Q10, 0, DD_dst.Shape_Q10, 0, Silk_define.DECISION_DELAY); - System.arraycopy(DD_src.Xq_Q10, 0, DD_dst.Xq_Q10, 0, Silk_define.DECISION_DELAY); - - System.arraycopy(DD_src.sLPC_Q14, LPC_state_idx, DD_dst.sLPC_Q14, LPC_state_idx, Silk_define.NSQ_LPC_BUF_LENGTH()); - DD_dst.LF_AR_Q12 = DD_src.LF_AR_Q12; - DD_dst.Seed = DD_src.Seed; - DD_dst.SeedInit = DD_src.SeedInit; - DD_dst.RD_Q10 = DD_src.RD_Q10; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_PLC.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_PLC.java deleted file mode 100644 index 56fdb3d02..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_PLC.java +++ /dev/null @@ -1,473 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * SILK PNG. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_PLC -{ - static final int BWE_COEF_Q16 = 64880; /* 0.99 in Q16 */ - static final int V_PITCH_GAIN_START_MIN_Q14 = 11469; /* 0.7 in Q14 */ - static final int V_PITCH_GAIN_START_MAX_Q14 = 15565; /* 0.95 in Q14 */ - static final int MAX_PITCH_LAG_MS = 18; - static final int SA_THRES_Q8 = 50; - static final boolean USE_SINGLE_TAP = true; - static final int RAND_BUF_SIZE = 128; - static final int RAND_BUF_MASK = (RAND_BUF_SIZE - 1); - static final int LOG2_INV_LPC_GAIN_HIGH_THRES = 3; /* 2^3 = 8 dB LPC gain */ - static final int LOG2_INV_LPC_GAIN_LOW_THRES = 8; /* 2^8 = 24 dB LPC gain */ - static final int PITCH_DRIFT_FAC_Q16 = 655; /* 0.01 in Q16 */ - - static final int NB_ATT = 2; - - static short[] HARM_ATT_Q15 = { 32440, 31130 }; /* 0.99, 0.95 */ - static short[] PLC_RAND_ATTENUATE_V_Q15 = { 31130, 26214 }; /* 0.95, 0.8 */ - static short[] PLC_RAND_ATTENUATE_UV_Q15 = { 32440, 29491 }; /* 0.99, 0.9 */ - - /** - * PLC reset. - * @param psDec Decoder state. - */ - static void SKP_Silk_PLC_Reset( - SKP_Silk_decoder_state psDec /* I/O Decoder state */ - ) - { - psDec.sPLC.pitchL_Q8 = ( psDec.frame_length >> 1 ); - } - - /** - * - * @param psDec Decoder state. - * @param psDecCtrl Decoder control. - * @param signal Concealed signal. - * @param signal_offset offset of the valid data. - * @param length Length of residual. - * @param lost Loss flag. - */ - static void SKP_Silk_PLC( - SKP_Silk_decoder_state psDec, /* I Decoder state */ - SKP_Silk_decoder_control psDecCtrl, /* I Decoder control */ - short signal[], /* O Concealed signal */ - int signal_offset, - int length, /* I length of residual */ - int lost /* I Loss flag */ - ) - { - /* PLC control function */ - if( psDec.fs_kHz != psDec.sPLC.fs_kHz ) { - SKP_Silk_PLC_Reset( psDec ); - psDec.sPLC.fs_kHz = psDec.fs_kHz; - } - - if( lost != 0 ) { - /****************************/ - /* Generate Signal */ - /****************************/ - SKP_Silk_PLC_conceal( psDec, psDecCtrl, signal, signal_offset, length ); - } else { - /****************************/ - /* Update state */ - /****************************/ - SKP_Silk_PLC_update( psDec, psDecCtrl, signal, signal_offset, length ); - } - } - - /** - * Update state of PLC - * @param psDec Decoder state. - * @param psDecCtrl Decoder control. - * @param signal - * @param signal_offset - * @param length - */ - static void SKP_Silk_PLC_update( - SKP_Silk_decoder_state psDec, /* (I/O) Decoder state */ - SKP_Silk_decoder_control psDecCtrl, /* (I/O) Decoder control */ - short signal[], - int signal_offset, - int length - ) - { - int LTP_Gain_Q14, temp_LTP_Gain_Q14; - int i, j; - SKP_Silk_PLC_struct psPLC; - - psPLC = psDec.sPLC; - - /* Update parameters used in case of packet loss */ - psDec.prev_sigtype = psDecCtrl.sigtype; - LTP_Gain_Q14 = 0; - if( psDecCtrl.sigtype == Silk_define.SIG_TYPE_VOICED ) { - /* Find the parameters for the last subframe which contains a pitch pulse */ - for( j = 0; j * psDec.subfr_length < psDecCtrl.pitchL[ Silk_define.NB_SUBFR - 1 ]; j++ ) { - temp_LTP_Gain_Q14 = 0; - for( i = 0; i < Silk_define.LTP_ORDER; i++ ) { - temp_LTP_Gain_Q14 += psDecCtrl.LTPCoef_Q14[ ( Silk_define.NB_SUBFR - 1 - j ) * Silk_define.LTP_ORDER + i ]; - } - if( temp_LTP_Gain_Q14 > LTP_Gain_Q14 ) { - LTP_Gain_Q14 = temp_LTP_Gain_Q14; - System.arraycopy(psDecCtrl.LTPCoef_Q14, Silk_macros.SKP_SMULBB( Silk_define.NB_SUBFR - 1 - j, Silk_define.LTP_ORDER ), - psPLC.LTPCoef_Q14, 0, Silk_define.LTP_ORDER); - psPLC.pitchL_Q8 = ( psDecCtrl.pitchL[ Silk_define.NB_SUBFR - 1 - j ] << 8 ); - } - } - - if(USE_SINGLE_TAP) - { - Arrays.fill(psPLC.LTPCoef_Q14, 0, Silk_define.LTP_ORDER, (short)0); - psPLC.LTPCoef_Q14[ Silk_define.LTP_ORDER / 2 ] = (short) LTP_Gain_Q14; - } - - /* Limit LT coefs */ - if( LTP_Gain_Q14 < V_PITCH_GAIN_START_MIN_Q14 ) { - int scale_Q10; - int tmp; - - tmp = ( V_PITCH_GAIN_START_MIN_Q14 << 10 ); - - scale_Q10 = ( tmp / Math.max( LTP_Gain_Q14, 1 ) ); - - for( i = 0; i < Silk_define.LTP_ORDER; i++ ) { - psPLC.LTPCoef_Q14[ i ] = (short) ( Silk_macros.SKP_SMULBB( psPLC.LTPCoef_Q14[ i ], scale_Q10 ) >> 10 ); - } - } else if( LTP_Gain_Q14 > V_PITCH_GAIN_START_MAX_Q14 ) { - int scale_Q14; - int tmp; - - tmp = ( V_PITCH_GAIN_START_MAX_Q14 << 14 ); - scale_Q14 = ( tmp / Math.max( LTP_Gain_Q14, 1 ) ); - - for( i = 0; i < Silk_define.LTP_ORDER; i++ ) { - psPLC.LTPCoef_Q14[ i ] = (short) ( Silk_macros.SKP_SMULBB( psPLC.LTPCoef_Q14[ i ], scale_Q14 ) << 14 ); - } - } - } else { - psPLC.pitchL_Q8 = ( Silk_macros.SKP_SMULBB( psDec.fs_kHz, 18 ) << 8 ); - Arrays.fill(psPLC.LTPCoef_Q14, 0, Silk_define.LTP_ORDER, (short)0); - } - - /* Save LPC coeficients */ - System.arraycopy(psDecCtrl.PredCoef_Q12[1], 0, psPLC.prevLPC_Q12, 0, psDec.LPC_order); - psPLC.prevLTP_scale_Q14 = (short) psDecCtrl.LTP_scale_Q14; - - /* Save Gains */ - System.arraycopy(psDecCtrl.Gains_Q16, 0, psPLC.prevGain_Q16, 0, Silk_define.NB_SUBFR); - - } - - /** - * - * @param psDec Decoder state. - * @param psDecCtrl Decoder control. - * @param signal concealed signal. - * @param signal_offset offset of the valid data. - * @param length Length of residual. - */ - static void SKP_Silk_PLC_conceal( - SKP_Silk_decoder_state psDec, /* I/O Decoder state */ - SKP_Silk_decoder_control psDecCtrl, /* I/O Decoder control */ - short signal[], /* O concealed signal */ - int signal_offset, - int length /* I length of residual */ - ) - { - int i, j, k; - short[] B_Q14; - short[] exc_buf = new short[Silk_define.MAX_FRAME_LENGTH]; - short[] exc_buf_ptr; - int exc_buf_ptr_offset; - - short rand_scale_Q14; - short[] A_Q12_tmp = new short[Silk_define.MAX_LPC_ORDER]; - - - int rand_seed, harm_Gain_Q15, rand_Gain_Q15; - int lag, idx, shift1, shift2; - int shift1_ptr[] = new int[1]; - int shift2_ptr[] = new int[1]; - - int energy1, energy2; - int energy1_ptr[] = new int[1]; - int energy2_ptr[] = new int[1]; - - int[] rand_ptr, pred_lag_ptr; - int rand_ptr_offset, pred_lag_ptr_offset; - - int[] sig_Q10 = new int[Silk_define.MAX_FRAME_LENGTH]; - int[] sig_Q10_ptr; - int sig_Q10_ptr_offset; - - int LPC_exc_Q10, LPC_pred_Q10, LTP_pred_Q14; - - SKP_Silk_PLC_struct psPLC; - psPLC = psDec.sPLC; - - /* Update LTP buffer */ - System.arraycopy(psDec.sLTP_Q16, psDec.frame_length, psDec.sLTP_Q16, 0, psDec.frame_length); - - /* LPC concealment. Apply BWE to previous LPC */ - Silk_bwexpander.SKP_Silk_bwexpander( psPLC.prevLPC_Q12, psDec.LPC_order, BWE_COEF_Q16 ); - - /* Find random noise component */ - /* Scale previous excitation signal */ - exc_buf_ptr = exc_buf; - exc_buf_ptr_offset = 0; - - for( k = ( Silk_define.NB_SUBFR >> 1 ); k < Silk_define.NB_SUBFR; k++ ) { - for( i = 0; i < psDec.subfr_length; i++ ) { - exc_buf_ptr[exc_buf_ptr_offset + i ] = ( short )( Silk_macros.SKP_SMULWW( psDec.exc_Q10[ i + k * psDec.subfr_length ], psPLC.prevGain_Q16[ k ] ) >> 10 ); - - } - exc_buf_ptr_offset += psDec.subfr_length; - } - /* Find the subframe with lowest energy of the last two and use that as random noise generator */ - Silk_sum_sqr_shift.SKP_Silk_sum_sqr_shift( energy1_ptr, shift1_ptr, exc_buf, 0, psDec.subfr_length ); - energy1 = energy1_ptr[0]; - shift1 = shift1_ptr[0]; - - Silk_sum_sqr_shift.SKP_Silk_sum_sqr_shift( energy2_ptr, shift2_ptr, exc_buf, psDec.subfr_length , psDec.subfr_length ); - energy2 = energy2_ptr[0]; - shift2 = shift2_ptr[0]; - - if( ( energy1 >> shift2 ) < ( energy1 >> shift2 ) ) { - /* First sub-frame has lowest energy */ - rand_ptr = psDec.exc_Q10; - rand_ptr_offset = Math.max( 0, 3 * psDec.subfr_length - RAND_BUF_SIZE ); - } else { - /* Second sub-frame has lowest energy */ - rand_ptr = psDec.exc_Q10; - rand_ptr_offset = Math.max(0, psDec.frame_length - RAND_BUF_SIZE); - } - - /* Setup Gain to random noise component */ - B_Q14 = psPLC.LTPCoef_Q14; - rand_scale_Q14 = psPLC.randScale_Q14; - - /* Setup attenuation gains */ - harm_Gain_Q15 = HARM_ATT_Q15[ Math.min( NB_ATT - 1, psDec.lossCnt ) ]; - if( psDec.prev_sigtype == Silk_define.SIG_TYPE_VOICED ) { - rand_Gain_Q15 = PLC_RAND_ATTENUATE_V_Q15[ Math.min( NB_ATT - 1, psDec.lossCnt ) ]; - } else { - rand_Gain_Q15 = PLC_RAND_ATTENUATE_UV_Q15[ Math.min( NB_ATT - 1, psDec.lossCnt ) ]; - } - - /* First Lost frame */ - if( psDec.lossCnt == 0 ) { - rand_scale_Q14 = (1 << 14 ); - - /* Reduce random noise Gain for voiced frames */ - if( psDec.prev_sigtype == Silk_define.SIG_TYPE_VOICED ) { - for( i = 0; i < Silk_define.LTP_ORDER; i++ ) { - rand_scale_Q14 -= B_Q14[ i ]; - } - rand_scale_Q14 = (short) Math.max( 3277, rand_scale_Q14 ); /* 0.2 */ - rand_scale_Q14 = ( short )( Silk_macros.SKP_SMULBB( rand_scale_Q14, psPLC.prevLTP_scale_Q14 ) >> 14 ); - } - - /* Reduce random noise for unvoiced frames with high LPC gain */ - if( psDec.prev_sigtype == Silk_define.SIG_TYPE_UNVOICED ) { - int invGain_Q30, down_scale_Q30; - int invGain_Q30_ptr[] = new int[1]; - Silk_LPC_inv_pred_gain.SKP_Silk_LPC_inverse_pred_gain( invGain_Q30_ptr, psPLC.prevLPC_Q12, psDec.LPC_order ); - invGain_Q30 = invGain_Q30_ptr[0]; - - down_scale_Q30 = Math.min( ( ( 1 << 30 ) >> LOG2_INV_LPC_GAIN_HIGH_THRES ), invGain_Q30 ); - down_scale_Q30 = Math.max( ( ( 1 << 30 ) >> LOG2_INV_LPC_GAIN_LOW_THRES ), down_scale_Q30 ); - down_scale_Q30 = ( down_scale_Q30 << LOG2_INV_LPC_GAIN_HIGH_THRES ); - - rand_Gain_Q15 = ( Silk_macros.SKP_SMULWB( down_scale_Q30, rand_Gain_Q15 ) >> 14 ); - } - } - - rand_seed = psPLC.rand_seed; - lag = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( psPLC.pitchL_Q8, 8 ); - psDec.sLTP_buf_idx = psDec.frame_length; - - /***************************/ - /* LTP synthesis filtering */ - /***************************/ - sig_Q10_ptr = sig_Q10; - sig_Q10_ptr_offset = 0; - - - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - /* Setup pointer */ - pred_lag_ptr = psDec.sLTP_Q16; - pred_lag_ptr_offset = psDec.sLTP_buf_idx - lag + Silk_define.LTP_ORDER / 2; - - for( i = 0; i < psDec.subfr_length; i++ ) { - rand_seed = Silk_SigProc_FIX.SKP_RAND( rand_seed ); - idx = ( rand_seed >> 25 ) & RAND_BUF_MASK; - - /* Unrolled loop */ -// LTP_pred_Q14 = Silk_macros.SKP_SMULWB( pred_lag_ptr[ pred_lag_ptr_offset + 0 ], B_Q14[ 0 ] ); -//TODO: array bonds check??? - LTP_pred_Q14 = Silk_macros.SKP_SMULWB( pred_lag_ptr[ pred_lag_ptr_offset + 0 ], B_Q14[ 0 ] ); - LTP_pred_Q14 = Silk_macros.SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ pred_lag_ptr_offset - 1 ], B_Q14[ 1 ] ); - LTP_pred_Q14 = Silk_macros.SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ pred_lag_ptr_offset - 2 ], B_Q14[ 2 ] ); - LTP_pred_Q14 = Silk_macros.SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ pred_lag_ptr_offset - 3 ], B_Q14[ 3 ] ); - LTP_pred_Q14 = Silk_macros.SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ pred_lag_ptr_offset - 4 ], B_Q14[ 4 ] ); - pred_lag_ptr_offset++; - - /* Generate LPC residual */ - LPC_exc_Q10 = ( Silk_macros.SKP_SMULWB( rand_ptr[rand_ptr_offset + idx ], rand_scale_Q14 ) << 2 ); /* Random noise part */ - LPC_exc_Q10 = ( LPC_exc_Q10 + Silk_SigProc_FIX.SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 ) ); /* Harmonic part */ - - /* Update states */ - psDec.sLTP_Q16[ psDec.sLTP_buf_idx ] = ( LPC_exc_Q10 << 6 ); - psDec.sLTP_buf_idx++; - - /* Save LPC residual */ - sig_Q10_ptr[ sig_Q10_ptr_offset + i ] = LPC_exc_Q10; - } - sig_Q10_ptr_offset += psDec.subfr_length; - /* Gradually reduce LTP gain */ - for( j = 0; j < Silk_define.LTP_ORDER; j++ ) { - B_Q14[ j ] = (short) ( Silk_macros.SKP_SMULBB( harm_Gain_Q15, B_Q14[ j ] )>> 15 ); - } - /* Gradually reduce excitation gain */ - rand_scale_Q14 = (short) ( Silk_macros.SKP_SMULBB( rand_scale_Q14, rand_Gain_Q15 ) >> 15 ); - - /* Slowly increase pitch lag */ - psPLC.pitchL_Q8 += Silk_macros.SKP_SMULWB( psPLC.pitchL_Q8, PITCH_DRIFT_FAC_Q16 ); - psPLC.pitchL_Q8 = Math.min( psPLC.pitchL_Q8, ( Silk_macros.SKP_SMULBB( MAX_PITCH_LAG_MS, psDec.fs_kHz ) << 8 ) ); - lag = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( psPLC.pitchL_Q8, 8 ); - } - - /***************************/ - /* LPC synthesis filtering */ - /***************************/ - sig_Q10_ptr = sig_Q10; - sig_Q10_ptr_offset = 0; - /* Preload LPC coeficients to array on stack. Gives small performance gain */ - System.arraycopy(psPLC.prevLPC_Q12, 0, A_Q12_tmp, 0, psDec.LPC_order); - Silk_typedef.SKP_assert( psDec.LPC_order >= 10 ); /* check that unrolling works */ - - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - for( i = 0; i < psDec.subfr_length; i++ ){ - /* partly unrolled */ - LPC_pred_Q10 = Silk_macros.SKP_SMULWB( psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 1 ], A_Q12_tmp[ 0 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 2 ], A_Q12_tmp[ 1 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 3 ], A_Q12_tmp[ 2 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 4 ], A_Q12_tmp[ 3 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 5 ], A_Q12_tmp[ 4 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 6 ], A_Q12_tmp[ 5 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 7 ], A_Q12_tmp[ 6 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 8 ], A_Q12_tmp[ 7 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 9 ], A_Q12_tmp[ 8 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 10 ], A_Q12_tmp[ 9 ] ); - - for( j = 10; j < psDec.LPC_order; j++ ) { - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - j - 1 ], A_Q12_tmp[ j ] ); - } - /* Add prediction to LPC residual */ - sig_Q10_ptr[ sig_Q10_ptr_offset = i ] = ( sig_Q10_ptr[ sig_Q10_ptr_offset +i ] + LPC_pred_Q10 ); - - /* Update states */ - psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i ] = ( sig_Q10_ptr[sig_Q10_ptr_offset+ i ] << 4 ); - } - sig_Q10_ptr_offset += psDec.subfr_length; - /* Update LPC filter state */ - System.arraycopy(psDec.sLPC_Q14, psDec.subfr_length, psDec.sLPC_Q14, 0, Silk_define.MAX_LPC_ORDER); - } - - /* Scale with Gain */ - for( i = 0; i < psDec.frame_length; i++ ) { - signal[ signal_offset + i ] = ( short )Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( Silk_macros.SKP_SMULWW( sig_Q10[ i ], psPLC.prevGain_Q16[ Silk_define.NB_SUBFR - 1 ] ), 10 ) ); - } - - /**************************************/ - /* Update states */ - /**************************************/ - psPLC.rand_seed = rand_seed; - psPLC.randScale_Q14 = rand_scale_Q14; - for( i = 0; i < Silk_define.NB_SUBFR; i++ ) { - psDecCtrl.pitchL[ i ] = lag; - } - } - - /** - * Glues concealed frames with new good recieved frames. - * @param psDec Decoder state. - * @param psDecCtrl Decoder control. - * @param signal signal. - * @param signal_offset offset of the valid data. - * @param length length of the residual. - */ - static void SKP_Silk_PLC_glue_frames( - SKP_Silk_decoder_state psDec, /* I/O decoder state */ - SKP_Silk_decoder_control psDecCtrl, /* I/O Decoder control */ - short signal[], /* I/O signal */ - int signal_offset, - int length /* I length of residual */ - ) - { - int i, energy_shift; - int energy; - int energy_ptr[] = new int[1]; - int energy_shift_ptr[] = new int[1]; - - SKP_Silk_PLC_struct psPLC; - psPLC = psDec.sPLC; - - if( psDec.lossCnt != 0) { - /* Calculate energy in concealed residual */ - int[] conc_energy_ptr = new int[1]; - int[] conc_energy_shift_ptr = new int[1]; - Silk_sum_sqr_shift.SKP_Silk_sum_sqr_shift( conc_energy_ptr, conc_energy_shift_ptr, signal, signal_offset, length ); - psPLC.conc_energy = conc_energy_ptr[0]; - psPLC.conc_energy_shift = conc_energy_shift_ptr[0]; - - psPLC.last_frame_lost = 1; - } else { - if( psDec.sPLC.last_frame_lost != 0 ) { - /* Calculate residual in decoded signal if last frame was lost */ - Silk_sum_sqr_shift.SKP_Silk_sum_sqr_shift( energy_ptr, energy_shift_ptr, signal, signal_offset, length ); - energy = energy_ptr[0]; - energy_shift = energy_shift_ptr[0]; - - - /* Normalize energies */ - if( energy_shift > psPLC.conc_energy_shift ) { - psPLC.conc_energy = ( psPLC.conc_energy >> energy_shift - psPLC.conc_energy_shift ); - } else if( energy_shift < psPLC.conc_energy_shift ) { - energy = ( energy >> psPLC.conc_energy_shift - energy_shift ); - } - - /* Fade in the energy difference */ - if( energy > psPLC.conc_energy ) { - int frac_Q24, LZ; - int gain_Q12, slope_Q12; - - LZ = Silk_macros.SKP_Silk_CLZ32( psPLC.conc_energy ); - LZ = LZ - 1; - psPLC.conc_energy = ( psPLC.conc_energy << LZ ); - energy = ( energy >> Math.max( 24 - LZ, 0 ) ); - - frac_Q24 = ( psPLC.conc_energy / Math.max( energy, 1 ) ); - - gain_Q12 = Silk_Inlines.SKP_Silk_SQRT_APPROX( frac_Q24 ); - slope_Q12 = ( ( 1 << 12 ) - gain_Q12 / length ); - - for( i = 0; i < length; i++ ) { - signal[signal_offset + i ] = (short) ( ( gain_Q12 * signal[ signal_offset + i ] ) >> 12 ); - gain_Q12 += slope_Q12; - gain_Q12 = Math.min( gain_Q12, ( 1 << 12 ) ); - } - } - } - psPLC.last_frame_lost = 0; - - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_SDK_API.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_SDK_API.java deleted file mode 100644 index 7fd776699..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_SDK_API.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - */ -public class Silk_SDK_API -{ - static final int SILK_MAX_FRAMES_PER_PACKET = 5; -} - -/** - * Struct for TOC (Table of Contents). - * - * @author Jing Dai - * @author Dingxin Xu - */ -class SKP_Silk_TOC_struct -{ - int framesInPacket; /* Number of 20 ms frames in packet */ - int fs_kHz; /* Sampling frequency in packet */ - int inbandLBRR; /* Does packet contain LBRR information */ - int corrupt; /* Packet is corrupt */ - int[] vadFlags = new int[Silk_SDK_API.SILK_MAX_FRAMES_PER_PACKET ]; /* VAD flag for each frame in packet */ - int[] sigtypeFlags = new int[Silk_SDK_API.SILK_MAX_FRAMES_PER_PACKET ]; /* Signal type for each frame in packet */ -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_SigProc_FIX.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_SigProc_FIX.java deleted file mode 100644 index 192e81812..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_SigProc_FIX.java +++ /dev/null @@ -1,810 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -class Silk_SigProc_FIX_constants -{ - /** - * max order of the LPC analysis in schur() and k2a(). - */ - static final int SKP_Silk_MAX_ORDER_LPC = 16; /* max order of the LPC analysis in schur() and k2a() */ - /** - * max input length to the correlation. - */ - static final int SKP_Silk_MAX_CORRELATION_LENGTH = 640;/* max input length to the correlation */ - - /* Pitch estimator */ - static final int SKP_Silk_PITCH_EST_MIN_COMPLEX = 0; - static final int SKP_Silk_PITCH_EST_MID_COMPLEX = 1; - static final int SKP_Silk_PITCH_EST_MAX_COMPLEX = 2; - - /* parameter defining the size and accuracy of the piecewise linear */ - /* cosine approximatin table. */ - static final int LSF_COS_TAB_SZ_FIX = 128; - /* rom table with cosine values */ -// (to see rom table value, refer to Silk_LSF_cos_table.java) -} - -public class Silk_SigProc_FIX - extends Silk_SigProc_FIX_constants -{ - /** - * Rotate a32 right by 'rot' bits. Negative rot values result in rotating - * left. Output is 32bit int. - * - * @param a32 - * @param rot - * @return - */ - static int SKP_ROR32( int a32, int rot ) - { - if(rot <= 0) - return ((a32 << -rot) | (a32 >>> (32 + rot))); - else - return ((a32 << (32 - rot)) | (a32 >>> rot)); - } - - /* fixed point */ - - /** - * (a32 * b32) output have to be 32bit int - */ - static int SKP_MUL(int a32, int b32) - { - return a32*b32; - } - - /** - * (a32 * b32) output have to be 32bit uint. - * @param a32 - * @param b32 - * @return - */ - static long SKP_MUL_uint(long a32, long b32) - { - return a32*b32; - } - - /** - * a32 + (b32 * c32) output have to be 32bit int - * @param a32 - * @param b32 - * @param c32 - * @return - */ - static int SKP_MLA(int a32, int b32, int c32) - { - return a32 + b32*c32; - } - - /** - * a32 + (b32 * c32) output have to be 32bit uint - * @param a32 - * @param b32 - * @param c32 - * @return - */ - static long SKP_MLA_uint(long a32, long b32, long c32) - { - return a32 + b32*c32; - } - - /** - * ((a32 >> 16) * (b32 >> 16)) output have to be 32bit int - * @param a32 - * @param b32 - * @return - */ - static int SKP_SMULTT(int a32, int b32) - { - return (((a32) >> 16) * ((b32) >> 16)); - } - - /** - * a32 + ((b32 >> 16) * (c32 >> 16)) output have to be 32bit int - * @param a32 - * @param b32 - * @param c32 - * @return - */ - static int SKP_SMLATT(int a32, int b32, int c32) - { - return (a32) + ((b32) >> 16) * ((c32) >> 16); - } - - /** - * SKP_ADD64((a64),(SKP_int64)((SKP_int32)(b16) * (SKP_int32)(c16))). - * @param a64 - * @param b16 - * @param c16 - * @return - */ - static long SKP_SMLALBB(long a64, short b16, short c16) - { - return (a64) + ((b16) * (c16)); - } - - /** - * (a32 * b32) - * @param a32 - * @param b32 - * @return - */ - static long SKP_SMULL(int a32, int b32) - { - return ((long)(a32) * /*(long)*/(b32)); - } - - // multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode) - /** - * SKP_MLA(a32, b32, c32). - */ - static int SKP_MLA_ovflw(int a32, int b32, int c32) - { - return a32 + b32*c32; - } - - /** - * SKP_SMLABB(a32, b32, c32) - * @param a32 - * @param b32 - * @param c32 - * @return - */ - static int SKP_SMLABB_ovflw(int a32, int b32, int c32) - { - return ((a32) + (((short)(b32))) * ((short)(c32))); - } - /** - * SKP_SMLABT(a32, b32, c32) - * @param a32 - * @param b32 - * @param c32 - * @return - */ - static int SKP_SMLABT_ovflw(int a32, int b32, int c32) - { - return ((a32) + (((short)(b32))) * ((c32) >> 16)); - } - /** - * SKP_SMLATT(a32, b32, c32) - * @param a32 - * @param b32 - * @param c32 - * @return - */ - static int SKP_SMLATT_ovflw(int a32, int b32, int c32) - { - return (a32) + ((b32) >> 16) * ((c32) >> 16); - } - /** - * SKP_SMLAWB(a32, b32, c32) - * @param a32 - * @param b32 - * @param c32 - * @return - */ - static int SKP_SMLAWB_ovflw(int a32, int b32, int c32) - { - return ((a32) + ((((b32) >> 16) * ((short)(c32))) + ((((b32) & 0x0000FFFF) * ((short)(c32))) >> 16))); - } - /** - * SKP_SMLAWT(a32, b32, c32) - * @param a32 - * @param b32 - * @param c32 - * @return - */ - static int SKP_SMLAWT_ovflw(int a32, int b32, int c32) - { - return ((a32) + (((b32) >> 16) * ((c32) >> 16)) + ((((b32) & 0x0000FFFF) * ((c32) >> 16)) >> 16)); - } - - /** - * ((a64)/(b32)) - * TODO: rewrite it as a set of SKP_DIV32. - */ - static long SKP_DIV64_32(long a64, int b32) - { - return a64/b32; - } - - /** - * ((int)((a32) / (b16))) - * @param a32 - * @param b16 - * @return - */ - static int SKP_DIV32_16(int a32, short b16) - { - return (((a32) / (b16))); - } - /** - * ((SKP_int32)((a32) / (b32))) - * @param a32 - * @param b32 - * @return - */ - static int SKP_DIV32(int a32, int b32) - { - return (((a32) / (b32))); - } - - // These macros enables checking for overflow in SKP_Silk_API_Debug.h - /** - * ((a) + (b)) - */ - static short SKP_ADD16(short a, short b) - { - return (short)(a+b); - } - /** - * ((a) + (b)) - * @param a - * @param b - * @return - */ - static int SKP_ADD32(int a, int b) - { - return a+b; - } - /** - * ((a) + (b)) - * @param a - * @param b - * @return - */ - static long SKP_ADD64(long a, long b) - { - return a+b; - } - - /** - * ((a) - (b)) - * @param a - * @param b - * @return - */ - static short SKP_SUB16(short a, short b) - { - return (short)(a-b); - } - /** - * ((a) - (b)) - * @param a - * @param b - * @return - */ - static int SKP_SUB32(int a, int b) - { - return a-b; - } - /** - * ((a) - (b)) - * @param a - * @param b - * @return - */ - static long SKP_SUB64(long a, long b) - { - return a-b; - } - - static int SKP_SAT8(int a) - { - return ((a) > Byte.MAX_VALUE ? Byte.MAX_VALUE : ((a) < Byte.MIN_VALUE ? Byte.MIN_VALUE : (a))); - } - - static int SKP_SAT16(int a) - { - return ((a) > Short.MAX_VALUE ? Short.MAX_VALUE : ((a) < Short.MIN_VALUE ? Short.MIN_VALUE : (a))); - } - - static long SKP_SAT32(long a) - { - return ((a) > Integer.MAX_VALUE ? Integer.MAX_VALUE : ((a) < Integer.MIN_VALUE ? Integer.MIN_VALUE : (a))); - } - - /** - * (a) - * @param a - * @return - */ - static byte SKP_CHECK_FIT8(int a) - { - return (byte)a; - } - /** - * (a) - * @param a - * @return - */ - static short SKP_CHECK_FIT16(int a) - { - return (short)a; - } - /** - * (a) - * @param a - * @return - */ - static int SKP_CHECK_FIT32(int a) - { - return a; - } - - static short SKP_ADD_SAT16(short a, short b) - { - return (short)SKP_SAT16( (a) + (b) ); - } - - static long SKP_ADD_SAT64(long a, long b) - { - if( ((a + b) & 0x8000000000000000L) == 0 ) - return ((a & b) & 0x8000000000000000L) != 0 ? Long.MIN_VALUE : a+b; - else - return ((a | b) & 0x8000000000000000L) == 0 ? Long.MAX_VALUE : a+b; - } - - static short SKP_SUB_SAT16(short a, short b) - { - return (short)SKP_SAT16( (a) - (b) ); - } - - static long SKP_SUB_SAT64(long a, long b) - { - if( ((a - b) & 0x8000000000000000L) == 0 ) - return ( a & (b^0x8000000000000000L) & 0x8000000000000000L) != 0 ? Long.MIN_VALUE : a-b; - else - return ( (a^0x8000000000000000L) & b & 0x8000000000000000L) != 0 ? Long.MAX_VALUE : a-b; - } - - /* Saturation for positive input values */ - static long SKP_POS_SAT32(long a) - { - return ((a) > Integer.MAX_VALUE ? Integer.MAX_VALUE : (a)); - } - - /* Add with saturation for positive input values */ - static byte SKP_ADD_POS_SAT8(byte a, byte b) - { - return ((a+b) & 0x80) != 0? Byte.MAX_VALUE : (byte)(a+b); - } - static short SKP_ADD_POS_SAT16(short a, short b) - { - return ((a+b) & 0x8000) != 0 ? Short.MAX_VALUE : (short)(a+b); - } - static int SKP_ADD_POS_SAT32(int a, int b) - { - return ((((a)+(b)) & 0x80000000) != 0 ? Integer.MAX_VALUE : ((a)+(b))); - } - static long SKP_ADD_POS_SAT64(long a, long b) - { - return ((((a)+(b)) & 0x8000000000000000L) != 0 ? Long.MAX_VALUE : ((a)+(b))); - } - - /** - * ((a)<<(shift)) // shift >= 0, shift < 8 - * @param a - * @param shift - * @return - */ - static byte SKP_LSHIFT8(byte a, int shift) - { - return (byte)(a<= 0, shift < 16 - * @param a - * @param shift - * @return - */ - static short SKP_LSHIFT16(short a, int shift) - { - return (short)(a<= 0, shift < 32 - * @param a - * @param shift - * @return - */ - static int SKP_LSHIFT32(int a, int shift) - { - return a<= 0, shift < 64 - * @param a - * @param shift - * @return - */ - static long SKP_LSHIFT64(long a, int shift) - { - return a<= 0, shift < 32 - * @param a - * @param shift - * @return - */ - static int SKP_LSHIFT(int a, int shift) - { - return a<>(shift)) // shift >= 0, shift < 8 - * @param a - * @param shift - * @return - */ - static byte SKP_RSHIFT8(byte a, int shift) - { - return (byte)(a>>shift); - } - /** - * ((a)>>(shift)) // shift >= 0, shift < 16 - * @param a - * @param shift - * @return - */ - static short SKP_RSHIFT16(short a, int shift) - { - return (short)(a>>shift); - } - /** - * ((a)>>(shift)) // shift >= 0, shift < 32 - * @param a - * @param shift - * @return - */ - static int SKP_RSHIFT32(int a, int shift) - { - return a>>shift; - } - /** - * ((a)>>(shift)) // shift >= 0, shift < 64 - * @param a - * @param shift - * @return - */ - static long SKP_RSHIFT64(long a, int shift) - { - return a>>shift; - } - /** - * SKP_RSHIFT32(a, shift) // shift >= 0, shift < 32 - * @param a - * @param shift - * @return - */ - static int SKP_RSHIFT(int a, int shift) - { - return a>>shift; - } - - /* saturates before shifting */ - static short SKP_LSHIFT_SAT16(short a, int shift) - { - return SKP_LSHIFT16( SKP_LIMIT_16( a, (short)(Short.MIN_VALUE>>shift), (short)(Short.MAX_VALUE>>shift) ), shift ); - } - - static int SKP_LSHIFT_SAT32(int a, int shift) - { - return SKP_LSHIFT32( SKP_LIMIT( a, Integer.MIN_VALUE>>shift, Integer.MAX_VALUE>>shift ), shift ); - } - - /** - * ((a)<<(shift)) // shift >= 0, allowed to overflow - * @param a - * @param shift - * @return - */ - static int SKP_LSHIFT_ovflw(int a, int shift) - { - return a<= 0 - * @param a - * @param shift - * @return - */ - static int SKP_LSHIFT_uint(int a, int shift) - { - return a<>(shift)) // shift >= 0 - * @param a - * @param shift - * @return - */ - static int SKP_RSHIFT_uint(int a, int shift) - { - return a>>>shift; - } - - /** - * ((a) + SKP_LSHIFT((b), (shift))) // shift >= 0 - * @param a - * @param b - * @param shift - * @return - */ - static int SKP_ADD_LSHIFT(int a, int b, int shift) - { - return a + (b<= 0 - * @param a - * @param b - * @param shift - * @return - */ - static int SKP_ADD_LSHIFT32(int a, int b, int shift) - { - return a + (b<= 0 - * @param a - * @param b - * @param shift - * @return - */ - static int SKP_ADD_LSHIFT_uint(int a, int b, int shift) - { - return a + (b<= 0 - * @param a - * @param b - * @param shift - * @return - */ - static int SKP_ADD_RSHIFT(int a, int b, int shift) - { - return a + (b>>shift); - } - /** - * SKP_ADD32((a), SKP_RSHIFT32((b), (shift))) // shift >= 0 - * @param a - * @param b - * @param shift - * @return - */ - static int SKP_ADD_RSHIFT32(int a, int b, int shift) - { - return a + (b>>shift); - } - /** - * ((a) + SKP_RSHIFT_uint((b), (shift))) // shift >= 0 - * @param a - * @param b - * @param shift - * @return - */ - static int SKP_ADD_RSHIFT_uint(int a, int b, int shift) - { - return a + (b>>>shift); - } - /** - * SKP_SUB32((a), SKP_LSHIFT32((b), (shift))) // shift >= 0 - * @param a - * @param b - * @param shift - * @return - */ - static int SKP_SUB_LSHIFT32(int a, int b, int shift) - { - return a - (b<= 0 - * @param a - * @param b - * @param shift - * @return - */ - static int SKP_SUB_RSHIFT32(int a, int b, int shift) - { - return a - (b>>shift); - } - - /* Requires that shift > 0 */ - /** - * ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1) - */ - static int SKP_RSHIFT_ROUND(int a, int shift) - { - return shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; - } - /** - * ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1) - * @param a - * @param shift - * @return - */ - static long SKP_RSHIFT_ROUND64(long a, int shift) - { - return shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; - } - - /* Number of rightshift required to fit the multiplication */ - static int SKP_NSHIFT_MUL_32_32(int a, int b) - { - return -(31- (32-Silk_macros.SKP_Silk_CLZ32(Math.abs(a)) + (32-Silk_macros.SKP_Silk_CLZ32(Math.abs(b))))); - } - static int SKP_NSHIFT_MUL_16_16(short a, short b) - { - return -(15- (16-Silk_macros.SKP_Silk_CLZ16((short)Math.abs(a)) + (16-Silk_macros.SKP_Silk_CLZ16((short)Math.abs(b))))); - } - - - static int SKP_min(int a, int b) - { - return ab ? a:b; - } - - /* Macro to convert floating-point constants to fixed-point */ - /** - * ((int)((C) * (1 << (Q)) + 0.5)) - */ - static int SKP_FIX_CONST( float C, int Q ) - { - return (int)(C * (1 << Q) + 0.5); - } - - /* SKP_min() versions with typecast in the function call */ - static int SKP_min_int(int a, int b) - { - return (((a) < (b)) ? (a) : (b)); - } - static short SKP_min_16(short a, short b) - { - return (((a) < (b)) ? (a) : (b)); - } - static int SKP_min_32(int a, int b) - { - return (((a) < (b)) ? (a) : (b)); - } - static long SKP_min_64(long a, long b) - { - return (((a) < (b)) ? (a) : (b)); - } - - /* SKP_min() versions with typecast in the function call */ - static int SKP_max_int(int a, int b) - { - return (((a) > (b)) ? (a) : (b)); - } - static short SKP_max_16(short a, short b) - { - return (((a) > (b)) ? (a) : (b)); - } - static int SKP_max_32(int a, int b) - { - return (((a) > (b)) ? (a) : (b)); - } - static long SKP_max_64(long a, long b) - { - return (((a) > (b)) ? (a) : (b)); - } - - static int SKP_LIMIT( int a, int limit1, int limit2) - { - if( limit1 > limit2 ) - return a > limit1 ? limit1 : (a < limit2 ? limit2 : a); - else - return a > limit2 ? limit2 : (a < limit1 ? limit1 : a); - } - static float SKP_LIMIT( float a, float limit1, float limit2) - { - if( limit1 > limit2 ) - return a > limit1 ? limit1 : (a < limit2 ? limit2 : a); - else - return a > limit2 ? limit2 : (a < limit1 ? limit1 : a); - } - - static int SKP_LIMIT_int( int a, int limit1, int limit2) - { - if( limit1 > limit2 ) - return a > limit1 ? limit1 : (a < limit2 ? limit2 : a); - else - return a > limit2 ? limit2 : (a < limit1 ? limit1 : a); - } - static short SKP_LIMIT_16( short a, short limit1, short limit2) - { - if( limit1 > limit2 ) - return a > limit1 ? limit1 : (a < limit2 ? limit2 : a); - else - return a > limit2 ? limit2 : (a < limit1 ? limit1 : a); - } - static int SKP_LIMIT_32( int a, int limit1, int limit2) - { - if( limit1 > limit2 ) - return a > limit1 ? limit1 : (a < limit2 ? limit2 : a); - else - return a > limit2 ? limit2 : (a < limit1 ? limit1 : a); - } - - - /** - * (((a) > 0) ? (a) : -(a)) - * Be careful, SKP_abs returns wrong when input equals to SKP_intXX_MIN - * @param a - * @return - */ - static int SKP_abs(int a) - { - return (((a) > 0) ? (a) : -(a)); - } - static int SKP_abs_int(int a) - { - return (((a) ^ ((a) >> (Integer.SIZE - 1))) - ((a) >> (Integer.SIZE - 1))); - } - static int SKP_abs_int32(int a) - { - return (((a) ^ ((a) >> 31)) - ((a) >> 31)); - } - static long SKP_abs_int64(long a) - { - return (((a) > 0) ? (a) : -(a)); - } - - static int SKP_sign(int a) - { - return ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 )); - } - - static double SKP_sqrt(int a) - { - return Math.sqrt(a); - } - - /** - * PSEUDO-RANDOM GENERATOR - * Make sure to store the result as the seed for the next call (also in between - * frames), otherwise result won't be random at all. When only using some of the - * bits, take the most significant bits by right-shifting. Do not just mask off - * the lowest bits. - * SKP_RAND(seed) (SKP_MLA_ovflw(907633515, (seed), 196314165)) - * @param seed - * @return - */ - static int SKP_RAND(int seed) - { - return 907633515 + seed*196314165; - } - - // Add some multiplication functions that can be easily mapped to ARM. - -// SKP_SMMUL: Signed top word multiply. -// ARMv6 2 instruction cycles. -// ARMv3M+ 3 instruction cycles. use SMULL and ignore LSB registers.(except xM) -// #define SKP_SMMUL(a32, b32) (SKP_int32)SKP_RSHIFT(SKP_SMLAL(SKP_SMULWB((a32), (b32)), (a32), SKP_RSHIFT_ROUND((b32), 16)), 16) -// the following seems faster on x86 -// #define SKP_SMMUL(a32, b32) (SKP_int32)SKP_RSHIFT64(SKP_SMULL((a32), (b32)), 32) - static int SKP_SMMUL(int a32, int b32) - { - return (int)( ( (long)a32*b32 )>>32 ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_SigProc_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_SigProc_FLP.java deleted file mode 100644 index 3384cd56d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_SigProc_FLP.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -class Silk_SigProc_FLP_constants -{ - /* Pitch estimator */ - static final int SigProc_PITCH_EST_MIN_COMPLEX = 0; - static final int SigProc_PITCH_EST_MID_COMPLEX = 1; - static final int SigProc_PITCH_EST_MAX_COMPLEX = 2; - - static final float PI = 3.1415926536f; -} - -public class Silk_SigProc_FLP - extends Silk_SigProc_FLP_constants -{ - static float SKP_min_float(float a, float b) - { - return (((a) < (b)) ? (a) : (b)); - } - static float SKP_max_float(float a, float b) - { - return (((a) > (b)) ? (a) : (b)); - } - static float SKP_abs_float(float a) - { - return Math.abs(a); - } - - static float SKP_LIMIT_float( float a, float limit1, float limit2) - { - if( limit1 > limit2 ) - return a > limit1 ? limit1 : (a < limit2 ? limit2 : a); - else - return a > limit2 ? limit2 : (a < limit1 ? limit1 : a); - } - - /* sigmoid function */ - static float SKP_sigmoid(float x) - { - return (float)(1.0 / (1.0 + Math.exp(-x))); - } - - /* floating-point to integer conversion (rounding) */ - static void SKP_float2short_array - ( - short[] out, - int out_offset, - float[] in, - int in_offset, - int length - ) - { - int k; - for (k = length-1; k >= 0; k--) - { - double x = in[in_offset+k]; - out[out_offset+k] = (short)Silk_SigProc_FIX.SKP_SAT16( (int)(( x > 0 ) ? x + 0.5 : x - 0.5) ); - } - } - - /* floating-point to integer conversion (rounding) */ - static int SKP_float2int(double x) - { - return (int)( ( x > 0 ) ? x + 0.5 : x - 0.5 ); - } - - /* integer to floating-point conversion */ - static void SKP_short2float_array - ( - float[] out, - int out_offset, - short[] in, - int in_offset, - int length - ) - { - int k; - for (k = length-1; k >= 0; k--) - { - out[out_offset+k] = in[in_offset+k]; - } - } - -//TODO: #define SKP_round(x) (SKP_float)((x)>=0 ? (SKP_int64)((x)+0.5) : (SKP_int64)((x)-0.5)) - static float SKP_round(float x) - { - return ((x)>=0 ? (long)(x+0.5) : (long)(x-0.5)); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_VAD.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_VAD.java deleted file mode 100644 index 12d4e2b03..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_VAD.java +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_VAD -{ - /** - * Initialization of the Silk VAD. - * @param psSilk_VAD Silk VAD state. - * @return return 0 if success. - */ - static int SKP_Silk_VAD_Init( /* O Return value, 0 if success */ - SKP_Silk_VAD_state psSilk_VAD /* I/O Pointer to Silk VAD state */ - ) - { - int b, ret = 0; - - /* reset state memory */ -//TODO: memset -// SKP_memset( psSilk_VAD, 0, sizeof( SKP_Silk_VAD_state ) ); - - /* init noise levels */ - /* Initialize array with approx pink noise levels (psd proportional to inverse of frequency) */ - for( b = 0; b < Silk_define.VAD_N_BANDS; b++ ) - { - psSilk_VAD.NoiseLevelBias[ b ] = Math.max( Silk_define.VAD_NOISE_LEVELS_BIAS / ( b + 1 ), 1 ); - } - - /* Initialize state */ - for( b = 0; b < Silk_define.VAD_N_BANDS; b++ ) - { - psSilk_VAD.NL[ b ] = 100 * psSilk_VAD.NoiseLevelBias[ b ]; - psSilk_VAD.inv_NL[ b ] = Silk_typedef.SKP_int32_MAX / psSilk_VAD.NL[ b ]; - } - psSilk_VAD.counter = 15; - - /* init smoothed energy-to-noise ratio*/ - for( b = 0; b < Silk_define.VAD_N_BANDS; b++ ) { - psSilk_VAD.NrgRatioSmth_Q8[ b ] = 100 * 256; /* 100 * 256 --> 20 dB SNR */ - } - - return( ret ); - } - - /* Weighting factors for tilt measure */ - static int[] tiltWeights = { 30000, 6000, -12000, -12000 }; - - /** - * Get the speech activity level in Q8. - * @param psSilk_VAD Silk VAD state. - * @param pSA_Q8 Speech activity level in Q8. - * @param pSNR_dB_Q7 SNR for current frame in Q7. - * @param pQuality_Q15 Smoothed SNR for each band. - * @param pTilt_Q15 Smoothed SNR for each band. - * @param pIn PCM input[framelength]. - * @param pIn_offset offset of valid data. - * @param framelength Input frame length. - * @return Return value, 0 if success. - */ - static int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if success */ - SKP_Silk_VAD_state psSilk_VAD, /* I/O Silk VAD state */ - int[] pSA_Q8, /* O Speech activity level in Q8 */ - int[] pSNR_dB_Q7, /* O SNR for current frame in Q7 */ - int[] pQuality_Q15, /* O Smoothed SNR for each band */ - int[] pTilt_Q15, /* O current frame's frequency tilt */ - short[] pIn, /* I PCM input [framelength] */ - int pIn_offset, - int framelength /* I Input frame length */ - ) - { - int SA_Q15, input_tilt; - int[] scratch = new int[ 3 * Silk_define.MAX_FRAME_LENGTH / 2 ]; - int decimated_framelength, dec_subframe_length, dec_subframe_offset, SNR_Q7, i, b, s; - int sumSquared=0, smooth_coef_Q16; - short HPstateTmp; - - short[][] X = new short[ Silk_define.VAD_N_BANDS ][ Silk_define.MAX_FRAME_LENGTH / 2 ]; - int[] Xnrg = new int[ Silk_define.VAD_N_BANDS ]; - int[] NrgToNoiseRatio_Q8 = new int[ Silk_define.VAD_N_BANDS ]; - int speech_nrg, x_tmp; - int ret = 0; - - /* Safety checks */ - assert( Silk_define.VAD_N_BANDS == 4 ); - assert( Silk_define.MAX_FRAME_LENGTH >= framelength ); - assert( framelength <= 512 ); - - /***********************/ - /* Filter and Decimate */ - /***********************/ - /* 0-8 kHz to 0-4 kHz and 4-8 kHz */ - Silk_ana_filt_bank_1.SKP_Silk_ana_filt_bank_1( pIn,pIn_offset, psSilk_VAD.AnaState,0, X[ 0 ],0, X[ 3 ],0, scratch, framelength ); - - /* 0-4 kHz to 0-2 kHz and 2-4 kHz */ - Silk_ana_filt_bank_1.SKP_Silk_ana_filt_bank_1( X[ 0 ],0, psSilk_VAD.AnaState1,0, X[ 0 ],0, X[ 2 ],0, scratch, framelength>>1 ); - - /* 0-2 kHz to 0-1 kHz and 1-2 kHz */ - Silk_ana_filt_bank_1.SKP_Silk_ana_filt_bank_1( X[ 0 ],0, psSilk_VAD.AnaState2,0, X[ 0 ],0, X[ 1 ],0, scratch, framelength>>2 ); - - /*********************************************/ - /* HP filter on lowest band (differentiator) */ - /*********************************************/ - decimated_framelength = framelength >> 3; - X[ 0 ][ decimated_framelength - 1 ] = (short)( X[ 0 ][ decimated_framelength - 1 ] >> 1 ); - HPstateTmp = X[ 0 ][ decimated_framelength - 1 ]; - for( i = decimated_framelength - 1; i > 0; i-- ) - { - X[ 0 ][ i - 1 ] = (short)( X[ 0 ][ i - 1 ] >> 1 ); - X[ 0 ][ i ] -= X[ 0 ][ i - 1 ]; - } - X[ 0 ][ 0 ] -= psSilk_VAD.HPstate; - psSilk_VAD.HPstate = HPstateTmp; - - /*************************************/ - /* Calculate the energy in each band */ - /*************************************/ - for( b = 0; b < Silk_define.VAD_N_BANDS; b++ ) - { - /* Find the decimated framelength in the non-uniformly divided bands */ - decimated_framelength = framelength >> Math.min( Silk_define.VAD_N_BANDS - b, Silk_define.VAD_N_BANDS - 1); - - /* Split length into subframe lengths */ - dec_subframe_length = decimated_framelength >> Silk_define.VAD_INTERNAL_SUBFRAMES_LOG2; - dec_subframe_offset = 0; - - /* Compute energy per sub-frame */ - /* initialize with summed energy of last subframe */ - Xnrg[ b ] = psSilk_VAD.XnrgSubfr[ b ]; - for( s = 0; s < Silk_define.VAD_INTERNAL_SUBFRAMES; s++ ) - { - sumSquared = 0; - for( i = 0; i < dec_subframe_length; i++ ) - { - /* The energy will be less than dec_subframe_length * ( SKP_int16_MIN / 8 )^2. */ - /* Therefore we can accumulate with no risk of overflow (unless dec_subframe_length > 128) */ - x_tmp = X[ b ][ i + dec_subframe_offset ] >> 3; - sumSquared = Silk_macros.SKP_SMLABB( sumSquared, x_tmp, x_tmp ); - - /* Safety check */ - assert( sumSquared >= 0 ); - } - - /* add/saturate summed energy of current subframe */ - if( s < Silk_define.VAD_INTERNAL_SUBFRAMES - 1 ) - { - Xnrg[ b ] = Silk_SigProc_FIX.SKP_ADD_POS_SAT32( Xnrg[ b ], sumSquared ); - } - else - { - /* look-ahead subframe */ - Xnrg[ b ] = Silk_SigProc_FIX.SKP_ADD_POS_SAT32( Xnrg[ b ], sumSquared>>1 ); - } - - dec_subframe_offset += dec_subframe_length; - } - psSilk_VAD.XnrgSubfr[ b ] = sumSquared; - } - - /********************/ - /* Noise estimation */ - /********************/ - SKP_Silk_VAD_GetNoiseLevels( Xnrg, psSilk_VAD ); - - /***********************************************/ - /* Signal-plus-noise to noise ratio estimation */ - /***********************************************/ - sumSquared = 0; - input_tilt = 0; - for( b = 0; b < Silk_define.VAD_N_BANDS; b++ ) - { - speech_nrg = Xnrg[ b ] - psSilk_VAD.NL[ b ]; - if( speech_nrg > 0 ) - { - /* Divide, with sufficient resolution */ - if( ( Xnrg[ b ] & 0xFF800000 ) == 0 ) - { - NrgToNoiseRatio_Q8[ b ] = ( Xnrg[ b ] << 8 ) / ( psSilk_VAD.NL[ b ] + 1 ); - } - else - { - NrgToNoiseRatio_Q8[ b ] = Xnrg[ b ] / ( ( psSilk_VAD.NL[ b ] >> 8 ) + 1 ); - } - - /* Convert to log domain */ - SNR_Q7 = Silk_lin2log.SKP_Silk_lin2log( NrgToNoiseRatio_Q8[ b ] ) - 8 * 128; - - /* Sum-of-squares */ - sumSquared = Silk_macros.SKP_SMLABB( sumSquared, SNR_Q7, SNR_Q7 ); /* Q14 */ - - /* Tilt measure */ - if( speech_nrg < ( 1 << 20 ) ) { - /* Scale down SNR value for small subband speech energies */ - SNR_Q7 = Silk_macros.SKP_SMULWB( Silk_Inlines.SKP_Silk_SQRT_APPROX( speech_nrg ) << 6, SNR_Q7 ); - } - input_tilt = Silk_macros.SKP_SMLAWB( input_tilt, tiltWeights[ b ], SNR_Q7 ); - } - else - { - NrgToNoiseRatio_Q8[ b ] = 256; - } - } - - /* Mean-of-squares */ - sumSquared = sumSquared / Silk_define.VAD_N_BANDS; /* Q14 */ - - /* Root-mean-square approximation, scale to dBs, and write to output pointer */ - pSNR_dB_Q7[0] = ( short )( 3 * Silk_Inlines.SKP_Silk_SQRT_APPROX( sumSquared ) ); /* Q7 */ - - /*********************************/ - /* Speech Probability Estimation */ - /*********************************/ - SA_Q15 = Silk_sigm_Q15.SKP_Silk_sigm_Q15( Silk_macros.SKP_SMULWB( Silk_define.VAD_SNR_FACTOR_Q16, pSNR_dB_Q7[0] ) - Silk_define.VAD_NEGATIVE_OFFSET_Q5 ); - - /**************************/ - /* Frequency Tilt Measure */ - /**************************/ - pTilt_Q15[0] = ( Silk_sigm_Q15.SKP_Silk_sigm_Q15( input_tilt ) - 16384 ) << 1; - - /**************************************************/ - /* Scale the sigmoid output based on power levels */ - /**************************************************/ - speech_nrg = 0; - for( b = 0; b < Silk_define.VAD_N_BANDS; b++ ) - { - /* Accumulate signal-without-noise energies, higher frequency bands have more weight */ - speech_nrg += ( b + 1 ) * ( ( Xnrg[ b ] - psSilk_VAD.NL[ b ] ) >> 4 ); - } - - /* Power scaling */ - if( speech_nrg <= 0 ) - { - SA_Q15 = SA_Q15 >> 1; - } - else if( speech_nrg < 32768 ) - { - /* square-root */ - speech_nrg = Silk_Inlines.SKP_Silk_SQRT_APPROX( speech_nrg << 15 ); - SA_Q15 = Silk_macros.SKP_SMULWB( 32768 + speech_nrg, SA_Q15 ); - } - - /* Copy the resulting speech activity in Q8 to *pSA_Q8 */ - pSA_Q8[0] = Math.min( SA_Q15 >> 7, Silk_typedef.SKP_uint8_MAX ); - - /***********************************/ - /* Energy Level and SNR estimation */ - /***********************************/ - /* smoothing coefficient */ - smooth_coef_Q16 = Silk_macros.SKP_SMULWB( Silk_define.VAD_SNR_SMOOTH_COEF_Q18, Silk_macros.SKP_SMULWB( SA_Q15, SA_Q15 ) ); - for( b = 0; b < Silk_define.VAD_N_BANDS; b++ ) - { - /* compute smoothed energy-to-noise ratio per band */ - psSilk_VAD.NrgRatioSmth_Q8[ b ] = Silk_macros.SKP_SMLAWB( psSilk_VAD.NrgRatioSmth_Q8[ b ], - NrgToNoiseRatio_Q8[ b ] - psSilk_VAD.NrgRatioSmth_Q8[ b ], smooth_coef_Q16 ); - - /* signal to noise ratio in dB per band */ - SNR_Q7 = 3 * ( Silk_lin2log.SKP_Silk_lin2log( psSilk_VAD.NrgRatioSmth_Q8[b] ) - 8 * 128 ); - /* quality = sigmoid( 0.25 * ( SNR_dB - 16 ) ); */ - pQuality_Q15[ b ] = Silk_sigm_Q15.SKP_Silk_sigm_Q15( ( SNR_Q7 - 16 * 128 ) >> 4 ); - } - - return( ret ); - } - - /** - * Noise level estimation. - * @param pX subband energies. - * @param psSilk_VAD Silk VAD state. - */ - static void SKP_Silk_VAD_GetNoiseLevels - ( - int[] pX, /* I subband energies */ - SKP_Silk_VAD_state psSilk_VAD /* I/O Pointer to Silk VAD state */ - ) - { - int k; - int nl, nrg, inv_nrg; - int coef, min_coef; - - /* Initially faster smoothing */ - if( psSilk_VAD.counter < 1000 ) - { /* 1000 = 20 sec */ - min_coef = Silk_typedef.SKP_int16_MAX / ( ( psSilk_VAD.counter >> 4 ) + 1 ); - } - else - { - min_coef = 0; - } - - for( k = 0; k < Silk_define.VAD_N_BANDS; k++ ) - { - /* Get old noise level estimate for current band */ - nl = psSilk_VAD.NL[ k ]; - assert( nl >= 0 ); - - /* Add bias */ - nrg = Silk_SigProc_FIX.SKP_ADD_POS_SAT32( pX[ k ], psSilk_VAD.NoiseLevelBias[ k ] ); - assert( nrg > 0 ); - - /* Invert energies */ - inv_nrg = Silk_typedef.SKP_int32_MAX / nrg; - assert( inv_nrg >= 0 ); - - /* Less update when subband energy is high */ - if( nrg > nl<<3 ) - { - coef = Silk_define.VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 >> 3; - } - else if( nrg < nl ) - { - coef = Silk_define.VAD_NOISE_LEVEL_SMOOTH_COEF_Q16; - } - else - { - coef = Silk_macros.SKP_SMULWB( Silk_macros.SKP_SMULWW( inv_nrg, nl ), Silk_define.VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 << 1 ); - } - - /* Initially faster smoothing */ - coef = Math.max( coef, min_coef ); - - /* Smooth inverse energies */ - psSilk_VAD.inv_NL[ k ] = Silk_macros.SKP_SMLAWB( psSilk_VAD.inv_NL[ k ], inv_nrg - psSilk_VAD.inv_NL[ k ], coef ); - assert( psSilk_VAD.inv_NL[ k ] >= 0 ); - - /* Compute noise level by inverting again */ - nl = Silk_typedef.SKP_int32_MAX / psSilk_VAD.inv_NL[ k ]; - assert( nl >= 0 ); - - /* Limit noise levels (guarantee 7 bits of head room) */ - nl = Math.min( nl, 0x00FFFFFF ); - - /* Store as part of state */ - psSilk_VAD.NL[ k ] = nl; - } - - /* Increment frame counter */ - psSilk_VAD.counter++; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_VQ_nearest_neighbor_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_VQ_nearest_neighbor_FLP.java deleted file mode 100644 index 09db674fa..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_VQ_nearest_neighbor_FLP.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Dingxin Xu - */ -public class Silk_VQ_nearest_neighbor_FLP -{ - /** - * entropy constrained MATRIX-weighted VQ, for a single input data vector. - * @param ind Index of best codebook vector - * @param rate_dist Best weighted quant. error + mu * rate - * @param in Input vector to be quantized - * @param W Weighting matrix - * @param cb Codebook - * @param cl_Q6 Code length for each codebook vector - * @param mu Tradeoff between WSSE and rate - * @param L Number of vectors in codebook - */ - static void SKP_Silk_VQ_WMat_EC_FLP( - int []ind, /* O Index of best codebook vector */ - int ind_offset, - float []rate_dist, /* O Best weighted quant. error + mu * rate */ - final float []in, /* I Input vector to be quantized */ - int in_offset, - final float []W, /* I Weighting matrix */ - int W_offset, - final short []cb, /* I Codebook */ - final short []cl_Q6, /* I Code length for each codebook vector */ - final float mu, /* I Tradeoff between WSSE and rate */ - final int L /* I Number of vectors in codebook */ - ) - { -// SKP_int k; -// SKP_float sum1; -// SKP_float diff[ 5 ]; -// const SKP_int16 *cb_row; - int k; - float sum1; - float diff[] = new float[5]; - final short []cb_row; - int cb_row_offset = 0; - - /* Loop over codebook */ -// *rate_dist = SKP_float_MAX; - rate_dist[0] = Float.MAX_VALUE; - - cb_row = cb; - cb_row_offset = 0; - - for( k = 0; k < L; k++ ) { - /* Calc difference between in vector and cbk vector */ - diff[ 0 ] = in[ in_offset + 0 ] - cb_row[ 0 ] * Silk_define_FLP.Q14_CONVERSION_FAC; - diff[ 1 ] = in[ in_offset + 1 ] - cb_row[ 1 ] * Silk_define_FLP.Q14_CONVERSION_FAC; - diff[ 2 ] = in[ in_offset + 2 ] - cb_row[ 2 ] * Silk_define_FLP.Q14_CONVERSION_FAC; - diff[ 3 ] = in[ in_offset + 3 ] - cb_row[ 3 ] * Silk_define_FLP.Q14_CONVERSION_FAC; - diff[ 4 ] = in[ in_offset + 4 ] - cb_row[ 4 ] * Silk_define_FLP.Q14_CONVERSION_FAC; - - /* Weighted rate */ - sum1 = mu * cl_Q6[ k ] / 64.0f; - - /* Add weighted quantization error, assuming W is symmetric */ - /* first row of W */ - sum1 += diff[ 0 ] * ( W[ W_offset + 0 ] * diff[ 0 ] + - 2.0f * ( W[ W_offset + 1 ] * diff[ 1 ] + - W[ W_offset + 2 ] * diff[ 2 ] + - W[ W_offset + 3 ] * diff[ 3 ] + - W[ W_offset + 4 ] * diff[ 4 ] ) ); - - /* second row of W */ - sum1 += diff[ 1 ] * ( W[ W_offset + 6 ] * diff[ 1 ] + - 2.0f * ( W[ W_offset + 7 ] * diff[ 2 ] + - W[ W_offset + 8 ] * diff[ 3 ] + - W[ W_offset + 9 ] * diff[ 4 ] ) ); - - /* third row of W */ - sum1 += diff[ 2 ] * ( W[ W_offset + 12 ] * diff[ 2 ] + - 2.0f * ( W[ W_offset + 13 ] * diff[ 3 ] + - W[ W_offset + 14 ] * diff[ 4 ] ) ); - - /* fourth row of W */ - sum1 += diff[ 3 ] * ( W[ W_offset + 18 ] * diff[ 3 ] + - 2.0f * ( W[ W_offset + 19 ] * diff[ 4 ] ) ); - - /* last row of W */ - sum1 += diff[ 4 ] * ( W[ W_offset + 24 ] * diff[ 4 ] ); - - /* find best */ - if( sum1 < rate_dist[0] ) { - rate_dist[0] = sum1; - ind[ind_offset + 0] = k; - } - - /* Go to next cbk vector */ - cb_row_offset += Silk_define.LTP_ORDER; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_allpass_int.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_allpass_int.java deleted file mode 100644 index d04b7f295..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_allpass_int.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * First-order allpass filter with - * transfer function: - * - * A + Z^(-1) - * H(z) = ------------ - * 1 + A*Z^(-1) - * - * Implemented using minimum multiplier filter design. - * - * Reference: http://www.univ.trieste.it/~ramponi/teaching/ - * DSP/materiale/Ch6(2).pdf - * - * @author Dingxin Xu - */ -public class Silk_allpass_int -{ - /** - * First-order allpass filter. - * @param in Q25 input signal [len] - * @param in_offset offset of valid data. - * @param S Q25 state [1] - * @param S_offset offset of valid data. - * @param A Q15 coefficient (0 <= A < 32768) - * @param out Q25 output signal [len] - * @param out_offset offset of valid data. - * @param len Number of samples - */ - static void SKP_Silk_allpass_int( - final int []in, /* I: Q25 input signal [len] */ - int in_offset, - int []S, /* I/O: Q25 state [1] */ - int S_offset, - int A, /* I: Q15 coefficient (0 <= A < 32768) */ - int []out, /* O: Q25 output signal [len] */ - int out_offset, - final int len /* I: Number of samples */ - ) - { - int Y2, X2, S0; - int k; - - S0 = S[ S_offset+ 0 ]; - for( k = len - 1; k >= 0; k-- ) { - Y2 = in[in_offset + 0] - S0; - X2 = ( Y2 >> 15 ) * A + ( ( ( Y2 & 0x00007FFF ) * A ) >> 15 ); - ( out[out_offset++]) = S0 + X2; - S0 = in[in_offset++] + X2; - } - S[ S_offset + 0 ] = S0; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_allpass_int_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_allpass_int_FLP.java deleted file mode 100644 index 9c7609b44..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_allpass_int_FLP.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * first-order allpass filter. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_allpass_int_FLP -{ - /** - * first-order allpass filter. - * @param in input signal [len]. - * @param in_offset offset of valid data. - * @param S I/O: state [1]. - * @param S_offset offset of valid data. - * @param A coefficient (0 <= A < 1). - * @param out output signal [len]. - * @param out_offset offset of valid data. - * @param len number of samples. - */ -//TODO:float or double ??? - static void SKP_Silk_allpass_int_FLP - ( - float[] in, /* I: input signal [len] */ - int in_offset, - float[] S, /* I/O: state [1] */ - int S_offset, - float A, /* I: coefficient (0 <= A < 1) */ - float[] out, /* O: output signal [len] */ - int out_offset, - final int len /* I: number of samples */ - ) - { - float Y2, X2, S0; - int k; - - S0 = S[ S_offset ]; - for ( k = len-1; k >= 0; k-- ) - { - Y2 = in[in_offset] - S0; - X2 = Y2 * A; - out[out_offset++] = S0 + X2; - S0 = in[in_offset++] + X2; - } - S[ S_offset ] = S0; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_ana_filt_bank_1.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_ana_filt_bank_1.java deleted file mode 100644 index baa893fcb..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_ana_filt_bank_1.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Split signal into two decimated bands using first-order allpass filters. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_ana_filt_bank_1 -{ - /* Coefficients for 2-band filter bank based on first-order allpass filters */ - // old - static short[] A_fb1_20 = { 5394 << 1 }; - static short[] A_fb1_21 = { (short)(20623 << 1) }; /* wrap-around to negative number is intentional */ - - /** - * Split signal into two decimated bands using first-order allpass filters. - * @param in Input signal [N]. - * @param in_offset offset of valid data. - * @param S State vector [2]. - * @param S_offset offset of valid data. - * @param outL Low band [N/2]. - * @param outL_offset offset of valid data. - * @param outH High band [N/2]. - * @param outH_offset offset of valid data. - * @param scratch Scratch memory [3*N/2]. - * @param N Number of input samples. - */ - static void SKP_Silk_ana_filt_bank_1 - ( - short[] in, /* I: Input signal [N] */ - int in_offset, - int[] S, /* I/O: State vector [2] */ - int S_offset, - short[] outL, /* O: Low band [N/2] */ - int outL_offset, - short[] outH, /* O: High band [N/2] */ - int outH_offset, - int[] scratch, /* I: Scratch memory [3*N/2] */ // todo: remove - no longer used - final int N /* I: Number of input samples */ - ) - { - int k, N2 = N >> 1; - int in32, X, Y, out_1, out_2; - - /* Internal variables and state are in Q10 format */ - for( k = 0; k < N2; k++ ) - { - /* Convert to Q10 */ - in32 = in[ in_offset + 2 * k ] << 10; - - /* All-pass section for even input sample */ - Y = in32 - S[ S_offset + 0 ]; - X = Silk_macros.SKP_SMLAWB( Y, Y, A_fb1_21[ 0 ] ); - out_1 = S[ S_offset + 0 ] + X; - S[ S_offset + 0 ] = in32 + X; - - /* Convert to Q10 */ - in32 = in[ in_offset + 2 * k + 1 ] << 10; - - /* All-pass section for odd input sample, and add to output of previous section */ - Y = in32 - S[ S_offset + 1 ]; - X = Silk_macros.SKP_SMULWB( Y, A_fb1_20[ 0 ] ); - out_2 = S[ S_offset + 1 ] + X; - S[ S_offset + 1 ] = in32 + X; - - /* Add/subtract, convert back to int16 and store to output */ - outL[ outL_offset + k ] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out_2 + out_1, 11 ) ); - outH[ outH_offset + k ] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out_2 - out_1, 11 ) ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_apply_sine_window_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_apply_sine_window_FLP.java deleted file mode 100644 index b89e2e574..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_apply_sine_window_FLP.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Apply sine window to signal vector. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_apply_sine_window_FLP -{ - /** - * Apply sine window to signal vector. - * Window types: - * 0 -> sine window from 0 to pi. - * 1 -> sine window from 0 to pi/2. - * 2 -> sine window from pi/2 to pi. - * - * @param px_win Pointer to windowed signal. - * @param px_win_offset offset of valid data. - * @param px Pointer to input signal. - * @param px_offset offset of valid data. - * @param win_type Selects a window type. - * @param length Window length, multiple of 4. - */ -//TODO float or double - static void SKP_Silk_apply_sine_window_FLP( - float px_win[], /* O Pointer to windowed signal */ - int px_win_offset, - float px[], /* I Pointer to input signal */ - int px_offset, - final int win_type, /* I Selects a window type */ - final int length /* I Window length, multiple of 4 */ - ) - { - int k; - float freq, c, S0, S1; - - /* Length must be multiple of 4 */ - assert( ( length & 3 ) == 0 ); - - freq = Silk_SigProc_FLP.PI / ( length + 1 ); - if( win_type == 0 ) - { - freq = 2.0f * freq; - } - - /* Approximation of 2 * cos(f) */ - c = 2.0f - freq * freq; - - /* Initialize state */ - if( win_type < 2 ) - { - /* Start from 0 */ - S0 = 0.0f; - /* Approximation of sin(f) */ - S1 = freq; - } - else - { - /* Start from 1 */ - S0 = 1.0f; - /* Approximation of cos(f) */ - S1 = 0.5f * c; - } - - /* Uses the recursive equation: sin(n*f) = 2 * cos(f) * sin((n-1)*f) - sin((n-2)*f) */ - /* 4 samples at a time */ - for( k = 0; k < length; k += 4 ) - { - px_win[ px_win_offset + k + 0 ] = px[ px_offset + k + 0 ] * 0.5f * ( S0 + S1 ); - px_win[ px_win_offset + k + 1 ] = px[ px_offset + k + 1 ] * S1; - S0 = c * S1 - S0; - px_win[ px_win_offset + k + 2 ] = px[ px_offset + k + 2 ] * 0.5f * ( S1 + S0 ); - px_win[ px_win_offset + k + 3 ] = px[ px_offset + k + 3 ] * S0; - S1 = c * S0 - S1; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_autocorrelation_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_autocorrelation_FLP.java deleted file mode 100644 index a12689763..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_autocorrelation_FLP.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * compute autocorrelation. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_autocorrelation_FLP -{ - /** - * compute autocorrelation. - * @param results result (length correlationCount) - * @param results_offset offset of valid data. - * @param inputData input data to correlate - * @param inputData_offset offset of valid data. - * @param inputDataSize length of input - * @param correlationCount number of correlation taps to compute - */ - //TODO: float or double??? - static void SKP_Silk_autocorrelation_FLP( - float[] results, /* O result (length correlationCount) */ - int results_offset, - float[] inputData, /* I input data to correlate */ - int inputData_offset, - int inputDataSize, /* I length of input */ - int correlationCount /* I number of correlation taps to compute */ - ) - { - int i; - - if ( correlationCount > inputDataSize ) - { - correlationCount = inputDataSize; - } - - for( i = 0; i < correlationCount; i++ ) - { - results[ results_offset+i ] = (float)Silk_inner_product_FLP.SKP_Silk_inner_product_FLP( inputData,inputData_offset, inputData,inputData_offset + i, inputDataSize - i ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_biquad.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_biquad.java deleted file mode 100644 index 0778e1f0c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_biquad.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Second order ARMA filter - * Can handle slowly varying filter coefficients - * - * @author Jing Dai - */ -public class Silk_biquad -{ - /** - * Second order ARMA filter - * Can handle slowly varying filter coefficients - * @param in input signal - * @param in_offset offset of valid data. - * @param B MA coefficients, Q13 [3] - * @param A AR coefficients, Q13 [2] - * @param S state vector [2] - * @param out output signal - * @param out_offset offset of valid data. - * @param len signal length - */ - static void SKP_Silk_biquad( - short []in, /* I: input signal */ - int in_offset, - short []B, /* I: MA coefficients, Q13 [3] */ - short []A, /* I: AR coefficients, Q13 [2] */ - int []S, /* I/O: state vector [2] */ - short []out, /* O: output signal */ - int out_offset, - final int len /* I: signal length */ - ) - { - int k, in16; - int A0_neg, A1_neg, S0, S1, out32, tmp32; - - S0 = S[ 0 ]; - S1 = S[ 1 ]; - A0_neg = -A[ 0 ]; - A1_neg = -A[ 1 ]; - for( k = 0; k < len; k++ ) { - /* S[ 0 ], S[ 1 ]: Q13 */ - in16 = in[ in_offset + k ]; - out32 = Silk_macros.SKP_SMLABB( S0, in16, B[ 0 ] ); - - S0 = Silk_macros.SKP_SMLABB( S1, in16, B[ 1 ] ); - S0 += ( Silk_macros.SKP_SMULWB( out32, A0_neg ) << 3 ); - - - S1 = ( Silk_macros.SKP_SMULWB( out32, A1_neg ) << 3 ); - S1 = Silk_macros.SKP_SMLABB( S1, in16, B[ 2 ] ); - tmp32 = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32, 13 ) + 1; - out[ out_offset + k ] = (short)Silk_SigProc_FIX.SKP_SAT16( tmp32 ); - } - S[ 0 ] = S0; - S[ 1 ] = S1; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_biquad_alt.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_biquad_alt.java deleted file mode 100644 index 707c60a20..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_biquad_alt.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Second order ARMA filter, alternative implementation. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_biquad_alt -{ - /** - * Second order ARMA filter, alternative implementation. - * @param in Input signal. - * @param in_offset offset of valid data. - * @param B_Q28 MA coefficients [3]. - * @param A_Q28 AR coefficients [2]. - * @param S State vector [2]. - * @param out Output signal. - * @param out_offset offset of valid data. - * @param len Signal length (must be even). - */ - static void SKP_Silk_biquad_alt( - short[] in, /* I: Input signal */ - int in_offset, - int[] B_Q28, /* I: MA coefficients [3] */ - int[] A_Q28, /* I: AR coefficients [2] */ - int[] S, /* I/O: State vector [2] */ - short[] out, /* O: Output signal */ - int out_offset, - final int len /* I: Signal length (must be even) */ - ) - { - /* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */ - int k; - int inval, A0_U_Q28, A0_L_Q28, A1_U_Q28, A1_L_Q28, out32_Q14; - - /* Negate A_Q28 values and split in two parts */ - A0_L_Q28 = ( -A_Q28[ 0 ] ) & 0x00003FFF; /* lower part */ - A0_U_Q28 = ( -A_Q28[ 0 ] ) >> 14; /* upper part */ - A1_L_Q28 = ( -A_Q28[ 1 ] ) & 0x00003FFF; /* lower part */ - A1_U_Q28 = ( -A_Q28[ 1 ] ) >> 14; /* upper part */ - - for( k = 0; k < len; k++ ) - { - /* S[ 0 ], S[ 1 ]: Q12 */ - inval = in[ in_offset+k ]; - out32_Q14 = Silk_macros.SKP_SMLAWB( S[ 0 ], B_Q28[ 0 ], inval ) << 2; - - S[ 0 ] = S[1] + ( Silk_macros.SKP_SMULWB( out32_Q14, A0_L_Q28 ) >> 14 ); - S[ 0 ] = Silk_macros.SKP_SMLAWB( S[ 0 ], out32_Q14, A0_U_Q28 ); - S[ 0 ] = Silk_macros.SKP_SMLAWB( S[ 0 ], B_Q28[ 1 ], inval); - - S[ 1 ] = Silk_macros.SKP_SMULWB( out32_Q14, A1_L_Q28 ) >> 14; - S[ 1 ] = Silk_macros.SKP_SMLAWB( S[ 1 ], out32_Q14, A1_U_Q28 ); - S[ 1 ] = Silk_macros.SKP_SMLAWB( S[ 1 ], B_Q28[ 2 ], inval ); - - /* Scale back to Q0 and saturate */ - out[ out_offset+k ] = (short)Silk_SigProc_FIX.SKP_SAT16( ( out32_Q14 >> 14 ) + 2 ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_burg_modified_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_burg_modified_FLP.java deleted file mode 100644 index d4f24f07d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_burg_modified_FLP.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Calculates the reflection coefficients from the input vector - * Input vector contains nb_subfr sub vectors of length L_sub + D - * - * @author Dingxin Xu - */ -public class Silk_burg_modified_FLP -{ - static final int MAX_FRAME_SIZE = 544; // subfr_length * nb_subfr = ( 0.005 * 24000 + 16 ) * 4 = 544 - static final int MAX_NB_SUBFR = 4; - - /** - * Compute reflection coefficients from input signal. - * @param A prediction coefficients (length order). - * @param x input signal, length: nb_subfr*(D+L_sub). - * @param x_offset offset of valid data. - * @param subfr_length input signal subframe length (including D preceeding samples). - * @param nb_subfr number of subframes stacked in x. - * @param WhiteNoiseFrac fraction added to zero-lag autocorrelation. - * @param D order. - * @return - */ - static float SKP_Silk_burg_modified_FLP( /* O returns residual energy */ - float A[], /* O prediction coefficients (length order) */ - final float x[], /* I input signal, length: nb_subfr*(D+L_sub) */ - int x_offset, - final int subfr_length, /* I input signal subframe length (including D preceeding samples) */ - final int nb_subfr, /* I number of subframes stacked in x */ - final float WhiteNoiseFrac, /* I fraction added to zero-lag autocorrelation */ - final int D /* I order */ - ) - { - int k, n, s; - double C0, num, nrg_f, nrg_b, rc, Atmp, tmp1, tmp2; - float []x_ptr; - int x_ptr_offset; - double C_first_row[] = new double [ Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC ], - C_last_row[] = new double [ Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC ]; - double CAf[] = new double [ Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC + 1 ], - CAb[] = new double [ Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC + 1 ]; - double Af[] = new double [ Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC ]; - - assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE ); - assert( nb_subfr <= MAX_NB_SUBFR ); - - /* Compute autocorrelations, added over subframes */ - C0 = Silk_energy_FLP.SKP_Silk_energy_FLP( x, x_offset, nb_subfr * subfr_length ); - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x; - x_ptr_offset = x_offset + s * subfr_length; - for( n = 1; n < D + 1; n++ ) { - C_first_row[ n - 1 ] += Silk_inner_product_FLP.SKP_Silk_inner_product_FLP( x_ptr, x_ptr_offset, - x_ptr, x_ptr_offset + n, subfr_length - n ); - } - } - System.arraycopy(C_first_row, 0, C_last_row, 0, Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC); - - /* Initialize */ - CAb[ 0 ] = CAf[ 0 ] = C0 + WhiteNoiseFrac * C0 + 1e-9f; - - for( n = 0; n < D; n++ ) { - /* Update first row of correlation matrix (without first element) */ - /* Update last row of correlation matrix (without last element, stored in reversed order) */ - /* Update C * Af */ - /* Update C * flipud(Af) (stored in reversed order) */ - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x; - x_ptr_offset = x_offset + s * subfr_length; - tmp1 = x_ptr[ x_ptr_offset + n ]; - tmp2 = x_ptr[ x_ptr_offset + subfr_length - n - 1 ]; - for( k = 0; k < n; k++ ) { - C_first_row[ k ] -= x_ptr[ x_ptr_offset + n ] * x_ptr[ x_ptr_offset + n - k - 1 ]; - C_last_row[ k ] -= x_ptr[ x_ptr_offset + subfr_length - n - 1 ] * x_ptr[ x_ptr_offset + subfr_length - n + k ]; - Atmp = Af[ k ]; - tmp1 += x_ptr[ x_ptr_offset + n - k - 1 ] * Atmp; - tmp2 += x_ptr[ x_ptr_offset + subfr_length - n + k ] * Atmp; - } - for( k = 0; k <= n; k++ ) { - CAf[ k ] -= tmp1 * x_ptr[ x_ptr_offset + n - k ]; - CAb[ k ] -= tmp2 * x_ptr[ x_ptr_offset + subfr_length - n + k - 1 ]; - } - } - tmp1 = C_first_row[ n ]; - tmp2 = C_last_row[ n ]; - for( k = 0; k < n; k++ ) { - Atmp = Af[ k ]; - tmp1 += C_last_row[ n - k - 1 ] * Atmp; - tmp2 += C_first_row[ n - k - 1 ] * Atmp; - } - CAf[ n + 1 ] = tmp1; - CAb[ n + 1 ] = tmp2; - - /* Calculate nominator and denominator for the next order reflection (parcor) coefficient */ - num = CAb[ n + 1 ]; - nrg_b = CAb[ 0 ]; - nrg_f = CAf[ 0 ]; - for( k = 0; k < n; k++ ) { - Atmp = Af[ k ]; - num += CAb[ n - k ] * Atmp; - nrg_b += CAb[ k + 1 ] * Atmp; - nrg_f += CAf[ k + 1 ] * Atmp; - } - assert( nrg_f > 0.0 ); - assert( nrg_b > 0.0 ); - - /* Calculate the next order reflection (parcor) coefficient */ - rc = -2.0 * num / ( nrg_f + nrg_b ); - assert( rc > -1.0 && rc < 1.0 ); - - /* Update the AR coefficients */ - for( k = 0; k < (n + 1) >> 1; k++ ) { - tmp1 = Af[ k ]; - tmp2 = Af[ n - k - 1 ]; - Af[ k ] = tmp1 + rc * tmp2; - Af[ n - k - 1 ] = tmp2 + rc * tmp1; - } - Af[ n ] = rc; - - /* Update C * Af and C * Ab */ - for( k = 0; k <= n + 1; k++ ) { - tmp1 = CAf[ k ]; - CAf[ k ] += rc * CAb[ n - k + 1 ]; - CAb[ n - k + 1 ] += rc * tmp1; - } - } - - /* Return residual energy */ - nrg_f = CAf[ 0 ]; - tmp1 = 1.0; - for( k = 0; k < D; k++ ) { - Atmp = Af[ k ]; - nrg_f += CAf[ k + 1 ] * Atmp; - tmp1 += Atmp * Atmp; - A[ k ] = (float)(-Atmp); - } - nrg_f -= WhiteNoiseFrac * C0 * tmp1; - - return (float)nrg_f; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_bwexpander.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_bwexpander.java deleted file mode 100644 index 34c3c6464..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_bwexpander.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Chirp (bandwidth expand) LP AR filter - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_bwexpander -{ - /** - * Chirp (bandwidth expand) LP AR filter. - * @param ar AR filter to be expanded (without leading 1). - * @param d Length of ar. - * @param chirp_Q16 Chirp factor (typically in the range 0 to 1). - */ - static void SKP_Silk_bwexpander( - short []ar, /* I/O AR filter to be expanded (without leading 1) */ - final int d, /* I Length of ar */ - int chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */ - ) - { - int i; - int chirp_minus_one_Q16; - - chirp_minus_one_Q16 = chirp_Q16 - 65536; - - /* NB: Dont use SKP_SMULWB, instead of SKP_RSHIFT_ROUND( SKP_MUL() , 16 ), below. */ - /* Bias in SKP_SMULWB can lead to unstable filters */ - for( i = 0; i < d - 1; i++ ) { - ar[ i ] = (short)Silk_SigProc_FIX.SKP_RSHIFT_ROUND( ( chirp_Q16 * ar[ i ]), 16 ); - chirp_Q16 += Silk_SigProc_FIX.SKP_RSHIFT_ROUND( ( chirp_Q16 * chirp_minus_one_Q16 ), 16 ); - } - ar[ d - 1 ] = (short)Silk_SigProc_FIX.SKP_RSHIFT_ROUND( ( chirp_Q16 * ar[ d - 1 ] ), 16 ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_bwexpander_32.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_bwexpander_32.java deleted file mode 100644 index 0971fbee7..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_bwexpander_32.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_bwexpander_32 -{ - /** - * Chirp (bandwidth expand) LP AR filter. - * @param ar AR filter to be expanded (without leading 1). - * @param d Length of ar. - * @param chirp_Q16 Chirp factor in Q16. - */ - static void SKP_Silk_bwexpander_32( - int []ar, /* I/O AR filter to be expanded (without leading 1) */ - final int d, /* I Length of ar */ - int chirp_Q16 /* I Chirp factor in Q16 */ - ) - { - int i; - int tmp_chirp_Q16; - - tmp_chirp_Q16 = chirp_Q16; - for( i = 0; i < d - 1; i++ ) { - ar[ i ] = Silk_macros.SKP_SMULWW( ar[ i ], tmp_chirp_Q16 ); - tmp_chirp_Q16 = Silk_macros.SKP_SMULWW( chirp_Q16, tmp_chirp_Q16 ); - } - ar[ d - 1 ] = Silk_macros.SKP_SMULWW( ar[ d - 1 ], tmp_chirp_Q16 ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_bwexpander_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_bwexpander_FLP.java deleted file mode 100644 index fc88c9962..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_bwexpander_FLP.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_bwexpander_FLP -{ - /** - * Chirp (bw expand) LP AR filter. - * @param ar AR filter to be expanded (without leading 1). - * @param ar_offset offset of valid data. - * @param d length of ar. - * @param chirp chirp factor (typically in range (0..1) ). - */ - static void SKP_Silk_bwexpander_FLP( - float[] ar, /* I/O AR filter to be expanded (without leading 1) */ - int ar_offset, - final int d, /* I length of ar */ - final float chirp /* I chirp factor (typically in range (0..1) ) */ - ) - { - int i; - float cfac = chirp; - - for( i = 0; i < d - 1; i++ ) - { - ar[ ar_offset+i ] *= cfac; - cfac *= chirp; - } - ar[ ar_offset + d - 1 ] *= cfac; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_code_signs.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_code_signs.java deleted file mode 100644 index 449b32dde..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_code_signs.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_code_signs -{ - /* shifting avoids if-statement */ -// #define SKP_enc_map(a) ( SKP_RSHIFT( (a), 15 ) + 1 ) - static int SKP_enc_map(int a) - { - return (a>>15)+1; - } - -// #define SKP_dec_map(a) ( SKP_LSHIFT( (a), 1 ) - 1 ) - static int SKP_dec_map(int a) - { - return (a<<1)-1; - } - - /** - * Encodes signs of excitation. - * @param sRC Range coder state. - * @param q Pulse signal. - * @param length Length of input. - * @param sigtype Signal type. - * @param QuantOffsetType QuantOffsetType. - * @param RateLevelIndex Rate level index. - */ - static void SKP_Silk_encode_signs( - SKP_Silk_range_coder_state sRC, /* I/O Range coder state */ - byte[] q, /* I Pulse signal */ - final int length, /* I Length of input */ - final int sigtype, /* I Signal type */ - final int QuantOffsetType, /* I Quantization offset type */ - final int RateLevelIndex /* I Rate level index */ - ) - { - int i; - int inData; - int[] cdf = new int[3]; - - i = Silk_macros.SKP_SMULBB( Silk_define.N_RATE_LEVELS - 1, ( sigtype << 1 ) + QuantOffsetType ) + RateLevelIndex; - cdf[ 0 ] = 0; - cdf[ 1 ] = Silk_tables_sign.SKP_Silk_sign_CDF[ i ]; - cdf[ 2 ] = 65535; - - for( i = 0; i < length; i++ ) - { - if( q[ i ] != 0 ) - { -// inData = SKP_enc_map( q[ i ] ); /* - = 0, + = 1 */ - inData = (q[i] >>15) + 1; /* - = 0, + = 1 */ - Silk_range_coder.SKP_Silk_range_encoder( sRC, inData, cdf, 0 ); - } - } - } - - /** - * Decodes signs of excitation. - * @param sRC Range coder state. - * @param q pulse signal. - * @param length length of output. - * @param sigtype Signal type. - * @param QuantOffsetType Quantization offset type. - * @param RateLevelIndex Rate Level Index. - */ - static void SKP_Silk_decode_signs( - SKP_Silk_range_coder_state sRC, /* I/O Range coder state */ - int q[], /* I/O pulse signal */ - final int length, /* I length of output */ - final int sigtype, /* I Signal type */ - final int QuantOffsetType, /* I Quantization offset type */ - final int RateLevelIndex /* I Rate Level Index */ - ) - { - int i; - int data; - int data_ptr[] = new int[1]; - int[] cdf = new int[3]; - - i = Silk_macros.SKP_SMULBB( Silk_define.N_RATE_LEVELS - 1, ( sigtype << 1 ) + QuantOffsetType ) + RateLevelIndex; - cdf[ 0 ] = 0; - cdf[ 1 ] = Silk_tables_sign.SKP_Silk_sign_CDF[ i ]; - cdf[ 2 ] = 65535; - - for( i = 0; i < length; i++ ) { - if( q[ i ] > 0 ) { - Silk_range_coder.SKP_Silk_range_decoder( data_ptr, 0, sRC, cdf, 0, 1 ); - data = data_ptr[0]; - /* attach sign */ - /* implementation with shift, subtraction, multiplication */ -// q[ i ] *= SKP_dec_map( data ); - q[ i ] *= (data<<1) - 1; - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_common_pitch_est_defines.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_common_pitch_est_defines.java deleted file mode 100644 index 3344f8d53..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_common_pitch_est_defines.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Definitions For Fix pitch estimator. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_common_pitch_est_defines -{ - static final int PITCH_EST_MAX_FS_KHZ = 24; /* Maximum sampling frequency used */ - - static final int PITCH_EST_FRAME_LENGTH_MS = 40; /* 40 ms */ - - static final int PITCH_EST_MAX_FRAME_LENGTH = (PITCH_EST_FRAME_LENGTH_MS * PITCH_EST_MAX_FS_KHZ); - static final int PITCH_EST_MAX_FRAME_LENGTH_ST_1 = (PITCH_EST_MAX_FRAME_LENGTH >> 2); - static final int PITCH_EST_MAX_FRAME_LENGTH_ST_2 = (PITCH_EST_MAX_FRAME_LENGTH >> 1); -//TODO: PITCH_EST_SUB_FRAME is neither defined nor used, temporally ignore it; -// static final int PITCH_EST_MAX_SF_FRAME_LENGTH = (PITCH_EST_SUB_FRAME * PITCH_EST_MAX_FS_KHZ); - - static final int PITCH_EST_MAX_LAG_MS = 18; /* 18 ms -> 56 Hz */ - static final int PITCH_EST_MIN_LAG_MS = 2; /* 2 ms -> 500 Hz */ - static final int PITCH_EST_MAX_LAG = (PITCH_EST_MAX_LAG_MS * PITCH_EST_MAX_FS_KHZ); - static final int PITCH_EST_MIN_LAG = (PITCH_EST_MIN_LAG_MS * PITCH_EST_MAX_FS_KHZ); - - static final int PITCH_EST_NB_SUBFR = 4; - - static final int PITCH_EST_D_SRCH_LENGTH = 24; - - static final int PITCH_EST_MAX_DECIMATE_STATE_LENGTH = 7; - - static final int PITCH_EST_NB_STAGE3_LAGS = 5; - - static final int PITCH_EST_NB_CBKS_STAGE2 = 3; - static final int PITCH_EST_NB_CBKS_STAGE2_EXT = 11; - - static final int PITCH_EST_CB_mn2 = 1; - static final int PITCH_EST_CB_mx2 = 2; - - static final int PITCH_EST_NB_CBKS_STAGE3_MAX = 34; - static final int PITCH_EST_NB_CBKS_STAGE3_MID = 24; - static final int PITCH_EST_NB_CBKS_STAGE3_MIN = 16; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_control.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_control.java deleted file mode 100644 index 99bb3a477..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_control.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Silk codec encoder/decoder control class. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_control -{ -} - -/** - * Class for controlling encoder operation - * - * @author Jing Dai - * @author Dingxin Xu - */ -class SKP_SILK_SDK_EncControlStruct -{ - /** - * (Input) Input signal sampling rate in Hertz; 8000/12000/16000/24000. - */ - int API_sampleRate; - - /** - * (Input) Maximum internal sampling rate in Hertz; 8000/12000/16000/24000. - */ - int maxInternalSampleRate; - - /** - * (Input) Number of samples per packet; must be equivalent of 20, 40, 60, 80 or 100 ms. - */ - int packetSize; - - /** - * (Input) Bitrate during active speech in bits/second; internally limited. - */ - int bitRate; - - /** - * (Inpupt) Uplink packet loss in percent (0-100). - */ - int packetLossPercentage; - - /** - * (Input) Complexity mode; 0 is lowest; 1 is medium and 2 is highest complexity. - */ - int complexity; - - /** - * (Input) Flag to enable in-band Forward Error Correction (FEC); 0/1 - */ - int useInBandFEC; - - /** - * (Input) Flag to enable discontinuous transmission (DTX); 0/1 - */ - int useDTX; -} - -/** - * Class for controlling decoder operation and reading decoder status. - * @author Jing Dai - * @author Dingxin Xu - */ -class SKP_SILK_SDK_DecControlStruct -{ - /** - * (Input) Output signal sampling rate in Hertz; 8000/12000/16000/24000. - */ - int API_sampleRate; - - /** - * (Output) Number of samples per frame. - */ - int frameSize; - - /** - * (Output) Frames per packet 1, 2, 3, 4, 5. - */ - int framesPerPacket; - - /** - * (Output) Flag to indicate that the decoder has remaining payloads internally. - */ - int moreInternalDecoderFrames; - - /** - * (Output) Distance between main payload and redundant payload in packets. - */ - int inBandFECOffset; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_control_codec_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_control_codec_FLP.java deleted file mode 100644 index d0377863c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_control_codec_FLP.java +++ /dev/null @@ -1,665 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_control_codec_FLP { - /** - * Control encoder SNR. - * - * @param psEnc - * Pointer to Silk encoder state FLP - * @param API_fs_Hz - * External (API) sampling rate (Hz). - * @param max_internal_fs_kHz - * Maximum internal sampling rate (kHz). - * @param PacketSize_ms - * Packet length (ms). - * @param TargetRate_bps - * Target max bitrate (if SNR_dB == 0). - * @param PacketLoss_perc - * Packet loss rate (in percent). - * @param INBandFEC_enabled - * Enable (1) / disable (0) inband FEC. - * @param DTX_enabled - * Enable / disable DTX. - * @param InputFramesize_ms - * Inputframe in ms. - * @param Complexity - * Complexity (0->low; 1->medium; 2->high). - * @return - */ - static int SKP_Silk_control_encoder_FLP( - SKP_Silk_encoder_state_FLP psEnc, /* I/O Pointer to Silk encoder state FLP */ - final int API_fs_Hz, /* I External (API) sampling rate (Hz) */ - final int max_internal_fs_kHz,/* I Maximum internal sampling rate (kHz) */ - final int PacketSize_ms, /* I Packet length (ms) */ - int TargetRate_bps, /* I Target max bitrate (if SNR_dB == 0) */ - final int PacketLoss_perc, /* I Packet loss rate (in percent) */ - final int INBandFEC_enabled, /* I Enable (1) / disable (0) inband FEC */ - final int DTX_enabled, /* I Enable / disable DTX */ - final int InputFramesize_ms, /* I Inputframe in ms */ - final int Complexity /* I Complexity (0->low; 1->medium; 2->high) */ - ) - { - int LBRRRate_thres_bps; - int k, fs_kHz, ret = 0; - float frac; - int[] rateTable; - - /* State machine for the SWB/WB switching */ - fs_kHz = psEnc.sCmn.fs_kHz; - - /* Only switch during low speech activity, when no frames are sitting in the payload buffer */ - if( API_fs_Hz == 8000 || fs_kHz == 0 || API_fs_Hz < fs_kHz * 1000 || fs_kHz > max_internal_fs_kHz ) - { - /* Switching is not possible, encoder just initialized, internal mode higher than external, */ - /* or internal mode higher than maximum allowed internal mode */ - fs_kHz = Math.min( API_fs_Hz/1000, max_internal_fs_kHz ); - } - else - { - /* Accumulate the difference between the target rate and limit for switching down */ - psEnc.sCmn.bitrateDiff += InputFramesize_ms * (TargetRate_bps - psEnc.sCmn.bitrate_threshold_down); - psEnc.sCmn.bitrateDiff = Math.min( psEnc.sCmn.bitrateDiff, 0 ); - - if( psEnc.speech_activity < 0.5f && psEnc.sCmn.nFramesInPayloadBuf == 0 ) - { /* Low speech activity and payload buffer empty */ - /* Check if we should switch down */ - if(Silk_define.SWITCH_TRANSITION_FILTERING!=0) - { - if( ( psEnc.sCmn.sLP.transition_frame_no == 0 ) && /* Transition phase not active */ - ( psEnc.sCmn.bitrateDiff <= -Silk_define.ACCUM_BITS_DIFF_THRESHOLD || /* Bitrate threshold is met */ - ( psEnc.sCmn.sSWBdetect.WB_detected * psEnc.sCmn.fs_kHz == 24 ) ) ) - { /* Forced down-switching due to WB input */ - psEnc.sCmn.sLP.transition_frame_no = 1; /* Begin transition phase */ - psEnc.sCmn.sLP.mode = 0; /* Switch down */ - } - else if( - ( psEnc.sCmn.sLP.transition_frame_no >= Silk_define.TRANSITION_FRAMES_DOWN ) && /* Transition phase complete */ - ( psEnc.sCmn.sLP.mode == 0 ) ) - { /* Ready to switch down */ - psEnc.sCmn.sLP.transition_frame_no = 0; /* Ready for new transition phase */ - psEnc.sCmn.bitrateDiff = 0; - - /* Switch to a lower sample frequency */ - if( psEnc.sCmn.fs_kHz == 24 ) - { - fs_kHz = 16; - } - else if( psEnc.sCmn.fs_kHz == 16 ) - { - fs_kHz = 12; - } - else - { - assert( psEnc.sCmn.fs_kHz == 12 ); - fs_kHz = 8; - } - } - } - else - { - if( psEnc.sCmn.bitrateDiff <= -Silk_define.ACCUM_BITS_DIFF_THRESHOLD ) - { /* Bitrate threshold is met */ - psEnc.sCmn.bitrateDiff = 0; - - /* Switch to a lower sample frequency */ - if( psEnc.sCmn.fs_kHz == 24 ) - { - fs_kHz = 16; - } - else if( psEnc.sCmn.fs_kHz == 16 ) - { - fs_kHz = 12; - } - else - { - assert( psEnc.sCmn.fs_kHz == 12 ); - fs_kHz = 8; - } - } - } - /* Check if we should switch up */ - if(Silk_define.SWITCH_TRANSITION_FILTERING != 0) - { - if( ( ( psEnc.sCmn.fs_kHz * 1000 < API_fs_Hz ) && - ( TargetRate_bps >= psEnc.sCmn.bitrate_threshold_up ) && - ( psEnc.sCmn.sSWBdetect.WB_detected * psEnc.sCmn.fs_kHz != 16 ) ) && - ( ( psEnc.sCmn.fs_kHz == 16 ) && ( max_internal_fs_kHz >= 24 ) || - ( psEnc.sCmn.fs_kHz == 12 ) && ( max_internal_fs_kHz >= 16 ) || - ( psEnc.sCmn.fs_kHz == 8 ) && ( max_internal_fs_kHz >= 12 ) ) - // #if SWITCH_TRANSITION_FILTERING - && ( psEnc.sCmn.sLP.transition_frame_no == 0 ) ) - { /* No transition phase running, ready to switch */ - psEnc.sCmn.sLP.mode = 1; /* Switch up */ - // #else - // ) { - // #endif - psEnc.sCmn.bitrateDiff = 0; - - /* Switch to a higher sample frequency */ - if( psEnc.sCmn.fs_kHz == 8 ) - { - fs_kHz = 12; - } - else if( psEnc.sCmn.fs_kHz == 12 ) - { - fs_kHz = 16; - } - else - { - assert( psEnc.sCmn.fs_kHz == 16 ); - fs_kHz = 24; - } - } - } - else - { - /* Check if we should switch up */ - if( ( ( psEnc.sCmn.fs_kHz * 1000 < API_fs_Hz ) && - ( TargetRate_bps >= psEnc.sCmn.bitrate_threshold_up ) && - ( psEnc.sCmn.sSWBdetect.WB_detected * psEnc.sCmn.fs_kHz != 16 ) ) && - ( ( psEnc.sCmn.fs_kHz == 16 ) && ( max_internal_fs_kHz >= 24 ) || - ( psEnc.sCmn.fs_kHz == 12 ) && ( max_internal_fs_kHz >= 16 ) || - ( psEnc.sCmn.fs_kHz == 8 ) && ( max_internal_fs_kHz >= 12 ) ) -// // #if SWITCH_TRANSITION_FILTERING -// && ( psEnc.sCmn.sLP.transition_frame_no == 0 ) ) -// { /* No transition phase running, ready to switch */ -// psEnc.sCmn.sLP.mode = 1; /* Switch up */ -// // #else - ) { - // #endif - psEnc.sCmn.bitrateDiff = 0; - - /* Switch to a higher sample frequency */ - if( psEnc.sCmn.fs_kHz == 8 ) - { - fs_kHz = 12; - } - else if( psEnc.sCmn.fs_kHz == 12 ) - { - fs_kHz = 16; - } - else - { - assert( psEnc.sCmn.fs_kHz == 16 ); - fs_kHz = 24; - } - } - } - } - } - - if(Silk_define.SWITCH_TRANSITION_FILTERING != 0) - { - /* After switching up, stop transition filter during speech inactivity */ - if( ( psEnc.sCmn.sLP.mode == 1 ) && - ( psEnc.sCmn.sLP.transition_frame_no >= Silk_define.TRANSITION_FRAMES_UP ) && - ( psEnc.speech_activity < 0.5f ) && - ( psEnc.sCmn.nFramesInPayloadBuf == 0 ) ) - { - - psEnc.sCmn.sLP.transition_frame_no = 0; - - /* Reset transition filter state */ - Arrays.fill(psEnc.sCmn.sLP.In_LP_State, 0, 2, 0); - } - } - - /* Resampler setup */ - if( psEnc.sCmn.fs_kHz != fs_kHz || psEnc.sCmn.prev_API_fs_Hz != API_fs_Hz ) - { - /* Allocate space for worst case temporary upsampling, 8 to 48 kHz, so a factor 6 */ - short[] x_buf_API_fs_Hz = new short[ ( Silk_define.MAX_API_FS_KHZ / 8 ) * ( 2 * Silk_define.MAX_FRAME_LENGTH + Silk_define.LA_SHAPE_MAX ) ]; - short[] x_bufFIX = new short[ 2 * Silk_define.MAX_FRAME_LENGTH + Silk_define.LA_SHAPE_MAX ]; - - int nSamples_temp = 2 * psEnc.sCmn.frame_length + psEnc.sCmn.la_shape; - - Silk_SigProc_FLP.SKP_float2short_array( x_bufFIX, 0, psEnc.x_buf, 0, 2 * Silk_define.MAX_FRAME_LENGTH + Silk_define.LA_SHAPE_MAX ); - - if( fs_kHz * 1000 < API_fs_Hz && psEnc.sCmn.fs_kHz != 0 ) - { - /* Resample buffered data in x_buf to API_fs_Hz */ - - SKP_Silk_resampler_state_struct temp_resampler_state = new SKP_Silk_resampler_state_struct(); - - /* Initialize resampler for temporary resampling of x_buf data to API_fs_Hz */ - ret += Silk_resampler.SKP_Silk_resampler_init( temp_resampler_state, psEnc.sCmn.fs_kHz * 1000, API_fs_Hz ); - - /* Temporary resampling of x_buf data to API_fs_Hz */ - ret += Silk_resampler.SKP_Silk_resampler( temp_resampler_state, x_buf_API_fs_Hz,0, x_bufFIX,0, nSamples_temp ); - - /* Calculate number of samples that has been temporarily upsampled */ - nSamples_temp = ( nSamples_temp * API_fs_Hz ) / ( psEnc.sCmn.fs_kHz * 1000 ); - - /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */ - ret += Silk_resampler.SKP_Silk_resampler_init( psEnc.sCmn.resampler_state, API_fs_Hz, fs_kHz * 1000 ); - - } - else - { - /* Copy data */ - System.arraycopy(x_bufFIX, 0, x_buf_API_fs_Hz, 0, nSamples_temp); - } - - if( 1000 * fs_kHz != API_fs_Hz ) - { - /* Correct resampler state (unless resampling by a factor 1) by resampling buffered data from API_fs_Hz to fs_kHz */ - ret += Silk_resampler.SKP_Silk_resampler( psEnc.sCmn.resampler_state, x_bufFIX,0, x_buf_API_fs_Hz,0, nSamples_temp ); - } - Silk_SigProc_FLP.SKP_short2float_array( psEnc.x_buf,0, x_bufFIX,0, 2 * Silk_define.MAX_FRAME_LENGTH + Silk_define.LA_SHAPE_MAX ); - } - - psEnc.sCmn.prev_API_fs_Hz = API_fs_Hz; - - /* Set internal sampling frequency */ - if( psEnc.sCmn.fs_kHz != fs_kHz ) { -//TODO:whether need to set 0 explicitly??? - /* reset part of the state */ -// SKP_memset( &psEnc->sShape, 0, sizeof( SKP_Silk_shape_state_FLP ) ); - psEnc.sShape.memZero(); -// SKP_memset( &psEnc->sPrefilt, 0, sizeof( SKP_Silk_prefilter_state_FLP ) ); - psEnc.sPrefilt.memZero(); -// SKP_memset( &psEnc->sNSQ, 0, sizeof( SKP_Silk_nsq_state ) ); - psEnc.sNSQ.memZero(); -// SKP_memset( &psEnc->sPred, 0, sizeof( SKP_Silk_predict_state_FLP ) ); - psEnc.sPred.memZero(); -// SKP_memset( psEnc->sNSQ.xq, 0, ( 2 * MAX_FRAME_LENGTH ) * sizeof( SKP_float ) ); -//TODO: psEnc.sNSQ.vq is of short[], why sizeof(SKP_float)??? - Arrays.fill(psEnc.sNSQ.xq, 0, 2 * Silk_define.MAX_FRAME_LENGTH, (short)0); -// SKP_memset( psEnc->sNSQ_LBRR.xq, 0, ( 2 * MAX_FRAME_LENGTH ) * sizeof( SKP_float ) ); - Arrays.fill(psEnc.sNSQ_LBRR.xq, (short)0); -// SKP_memset( psEnc->sCmn.LBRR_buffer, 0, MAX_LBRR_DELAY * sizeof( SKP_SILK_LBRR_struct ) ); - for(int i=0; i < Silk_define.MAX_LBRR_DELAY; i++) - { - psEnc.sCmn.LBRR_buffer[i].memZero(); - } - - if(Silk_define.SWITCH_TRANSITION_FILTERING != 0) - { - Arrays.fill(psEnc.sCmn.sLP.In_LP_State, 0, 2, 0); - if( psEnc.sCmn.sLP.mode == 1 ) - { - /* Begin transition phase */ - psEnc.sCmn.sLP.transition_frame_no = 1; - } - else - { - /* End transition phase */ - psEnc.sCmn.sLP.transition_frame_no = 0; - } - } - psEnc.sCmn.inputBufIx = 0; - psEnc.sCmn.nFramesInPayloadBuf = 0; - psEnc.sCmn.nBytesInPayloadBuf = 0; - psEnc.sCmn.oldest_LBRR_idx = 0; - psEnc.sCmn.TargetRate_bps = 0; /* Ensures that psEnc->SNR_dB is recomputed */ - -// SKP_memset( psEnc->sPred.prev_NLSFq, 0, MAX_LPC_ORDER * sizeof( SKP_float ) ); - Arrays.fill(psEnc.sPred.prev_NLSFq, 0, Silk_define.MAX_LPC_ORDER, 0); - - /* Initialize non-zero parameters */ - psEnc.sCmn.prevLag = 100; - psEnc.sCmn.prev_sigtype = Silk_define.SIG_TYPE_UNVOICED; - psEnc.sCmn.first_frame_after_reset = 1; - psEnc.sPrefilt.lagPrev = 100; - psEnc.sShape.LastGainIndex = 1; - psEnc.sNSQ.lagPrev = 100; - psEnc.sNSQ.prev_inv_gain_Q16 = 65536; - psEnc.sNSQ_LBRR.prev_inv_gain_Q16 = 65536; - - psEnc.sCmn.fs_kHz = fs_kHz; - if( psEnc.sCmn.fs_kHz == 8 ) - { - psEnc.sCmn.predictLPCOrder = Silk_define.MIN_LPC_ORDER; -// psEnc.sCmn.psNLSF_CB[ 0 ] = &SKP_Silk_NLSF_CB0_10; -// psEnc.sCmn.psNLSF_CB[ 1 ] = &SKP_Silk_NLSF_CB1_10; -// psEnc.psNLSF_CB_FLP[ 0 ] = &SKP_Silk_NLSF_CB0_10_FLP; -// psEnc.psNLSF_CB_FLP[ 1 ] = &SKP_Silk_NLSF_CB1_10_FLP; - psEnc.sCmn.psNLSF_CB[ 0 ] = Silk_tables_NLSF_CB0_10.SKP_Silk_NLSF_CB0_10; - psEnc.sCmn.psNLSF_CB[ 1 ] = Silk_tables_NLSF_CB1_10.SKP_Silk_NLSF_CB1_10; - psEnc.psNLSF_CB_FLP[ 0 ] = Silk_tables_NLSF_CB0_10_FLP.SKP_Silk_NLSF_CB0_10_FLP; - psEnc.psNLSF_CB_FLP[ 1 ] = Silk_tables_NLSF_CB1_10_FLP.SKP_Silk_NLSF_CB1_10_FLP; - } - else - { - psEnc.sCmn.predictLPCOrder = Silk_define.MAX_LPC_ORDER; - psEnc.sCmn.psNLSF_CB[ 0 ] = Silk_tables_NLSF_CB0_16.SKP_Silk_NLSF_CB0_16; - psEnc.sCmn.psNLSF_CB[ 1 ] = Silk_tables_NLSF_CB1_16.SKP_Silk_NLSF_CB1_16; - psEnc.psNLSF_CB_FLP[ 0 ] = Silk_tables_NLSF_CB0_16_FLP.SKP_Silk_NLSF_CB0_16_FLP; - psEnc.psNLSF_CB_FLP[ 1 ] = Silk_tables_NLSF_CB1_16_FLP.SKP_Silk_NLSF_CB1_16_FLP; - } - psEnc.sCmn.frame_length = Silk_define.FRAME_LENGTH_MS * fs_kHz; - psEnc.sCmn.subfr_length = psEnc.sCmn.frame_length / Silk_define.NB_SUBFR; - psEnc.sCmn.la_pitch = Silk_define.LA_PITCH_MS * fs_kHz; - psEnc.sCmn.la_shape = Silk_define.LA_SHAPE_MS * fs_kHz; - psEnc.sPred.min_pitch_lag = 3 * fs_kHz; - psEnc.sPred.max_pitch_lag = 18 * fs_kHz; - psEnc.sPred.pitch_LPC_win_length = Silk_define.FIND_PITCH_LPC_WIN_MS * fs_kHz; - if( psEnc.sCmn.fs_kHz == 24 ) - { - psEnc.mu_LTP = Silk_define_FLP.MU_LTP_QUANT_SWB; - psEnc.sCmn.bitrate_threshold_up = Silk_typedef.SKP_int32_MAX; - psEnc.sCmn.bitrate_threshold_down = Silk_define.SWB2WB_BITRATE_BPS; - } - else if( psEnc.sCmn.fs_kHz == 16 ) - { - psEnc.mu_LTP = Silk_define_FLP.MU_LTP_QUANT_WB; - psEnc.sCmn.bitrate_threshold_up = Silk_define.WB2SWB_BITRATE_BPS; - psEnc.sCmn.bitrate_threshold_down = Silk_define.WB2MB_BITRATE_BPS; - } - else if( psEnc.sCmn.fs_kHz == 12 ) - { - psEnc.mu_LTP = Silk_define_FLP.MU_LTP_QUANT_MB; - psEnc.sCmn.bitrate_threshold_up = Silk_define.MB2WB_BITRATE_BPS; - psEnc.sCmn.bitrate_threshold_down = Silk_define.MB2NB_BITRATE_BPS; - } - else - { - psEnc.mu_LTP = Silk_define_FLP.MU_LTP_QUANT_NB; - psEnc.sCmn.bitrate_threshold_up = Silk_define.NB2MB_BITRATE_BPS; - psEnc.sCmn.bitrate_threshold_down = 0; - } - psEnc.sCmn.fs_kHz_changed = 1; - - /* Check that settings are valid */ - assert( ( psEnc.sCmn.subfr_length * Silk_define.NB_SUBFR ) == psEnc.sCmn.frame_length ); - } - - /* Check that settings are valid */ - if( Silk_define.LOW_COMPLEXITY_ONLY !=0 && Complexity != 0 ) - { - ret = Silk_errors.SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING; - } - - /* Set encoding complexity */ - if( Complexity == 0 || Silk_define.LOW_COMPLEXITY_ONLY !=0 ) - { - /* Low complexity */ - psEnc.sCmn.Complexity = 0; - psEnc.sCmn.pitchEstimationComplexity = Silk_define.PITCH_EST_COMPLEXITY_LC_MODE; - psEnc.pitchEstimationThreshold = Silk_define_FLP.FIND_PITCH_CORRELATION_THRESHOLD_LC_MODE; - psEnc.sCmn.pitchEstimationLPCOrder = 8; - psEnc.sCmn.shapingLPCOrder = 12; - psEnc.sCmn.nStatesDelayedDecision = 1; -// psEnc.NoiseShapingQuantizer = SKP_Silk_NSQ; - psEnc.noiseShapingQuantizerCB = new NSQImplNSQ(); - psEnc.sCmn.useInterpolatedNLSFs = 0; - psEnc.sCmn.LTPQuantLowComplexity = 1; - psEnc.sCmn.NLSF_MSVQ_Survivors = Silk_define.MAX_NLSF_MSVQ_SURVIVORS_LC_MODE; - } - else if( Complexity == 1 ) - { - /* Medium complexity */ - psEnc.sCmn.Complexity = 1; - psEnc.sCmn.pitchEstimationComplexity = Silk_define.PITCH_EST_COMPLEXITY_MC_MODE; - psEnc.pitchEstimationThreshold = Silk_define_FLP.FIND_PITCH_CORRELATION_THRESHOLD_MC_MODE; - psEnc.sCmn.pitchEstimationLPCOrder = 12; - psEnc.sCmn.shapingLPCOrder = 16; - psEnc.sCmn.nStatesDelayedDecision = 2; -// psEnc.NoiseShapingQuantizer = SKP_Silk_NSQ_del_dec; - psEnc.noiseShapingQuantizerCB = new NSQImplNSQDelDec(); - psEnc.sCmn.useInterpolatedNLSFs = 0; - psEnc.sCmn.LTPQuantLowComplexity = 0; - psEnc.sCmn.NLSF_MSVQ_Survivors = Silk_define.MAX_NLSF_MSVQ_SURVIVORS_MC_MODE; - } - else if( Complexity == 2 ) - { - /* High complexity */ - psEnc.sCmn.Complexity = 2; - psEnc.sCmn.pitchEstimationComplexity = Silk_define.PITCH_EST_COMPLEXITY_HC_MODE; - psEnc.pitchEstimationThreshold = Silk_define_FLP.FIND_PITCH_CORRELATION_THRESHOLD_HC_MODE; - psEnc.sCmn.pitchEstimationLPCOrder = 16; - psEnc.sCmn.shapingLPCOrder = 16; - psEnc.sCmn.nStatesDelayedDecision = 4; -// psEnc.NoiseShapingQuantizer = SKP_Silk_NSQ_del_dec; - psEnc.noiseShapingQuantizerCB = new NSQImplNSQDelDec(); - psEnc.sCmn.useInterpolatedNLSFs = 1; - psEnc.sCmn.LTPQuantLowComplexity = 0; - psEnc.sCmn.NLSF_MSVQ_Survivors = Silk_define.MAX_NLSF_MSVQ_SURVIVORS; - } - else - { - ret = Silk_errors.SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING; - } - - /* Do not allow higher pitch estimation LPC order than predict LPC order */ - psEnc.sCmn.pitchEstimationLPCOrder = Math.min( psEnc.sCmn.pitchEstimationLPCOrder, psEnc.sCmn.predictLPCOrder ); - - assert( psEnc.sCmn.pitchEstimationLPCOrder <= Silk_define.FIND_PITCH_LPC_ORDER_MAX ); - assert( psEnc.sCmn.shapingLPCOrder <= Silk_define.SHAPE_LPC_ORDER_MAX ); - assert( psEnc.sCmn.nStatesDelayedDecision <= Silk_define.DEL_DEC_STATES_MAX ); - - /* Set bitrate/coding quality */ - TargetRate_bps = Math.min( TargetRate_bps, 100000 ); - if( psEnc.sCmn.fs_kHz == 8 ) - { - TargetRate_bps = Math.max( TargetRate_bps, Silk_define.MIN_TARGET_RATE_NB_BPS ); - } - else if( psEnc.sCmn.fs_kHz == 12 ) - { - TargetRate_bps = Math.max( TargetRate_bps, Silk_define.MIN_TARGET_RATE_MB_BPS ); - } - else if( psEnc.sCmn.fs_kHz == 16 ) - { - TargetRate_bps = Math.max( TargetRate_bps, Silk_define.MIN_TARGET_RATE_WB_BPS ); - } - else - { - TargetRate_bps = Math.max( TargetRate_bps, Silk_define.MIN_TARGET_RATE_SWB_BPS ); - } - if( TargetRate_bps != psEnc.sCmn.TargetRate_bps ) - { - psEnc.sCmn.TargetRate_bps = TargetRate_bps; - - /* If new TargetRate_bps, translate to SNR_dB value */ - if( psEnc.sCmn.fs_kHz == 8 ) - { - rateTable = Silk_tables_other.TargetRate_table_NB; - } - else if( psEnc.sCmn.fs_kHz == 12 ) - { - rateTable = Silk_tables_other.TargetRate_table_MB; - } - else if( psEnc.sCmn.fs_kHz == 16 ) - { - rateTable = Silk_tables_other.TargetRate_table_WB; - } - else - { - rateTable = Silk_tables_other.TargetRate_table_SWB; - } - for( k = 1; k < Silk_define.TARGET_RATE_TAB_SZ; k++ ) - { - /* Find bitrate interval in table and interpolate */ - if( TargetRate_bps < rateTable[ k ] ) - { - frac = (float)( TargetRate_bps - rateTable[ k - 1 ] ) / - (float)( rateTable[ k ] - rateTable[ k - 1 ] ); - psEnc.SNR_dB = 0.5f * ( Silk_tables_other.SNR_table_Q1[ k - 1 ] + frac * ( Silk_tables_other.SNR_table_Q1[ k ] - Silk_tables_other.SNR_table_Q1[ k - 1 ] ) ); - break; - } - } - } - - /* Set packet size */ - if( ( PacketSize_ms != 20 ) && - ( PacketSize_ms != 40 ) && - ( PacketSize_ms != 60 ) && - ( PacketSize_ms != 80 ) && - ( PacketSize_ms != 100 ) ) - { - ret = Silk_errors.SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED; - } - else - { - if( PacketSize_ms != psEnc.sCmn.PacketSize_ms ) - { - psEnc.sCmn.PacketSize_ms = PacketSize_ms; - - /* Packet length changes. Reset LBRR buffer */ - Silk_LBRR_reset.SKP_Silk_LBRR_reset( psEnc.sCmn ); - } - } - - /* Set packet loss rate measured by farend */ - if( ( PacketLoss_perc < 0 ) || ( PacketLoss_perc > 100 ) ) - { - ret = Silk_errors.SKP_SILK_ENC_INVALID_LOSS_RATE; - } - psEnc.sCmn.PacketLoss_perc = PacketLoss_perc; - -// #if USE_LBRR - if(Silk_define.USE_LBRR != 0) - { - if( INBandFEC_enabled < 0 || INBandFEC_enabled > 1 ) - { - ret = Silk_errors.SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING; - } - - /* Only change settings if first frame in packet */ - if( psEnc.sCmn.nFramesInPayloadBuf == 0 ) - { - psEnc.sCmn.LBRR_enabled = INBandFEC_enabled; - if( psEnc.sCmn.fs_kHz == 8 ) - { - LBRRRate_thres_bps = Silk_define.INBAND_FEC_MIN_RATE_BPS - 9000; - } - else if( psEnc.sCmn.fs_kHz == 12 ) - { - LBRRRate_thres_bps = Silk_define.INBAND_FEC_MIN_RATE_BPS - 6000;; - } - else if( psEnc.sCmn.fs_kHz == 16 ) - { - LBRRRate_thres_bps = Silk_define.INBAND_FEC_MIN_RATE_BPS - 3000; - } - else - { - LBRRRate_thres_bps = Silk_define.INBAND_FEC_MIN_RATE_BPS; - } - - if( psEnc.sCmn.TargetRate_bps >= LBRRRate_thres_bps ) - { - /* Set gain increase / rate reduction for LBRR usage */ - /* Coarsely tuned with PESQ for now. */ - /* Linear regression coefs G = 8 - 0.5 * loss */ - /* Meaning that at 16% loss main rate and redundant rate is the same, -> G = 0 */ - psEnc.sCmn.LBRR_GainIncreases = Math.max( 8 - ( psEnc.sCmn.PacketLoss_perc >> 1 ), 0 ); - - /* Set main stream rate compensation */ - if( psEnc.sCmn.LBRR_enabled != 0 && psEnc.sCmn.PacketLoss_perc > Silk_define.LBRR_LOSS_THRES ) - { - /* Tuned to give aprox same mean / weighted bitrate as no inband FEC */ - psEnc.inBandFEC_SNR_comp = 6.0f - 0.5f * psEnc.sCmn.LBRR_GainIncreases; - } - else - { - psEnc.inBandFEC_SNR_comp = 0; - psEnc.sCmn.LBRR_enabled = 0; - } - } - else - { - psEnc.inBandFEC_SNR_comp = 0; - psEnc.sCmn.LBRR_enabled = 0; - } - } - } -// #else - else - { - if( INBandFEC_enabled != 0 ) - { - ret = Silk_errors.SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING; - } - psEnc.sCmn.LBRR_enabled = 0; -// #endif - } - - /* Set DTX mode */ - if( DTX_enabled < 0 || DTX_enabled > 1 ) - { - ret = Silk_errors.SKP_SILK_ENC_INVALID_DTX_SETTING; - } - psEnc.sCmn.useDTX = DTX_enabled; - - return ret; - } - - /** - * Control low bitrate redundancy usage. - * @param psEnc Encoder state FLP. - * @param psEncCtrl Encoder control. - */ - static void SKP_Silk_LBRR_ctrl_FLP( - SKP_Silk_encoder_state_FLP psEnc, /* I/O Encoder state FLP*/ - SKP_Silk_encoder_control psEncCtrl /* I/O Encoder control */ - ) - { - int LBRR_usage; - - if (psEnc.sCmn.LBRR_enabled != 0) { - /* Control LBRR */ - - /* Usage Control based on sensitivity and packet loss caracteristics */ - /* - * For now only enable adding to next for active frames. Make more - * complex later - */ - LBRR_usage = Silk_define.SKP_SILK_NO_LBRR; - if (psEnc.speech_activity > Silk_define_FLP.LBRR_SPEECH_ACTIVITY_THRES - && psEnc.sCmn.PacketLoss_perc > Silk_define.LBRR_LOSS_THRES) - { // nb! maybe multiply loss prob and speech activity - LBRR_usage = Silk_define.SKP_SILK_ADD_LBRR_TO_PLUS1; - } - psEncCtrl.LBRR_usage = LBRR_usage; - } else { - psEncCtrl.LBRR_usage = Silk_define.SKP_SILK_NO_LBRR; - } - } -} - -/** - * The NSQ callback implementation. - * - * @author Dingxin Xu - */ -class NSQImplNSQ implements NoiseShapingQuantizerFP -{ - public void NoiseShapingQuantizer(SKP_Silk_encoder_state psEnc, - SKP_Silk_encoder_control psEncCtrl, SKP_Silk_nsq_state NSQ, - short[] x, byte[] q, int arg6, short[] arg7, short[] arg8, - short[] arg9, int[] arg10, int[] arg11, int[] arg12, int[] arg13, - int arg14, int arg15) { - // TODO Auto-generated method stub - Silk_NSQ.SKP_Silk_NSQ(psEnc, psEncCtrl, NSQ, x, q, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); - } -} - -/** - * The NSQ callback implementation - * - * @author Dingxin Xu - */ -class NSQImplNSQDelDec implements NoiseShapingQuantizerFP -{ - public void NoiseShapingQuantizer(SKP_Silk_encoder_state psEnc, - SKP_Silk_encoder_control psEncCtrl, SKP_Silk_nsq_state NSQ, - short[] x, byte[] q, int arg6, short[] arg7, short[] arg8, - short[] arg9, int[] arg10, int[] arg11, int[] arg12, int[] arg13, - int arg14, int arg15) { - // TODO Auto-generated method stub - Silk_NSQ_del_dec.SKP_Silk_NSQ_del_dec(psEnc, psEncCtrl, NSQ, x, q, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_corrMatrix_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_corrMatrix_FLP.java deleted file mode 100644 index 43af48992..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_corrMatrix_FLP.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Correlation matrix computations for LS estimate. - * - * @author Dingxin Xu - */ -public class Silk_corrMatrix_FLP -{ - /** - * Calculates correlation vector X'*t. - * @param x x vector [L+order-1] used to create X. - * @param x_offset offset of valid data. - * @param t Target vector [L]. - * @param t_offset offset of valid data. - * @param L Length of vecors. - * @param Order Max lag for correlation. - * @param Xt X'*t correlation vector [order]. - */ - static void SKP_Silk_corrVector_FLP( - final float []x, /* I x vector [L+order-1] used to create X */ - int x_offset, - final float []t, /* I Target vector [L] */ - int t_offset, - final int L, /* I Length of vecors */ - final int Order, /* I Max lag for correlation */ - final float []Xt /* O X'*t correlation vector [order] */ - ) - { - int lag; - final float []ptr1; - int ptr1_offset; - - ptr1 = x; /* Points to first sample of column 0 of X: X[:,0] */ - ptr1_offset = x_offset + Order-1; - for( lag = 0; lag < Order; lag++ ) { - /* Calculate X[:,lag]'*t */ - Xt[lag] = (float) Silk_inner_product_FLP.SKP_Silk_inner_product_FLP(ptr1, ptr1_offset, t, t_offset, L); - ptr1_offset--; /* Next column of X */ - } - } - - /** - * Calculates correlation matrix X'*X. - * @param x x vector [ L+order-1 ] used to create X. - * @param x_offset offset of valid data. - * @param L Length of vectors. - * @param Order Max lag for correlation. - * @param XX X'*X correlation matrix [order x order]. - * @param XX_offset offset of valid data. - */ - static void SKP_Silk_corrMatrix_FLP( - final float []x, /* I x vector [ L+order-1 ] used to create X */ - int x_offset, - final int L, /* I Length of vectors */ - final int Order, /* I Max lag for correlation */ - float []XX, /* O X'*X correlation matrix [order x order] */ - int XX_offset - ) - { - int j, lag; - double energy; - final float ptr1[], ptr2[]; - int ptr1_offset, ptr2_offset; - - ptr1 = x; /* First sample of column 0 of X */ - ptr1_offset = x_offset + Order-1; - - energy = Silk_energy_FLP.SKP_Silk_energy_FLP(ptr1, ptr1_offset, L);/* X[:,0]'*X[:,0] */ - -// matrix_ptr( XX, 0, 0, Order ) = ( SKP_float )energy; - XX[XX_offset + 0] = (float) energy; - - for( j = 1; j < Order; j++ ) { - /* Calculate X[:,j]'*X[:,j] */ - energy += ptr1[ ptr1_offset -j ] * ptr1[ ptr1_offset-j ] - ptr1[ ptr1_offset + L - j ] * ptr1[ ptr1_offset + L - j ]; -// matrix_ptr( XX, j, j, Order ) = ( SKP_float )energy; - XX[XX_offset + j*Order+j] = (float) energy; - } - - ptr2 = x; /* First sample of column 1 of X */ - ptr2_offset = x_offset + Order - 2; - for( lag = 1; lag < Order; lag++ ) { - /* Calculate X[:,0]'*X[:,lag] */ -// matrix_ptr( XX, lag, 0, Order ) = ( SKP_float )energy; -// matrix_ptr( XX, 0, lag, Order ) = ( SKP_float )energy; - energy = Silk_inner_product_FLP.SKP_Silk_inner_product_FLP(ptr1, ptr1_offset, ptr2, ptr2_offset, L); - /* Calculate X[:,j]'*X[:,j + lag] */ - for( j = 1; j < ( Order - lag ); j++ ) { -// matrix_ptr( XX, lag + j, j, Order ) = ( SKP_float )energy; -// matrix_ptr( XX, j, lag + j, Order ) = ( SKP_float )energy; - energy += ptr1[ ptr1_offset-j ] * ptr2[ ptr2_offset-j ] - ptr1[ ptr1_offset + L - j ] * ptr2[ ptr2_offset + L - j ]; - XX[XX_offset + (lag+j)*Order + j] = (float) energy; - XX[XX_offset + j*Order + (lag+j)] = (float) energy; - } - ptr2_offset--; /* Next column of X */ - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_create_init_destroy.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_create_init_destroy.java deleted file mode 100644 index c53395e90..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_create_init_destroy.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Initialize decoder state. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_create_init_destroy -{ - /** - * Initialize decoder state. - * @param psDec the decoder state. - * @return - */ - static int SKP_Silk_init_decoder( - SKP_Silk_decoder_state psDec /* I/O Decoder state pointer */ - ) - { - //psDec = new SKP_Silk_decoder_state(); - - /* Set sampling rate to 24 kHz, and init non-zero values */ - Silk_decoder_set_fs.SKP_Silk_decoder_set_fs( psDec, 24 ); - - /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */ - psDec.first_frame_after_reset = 1; - psDec.prev_inv_gain_Q16 = 65536; - - /* Reset CNG state */ - Silk_CNG.SKP_Silk_CNG_Reset( psDec ); - - Silk_PLC.SKP_Silk_PLC_Reset(psDec); - return(0); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_dec_API.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_dec_API.java deleted file mode 100644 index 197b476e6..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_dec_API.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * The Decoder API. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_dec_API -{ - - /** - * Reset the decoder state. - * - * @param decState the decoder state - * @return ret - */ - static int SKP_Silk_SDK_InitDecoder( - Object decState /* I/O: State */ - ) - { - int ret = 0; - SKP_Silk_decoder_state struc; - struc = (SKP_Silk_decoder_state )decState; - ret = Silk_create_init_destroy.SKP_Silk_init_decoder( struc ); - - return ret; - } - - /** - * Decode a frame. - * - * @param decState the decoder state. - * @param decControl the decoder control. - * @param lostFlag the lost flag. 0: no loss; 1: loss. - * @param inData encoding input vector. - * @param inData_offset the actual data offset in the input vector. - * @param nBytesIn number of input bytes. - * @param samplesOut decoded output speech vector. - * @param samplesOut_offset the actual data offset in the output vector. - * @param nSamplesOut number of samples. - * @return the returned value carries the error message. - * 0 indicates OK; other indicates error. - */ - static int SKP_Silk_SDK_Decode( - Object decState, /* I/O: State */ - SKP_SILK_SDK_DecControlStruct decControl, /* I/O: Control structure */ - int lostFlag, /* I: 0: no loss, 1 loss */ - byte[] inData, /* I: Encoded input vector */ - int inData_offset, - final int nBytesIn, /* I: Number of input Bytes */ - short[] samplesOut, /* O: Decoded output speech vector */ - int samplesOut_offset, - short[] nSamplesOut /* I/O: Number of samples (vector/decoded) */ - ) - { - int ret = 0, used_bytes, prev_fs_kHz; - SKP_Silk_decoder_state psDec; - - psDec = (SKP_Silk_decoder_state )decState; - - /**********************************/ - /* Test if first frame in payload */ - /**********************************/ - if( psDec.moreInternalDecoderFrames == 0 ) { - /* First Frame in Payload */ - psDec.nFramesDecoded = 0; /* Used to count frames in packet */ - } - - if( psDec.moreInternalDecoderFrames == 0 && /* First frame in packet */ - lostFlag == 0 && /* Not packet loss */ - nBytesIn > Silk_define.MAX_ARITHM_BYTES ) { /* Too long payload */ - /* Avoid trying to decode a too large packet */ - lostFlag = 1; - ret = Silk_errors.SKP_SILK_DEC_PAYLOAD_TOO_LARGE; - } - - /* Save previous sample frequency */ - prev_fs_kHz = psDec.fs_kHz; - - /* Call decoder for one frame */ - int[] used_bytes_ptr =new int[1]; - ret += Silk_decode_frame.SKP_Silk_decode_frame( psDec, samplesOut, samplesOut_offset, nSamplesOut, inData, inData_offset, - nBytesIn, lostFlag, used_bytes_ptr ); - used_bytes = used_bytes_ptr[0]; - - if( used_bytes !=0) /* Only Call if not a packet loss */ - { - if( psDec.nBytesLeft > 0 && psDec.FrameTermination == Silk_define.SKP_SILK_MORE_FRAMES && psDec.nFramesDecoded < 5 ) { - /* We have more frames in the Payload */ - psDec.moreInternalDecoderFrames = 1; - } else { - /* Last frame in Payload */ - psDec.moreInternalDecoderFrames = 0; - psDec.nFramesInPacket = psDec.nFramesDecoded; - - /* Track inband FEC usage */ - if( psDec.vadFlag == Silk_define.VOICE_ACTIVITY ) { - if( psDec.FrameTermination == Silk_define.SKP_SILK_LAST_FRAME ) { - psDec.no_FEC_counter++; - if( psDec.no_FEC_counter > Silk_define.NO_LBRR_THRES ) { - psDec.inband_FEC_offset = 0; - } - } else if( psDec.FrameTermination == Silk_define.SKP_SILK_LBRR_VER1 ) { - psDec.inband_FEC_offset = 1; /* FEC info with 1 packet delay */ - psDec.no_FEC_counter = 0; - } else if( psDec.FrameTermination == Silk_define.SKP_SILK_LBRR_VER2 ) { - psDec.inband_FEC_offset = 2; /* FEC info with 2 packets delay */ - psDec.no_FEC_counter = 0; - } - } - } - } - - if( Silk_define.MAX_API_FS_KHZ * 1000 < decControl.API_sampleRate || - 8000 > decControl.API_sampleRate ) { - ret = Silk_errors.SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY; - return( ret ); - } - - /* Resample if needed */ - if( psDec.fs_kHz * 1000 != decControl.API_sampleRate ) { - short[] samplesOut_tmp = new short[Silk_define.MAX_API_FS_KHZ * Silk_define.FRAME_LENGTH_MS]; - Silk_typedef.SKP_assert( psDec.fs_kHz <= Silk_define.MAX_API_FS_KHZ ); - - /* Copy to a tmp buffer as the resampling writes to samplesOut */ - System.arraycopy(samplesOut, samplesOut_offset+0, samplesOut_tmp, 0, nSamplesOut[0]); - /* (Re-)initialize resampler state when switching internal sampling frequency */ - if( prev_fs_kHz != psDec.fs_kHz || psDec.prev_API_sampleRate != decControl.API_sampleRate ) { - ret = Silk_resampler.SKP_Silk_resampler_init( psDec.resampler_state, psDec.fs_kHz*1000, decControl.API_sampleRate ); - } - - /* Resample the output to API_sampleRate */ - ret += Silk_resampler.SKP_Silk_resampler( psDec.resampler_state, samplesOut, samplesOut_offset, samplesOut_tmp, 0, nSamplesOut[0]); - - /* Update the number of output samples */ - nSamplesOut[0] = (short)((nSamplesOut[0] * decControl.API_sampleRate) / (psDec.fs_kHz * 1000)); - } - - psDec.prev_API_sampleRate = decControl.API_sampleRate; - - /* Copy all parameters that are needed out of internal structure to the control stucture */ - decControl.frameSize = psDec.frame_length; - decControl.framesPerPacket = psDec.nFramesInPacket; - decControl.inBandFECOffset = psDec.inband_FEC_offset; - decControl.moreInternalDecoderFrames = psDec.moreInternalDecoderFrames; - - return ret; - } - - /** - * Find LBRR information in a packet. - * - * @param inData encoded input vector. - * @param inData_offset offset of the valid data. - * @param nBytesIn number of input bytes. - * @param lost_offset offset from lost packet. - * @param LBRRData LBRR payload. - * @param LBRRData_offset offset of the valid data. - * @param nLBRRBytes number of LBRR bytes. - */ - static void SKP_Silk_SDK_search_for_LBRR( - byte[] inData, /* I: Encoded input vector */ - int inData_offset, - final short nBytesIn, /* I: Number of input Bytes */ - int lost_offset, /* I: Offset from lost packet */ - byte[] LBRRData, /* O: LBRR payload */ - int LBRRData_offset, - short[] nLBRRBytes /* O: Number of LBRR Bytes */ - ) - { - SKP_Silk_decoder_state sDec = new SKP_Silk_decoder_state(); // Local decoder state to avoid interfering with running decoder */ - SKP_Silk_decoder_control sDecCtrl = new SKP_Silk_decoder_control(); - int[] TempQ = new int[ Silk_define.MAX_FRAME_LENGTH ]; - - if( lost_offset < 1 || lost_offset > Silk_define.MAX_LBRR_DELAY ) { - /* No useful FEC in this packet */ - nLBRRBytes[0] = 0; - return; - } - - sDec.nFramesDecoded = 0; - sDec.fs_kHz = 0; /* Force update parameters LPC_order etc */ - Arrays.fill(sDec.prevNLSF_Q15, 0, Silk_define.MAX_LPC_ORDER, 0); - - for(int i=0; i 0 && sDec.nBytesLeft >= 0 ) { - /* The wanted FEC is present in the packet */ - nLBRRBytes[0] = (short)sDec.nBytesLeft; - System.arraycopy(inData, inData_offset+nBytesIn - sDec.nBytesLeft, LBRRData, LBRRData_offset+0, sDec.nBytesLeft); - break; - } - if( sDec.nBytesLeft > 0 && sDec.FrameTermination == Silk_define.SKP_SILK_MORE_FRAMES ) { - sDec.nFramesDecoded++; - } else { - LBRRData = null; - nLBRRBytes[0] = 0; - break; - } - } - } - - /** - * Getting type of content for a packet. - * @param inData encoded input vector. - * @param nBytesIn number of input bytes. - * @param Silk_TOC type of content. - */ - static void SKP_Silk_SDK_get_TOC( - byte[] inData, /* I: Encoded input vector */ - final short nBytesIn, /* I: Number of input bytes */ - SKP_Silk_TOC_struct Silk_TOC /* O: Type of content */ - ) - { - SKP_Silk_decoder_state sDec = new SKP_Silk_decoder_state(); - SKP_Silk_decoder_control sDecCtrl = new SKP_Silk_decoder_control(); - int[] TempQ = new int[ Silk_define.MAX_FRAME_LENGTH ]; - - sDec.nFramesDecoded = 0; - sDec.fs_kHz = 0; /* Force update parameters LPC_order etc */ - Silk_range_coder.SKP_Silk_range_dec_init( sDec.sRC, inData, 0, nBytesIn ); - - Silk_TOC.corrupt = 0; - while( true ) { - Silk_decode_parameters.SKP_Silk_decode_parameters( sDec, sDecCtrl, TempQ, 0 ); - - Silk_TOC.vadFlags[ sDec.nFramesDecoded ] = sDec.vadFlag; - Silk_TOC.sigtypeFlags[ sDec.nFramesDecoded ] = sDecCtrl.sigtype; - - if( sDec.sRC.error != 0) { - /* Corrupt stream */ - Silk_TOC.corrupt = 1; - break; - } -//TODO:note the semicolon; -// }; - if( sDec.nBytesLeft > 0 && sDec.FrameTermination == Silk_define.SKP_SILK_MORE_FRAMES ) { - sDec.nFramesDecoded++; - } else { - break; - } - } - if( Silk_TOC.corrupt !=0 || sDec.FrameTermination == Silk_define.SKP_SILK_MORE_FRAMES || - sDec.nFramesInPacket > Silk_SDK_API.SILK_MAX_FRAMES_PER_PACKET ) { - /* Corrupt packet */ - { - Silk_TOC.corrupt = 0; - Silk_TOC.framesInPacket = 0; - Silk_TOC.fs_kHz = 0; - Silk_TOC.inbandLBRR = 0; - - for(int i=0; i>31; - - psDec.exc_Q10[ i ] = (q[ i ] << 10) + offset_Q10; - psDec.exc_Q10[ i ] = ( psDec.exc_Q10[ i ] ^ dither ) - dither; - - rand_seed += q[ i ]; - } - - - pexc_Q10 = psDec.exc_Q10; - pexc_Q10_offset = 0; - - pres_Q10 = psDec.res_Q10; - pres_Q10_offset = 0; - - pxq = psDec.outBuf; - pxq_offset = psDec.frame_length; - - psDec.sLTP_buf_idx = psDec.frame_length; - /* Loop over subframes */ - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - A_Q12 = psDecCtrl.PredCoef_Q12[ k >> 1 ]; - - /* Preload LPC coeficients to array on stack. Gives small performance gain */ - System.arraycopy(A_Q12, 0, A_Q12_tmp, 0, psDec.LPC_order); - - B_Q14 = psDecCtrl.LTPCoef_Q14; - B_Q14_offset = k*Silk_define.LTP_ORDER; - - Gain_Q16 = psDecCtrl.Gains_Q16[ k ]; - LTP_scale_Q14 = psDecCtrl.LTP_scale_Q14; - sigtype = psDecCtrl.sigtype; - - inv_gain_Q16 = Silk_typedef.SKP_int32_MAX/(Gain_Q16>>1); - inv_gain_Q16 = Math.min(inv_gain_Q16, Silk_typedef.SKP_int16_MAX); - - /* Calculate Gain adjustment factor */ - gain_adj_Q16 = 1 << 16; - if( inv_gain_Q16 != psDec.prev_inv_gain_Q16 ) { - gain_adj_Q16 = Silk_Inlines.SKP_DIV32_varQ( inv_gain_Q16, psDec.prev_inv_gain_Q16, 16 ); - } - - /* Avoid abrupt transition from voiced PLC to unvoiced normal decoding */ - if( psDec.lossCnt !=0 && psDec.prev_sigtype == Silk_define.SIG_TYPE_VOICED && - psDecCtrl.sigtype == Silk_define.SIG_TYPE_UNVOICED && k < ( Silk_define.NB_SUBFR >> 1 ) ) { - - Arrays.fill(B_Q14, B_Q14_offset, B_Q14_offset+Silk_define.LTP_ORDER, (short)0); - - B_Q14[ B_Q14_offset + Silk_define.LTP_ORDER/2 ] = ( short )1 << 12; /* 0.25 */ - - sigtype = Silk_define.SIG_TYPE_VOICED; - psDecCtrl.pitchL[ k ] = psDec.lagPrev; - LTP_scale_Q14 = 1 << 14; - } - - if( sigtype == Silk_define.SIG_TYPE_VOICED ) { - /* Voiced */ - - lag = psDecCtrl.pitchL[ k ]; - /* Re-whitening */ - if( ( k & ( 3 - (NLSF_interpolation_flag << 1))) == 0 ) { - /* Rewhiten with new A coefs */ - start_idx = psDec.frame_length - lag - psDec.LPC_order - Silk_define.LTP_ORDER / 2; - start_idx = Silk_SigProc_FIX.SKP_LIMIT_int( start_idx, 0, psDec.frame_length - psDec.LPC_order ); - - Arrays.fill(FiltState, 0, psDec.LPC_order, 0); - - Silk_MA.SKP_Silk_MA_Prediction( psDec.outBuf, start_idx + k * ( psDec.frame_length >> 2 ), - A_Q12, 0, FiltState, sLTP, start_idx, psDec.frame_length - start_idx, psDec.LPC_order ); - - - /* After rewhitening the LTP state is unscaled */ - inv_gain_Q32 = ( inv_gain_Q16 << 16 ); - - if( k == 0 ) { - /* Do LTP downscaling */ - inv_gain_Q32 = ( Silk_macros.SKP_SMULWB( inv_gain_Q32, psDecCtrl.LTP_scale_Q14 )<< 2 ); - } - for( i = 0; i < (lag + Silk_define.LTP_ORDER/2); i++ ) { - psDec.sLTP_Q16[ psDec.sLTP_buf_idx - i - 1 ] = Silk_macros.SKP_SMULWB( inv_gain_Q32, sLTP[ psDec.frame_length - i - 1 ] ); - } - } else { - /* Update LTP state when Gain changes */ - if( gain_adj_Q16 != 1 << 16 ) { - for( i = 0; i < ( lag + Silk_define.LTP_ORDER / 2 ); i++ ) { - psDec.sLTP_Q16[ psDec.sLTP_buf_idx - i - 1 ] = Silk_macros.SKP_SMULWW( gain_adj_Q16, psDec.sLTP_Q16[ psDec.sLTP_buf_idx - i - 1 ] ); - } - } - } - } - - /* Scale short term state */ - for( i = 0; i < Silk_define.MAX_LPC_ORDER; i++ ) { - psDec.sLPC_Q14[ i ] = Silk_macros.SKP_SMULWW( gain_adj_Q16, psDec.sLPC_Q14[ i ] ); - } - - /* Save inv_gain */ - Silk_typedef.SKP_assert( inv_gain_Q16 != 0 ); - psDec.prev_inv_gain_Q16 = inv_gain_Q16; - - /* Long-term prediction */ - if( sigtype == Silk_define.SIG_TYPE_VOICED ) { - /* Setup pointer */ - pred_lag_ptr = psDec.sLTP_Q16; - pred_lag_ptr_offset = psDec.sLTP_buf_idx - lag + Silk_define.LTP_ORDER / 2; - - for( i = 0; i < psDec.subfr_length; i++ ) { - /* Unrolled loop */ - LTP_pred_Q14 = Silk_macros.SKP_SMULWB( pred_lag_ptr[ pred_lag_ptr_offset +0 ], B_Q14[ B_Q14_offset + 0 ] ); - LTP_pred_Q14 = Silk_macros.SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ pred_lag_ptr_offset -1 ], B_Q14[ B_Q14_offset + 1 ] ); - LTP_pred_Q14 = Silk_macros.SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ pred_lag_ptr_offset -2 ], B_Q14[ B_Q14_offset + 2 ] ); - LTP_pred_Q14 = Silk_macros.SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ pred_lag_ptr_offset -3 ], B_Q14[ B_Q14_offset + 3 ] ); - LTP_pred_Q14 = Silk_macros.SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ pred_lag_ptr_offset -4 ], B_Q14[ B_Q14_offset + 4 ] ); - pred_lag_ptr_offset++; - - /* Generate LPC residual */ - pres_Q10[ pres_Q10_offset + i ] = ( pexc_Q10[ pexc_Q10_offset + i ] + Silk_SigProc_FIX.SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 ) ); - - /* Update states */ - psDec.sLTP_Q16[ psDec.sLTP_buf_idx ] = ( pres_Q10[ pres_Q10_offset + i ]<< 6 ); - psDec.sLTP_buf_idx++; - } - } else { - System.arraycopy(pexc_Q10, pexc_Q10_offset + 0, pres_Q10, pres_Q10_offset + 0, psDec.subfr_length); - } - - - for( i = 0; i < psDec.subfr_length; i++ ) { - /* Partially unrolled */ - LPC_pred_Q10 = Silk_macros.SKP_SMULWB( psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 1 ], A_Q12_tmp[ 0 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 2 ], A_Q12_tmp[ 1 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 3 ], A_Q12_tmp[ 2 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 4 ], A_Q12_tmp[ 3 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 5 ], A_Q12_tmp[ 4 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 6 ], A_Q12_tmp[ 5 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 7 ], A_Q12_tmp[ 6 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 8 ], A_Q12_tmp[ 7 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 9 ], A_Q12_tmp[ 8 ] ); - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - 10 ], A_Q12_tmp[ 9 ] ); - - for( j = 10; j < psDec.LPC_order; j ++ ) { - LPC_pred_Q10 = Silk_macros.SKP_SMLAWB( LPC_pred_Q10, psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i - j - 1 ], A_Q12_tmp[ j ] ); - } - - /* Add prediction to LPC residual */ - vec_Q10[ i ] = ( pres_Q10[ pres_Q10_offset + i ]+ LPC_pred_Q10 ); - - /* Update states */ - psDec.sLPC_Q14[ Silk_define.MAX_LPC_ORDER + i ] = ( vec_Q10[ i ]<< 4 ); - } - /* Scale with Gain */ - for( i = 0; i < psDec.subfr_length; i++ ) { - pxq[ pxq_offset+i ] = ( short )Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( Silk_macros.SKP_SMULWW( vec_Q10[ i ], Gain_Q16 ), 10 ) ); - } - - /* Update LPC filter state */ - System.arraycopy(psDec.sLPC_Q14, psDec.subfr_length, psDec.sLPC_Q14, 0, Silk_define.MAX_LPC_ORDER); - - pexc_Q10_offset += psDec.subfr_length; - pres_Q10_offset += psDec.subfr_length; - pxq_offset += psDec.subfr_length; - } - - /* Copy to output */ - System.arraycopy(psDec.outBuf, psDec.frame_length, xq, xq_offset+0, psDec.frame_length); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decode_frame.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decode_frame.java deleted file mode 100644 index 97e87b7d9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decode_frame.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Decode frame - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_decode_frame -{ - /** - * Decode frame. - * @param psDec reference to Silk decoder state. - * @param pOut reference to output speech frame. - * @param pOut_offset offset of the valid data. - * @param pN reference to size of output frame. - * @param pCode reference to payload. - * @param pCode_offset offset the valid data. - * @param nBytes payload length. - * @param action action from Jitter buffer. - * @param decBytes Used bytes to decoder this frame. - * @return the returned value carries the error message. - * 0 indicates OK; other indicates error. - */ - static int SKP_Silk_decode_frame( - SKP_Silk_decoder_state psDec, /* I/O Pointer to Silk decoder state */ - short[] pOut, /* O Pointer to output speech frame */ - int pOut_offset, - short[] pN, /* O Pointer to size of output frame */ - byte[] pCode, /* I Pointer to payload */ - int pCode_offset, - final int nBytes, /* I Payload length */ - int action, /* I Action from Jitter Buffer */ - int[] decBytes /* O Used bytes to decode this frame */ - ) - { - SKP_Silk_decoder_control sDecCtrl = new SKP_Silk_decoder_control(); - int L, fs_Khz_old, LPC_order_old, ret = 0; - int[] Pulses = new int[ Silk_define.MAX_FRAME_LENGTH ]; - - - L = psDec.frame_length; - sDecCtrl.LTP_scale_Q14 = 0; - - /* Safety checks */ - Silk_typedef.SKP_assert( L > 0 && L <= Silk_define.MAX_FRAME_LENGTH ); - - /********************************************/ - /* Decode Frame if packet is not lost */ - /********************************************/ - decBytes[0] = 0; - if( action == 0 ) { - /********************************************/ - /* Initialize arithmetic coder */ - /********************************************/ - fs_Khz_old = psDec.fs_kHz; - LPC_order_old = psDec.LPC_order; - if( psDec.nFramesDecoded == 0 ) { - /* Initialize range decoder state */ - Silk_range_coder.SKP_Silk_range_dec_init( psDec.sRC, pCode, pCode_offset, nBytes ); - } - - /********************************************/ - /* Decode parameters and pulse signal */ - /********************************************/ - Silk_decode_parameters.SKP_Silk_decode_parameters( psDec, sDecCtrl, Pulses, 1 ); - - if( psDec.sRC.error !=0 ) { - psDec.nBytesLeft = 0; - - action = 1; /* PLC operation */ - /* revert fs if changed in decode_parameters */ - Silk_decoder_set_fs.SKP_Silk_decoder_set_fs( psDec, fs_Khz_old ); - - /* Avoid crashing */ - decBytes[0] = psDec.sRC.bufferLength; - - if( psDec.sRC.error == Silk_define.RANGE_CODER_DEC_PAYLOAD_TOO_LONG ) { - ret = Silk_errors.SKP_SILK_DEC_PAYLOAD_TOO_LARGE; - } else { - ret = Silk_errors.SKP_SILK_DEC_PAYLOAD_ERROR; - } - } else { - decBytes[0] = psDec.sRC.bufferLength - psDec.nBytesLeft; - psDec.nFramesDecoded++; - - /* Update lengths. Sampling frequency could have changed */ - L = psDec.frame_length; - - /********************************************************/ - /* Run inverse NSQ */ - /********************************************************/ - Silk_decode_core.SKP_Silk_decode_core( psDec, sDecCtrl, pOut, pOut_offset, Pulses ); - - /********************************************************/ - /* Update PLC state */ - /********************************************************/ - Silk_PLC.SKP_Silk_PLC( psDec, sDecCtrl, pOut, pOut_offset, L, action ); - - psDec.lossCnt = 0; - psDec.prev_sigtype = sDecCtrl.sigtype; - - /* A frame has been decoded without errors */ - psDec.first_frame_after_reset = 0; - } - } - /*************************************************************/ - /* Generate Concealment Frame if packet is lost, or corrupt */ - /*************************************************************/ - if( action == 1 ) { - /* Handle packet loss by extrapolation */ - Silk_PLC.SKP_Silk_PLC( psDec, sDecCtrl, pOut, pOut_offset, L, action ); - psDec.lossCnt++; - - } - - /*************************/ - /* Update output buffer. */ - /*************************/ - System.arraycopy(pOut, pOut_offset+0, psDec.outBuf, 0, L ); - - /****************************************************************/ - /* Ensure smooth connection of extrapolated and good frames */ - /****************************************************************/ - Silk_PLC.SKP_Silk_PLC_glue_frames( psDec, sDecCtrl, pOut, pOut_offset, L ); - - /************************************************/ - /* Comfort noise generation / estimation */ - /************************************************/ - Silk_CNG.SKP_Silk_CNG( psDec, sDecCtrl, pOut , pOut_offset, L ); - - /********************************************/ - /* HP filter output */ - /********************************************/ - Silk_typedef.SKP_assert( ( ( psDec.fs_kHz == 12 ) && ( L % 3 ) == 0 ) || - ( ( psDec.fs_kHz != 12 ) && ( L % 2 ) == 0 ) ); - Silk_biquad.SKP_Silk_biquad( pOut, pOut_offset, psDec.HP_B, psDec.HP_A, psDec.HPState, pOut, pOut_offset, L ); - - /********************************************/ - /* set output frame length */ - /********************************************/ - pN[0] = (short)L; - - /* Update some decoder state variables */ - psDec.lagPrev = sDecCtrl.pitchL[ Silk_define.NB_SUBFR - 1 ]; - - return ret; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decode_parameters.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decode_parameters.java deleted file mode 100644 index 8d9ab56b2..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decode_parameters.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * Decode parameters from payload - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_decode_parameters -{ - /** - * Decode parameters from payload. - * @param psDec decoder state. - * @param psDecCtrl Decoder control. - * @param q Excitation signal - * @param fullDecoding Flag to tell if only arithmetic decoding - */ - static void SKP_Silk_decode_parameters( - SKP_Silk_decoder_state psDec, /* I/O State */ - SKP_Silk_decoder_control psDecCtrl, /* I/O Decoder control */ - int[] q, /* O Excitation signal */ - final int fullDecoding /* I Flag to tell if only arithmetic decoding */ - ) - { - int i, k, Ix, fs_kHz_dec, nBytesUsed; - int[] Ix_ptr = new int[1]; - int[] Ixs = new int[ Silk_define.NB_SUBFR ]; - int[] GainsIndices = new int[ Silk_define.NB_SUBFR ]; - int[] NLSFIndices = new int[ Silk_define.NLSF_MSVQ_MAX_CB_STAGES ]; - int[] pNLSF_Q15 = new int[ Silk_define.MAX_LPC_ORDER ]; - int [] pNLSF0_Q15 = new int[ Silk_define.MAX_LPC_ORDER ]; - - short[] cbk_ptr_Q14; - SKP_Silk_NLSF_CB_struct psNLSF_CB = null; - - SKP_Silk_range_coder_state psRC = psDec.sRC; - /************************/ - /* Decode sampling rate */ - /************************/ - /* only done for first frame of packet */ - if( psDec.nFramesDecoded == 0 ) { - Silk_range_coder.SKP_Silk_range_decoder( Ix_ptr, 0, psRC, Silk_tables_other.SKP_Silk_SamplingRates_CDF, 0, Silk_tables_other.SKP_Silk_SamplingRates_offset ); - Ix = Ix_ptr[0]; - - /* check that sampling rate is supported */ - if( Ix < 0 || Ix > 3 ) { - psRC.error = Silk_define.RANGE_CODER_ILLEGAL_SAMPLING_RATE; - return; - } - fs_kHz_dec = Silk_tables_other.SKP_Silk_SamplingRates_table[ Ix ]; - Silk_decoder_set_fs.SKP_Silk_decoder_set_fs( psDec, fs_kHz_dec ); - } - - /*******************************************/ - /* Decode signal type and quantizer offset */ - /*******************************************/ - if( psDec.nFramesDecoded == 0 ) { - /* first frame in packet: independent coding */ - Silk_range_coder.SKP_Silk_range_decoder( Ix_ptr, 0, psRC, Silk_tables_type_offset.SKP_Silk_type_offset_CDF, 0, Silk_tables_type_offset.SKP_Silk_type_offset_CDF_offset ); - Ix = Ix_ptr[0]; - } else { - /* condidtional coding */ - Silk_range_coder.SKP_Silk_range_decoder( Ix_ptr, 0, psRC, Silk_tables_type_offset.SKP_Silk_type_offset_joint_CDF[ psDec.typeOffsetPrev ], 0, - Silk_tables_type_offset.SKP_Silk_type_offset_CDF_offset ); - Ix = Ix_ptr[0]; - } - psDecCtrl.sigtype = Ix>>1; - psDecCtrl.QuantOffsetType = Ix & 1; - psDec.typeOffsetPrev = Ix; - - /****************/ - /* Decode gains */ - /****************/ - /* first subframe */ - if( psDec.nFramesDecoded == 0 ) { - /* first frame in packet: independent coding */ - Silk_range_coder.SKP_Silk_range_decoder( GainsIndices, 0, psRC, Silk_tables_gain.SKP_Silk_gain_CDF[ psDecCtrl.sigtype ], 0, Silk_tables_gain.SKP_Silk_gain_CDF_offset ); - } else { - /* condidtional coding */ - Silk_range_coder.SKP_Silk_range_decoder( GainsIndices, 0, psRC, Silk_tables_gain.SKP_Silk_delta_gain_CDF, 0, Silk_tables_gain.SKP_Silk_delta_gain_CDF_offset ); - } - - /* remaining subframes */ - for( i = 1; i < Silk_define.NB_SUBFR; i++ ) { - Silk_range_coder.SKP_Silk_range_decoder( GainsIndices, i, psRC, Silk_tables_gain.SKP_Silk_delta_gain_CDF, 0, Silk_tables_gain.SKP_Silk_delta_gain_CDF_offset ); - } - - /* Dequant Gains */ - int LastGainIndex_ptr[] = new int[1]; - LastGainIndex_ptr[0] = psDec.LastGainIndex; - Silk_gain_quant.SKP_Silk_gains_dequant( psDecCtrl.Gains_Q16, GainsIndices, LastGainIndex_ptr, psDec.nFramesDecoded ); - psDec.LastGainIndex = LastGainIndex_ptr[0]; - - /****************/ - /* Decode NLSFs */ - /****************/ - /* Set pointer to NLSF VQ CB for the current signal type */ - psNLSF_CB = psDec.psNLSF_CB[ psDecCtrl.sigtype ]; - - /* Arithmetically decode NLSF path */ - Silk_range_coder.SKP_Silk_range_decoder_multi( NLSFIndices, psRC, psNLSF_CB.StartPtr, psNLSF_CB.MiddleIx, psNLSF_CB.nStages ); - - - /* From the NLSF path, decode an NLSF vector */ - Silk_NLSF_MSVQ_decode.SKP_Silk_NLSF_MSVQ_decode( pNLSF_Q15, psNLSF_CB, NLSFIndices, psDec.LPC_order ); - - - /************************************/ - /* Decode NLSF interpolation factor */ - /************************************/ - int[] NLSFInterpCoef_Q2_ptr = new int[1]; - NLSFInterpCoef_Q2_ptr[0] = psDecCtrl.NLSFInterpCoef_Q2; - - Silk_range_coder.SKP_Silk_range_decoder( NLSFInterpCoef_Q2_ptr, 0, psRC, Silk_tables_other.SKP_Silk_NLSF_interpolation_factor_CDF, 0, - Silk_tables_other.SKP_Silk_NLSF_interpolation_factor_offset ); - psDecCtrl.NLSFInterpCoef_Q2 = NLSFInterpCoef_Q2_ptr[0]; - - /* If just reset, e.g., because internal Fs changed, do not allow interpolation */ - /* improves the case of packet loss in the first frame after a switch */ - if( psDec.first_frame_after_reset == 1 ) { - psDecCtrl.NLSFInterpCoef_Q2 = 4; - } - - if( fullDecoding !=0) { - /* Convert NLSF parameters to AR prediction filter coefficients */ - Silk_NLSF2A_stable.SKP_Silk_NLSF2A_stable( psDecCtrl.PredCoef_Q12[ 1 ], pNLSF_Q15, psDec.LPC_order ); - if( psDecCtrl.NLSFInterpCoef_Q2 < 4 ) { - /* Calculation of the interpolated NLSF0 vector from the interpolation factor, */ - /* the previous NLSF1, and the current NLSF1 */ - for( i = 0; i < psDec.LPC_order; i++ ) { - pNLSF0_Q15[ i ] = psDec.prevNLSF_Q15[ i ] + ( ( psDecCtrl.NLSFInterpCoef_Q2 * - ( pNLSF_Q15[ i ] - psDec.prevNLSF_Q15[ i ] ) ) >> 2 ); - } - - /* Convert NLSF parameters to AR prediction filter coefficients */ - Silk_NLSF2A_stable.SKP_Silk_NLSF2A_stable( psDecCtrl.PredCoef_Q12[ 0 ], pNLSF0_Q15, psDec.LPC_order ); - } else { - /* Copy LPC coefficients for first half from second half */ - System.arraycopy(psDecCtrl.PredCoef_Q12[1], 0, psDecCtrl.PredCoef_Q12[0], 0, psDec.LPC_order); - } - } - - System.arraycopy(pNLSF_Q15, 0, psDec.prevNLSF_Q15, 0, psDec.LPC_order); - - /* After a packet loss do BWE of LPC coefs */ - if( psDec.lossCnt !=0 ) { - Silk_bwexpander.SKP_Silk_bwexpander( psDecCtrl.PredCoef_Q12[ 0 ], psDec.LPC_order, Silk_define.BWE_AFTER_LOSS_Q16 ); - Silk_bwexpander.SKP_Silk_bwexpander( psDecCtrl.PredCoef_Q12[ 1 ], psDec.LPC_order, Silk_define.BWE_AFTER_LOSS_Q16 ); - } - - if( psDecCtrl.sigtype == Silk_define.SIG_TYPE_VOICED ) { - /*********************/ - /* Decode pitch lags */ - /*********************/ - /* Get lag index */ - if( psDec.fs_kHz == 8 ) { - Silk_range_coder.SKP_Silk_range_decoder(Ixs, 0, psRC, Silk_tables_pitch_lag.SKP_Silk_pitch_lag_NB_CDF, 0, Silk_tables_pitch_lag.SKP_Silk_pitch_lag_NB_CDF_offset); - } else if( psDec.fs_kHz == 12 ) { - Silk_range_coder.SKP_Silk_range_decoder(Ixs, 0, psRC, Silk_tables_pitch_lag.SKP_Silk_pitch_lag_MB_CDF, 0, Silk_tables_pitch_lag.SKP_Silk_pitch_lag_MB_CDF_offset); - } else if( psDec.fs_kHz == 16 ) { - Silk_range_coder.SKP_Silk_range_decoder(Ixs, 0, psRC, Silk_tables_pitch_lag.SKP_Silk_pitch_lag_WB_CDF, 0, Silk_tables_pitch_lag.SKP_Silk_pitch_lag_WB_CDF_offset); - } else { - Silk_range_coder.SKP_Silk_range_decoder(Ixs, 0, psRC, Silk_tables_pitch_lag.SKP_Silk_pitch_lag_SWB_CDF, 0, Silk_tables_pitch_lag.SKP_Silk_pitch_lag_SWB_CDF_offset); - } - - /* Get countour index */ - if( psDec.fs_kHz == 8 ) { - /* Less codevectors used in 8 khz mode */ - Silk_range_coder.SKP_Silk_range_decoder(Ixs, 1, psRC, Silk_tables_pitch_lag.SKP_Silk_pitch_contour_NB_CDF, 0, Silk_tables_pitch_lag.SKP_Silk_pitch_contour_NB_CDF_offset); - } else { - /* Joint for 12, 16, and 24 khz */ -// SKP_Silk_range_decoder( &Ixs[ 1 ], psRC, SKP_Silk_pitch_contour_CDF, SKP_Silk_pitch_contour_CDF_offset ); - Silk_range_coder.SKP_Silk_range_decoder( Ixs, 1, psRC, Silk_tables_pitch_lag.SKP_Silk_pitch_contour_CDF, 0, Silk_tables_pitch_lag.SKP_Silk_pitch_contour_CDF_offset ); - } - - /* Decode pitch values */ - Silk_decode_pitch.SKP_Silk_decode_pitch( Ixs[ 0 ], Ixs[ 1 ], psDecCtrl.pitchL, psDec.fs_kHz ); - - /********************/ - /* Decode LTP gains */ - /********************/ - /* Decode PERIndex value */ - int PERIndex_ptr[] = new int[1]; - PERIndex_ptr[0] = psDecCtrl.PERIndex; - - Silk_range_coder.SKP_Silk_range_decoder( PERIndex_ptr, 0, psRC, Silk_tables_LTP.SKP_Silk_LTP_per_index_CDF, 0, - Silk_tables_LTP.SKP_Silk_LTP_per_index_CDF_offset ); - psDecCtrl.PERIndex = PERIndex_ptr[0]; - - /* Decode Codebook Index */ - cbk_ptr_Q14 = Silk_tables_LTP.SKP_Silk_LTP_vq_ptrs_Q14[ psDecCtrl.PERIndex ]; // set pointer to start of codebook - - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - Silk_range_coder.SKP_Silk_range_decoder( Ix_ptr, 0, psRC, Silk_tables_LTP.SKP_Silk_LTP_gain_CDF_ptrs[psDecCtrl.PERIndex], 0 , - Silk_tables_LTP.SKP_Silk_LTP_gain_CDF_offsets[ psDecCtrl.PERIndex ] ); - Ix = Ix_ptr[0]; - for( i = 0; i < Silk_define.LTP_ORDER; i++ ) { - psDecCtrl.LTPCoef_Q14[ Silk_macros.SKP_SMULBB( k, Silk_define.LTP_ORDER ) + i ] = cbk_ptr_Q14[ Silk_macros.SKP_SMULBB( Ix, Silk_define.LTP_ORDER ) + i ]; - } - } - - /**********************/ - /* Decode LTP scaling */ - /**********************/ - Silk_range_coder.SKP_Silk_range_decoder( Ix_ptr, 0, psRC, Silk_tables_other.SKP_Silk_LTPscale_CDF, 0, Silk_tables_other.SKP_Silk_LTPscale_offset ); - Ix = Ix_ptr[0]; - psDecCtrl.LTP_scale_Q14 = Silk_tables_other.SKP_Silk_LTPScales_table_Q14[ Ix ]; - } else { - Arrays.fill(psDecCtrl.pitchL, 0, Silk_define.NB_SUBFR, 0); - Arrays.fill(psDecCtrl.LTPCoef_Q14, 0, Silk_define.NB_SUBFR, (short)0); - psDecCtrl.PERIndex = 0; - psDecCtrl.LTP_scale_Q14 = 0; - } - - /***************/ - /* Decode seed */ - /***************/ - Silk_range_coder.SKP_Silk_range_decoder( Ix_ptr, 0, psRC, Silk_tables_other.SKP_Silk_Seed_CDF, 0, Silk_tables_other.SKP_Silk_Seed_offset ); - Ix = Ix_ptr[0]; - psDecCtrl.Seed = Ix; - /*********************************************/ - /* Decode quantization indices of excitation */ - /*********************************************/ - Silk_decode_pulses.SKP_Silk_decode_pulses( psRC, psDecCtrl, q, psDec.frame_length ); - - /*********************************************/ - /* Decode VAD flag */ - /*********************************************/ - int[] vadFlag_ptr = new int[1]; - vadFlag_ptr[0] = psDec.vadFlag; - Silk_range_coder.SKP_Silk_range_decoder( vadFlag_ptr, 0, psRC, Silk_tables_other.SKP_Silk_vadflag_CDF, 0, Silk_tables_other.SKP_Silk_vadflag_offset ); - psDec.vadFlag = vadFlag_ptr[0]; - - /**************************************/ - /* Decode Frame termination indicator */ - /**************************************/ - int[] FrameTermination_ptr = new int[1]; - FrameTermination_ptr[0] = psDec.FrameTermination; - Silk_range_coder.SKP_Silk_range_decoder( FrameTermination_ptr, 0, psRC, Silk_tables_other.SKP_Silk_FrameTermination_CDF, 0, Silk_tables_other.SKP_Silk_FrameTermination_offset ); - psDec.FrameTermination = FrameTermination_ptr[0]; - - /****************************************/ - /* get number of bytes used so far */ - /****************************************/ - int nBytesUsed_ptr[] = new int[1]; - Silk_range_coder.SKP_Silk_range_coder_get_length( psRC, nBytesUsed_ptr ); - nBytesUsed = nBytesUsed_ptr[0]; - - psDec.nBytesLeft = psRC.bufferLength - nBytesUsed; - if( psDec.nBytesLeft < 0 ) { - psRC.error = Silk_define.RANGE_CODER_READ_BEYOND_BUFFER; - } - - /****************************************/ - /* check remaining bits in last byte */ - /****************************************/ - if( psDec.nBytesLeft == 0 ) { - Silk_range_coder.SKP_Silk_range_coder_check_after_decoding( psRC ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decode_pitch.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decode_pitch.java deleted file mode 100644 index 25f7f0853..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decode_pitch.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Pitch analyzer function. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_decode_pitch -{ - /** - * Pitch analyzer function. - * @param lagIndex - * @param contourIndex - * @param pitch_lags 4 pitch values. - * @param Fs_kHz sampling frequency(kHz). - */ - static void SKP_Silk_decode_pitch( - int lagIndex, /* I */ - int contourIndex, /* O */ - int pitch_lags[], /* O 4 pitch values */ - int Fs_kHz /* I sampling frequency (kHz) */ - ) - { - int lag, i, min_lag; - - min_lag = Silk_macros.SKP_SMULBB(Silk_common_pitch_est_defines.PITCH_EST_MIN_LAG_MS, Fs_kHz); - - /* Only for 24 / 16 kHz version for now */ - lag = min_lag + lagIndex; - if( Fs_kHz == 8 ) { - /* Only a small codebook for 8 khz */ - for( i = 0; i < Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR; i++ ) { - pitch_lags[ i ] = lag + Silk_pitch_est_tables.SKP_Silk_CB_lags_stage2[ i ][ contourIndex ]; - } - } else { - for( i = 0; i < Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR; i++ ) { - pitch_lags[ i ] = lag + Silk_pitch_est_tables.SKP_Silk_CB_lags_stage3[ i ][ contourIndex ]; - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decode_pulses.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decode_pulses.java deleted file mode 100644 index 06acfaf19..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decode_pulses.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * Decode quantization indices of excitation. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_decode_pulses -{ - /** - * Decode quantization indices of excitation. - * @param psRC Range coder state. - * @param psDecCtrl Decoder control. - * @param q Excitation signal. - * @param frame_length Frame length (preliminary). - */ - static void SKP_Silk_decode_pulses( - SKP_Silk_range_coder_state psRC, /* I/O Range coder state */ - SKP_Silk_decoder_control psDecCtrl, /* I/O Decoder control */ - int q[], /* O Excitation signal */ - final int frame_length /* I Frame length (preliminary) */ - ) - { - int i, j, k, iter, abs_q, nLS, bit; - int[] sum_pulses = new int[ Silk_define.MAX_NB_SHELL_BLOCKS ]; - int[] nLshifts = new int[ Silk_define.MAX_NB_SHELL_BLOCKS ]; - int[] pulses_ptr; - int pulses_ptr_offset; - int[] cdf_ptr; - - /*********************/ - /* Decode rate level */ - /*********************/ - int RateLevelIndex_ptr[] = new int[1]; - RateLevelIndex_ptr[0] = psDecCtrl.RateLevelIndex; - Silk_range_coder.SKP_Silk_range_decoder( RateLevelIndex_ptr, 0, psRC, - Silk_tables_pulses_per_block.SKP_Silk_rate_levels_CDF[ psDecCtrl.sigtype ], 0, Silk_tables_pulses_per_block.SKP_Silk_rate_levels_CDF_offset ); - psDecCtrl.RateLevelIndex = RateLevelIndex_ptr[0]; - - /* Calculate number of shell blocks */ - iter = frame_length / Silk_define.SHELL_CODEC_FRAME_LENGTH; - - /***************************************************/ - /* Sum-Weighted-Pulses Decoding */ - /***************************************************/ - cdf_ptr = Silk_tables_pulses_per_block.SKP_Silk_pulses_per_block_CDF[ psDecCtrl.RateLevelIndex ]; - - for( i = 0; i < iter; i++ ) { - nLshifts[ i ] = 0; - Silk_range_coder.SKP_Silk_range_decoder( sum_pulses, i, psRC, cdf_ptr, 0, Silk_tables_pulses_per_block.SKP_Silk_pulses_per_block_CDF_offset ); - - /* LSB indication */ - while( sum_pulses[ i ] == ( Silk_define.MAX_PULSES + 1 ) ) { - nLshifts[ i ]++; - Silk_range_coder.SKP_Silk_range_decoder( sum_pulses, i, psRC, - Silk_tables_pulses_per_block.SKP_Silk_pulses_per_block_CDF[ Silk_define.N_RATE_LEVELS - 1 ], 0, Silk_tables_pulses_per_block.SKP_Silk_pulses_per_block_CDF_offset ); - } - } - - /***************************************************/ - /* Shell decoding */ - /***************************************************/ - for( i = 0; i < iter; i++ ) { - if( sum_pulses[ i ] > 0 ) { - Silk_shell_coder.SKP_Silk_shell_decoder( q, Silk_macros.SKP_SMULBB( i, Silk_define.SHELL_CODEC_FRAME_LENGTH ), psRC, sum_pulses[ i ] ); - } else { - Arrays.fill(q, (Silk_macros.SKP_SMULBB(i, Silk_define.SHELL_CODEC_FRAME_LENGTH)), - ((Silk_macros.SKP_SMULBB(i, Silk_define.SHELL_CODEC_FRAME_LENGTH)) + Silk_define.SHELL_CODEC_FRAME_LENGTH), 0); - } - } - - /***************************************************/ - /* LSB Decoding */ - /***************************************************/ - for( i = 0; i < iter; i++ ) { - if( nLshifts[ i ] > 0 ) { - nLS = nLshifts[ i ]; - pulses_ptr = q; - pulses_ptr_offset = Silk_macros.SKP_SMULBB(i, Silk_define.SHELL_CODEC_FRAME_LENGTH); - - for( k = 0; k < Silk_define.SHELL_CODEC_FRAME_LENGTH; k++ ) { - abs_q = pulses_ptr[pulses_ptr_offset + k]; - for( j = 0; j < nLS; j++ ) { - abs_q = abs_q << 1; - int bit_ptr[] = new int[1]; - Silk_range_coder.SKP_Silk_range_decoder( bit_ptr, 0, psRC, Silk_tables_other.SKP_Silk_lsb_CDF, 0, 1 ); - bit = bit_ptr[0]; - abs_q += bit; - } - pulses_ptr[pulses_ptr_offset + k] = abs_q; - } - } - } - - /****************************************/ - /* Decode and add signs to pulse signal */ - /****************************************/ - Silk_code_signs.SKP_Silk_decode_signs( psRC, q, frame_length, psDecCtrl.sigtype, - psDecCtrl.QuantOffsetType, psDecCtrl.RateLevelIndex); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decoder_set_fs.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decoder_set_fs.java deleted file mode 100644 index d3bdf64a8..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_decoder_set_fs.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * Set decoder sampling rate. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_decoder_set_fs -{ - /** - * Set decoder sampling rate. - * @param psDec the decoder state. - * @param fs_kHz the sampling frequency(kHz). - */ - static void SKP_Silk_decoder_set_fs( - SKP_Silk_decoder_state psDec, /* I/O Decoder state pointer */ - int fs_kHz /* I Sampling frequency (kHz) */ - ) - { - if( psDec.fs_kHz != fs_kHz ) { - psDec.fs_kHz = fs_kHz; - psDec.frame_length = Silk_define.FRAME_LENGTH_MS*fs_kHz; - - psDec.subfr_length = (Silk_define.FRAME_LENGTH_MS/Silk_define.NB_SUBFR)*fs_kHz; - - if( psDec.fs_kHz == 8 ) { - psDec.LPC_order = Silk_define.MIN_LPC_ORDER; - psDec.psNLSF_CB[0] = Silk_tables_NLSF_CB0_10.SKP_Silk_NLSF_CB0_10; - psDec.psNLSF_CB[1] = Silk_tables_NLSF_CB1_10.SKP_Silk_NLSF_CB1_10; - } else { - psDec.LPC_order = Silk_define.MAX_LPC_ORDER; - psDec.psNLSF_CB[0] = Silk_tables_NLSF_CB0_16.SKP_Silk_NLSF_CB0_16; - psDec.psNLSF_CB[1] = Silk_tables_NLSF_CB1_16.SKP_Silk_NLSF_CB1_16; - } - /* Reset part of the decoder state */ - Arrays.fill(psDec.sLPC_Q14, 0, Silk_define.MAX_LPC_ORDER, 0); - - Arrays.fill(psDec.outBuf, 0, Silk_define.MAX_FRAME_LENGTH, (short)0); - - Arrays.fill(psDec.prevNLSF_Q15, 0, Silk_define.MAX_LPC_ORDER, 0); - - - psDec.sLTP_buf_idx = 0; - psDec.lagPrev = 100; - psDec.LastGainIndex = 1; - psDec.prev_sigtype = 0; - psDec.first_frame_after_reset = 1; - - if( fs_kHz == 24 ) { - psDec.HP_A = Silk_tables_other.SKP_Silk_Dec_A_HP_24; - psDec.HP_B = Silk_tables_other.SKP_Silk_Dec_B_HP_24; - } else if( fs_kHz == 16 ) { - psDec.HP_A = Silk_tables_other.SKP_Silk_Dec_A_HP_16; - psDec.HP_B = Silk_tables_other.SKP_Silk_Dec_B_HP_16; - } else if( fs_kHz == 12 ) { - psDec.HP_A = Silk_tables_other.SKP_Silk_Dec_A_HP_12; - psDec.HP_B = Silk_tables_other.SKP_Silk_Dec_B_HP_12; - } else if( fs_kHz == 8 ) { - psDec.HP_A = Silk_tables_other.SKP_Silk_Dec_A_HP_8; - psDec.HP_B = Silk_tables_other.SKP_Silk_Dec_B_HP_8; - } else { - /* unsupported sampling rate */ - Silk_typedef.SKP_assert( false ); - } - } - /* Check that settings are valid */ - Silk_typedef.SKP_assert( psDec.frame_length > 0 && psDec.frame_length <= Silk_define.MAX_FRAME_LENGTH ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_define.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_define.java deleted file mode 100644 index ae93cbd7d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_define.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * This class contains a number of defines that controls the operation of SILK. - * Most of these should be left alone for ensuring proper operation. However, a - * few can be changed if operation different from the default is desired. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_define -{ - static final int MAX_FRAMES_PER_PACKET = 5; - - /* MAX DELTA LAG used for multiframe packets */ - static final int MAX_DELTA_LAG = 10; - - /* Lower limit on bitrate for each mode */ - static final int MIN_TARGET_RATE_NB_BPS = 5000; - static final int MIN_TARGET_RATE_MB_BPS = 7000; - static final int MIN_TARGET_RATE_WB_BPS = 8000; - static final int MIN_TARGET_RATE_SWB_BPS = 20000; - - /* Transition bitrates between modes */ - static final int SWB2WB_BITRATE_BPS = 26000; - static final int WB2SWB_BITRATE_BPS = 32000; - static final int WB2MB_BITRATE_BPS = 15000; - static final int MB2WB_BITRATE_BPS = 20000; - static final int MB2NB_BITRATE_BPS = 10000; - static final int NB2MB_BITRATE_BPS = 14000; - - /* Integration/hysteresis threshold for lowering internal sample frequency */ - /* 30000000 -> 6 sec if bitrate is 5000 bps below limit; 3 sec if bitrate is 10000 bps below limit */ - static final int ACCUM_BITS_DIFF_THRESHOLD = 30000000; - static final int TARGET_RATE_TAB_SZ = 8; - - /* DTX settings */ - static final int NO_SPEECH_FRAMES_BEFORE_DTX = 5; /* eq 100 ms */ - static final int MAX_CONSECUTIVE_DTX = 20; /* eq 400 ms */ - - static final int USE_LBRR = 1; - - /* Amount of concecutive no FEC packets before telling JB */ - static final int NO_LBRR_THRES = 10; - - /* Maximum delay between real packet and LBRR packet */ - static final int MAX_LBRR_DELAY = 2; - static final int LBRR_IDX_MASK = 1; - - static final int INBAND_FEC_MIN_RATE_BPS = 18000; /* Dont use inband FEC below this total target rate */ - static final int LBRR_LOSS_THRES = 2; /* Start adding LBRR at this loss rate (needs tuning) */ - - /* LBRR usage defines */ - static final int SKP_SILK_NO_LBRR = 0; /* No LBRR information for this packet */ - static final int SKP_SILK_ADD_LBRR_TO_PLUS1 = 1; /* Add LBRR for this packet to packet n + 1 */ - static final int SKP_SILK_ADD_LBRR_TO_PLUS2 = 2; /* Add LBRR for this packet to packet n + 2 */ - - /* Frame termination indicator defines */ - static final int SKP_SILK_LAST_FRAME = 0; /* Last frames in packet */ - static final int SKP_SILK_MORE_FRAMES = 1; /* More frames to follow this one */ - static final int SKP_SILK_LBRR_VER1 = 2; /* LBRR information from packet n - 1 */ - static final int SKP_SILK_LBRR_VER2 = 3; /* LBRR information from packet n - 2 */ - static final int SKP_SILK_EXT_LAYER = 4; /* Extension layers added */ - - /* Number of Second order Sections for SWB detection HP filter */ - static final int NB_SOS = 3; - static final int HP_8_KHZ_THRES= 10; /* average energy per sample, above 8 kHz */ - static final int CONCEC_SWB_SMPLS_THRES= 480 * 15; /* 300 ms */ - static final int WB_DETECT_ACTIVE_SPEECH_MS_THRES = 15000; /* ms of active speech needed for WB detection */ - - /* Low complexity setting */ - static final int LOW_COMPLEXITY_ONLY = 0; - - /* Activate bandwidth transition filtering for mode switching */ - static final int SWITCH_TRANSITION_FILTERING = 1; - - /* Decoder Parameters */ - static final int DEC_HP_ORDER = 2; - - /* Maximum sampling frequency, should be 16 for embedded */ - static final int MAX_FS_KHZ = 24; - static final int MAX_API_FS_KHZ= 48; - - /* Signal Types used by silk */ - static final int SIG_TYPE_VOICED = 0; - static final int SIG_TYPE_UNVOICED = 1; - - /* VAD Types used by silk */ - static final int NO_VOICE_ACTIVITY = 0; - static final int VOICE_ACTIVITY = 1; - - /* Number of samples per frame */ - static final int FRAME_LENGTH_MS = 20; /* 20 ms */ - static final int MAX_FRAME_LENGTH = (FRAME_LENGTH_MS * MAX_FS_KHZ); - - /* Milliseconds of lookahead for pitch analysis */ - static final int LA_PITCH_MS = 3; - static final int LA_PITCH_MAX = (LA_PITCH_MS * MAX_FS_KHZ); - - /* Milliseconds of lookahead for noise shape analysis */ - static final int LA_SHAPE_MS = 5; - static final int LA_SHAPE_MAX = (LA_SHAPE_MS * MAX_FS_KHZ); - - /* Order of LPC used in find pitch */ - static final int FIND_PITCH_LPC_ORDER_MAX = 16; - - /* Length of LPC window used in find pitch */ - static final int FIND_PITCH_LPC_WIN_MS = (30 + (LA_PITCH_MS << 1)); - static final int FIND_PITCH_LPC_WIN_MAX = (FIND_PITCH_LPC_WIN_MS * MAX_FS_KHZ); - - static final int PITCH_EST_COMPLEXITY_HC_MODE = Silk_SigProc_FIX.SKP_Silk_PITCH_EST_MAX_COMPLEX; - static final int PITCH_EST_COMPLEXITY_MC_MODE = Silk_SigProc_FIX.SKP_Silk_PITCH_EST_MID_COMPLEX; - static final int PITCH_EST_COMPLEXITY_LC_MODE = Silk_SigProc_FIX.SKP_Silk_PITCH_EST_MIN_COMPLEX; - - - /* Max number of bytes in payload output buffer (may contain multiple frames) */ - static final int MAX_ARITHM_BYTES = 1024; - - static final int RANGE_CODER_WRITE_BEYOND_BUFFER = -1; - static final int RANGE_CODER_CDF_OUT_OF_RANGE = -2; - static final int RANGE_CODER_NORMALIZATION_FAILED = -3; - static final int RANGE_CODER_ZERO_INTERVAL_WIDTH = -4; - static final int RANGE_CODER_DECODER_CHECK_FAILED = -5; - static final int RANGE_CODER_READ_BEYOND_BUFFER = -6; - static final int RANGE_CODER_ILLEGAL_SAMPLING_RATE = -7; - static final int RANGE_CODER_DEC_PAYLOAD_TOO_LONG = -8; - - /* dB level of lowest gain quantization level */ - static final int MIN_QGAIN_DB = 6; - /* dB level of highest gain quantization level */ - static final int MAX_QGAIN_DB = 86; - /* Number of gain quantization levels */ - static final int N_LEVELS_QGAIN = 64; - /* Max increase in gain quantization index */ - static final int MAX_DELTA_GAIN_QUANT = 40; - /* Max decrease in gain quantization index */ - static final int MIN_DELTA_GAIN_QUANT = -4; - - /* Quantization offsets (multiples of 4) */ - static final int OFFSET_VL_Q10 = 32; - static final int OFFSET_VH_Q10 = 100; - static final int OFFSET_UVL_Q10 = 100; - static final int OFFSET_UVH_Q10 = 256; - - /* Maximum numbers of iterations used to stabilize a LPC vector */ - static final int MAX_LPC_STABILIZE_ITERATIONS = 20; - - static final int MAX_LPC_ORDER = 16; - static final int MIN_LPC_ORDER = 10; - - /* Find Pred Coef defines */ - static final int LTP_ORDER = 5; - - /* LTP quantization settings */ - static final int NB_LTP_CBKS = 3; - - /* Number of subframes */ - static final int NB_SUBFR = 4; - - /* Flag to use harmonic noise shaping */ - static final int USE_HARM_SHAPING = 1; - - /* Max LPC order of noise shaping filters */ - static final int SHAPE_LPC_ORDER_MAX = 16; - - static final int HARM_SHAPE_FIR_TAPS = 3; - - /* Length of LPC window used in noise shape analysis */ - static final int SHAPE_LPC_WIN_MS = 15; - static final int SHAPE_LPC_WIN_16_KHZ = (SHAPE_LPC_WIN_MS * 16); - static final int SHAPE_LPC_WIN_24_KHZ = (SHAPE_LPC_WIN_MS * 24); - static final int SHAPE_LPC_WIN_MAX = (SHAPE_LPC_WIN_MS * MAX_FS_KHZ); - - /* Maximum number of delayed decision states */ - static final int DEL_DEC_STATES_MAX = 4; - - static final int LTP_BUF_LENGTH = 512; - static final int LTP_MASK = (LTP_BUF_LENGTH - 1); - - static final int DECISION_DELAY = 32; - static final int DECISION_DELAY_MASK = (DECISION_DELAY - 1); - - /* number of subframes for excitation entropy coding */ - static final int SHELL_CODEC_FRAME_LENGTH = 16; - static final int MAX_NB_SHELL_BLOCKS = (MAX_FRAME_LENGTH / SHELL_CODEC_FRAME_LENGTH); - - /* number of rate levels, for entropy coding of excitation */ - static final int N_RATE_LEVELS = 10; - - /* maximum sum of pulses per shell coding frame */ - static final int MAX_PULSES = 18; - - static final int MAX_MATRIX_SIZE = MAX_LPC_ORDER; /* Max of LPC Order and LTP order */ - -//TODO: convert a macro to a method. - static int NSQ_LPC_BUF_LENGTH() - { - if(MAX_LPC_ORDER > DECISION_DELAY) - return MAX_LPC_ORDER; - else - return DECISION_DELAY; - } - /***********************/ - /* High pass filtering */ - /***********************/ - static final int HIGH_PASS_INPUT = 1; - - /***************************/ - /* Voice activity detector */ - /***************************/ - static final int VAD_N_BANDS = 4; /* 0-1, 1-2, 2-4, and 4-8 kHz */ - - static final int VAD_INTERNAL_SUBFRAMES_LOG2 = 2; - static final int VAD_INTERNAL_SUBFRAMES = (1 << VAD_INTERNAL_SUBFRAMES_LOG2); - - static final int VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 = 1024; /* Must be < 4096 */ - static final int VAD_NOISE_LEVELS_BIAS = 50 ; - - /* Sigmoid settings */ - static final int VAD_NEGATIVE_OFFSET_Q5 = 128 ; /* sigmoid is 0 at -128 */ - static final int VAD_SNR_FACTOR_Q16 = 45000 ; - - /* smoothing for SNR measurement */ - static final int VAD_SNR_SMOOTH_COEF_Q18 = 4096; - - /******************/ - /* NLSF quantizer */ - /******************/ - static final int NLSF_MSVQ_MAX_CB_STAGES = 10; /* Update manually when changing codebooks */ - static final int NLSF_MSVQ_MAX_VECTORS_IN_STAGE = 128;/* Update manually when changing codebooks */ - static final int NLSF_MSVQ_MAX_VECTORS_IN_STAGE_TWO_TO_END = 16; /* Update manually when changing codebooks */ - - static final int NLSF_MSVQ_FLUCTUATION_REDUCTION = 1; - static final int MAX_NLSF_MSVQ_SURVIVORS = 16; - static final int MAX_NLSF_MSVQ_SURVIVORS_LC_MODE = 2; - static final int MAX_NLSF_MSVQ_SURVIVORS_MC_MODE = 4; - - /* Based on above defines, calculate how much memory is necessary to allocate */ - static int NLSF_MSVQ_TREE_SEARCH_MAX_VECTORS_EVALUATED_LC_MODE() - { - if(NLSF_MSVQ_MAX_VECTORS_IN_STAGE > ( MAX_NLSF_MSVQ_SURVIVORS_LC_MODE * NLSF_MSVQ_MAX_VECTORS_IN_STAGE_TWO_TO_END )) - return NLSF_MSVQ_MAX_VECTORS_IN_STAGE; - else - return MAX_NLSF_MSVQ_SURVIVORS_LC_MODE * NLSF_MSVQ_MAX_VECTORS_IN_STAGE_TWO_TO_END; - } - - static int NLSF_MSVQ_TREE_SEARCH_MAX_VECTORS_EVALUATED() - { - if( NLSF_MSVQ_MAX_VECTORS_IN_STAGE > ( MAX_NLSF_MSVQ_SURVIVORS * NLSF_MSVQ_MAX_VECTORS_IN_STAGE_TWO_TO_END ) ) - return NLSF_MSVQ_MAX_VECTORS_IN_STAGE; - else - return MAX_NLSF_MSVQ_SURVIVORS * NLSF_MSVQ_MAX_VECTORS_IN_STAGE_TWO_TO_END; - } - - static final int NLSF_MSVQ_SURV_MAX_REL_RD = 4; - - /* Transition filtering for mode switching */ - static final int TRANSITION_TIME_UP_MS = 5120; // 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4) - static final int TRANSITION_TIME_DOWN_MS = 2560; // 2560 = 32 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 32*(20*4) - static final int TRANSITION_NB = 3; /* Hardcoded in tables */ - static final int TRANSITION_NA = 2; /* Hardcoded in tables */ - static final int TRANSITION_INT_NUM = 5; /* Hardcoded in tables */ - static final int TRANSITION_FRAMES_UP = ( TRANSITION_TIME_UP_MS / FRAME_LENGTH_MS ); - static final int TRANSITION_FRAMES_DOWN = ( TRANSITION_TIME_DOWN_MS / FRAME_LENGTH_MS ); - static final int TRANSITION_INT_STEPS_UP = ( TRANSITION_FRAMES_UP / ( TRANSITION_INT_NUM - 1 ) ); - static final int TRANSITION_INT_STEPS_DOWN = ( TRANSITION_FRAMES_DOWN / ( TRANSITION_INT_NUM - 1 ) ); - -//TODO:no need to convert from C to Java? - /* Row based */ -// #define matrix_ptr(Matrix_base_adr, row, column, N) *(Matrix_base_adr + ((row)*(N)+(column))) -// #define matrix_adr(Matrix_base_adr, row, column, N) (Matrix_base_adr + ((row)*(N)+(column))) - - /* Column based */ -// #ifndef matrix_c_ptr -// # define matrix_c_ptr(Matrix_base_adr, row, column, M) *(Matrix_base_adr + ((row)+(M)*(column))) -// #endif -// #define matrix_c_adr(Matrix_base_adr, row, column, M) (Matrix_base_adr + ((row)+(M)*(column))) - - /* BWE factors to apply after packet loss */ - static final int BWE_AFTER_LOSS_Q16 = 63570; - - /* Defines for CN generation */ - static final int CNG_BUF_MASK_MAX = 255; /* 2^floor(log2(MAX_FRAME_LENGTH)) */ - static final int CNG_GAIN_SMTH_Q16 = 4634; /* 0.25^(1/4) */ - static final int CNG_NLSF_SMTH_Q16 = 16348; /* 0.25 */ -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_define_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_define_FLP.java deleted file mode 100644 index 34d5f020f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_define_FLP.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_define_FLP -{ - /*******************/ - /* Pitch estimator */ - /*******************/ - - /* Level of noise floor for whitening filter LPC analysis in pitch analysis */ - static final float FIND_PITCH_WHITE_NOISE_FRACTION = 1e-3f; - - /* Bandwidth expansion for whitening filter in pitch analysis */ - static final float FIND_PITCH_BANDWITH_EXPANSION = 0.99f; - - /* Threshold used by pitch estimator for early escape */ - static final float FIND_PITCH_CORRELATION_THRESHOLD_HC_MODE = 0.7f; - static final float FIND_PITCH_CORRELATION_THRESHOLD_MC_MODE = 0.75f; - static final float FIND_PITCH_CORRELATION_THRESHOLD_LC_MODE = 0.8f; - - /***********************/ - /* Long-Term predictor */ - /***********************/ - - /* Regualarization factor for correlation matrix. Equivalent to adding noise at -50 dB */ - static final float FIND_LTP_COND_FAC = 1e-5f; - static final float FIND_LPC_COND_FAC = 6e-5f; - - /* Find prediction coefficients defines */ - static final float LTP_DAMPING = 0.001f; - static final float LTP_SMOOTHING = 0.1f; - - /* LTP quantization settings */ - static final float MU_LTP_QUANT_NB = 0.03f; - static final float MU_LTP_QUANT_MB = 0.025f; - static final float MU_LTP_QUANT_WB = 0.02f; - static final float MU_LTP_QUANT_SWB = 0.016f; - - /***********************/ - /* High pass filtering */ - /***********************/ - - /* Smoothing parameters for low end of pitch frequency range estimation */ - static final float VARIABLE_HP_SMTH_COEF1 = 0.1f; - static final float VARIABLE_HP_SMTH_COEF2 = 0.015f; - - /* Min and max values for low end of pitch frequency range estimation */ - static final float VARIABLE_HP_MIN_FREQ = 80.0f; - static final float VARIABLE_HP_MAX_FREQ = 150.0f; - - /* Max absolute difference between log2 of pitch frequency and smoother state, to enter the smoother */ - static final float VARIABLE_HP_MAX_DELTA_FREQ = 0.4f; - - /***********/ - /* Various */ - /***********/ - - /* Required speech activity for counting frame as active */ - static final float WB_DETECT_ACTIVE_SPEECH_LEVEL_THRES = 0.7f; - - static final float SPEECH_ACTIVITY_DTX_THRES = 0.1f; - - /* Speech Activity LBRR enable threshold (needs tuning) */ - static final float LBRR_SPEECH_ACTIVITY_THRES = 0.5f; - - static final float Q14_CONVERSION_FAC = 6.1035e-005f; // 1 / 2^14 -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_detect_SWB_input.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_detect_SWB_input.java deleted file mode 100644 index b34ec6630..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_detect_SWB_input.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Detect SWB input by measuring energy above 8 kHz. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_detect_SWB_input -{ - /** - * Detect SWB input by measuring energy above 8 kHz. - * @param psSWBdetect encoder state - * @param samplesIn input to encoder - * @param samplesIn_offset offset of valid data. - * @param nSamplesIn length of input - */ - static void SKP_Silk_detect_SWB_input( - SKP_Silk_detect_SWB_state psSWBdetect, /* (I/O) encoder state */ - short[] samplesIn, /* (I) input to encoder */ - int samplesIn_offset, - int nSamplesIn /* (I) length of input */ - ) - { - int HP_8_kHz_len, i, shift[] = new int[1]; - short[] in_HP_8_kHz = new short[ Silk_define.MAX_FRAME_LENGTH ]; - int[] energy_32 = new int[1]; - - /* High pass filter with cutoff at 8 khz */ - HP_8_kHz_len = Math.min( nSamplesIn, Silk_define.MAX_FRAME_LENGTH ); - HP_8_kHz_len = Math.max( HP_8_kHz_len, 0 ); - - /* Cutoff around 9 khz */ - /* A = conv(conv([8192,14613, 6868], [8192,12883, 7337]), [8192,11586, 7911]); */ - /* B = conv(conv([575, -948, 575], [575, -221, 575]), [575, 104, 575]); */ - Silk_biquad.SKP_Silk_biquad( samplesIn, samplesIn_offset, Silk_tables_other.SKP_Silk_SWB_detect_B_HP_Q13[ 0 ], Silk_tables_other.SKP_Silk_SWB_detect_A_HP_Q13[ 0 ], - psSWBdetect.S_HP_8_kHz[ 0 ], in_HP_8_kHz, 0, HP_8_kHz_len ); - for( i = 1; i < Silk_define.NB_SOS; i++ ) - { - Silk_biquad.SKP_Silk_biquad( in_HP_8_kHz, 0, Silk_tables_other.SKP_Silk_SWB_detect_B_HP_Q13[ i ], Silk_tables_other.SKP_Silk_SWB_detect_A_HP_Q13[ i ], - psSWBdetect.S_HP_8_kHz[ i ], in_HP_8_kHz, 0, HP_8_kHz_len ); - } - - /* Calculate energy in HP signal */ - Silk_sum_sqr_shift.SKP_Silk_sum_sqr_shift( energy_32, shift, in_HP_8_kHz, 0, HP_8_kHz_len ); - - /* Count concecutive samples above threshold, after adjusting threshold for number of input samples and shift */ - if( energy_32[0] > Silk_macros.SKP_SMULBB( Silk_define.HP_8_KHZ_THRES, HP_8_kHz_len ) >> shift[0] ) - { - psSWBdetect.ConsecSmplsAboveThres += nSamplesIn; - if( psSWBdetect.ConsecSmplsAboveThres > Silk_define.CONCEC_SWB_SMPLS_THRES ) - { - psSWBdetect.SWB_detected = 1; - } - } - else - { - psSWBdetect.ConsecSmplsAboveThres -= nSamplesIn; - psSWBdetect.ConsecSmplsAboveThres = Math.max( psSWBdetect.ConsecSmplsAboveThres, 0 ); - } - - /* If sufficient speech activity and no SWB detected, we detect the signal as being WB */ - if( ( psSWBdetect.ActiveSpeech_ms > Silk_define.WB_DETECT_ACTIVE_SPEECH_MS_THRES ) && ( psSWBdetect.SWB_detected == 0 ) ) - { - psSWBdetect.WB_detected = 1; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_enc_API.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_enc_API.java deleted file mode 100644 index a6f714977..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_enc_API.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Encoder API. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_enc_API -{ - /*** - * TODO: TEST - */ - static int frame_cnt = 0; - - /** - * Read control structure from encoder. - * @param encState State Vecotr. - * @param encStatus Control Structure. - * @return - */ - static int SKP_Silk_SDK_QueryEncoder - ( - Object encState, /* I: State Vector */ - SKP_SILK_SDK_EncControlStruct encStatus /* O: Control Structure */ - ) - { - SKP_Silk_encoder_state_FLP psEnc; - int ret = 0; - - psEnc = ( SKP_Silk_encoder_state_FLP )encState; - - encStatus.API_sampleRate = psEnc.sCmn.API_fs_Hz; - encStatus.maxInternalSampleRate = Silk_macros.SKP_SMULBB( psEnc.sCmn.maxInternal_fs_kHz, 1000 ); - encStatus.packetSize = ( psEnc.sCmn.API_fs_Hz * psEnc.sCmn.PacketSize_ms / 1000 ); /* convert samples -> ms */ - encStatus.bitRate = psEnc.sCmn.TargetRate_bps; - encStatus.packetLossPercentage = psEnc.sCmn.PacketLoss_perc; - encStatus.complexity = psEnc.sCmn.Complexity; - encStatus.useInBandFEC = psEnc.sCmn.useInBandFEC; - encStatus.useDTX = psEnc.sCmn.useDTX; - return ret; - } - - /** - * Init or Reset encoder. - * @param encState - * @param encStatus - * @return - */ - static int SKP_Silk_SDK_InitEncoder - ( - Object encState, /* I/O: State */ - SKP_SILK_SDK_EncControlStruct encStatus /* O: Control structure */ - ) - { - SKP_Silk_encoder_state_FLP psEnc; - int ret = 0; - - - psEnc = ( SKP_Silk_encoder_state_FLP )encState; - - /* Reset Encoder */ - if( (ret += Silk_init_encoder_FLP.SKP_Silk_init_encoder_FLP( psEnc )) != 0 ) - { - assert( false ); - } - - /* Read control structure */ - if( (ret += SKP_Silk_SDK_QueryEncoder( encState, encStatus )) != 0 ) - { - assert( false ); - } - return ret; - } - - /** - * Encode frame with Silk. - * @param encState State - * @param encControl Control structure - * @param samplesIn Speech sample input vector - * @param samplesIn_offset offset of valid data. - * @param nSamplesIn Number of samples in input vector - * @param outData Encoded output vector - * @param outData_offset offset of valid data. - * @param nBytesOut Number of bytes in outData (input: Max bytes) - * @return - */ - static int SKP_Silk_SDK_Encode - ( - Object encState, /* I/O: State */ - SKP_SILK_SDK_EncControlStruct encControl, /* I: Control structure */ - final short[] samplesIn, /* I: Speech sample input vector */ - int samplesIn_offset, - int nSamplesIn, /* I: Number of samples in input vector */ - byte[] outData, /* O: Encoded output vector */ - int outData_offset, - short[] nBytesOut /* I/O: Number of bytes in outData (input: Max bytes) */ - ) - { - int max_internal_fs_kHz, PacketSize_ms, PacketLoss_perc, UseInBandFEC, UseDTX, ret = 0; - int nSamplesToBuffer, Complexity, input_ms, nSamplesFromInput = 0; - int TargetRate_bps, API_fs_Hz; - short MaxBytesOut; - SKP_Silk_encoder_state_FLP psEnc = ( SKP_Silk_encoder_state_FLP )encState; - - assert( encControl != null ); - - /* Check sampling frequency first, to avoid divide by zero later */ - if( ( ( encControl.API_sampleRate != 8000 ) && - ( encControl.API_sampleRate != 12000 ) && - ( encControl.API_sampleRate != 16000 ) && - ( encControl.API_sampleRate != 24000 ) && - ( encControl.API_sampleRate != 32000 ) && - ( encControl.API_sampleRate != 44100 ) && - ( encControl.API_sampleRate != 48000 ) ) || - ( ( encControl.maxInternalSampleRate != 8000 ) && - ( encControl.maxInternalSampleRate != 12000 ) && - ( encControl.maxInternalSampleRate != 16000 ) && - ( encControl.maxInternalSampleRate != 24000 ) ) ) - { - ret = Silk_errors.SKP_SILK_ENC_FS_NOT_SUPPORTED; - assert( false ); - return( ret ); - } - - /* Set encoder parameters from control structure */ - API_fs_Hz = encControl.API_sampleRate; - max_internal_fs_kHz = encControl.maxInternalSampleRate / 1000; /* convert Hz -> kHz */ - PacketSize_ms = 1000 * encControl.packetSize / API_fs_Hz; - TargetRate_bps = encControl.bitRate; - PacketLoss_perc = encControl.packetLossPercentage; - UseInBandFEC = encControl.useInBandFEC; - Complexity = encControl.complexity; - UseDTX = encControl.useDTX; - /* Save values in state */ - psEnc.sCmn.API_fs_Hz = API_fs_Hz; - psEnc.sCmn.maxInternal_fs_kHz = max_internal_fs_kHz; - psEnc.sCmn.useInBandFEC = UseInBandFEC; - - /* Only accept input lengths that are a multiplum of 10 ms */ - input_ms = 1000 * nSamplesIn / API_fs_Hz; - if( ( input_ms % 10) != 0 || nSamplesIn < 0 ) - { - ret = Silk_errors.SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; - assert( false ); - return( ret ); - } - - /* Make sure no more than one packet can be produced */ - if( nSamplesIn > ( psEnc.sCmn.PacketSize_ms * API_fs_Hz / 1000 ) ) - { - ret = Silk_errors.SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; - assert( false ); - return( ret ); - } - if( ( ret = Silk_control_codec_FLP.SKP_Silk_control_encoder_FLP( psEnc, API_fs_Hz, max_internal_fs_kHz, PacketSize_ms, TargetRate_bps, - PacketLoss_perc, UseInBandFEC, UseDTX, input_ms, Complexity) ) != 0 ) - { - assert( false ); - return( ret ); - } - /* Detect energy above 8 kHz */ - if( Math.min( API_fs_Hz, 1000 * max_internal_fs_kHz ) == 24000 && psEnc.sCmn.sSWBdetect.SWB_detected == 0 && psEnc.sCmn.sSWBdetect.WB_detected == 0 ) - { - Silk_detect_SWB_input.SKP_Silk_detect_SWB_input( psEnc.sCmn.sSWBdetect, samplesIn,samplesIn_offset, nSamplesIn ); - } - - /* Input buffering/resampling and encoding */ - MaxBytesOut = 0; /* return 0 output bytes if no encoder called */ - while( true ) - { - nSamplesToBuffer = psEnc.sCmn.frame_length - psEnc.sCmn.inputBufIx; - if( API_fs_Hz == Silk_macros.SKP_SMULBB( 1000, psEnc.sCmn.fs_kHz ) ) - { - nSamplesToBuffer = Math.min( nSamplesToBuffer, nSamplesIn ); - nSamplesFromInput = nSamplesToBuffer; - /* Copy to buffer */ - System.arraycopy(samplesIn, samplesIn_offset, psEnc.sCmn.inputBuf, psEnc.sCmn.inputBufIx, nSamplesFromInput); - } - else - { - nSamplesToBuffer = Math.min( nSamplesToBuffer, nSamplesIn * psEnc.sCmn.fs_kHz * 1000 / API_fs_Hz ); - nSamplesFromInput = ( nSamplesToBuffer * API_fs_Hz / ( psEnc.sCmn.fs_kHz * 1000 ) ); - /* Resample and write to buffer */ - ret += Silk_resampler.SKP_Silk_resampler(psEnc.sCmn.resampler_state, - psEnc.sCmn.inputBuf, psEnc.sCmn.inputBufIx, samplesIn, samplesIn_offset, nSamplesFromInput); - -///*TEST****************************************************************************/ -// /** -// * test for inputbuf -// */ -// short[] inputbuf = psEnc.sCmn.inputBuf; -// String inputbuf_filename = "D:/gsoc/inputbuf-res/inputbuf-res"; -// inputbuf_filename += frame_cnt; -// DataInputStream inputbuf_datain = null; -// try -// { -// inputbuf_datain = new DataInputStream( -// new FileInputStream( -// new File(inputbuf_filename))); -// byte[] buffer = new byte[2]; -// for(int ii = 0; ii < inputbuf.length; ii++ ) -// { -// try -// { -// -// int res = inputbuf_datain.read(buffer); -// if(res != buffer.length) -// { -// throw new IOException("Unexpected End of Stream"); -// } -// inputbuf[ii] = ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).getShort(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// finally -// { -// if(inputbuf_datain != null) -// { -// try -// { -// inputbuf_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// frame_cnt++; -///*TEST END****************************************************************************/ - } - samplesIn_offset += nSamplesFromInput; - nSamplesIn -= nSamplesFromInput; - psEnc.sCmn.inputBufIx += nSamplesToBuffer; - - /* Silk encoder */ - if( psEnc.sCmn.inputBufIx >= psEnc.sCmn.frame_length ) - { - /* Enough data in input buffer, so encode */ - if( MaxBytesOut == 0 ) - { - /* No payload obtained so far */ - MaxBytesOut = nBytesOut[0]; - short MaxBytesOut_ptr[] = new short[1]; - MaxBytesOut_ptr[0] = MaxBytesOut; -// if( ( ret = Silk_encode_frame_FLP.SKP_Silk_encode_frame_FLP( psEnc, outData, outData_offset, -// MaxBytesOut_ptr, psEnc.sCmn.inputBuf, psEnc.sCmn.inputBufIx ) ) != 0 ) - if( ( ret = Silk_encode_frame_FLP.SKP_Silk_encode_frame_FLP( psEnc, outData, outData_offset, - MaxBytesOut_ptr, psEnc.sCmn.inputBuf, 0 ) ) != 0 ) - { - assert( false ); - } - MaxBytesOut = MaxBytesOut_ptr[0]; - } - else - { - /* outData already contains a payload */ -// if( ( ret = Silk_encode_frame_FLP.SKP_Silk_encode_frame_FLP( psEnc, outData, outData_offset, -// nBytesOut, psEnc.sCmn.inputBuf, psEnc.sCmn.inputBufIx) ) != 0 ) - if( ( ret = Silk_encode_frame_FLP.SKP_Silk_encode_frame_FLP( psEnc, outData, outData_offset, - nBytesOut, psEnc.sCmn.inputBuf, 0) ) != 0 ) - { - assert( false ); - } - /* Check that no second payload was created */ - assert( nBytesOut[0] == 0 ); - } - psEnc.sCmn.inputBufIx = 0; - } - else - { - break; - } - } - - nBytesOut[0] = MaxBytesOut; - if( psEnc.sCmn.useDTX!=0 && psEnc.sCmn.inDTX!=0 ) - { - /* DTX simulation */ - nBytesOut[0] = 0; - } - - return ret; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_encode_frame_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_encode_frame_FLP.java deleted file mode 100644 index b54741b2c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_encode_frame_FLP.java +++ /dev/null @@ -1,701 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * Encode frame. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_encode_frame_FLP -{ - /** - * TODO: TEST - */ - static int frame_cnt = 0; - /** - * Encode frame. - * @param psEnc Encoder state FLP - * @param pCode payload - * @param pCode_offset offset of valid data. - * @param pnBytesOut Number of payload bytes; input: max length; output: used. - * @param pIn Input speech frame - * @param pIn_offset offset of valid data. - * @return - */ - static int SKP_Silk_encode_frame_FLP( - SKP_Silk_encoder_state_FLP psEnc, /* I/O Encoder state FLP */ - byte[] pCode, - int pCode_offset, - short[] pnBytesOut, /* I/O Number of payload bytes; */ - /* input: max length; output: used */ - short[] pIn, /* I Input speech frame */ - int pIn_offset - ) - { - SKP_Silk_encoder_control_FLP sEncCtrl = new SKP_Silk_encoder_control_FLP(); - int k, nBytes[] = new int[1], ret = 0; - float[] x_frame, res_pitch_frame; - int x_frame_offset, res_pitch_frame_offset; - short[] pIn_HP = new short[ Silk_define.MAX_FRAME_LENGTH ]; - short[] pIn_HP_LP = new short[ Silk_define.MAX_FRAME_LENGTH ]; - float[] xfw = new float[ Silk_define.MAX_FRAME_LENGTH ]; - float[] res_pitch = new float[ 2 * Silk_define.MAX_FRAME_LENGTH + Silk_define.LA_PITCH_MAX ]; - int LBRR_idx, frame_terminator; - - /* Low bitrate redundancy parameters */ - byte[] LBRRpayload = new byte[Silk_define.MAX_ARITHM_BYTES]; - short[] nBytesLBRR = new short[1]; - - int[] FrameTermination_CDF; - - - sEncCtrl.sCmn.Seed = psEnc.sCmn.frameCounter++ & 3; - /**************************************************************/ - /* Setup Input Pointers, and insert frame in input buffer */ - /*************************************************************/ - /* pointers aligned with start of frame to encode */ - x_frame = psEnc.x_buf; - x_frame_offset = psEnc.x_buf_offset + psEnc.sCmn.frame_length; // start of frame to encode - res_pitch_frame = res_pitch; - res_pitch_frame_offset = psEnc.sCmn.frame_length; // start of pitch LPC residual frame - - /****************************/ - /* Voice Activity Detection */ - /****************************/ - Silk_wrappers_FLP.SKP_Silk_VAD_FLP( psEnc, sEncCtrl, pIn, pIn_offset ); - - /*******************************************/ - /* High-pass filtering of the input signal */ - /*******************************************/ - if (Silk_define.HIGH_PASS_INPUT !=0) { - /* Variable high-pass filter */ - Silk_HP_variable_cutoff_FLP.SKP_Silk_HP_variable_cutoff_FLP( psEnc, sEncCtrl, pIn_HP, 0, pIn, pIn_offset ); - } else { - System.arraycopy(pIn, pIn_offset, pIn_HP, 0, psEnc.sCmn.frame_length); - } - - -// /*TEST****************************************************************************/ -// /** -// * test for psEnc.x_buf -// */ -// short[] pin_hp = pIn_HP; -// String pin_hp_filename = "D:/gsoc/pin_hp/pin_hp"; -// pin_hp_filename += frame_cnt; -// DataInputStream pin_hp_datain = null; -// try -// { -// pin_hp_datain = new DataInputStream( -// new FileInputStream( -// new File(pin_hp_filename))); -// byte[] buffer = new byte[2]; -// for(int ii = 0; ii < pin_hp.length; ii++ ) -// { -// try -// { -// -// int res = pin_hp_datain.read(buffer); -// if(res != buffer.length) -// { -// throw new IOException("Unexpected End of Stream"); -// } -// pin_hp[ii] = ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).getShort(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// finally -// { -// if(pin_hp_datain != null) -// { -// try -// { -// pin_hp_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// frame_cnt++; -/*TEST END****************************************************************************/ - if (Silk_define.SWITCH_TRANSITION_FILTERING != 0) { - /* Ensure smooth bandwidth transitions */ - Silk_LP_variable_cutoff.SKP_Silk_LP_variable_cutoff( psEnc.sCmn.sLP, pIn_HP_LP, 0, pIn_HP, 0, psEnc.sCmn.frame_length ); - } else { - System.arraycopy(pIn_HP, 0, pIn_HP_LP, 0, psEnc.sCmn.frame_length); - } - -///*TEST****************************************************************************/ -// /** -// * test for psEnc.x_buf -// */ -// short[] pin_hp_lp = pIn_HP_LP; -// String pin_hp_lp_filename = "D:/gsoc/pin_hp_lp/pin_hp_lp"; -// pin_hp_lp_filename += frame_cnt; -// DataInputStream pin_hp_lp_datain = null; -// try -// { -// pin_hp_lp_datain = new DataInputStream( -// new FileInputStream( -// new File(pin_hp_lp_filename))); -// byte[] buffer = new byte[2]; -// for(int ii = 0; ii < pin_hp_lp.length; ii++ ) -// { -// try -// { -// -// int res = pin_hp_lp_datain.read(buffer); -// if(res != buffer.length) -// { -// throw new IOException("Unexpected End of Stream"); -// } -// pin_hp_lp[ii] = ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).getShort(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// finally -// { -// if(pin_hp_lp_datain != null) -// { -// try -// { -// pin_hp_lp_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// frame_cnt++; -///*TEST END****************************************************************************/ - - -///*TEST****************************************************************************/ -// /** -// * test for psEnc.x_buf -// */ -// float[] x_buf = psEnc.x_buf; -// String x_buf_filename = "D:/gsoc/x_buf/x_buf"; -// x_buf_filename += frame_cnt; -// DataInputStream x_buf_datain = null; -// try -// { -// x_buf_datain = new DataInputStream( -// new FileInputStream( -// new File(x_buf_filename))); -// byte[] buffer = new byte[4]; -// for(int ii = 0; ii < x_buf.length; ii++ ) -// { -// try -// { -// -// int res = x_buf_datain.read(buffer); -// if(res != 4) -// { -// throw new IOException("Unexpected End of Stream"); -// } -// x_buf[ii] = ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).getFloat(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// finally -// { -// if(x_buf_datain != null) -// { -// try -// { -// x_buf_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// frame_cnt++; -///*TEST END****************************************************************************/ - /*******************************************/ - /* Copy new frame to front of input buffer */ - /*******************************************/ - Silk_SigProc_FLP.SKP_short2float_array( x_frame, x_frame_offset +psEnc.sCmn.la_shape, - pIn_HP_LP, 0, psEnc.sCmn.frame_length ); - -///*TEST****************************************************************************/ -// /** -// * test for psEnc.x_buf -// */ -// float[] x_buf = psEnc.x_buf; -// String x_buf_filename = "D:/gsoc/x_buf/x_buf"; -// x_buf_filename += frame_cnt; -// DataInputStream x_buf_datain = null; -// try -// { -// x_buf_datain = new DataInputStream( -// new FileInputStream( -// new File(x_buf_filename))); -// byte[] buffer = new byte[4]; -// for(int ii = 0; ii < x_buf.length; ii++ ) -// { -// try -// { -// -// int res = x_buf_datain.read(buffer); -// if(res != 4) -// { -// throw new IOException("Unexpected End of Stream"); -// } -// x_buf[ii] = ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).getFloat(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// finally -// { -// if(x_buf_datain != null) -// { -// try -// { -// x_buf_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// frame_cnt++; -///*TEST END****************************************************************************/ - - /* Add tiny signal to avoid high CPU load from denormalized floating point numbers */ - for( k = 0; k < 8; k++ ) { - x_frame[ x_frame_offset + psEnc.sCmn.la_shape + k * ( psEnc.sCmn.frame_length >> 3 ) ] += ( 1 - ( k & 2 ) ) * 1e-6f; - } -/*TEST****************************************************************************/ - /** - * test for psEnc.x_buf - */ - /** - * Test for NLSF - */ -// float[] x_buf = new float[ psEnc.x_buf.length ]; -// float[] x_buf = psEnc.x_buf; -// String x_buf_filename = "D:/gsoc/x_buf/x_buf"; -// x_buf_filename += frame_cnt; -// DataInputStream x_buf_datain = null; -// try -// { -// x_buf_datain = new DataInputStream( -// new FileInputStream( -// new File(x_buf_filename))); -// byte[] buffer = new byte[4]; -// for(int ii = 0; ii < x_buf.length; ii++ ) -// { -// try -// { -// -// int res = x_buf_datain.read(buffer); -// if(res != 4) -// { -// throw new IOException("Unexpected End of Stream"); -// } -// x_buf[ii] = ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).getFloat(); -//// NLSF[ii] = nlsf[ii]; -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// finally -// { -// if(x_buf_datain != null) -// { -// try -// { -// x_buf_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// frame_cnt++; -/*TEST END****************************************************************************/ - /*****************************************/ - /* Find pitch lags, initial LPC analysis */ - /*****************************************/ - Silk_find_pitch_lags_FLP.SKP_Silk_find_pitch_lags_FLP( psEnc, sEncCtrl, res_pitch, x_frame, x_frame_offset ); - - /************************/ - /* Noise shape analysis */ - /************************/ - Silk_noise_shape_analysis_FLP.SKP_Silk_noise_shape_analysis_FLP( psEnc, sEncCtrl, - res_pitch_frame, res_pitch_frame_offset, x_frame, x_frame_offset ); - - /*****************************************/ - /* Prefiltering for noise shaper */ - /*****************************************/ - Silk_prefilter_FLP.SKP_Silk_prefilter_FLP( psEnc, sEncCtrl, xfw, x_frame, x_frame_offset ); - - /***************************************************/ - /* Find linear prediction coefficients (LPC + LTP) */ - /***************************************************/ - Silk_find_pred_coefs_FLP.SKP_Silk_find_pred_coefs_FLP( psEnc, sEncCtrl, res_pitch ); - - /****************************************/ - /* Process gains */ - /****************************************/ - Silk_process_gains_FLP.SKP_Silk_process_gains_FLP( psEnc, sEncCtrl ); - - /****************************************/ - /* Low Bitrate Redundant Encoding */ - /****************************************/ - nBytesLBRR[0] = Silk_define.MAX_ARITHM_BYTES; - SKP_Silk_LBRR_encode_FLP( psEnc, sEncCtrl, LBRRpayload, nBytesLBRR, xfw ); - - /*****************************************/ - /* Noise shaping quantization */ - /*****************************************/ - Silk_wrappers_FLP.SKP_Silk_NSQ_wrapper_FLP( psEnc, sEncCtrl, xfw, 0, psEnc.sCmn.q, 0, 0 ); - - /**************************************************/ - /* Convert speech activity into VAD and DTX flags */ - /**************************************************/ - if( psEnc.speech_activity < Silk_define_FLP.SPEECH_ACTIVITY_DTX_THRES ) { - psEnc.sCmn.vadFlag = Silk_define.NO_VOICE_ACTIVITY; - psEnc.sCmn.noSpeechCounter++; - if( psEnc.sCmn.noSpeechCounter > Silk_define.NO_SPEECH_FRAMES_BEFORE_DTX ) { - psEnc.sCmn.inDTX = 1; - } - if( psEnc.sCmn.noSpeechCounter > Silk_define.MAX_CONSECUTIVE_DTX ) { - psEnc.sCmn.noSpeechCounter = 0; - psEnc.sCmn.inDTX = 0; - } - } else { - psEnc.sCmn.noSpeechCounter = 0; - psEnc.sCmn.inDTX = 0; - psEnc.sCmn.vadFlag = Silk_define.VOICE_ACTIVITY; - } - - /****************************************/ - /* Initialize arithmetic coder */ - /****************************************/ - if( psEnc.sCmn.nFramesInPayloadBuf == 0 ) - { - Silk_range_coder.SKP_Silk_range_enc_init( psEnc.sCmn.sRC ); - psEnc.sCmn.nBytesInPayloadBuf = 0; - } - - /****************************************/ - /* Encode Parameters */ - /****************************************/ - Silk_encode_parameters.SKP_Silk_encode_parameters( psEnc.sCmn, sEncCtrl.sCmn, psEnc.sCmn.sRC, psEnc.sCmn.q ); - FrameTermination_CDF = Silk_tables_other.SKP_Silk_FrameTermination_CDF; - - /****************************************/ - /* Update Buffers and State */ - /****************************************/ - /* Update input buffer */ - System.arraycopy(psEnc.x_buf, psEnc.x_buf_offset + psEnc.sCmn.frame_length, - psEnc.x_buf, psEnc.x_buf_offset, psEnc.sCmn.frame_length + psEnc.sCmn.la_shape); - - /* Parameters needed for next frame */ - psEnc.sCmn.prev_sigtype = sEncCtrl.sCmn.sigtype; - psEnc.sCmn.prevLag = sEncCtrl.sCmn.pitchL[ Silk_define.NB_SUBFR - 1]; - psEnc.sCmn.first_frame_after_reset = 0; - - if( psEnc.sCmn.sRC.error != 0 ) { - /* Encoder returned error: Clear payload buffer */ - psEnc.sCmn.nFramesInPayloadBuf = 0; - } else { - psEnc.sCmn.nFramesInPayloadBuf++; - } - - /****************************************/ - /* Finalize payload and copy to output */ - /****************************************/ - if( psEnc.sCmn.nFramesInPayloadBuf * Silk_define.FRAME_LENGTH_MS >= psEnc.sCmn.PacketSize_ms ) { - - LBRR_idx = ( psEnc.sCmn.oldest_LBRR_idx + 1 ) & Silk_define.LBRR_IDX_MASK; - - /* Check if FEC information should be added */ - frame_terminator = Silk_define.SKP_SILK_LAST_FRAME; - if( psEnc.sCmn.LBRR_buffer[ LBRR_idx ].usage == Silk_define.SKP_SILK_ADD_LBRR_TO_PLUS1 ) { - frame_terminator = Silk_define.SKP_SILK_LBRR_VER1; - } - if( psEnc.sCmn.LBRR_buffer[ psEnc.sCmn.oldest_LBRR_idx ].usage == Silk_define.SKP_SILK_ADD_LBRR_TO_PLUS2 ) { - frame_terminator = Silk_define.SKP_SILK_LBRR_VER2; - LBRR_idx = psEnc.sCmn.oldest_LBRR_idx; - } - - /* Add the frame termination info to stream */ - Silk_range_coder.SKP_Silk_range_encoder( psEnc.sCmn.sRC, frame_terminator, FrameTermination_CDF,0 ); - - /* Payload length so far */ - Silk_range_coder.SKP_Silk_range_coder_get_length( psEnc.sCmn.sRC, nBytes ); - - /* Check that there is enough space in external output buffer, and move data */ - if( pnBytesOut[0] >= nBytes[0] ) { - Silk_range_coder.SKP_Silk_range_enc_wrap_up( psEnc.sCmn.sRC ); - System.arraycopy(psEnc.sCmn.sRC.buffer, 0, pCode, pCode_offset, nBytes[0]); - - if( frame_terminator > Silk_define.SKP_SILK_MORE_FRAMES && - pnBytesOut[0] >= nBytes[0] + psEnc.sCmn.LBRR_buffer[ LBRR_idx ].nBytes ) { - /* Get old packet and add to payload. */ - System.arraycopy(psEnc.sCmn.LBRR_buffer[ LBRR_idx ].payload, 0, - pCode, pCode_offset+nBytes[0], psEnc.sCmn.LBRR_buffer[ LBRR_idx ].nBytes); - nBytes[0] += psEnc.sCmn.LBRR_buffer[ LBRR_idx ].nBytes; - } - pnBytesOut[0] = (short) nBytes[0]; - - /* Update FEC buffer */ - System.arraycopy(LBRRpayload, 0, - psEnc.sCmn.LBRR_buffer[ psEnc.sCmn.oldest_LBRR_idx ].payload, 0, nBytesLBRR[0]); - psEnc.sCmn.LBRR_buffer[ psEnc.sCmn.oldest_LBRR_idx ].nBytes = nBytesLBRR[0]; - /* The below line describes how FEC should be used */ - psEnc.sCmn.LBRR_buffer[ psEnc.sCmn.oldest_LBRR_idx ].usage = sEncCtrl.sCmn.LBRR_usage; - psEnc.sCmn.oldest_LBRR_idx = ( ( psEnc.sCmn.oldest_LBRR_idx + 1 ) & Silk_define.LBRR_IDX_MASK ); - - /* Reset the number of frames in payload buffer */ - psEnc.sCmn.nFramesInPayloadBuf = 0; - } else { - /* Not enough space: Payload will be discarded */ - pnBytesOut[0] = 0; - nBytes[0] = 0; - psEnc.sCmn.nFramesInPayloadBuf = 0; - ret = Silk_errors.SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT; - } - } else { - /* No payload for you this time */ - pnBytesOut[0] = 0; - - /* Encode that more frames follows */ - frame_terminator = Silk_define.SKP_SILK_MORE_FRAMES; - Silk_range_coder.SKP_Silk_range_encoder( psEnc.sCmn.sRC, frame_terminator, FrameTermination_CDF, 0); - - /* Payload length so far */ - Silk_range_coder.SKP_Silk_range_coder_get_length( psEnc.sCmn.sRC, nBytes ); - } - - /* Check for arithmetic coder errors */ - if( psEnc.sCmn.sRC.error != 0 ) { - ret = Silk_errors.SKP_SILK_ENC_INTERNAL_ERROR; - } - - /* simulate number of ms buffered in channel because of exceeding TargetRate */ - psEnc.BufferedInChannel_ms += ( 8.0f * 1000.0f * ( nBytes[0] - psEnc.sCmn.nBytesInPayloadBuf ) ) / psEnc.sCmn.TargetRate_bps; - psEnc.BufferedInChannel_ms -= Silk_define.FRAME_LENGTH_MS; - psEnc.BufferedInChannel_ms = Silk_SigProc_FLP.SKP_LIMIT_float( psEnc.BufferedInChannel_ms, 0.0f, 100.0f ); - psEnc.sCmn.nBytesInPayloadBuf = nBytes[0]; - - if( psEnc.speech_activity > Silk_define_FLP.WB_DETECT_ACTIVE_SPEECH_LEVEL_THRES ) { - psEnc.sCmn.sSWBdetect.ActiveSpeech_ms = Silk_SigProc_FIX.SKP_ADD_POS_SAT32( psEnc.sCmn.sSWBdetect.ActiveSpeech_ms, Silk_define.FRAME_LENGTH_MS ); - } - - return( ret ); - } - - /** - * Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate. - * @param psEnc Encoder state FLP. - * @param psEncCtrl Encoder control FLP. - * @param pCode Payload. - * @param pnBytesOut Payload bytes; in: max; out: used. - * @param xfw Input signal. - */ - static void SKP_Silk_LBRR_encode_FLP( - SKP_Silk_encoder_state_FLP psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP psEncCtrl, /* I/O Encoder control FLP */ - byte []pCode, /* O Payload */ - short []pnBytesOut, /* I/O Payload bytes; in: max; out: used */ - float xfw[] /* I Input signal */ - ) - { - int[] Gains_Q16 = new int[ Silk_define.NB_SUBFR ]; - int k, TempGainsIndices[] = new int[ Silk_define.NB_SUBFR ], frame_terminator; - int nBytes[] = new int[1], nFramesInPayloadBuf; - float TempGains[] = new float[ Silk_define.NB_SUBFR ]; - int typeOffset, LTP_scaleIndex, Rate_only_parameters = 0; - /* Control use of inband LBRR */ - Silk_control_codec_FLP.SKP_Silk_LBRR_ctrl_FLP( psEnc, psEncCtrl.sCmn ); - - if( psEnc.sCmn.LBRR_enabled != 0 ) { - /* Save original gains */ - System.arraycopy(psEncCtrl.sCmn.GainsIndices, 0, TempGainsIndices, 0, Silk_define.NB_SUBFR); - System.arraycopy(psEncCtrl.Gains, 0, TempGains, 0, Silk_define.NB_SUBFR); - - typeOffset = psEnc.sCmn.typeOffsetPrev; // Temp save as cannot be overwritten - LTP_scaleIndex = psEncCtrl.sCmn.LTP_scaleIndex; - - /* Set max rate where quant signal is encoded */ - if( psEnc.sCmn.fs_kHz == 8 ) { - Rate_only_parameters = 13500; - } else if( psEnc.sCmn.fs_kHz == 12 ) { - Rate_only_parameters = 15500; - } else if( psEnc.sCmn.fs_kHz == 16 ) { - Rate_only_parameters = 17500; - } else if( psEnc.sCmn.fs_kHz == 24 ) { - Rate_only_parameters = 19500; - } else { - assert( false ); - } - - if( psEnc.sCmn.Complexity > 0 && psEnc.sCmn.TargetRate_bps > Rate_only_parameters ) { - if( psEnc.sCmn.nFramesInPayloadBuf == 0 ) { - /* First frame in packet copy everything */ -//TODO:use clone rather than memory copy. - psEnc.sNSQ_LBRR = (SKP_Silk_nsq_state) psEnc.sNSQ.clone(); - - psEnc.sCmn.LBRRprevLastGainIndex = psEnc.sShape.LastGainIndex; - /* Increase Gains to get target LBRR rate */ - psEncCtrl.sCmn.GainsIndices[ 0 ] += psEnc.sCmn.LBRR_GainIncreases; - psEncCtrl.sCmn.GainsIndices[ 0 ] = Silk_SigProc_FIX.SKP_LIMIT( psEncCtrl.sCmn.GainsIndices[ 0 ], 0, Silk_define.N_LEVELS_QGAIN - 1 ); - } - /* Decode to get Gains in sync with decoder */ - int LBRRprevLastGainIndex_ptr[] = new int[1]; - LBRRprevLastGainIndex_ptr[0] = psEnc.sCmn.LBRRprevLastGainIndex; - Silk_gain_quant.SKP_Silk_gains_dequant( Gains_Q16, psEncCtrl.sCmn.GainsIndices, - LBRRprevLastGainIndex_ptr, psEnc.sCmn.nFramesInPayloadBuf ); - psEnc.sCmn.LBRRprevLastGainIndex = LBRRprevLastGainIndex_ptr[0]; - - /* Overwrite unquantized gains with quantized gains and convert back to Q0 from Q16 */ - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - psEncCtrl.Gains[ k ] = Gains_Q16[ k ] / 65536.0f; - } - - /*****************************************/ - /* Noise shaping quantization */ - /*****************************************/ - Silk_wrappers_FLP.SKP_Silk_NSQ_wrapper_FLP( psEnc, psEncCtrl, xfw, 0, psEnc.sCmn.q_LBRR, 0, 1 ); - } else { - Arrays.fill(psEnc.sCmn.q_LBRR, (byte)0); - psEncCtrl.sCmn.LTP_scaleIndex = 0; - } - /****************************************/ - /* Initialize arithmetic coder */ - /****************************************/ - if( psEnc.sCmn.nFramesInPayloadBuf == 0 ) { - Silk_range_coder.SKP_Silk_range_enc_init( psEnc.sCmn.sRC_LBRR ); - psEnc.sCmn.nBytesInPayloadBuf = 0; - } - - /****************************************/ - /* Encode Parameters */ - /****************************************/ - Silk_encode_parameters.SKP_Silk_encode_parameters( psEnc.sCmn, psEncCtrl.sCmn, psEnc.sCmn.sRC_LBRR, psEnc.sCmn.q_LBRR ); - /****************************************/ - /* Encode Parameters */ - /****************************************/ - if( psEnc.sCmn.sRC_LBRR.error != 0) { - /* Encoder returned error: Clear payload buffer */ - nFramesInPayloadBuf = 0; - } else { - nFramesInPayloadBuf = psEnc.sCmn.nFramesInPayloadBuf + 1; - } - - /****************************************/ - /* Finalize payload and copy to output */ - /****************************************/ - if( Silk_macros.SKP_SMULBB( nFramesInPayloadBuf, Silk_define.FRAME_LENGTH_MS ) >= psEnc.sCmn.PacketSize_ms ) { - - /* Check if FEC information should be added */ - frame_terminator = Silk_define.SKP_SILK_LAST_FRAME; - - /* Add the frame termination info to stream */ - Silk_range_coder.SKP_Silk_range_encoder( psEnc.sCmn.sRC_LBRR, frame_terminator, Silk_tables_other.SKP_Silk_FrameTermination_CDF, 0 ); - - /* Payload length so far */ - Silk_range_coder.SKP_Silk_range_coder_get_length( psEnc.sCmn.sRC_LBRR, nBytes ); - - /* Check that there is enough space in external output buffer and move data */ - if( pnBytesOut[0] >= nBytes[0] ) { - Silk_range_coder.SKP_Silk_range_enc_wrap_up( psEnc.sCmn.sRC_LBRR ); - System.arraycopy(psEnc.sCmn.sRC_LBRR.buffer, 0, pCode, 0, nBytes[0]); - - pnBytesOut[0] = (short) nBytes[0]; - } else { - /* Not enough space: Payload will be discarded */ - pnBytesOut[0] = 0; - assert( false ); - } - } else { - /* No payload for you this time */ - pnBytesOut[0] = 0; - - /* Encode that more frames follows */ - frame_terminator = Silk_define.SKP_SILK_MORE_FRAMES; - Silk_range_coder.SKP_Silk_range_encoder( psEnc.sCmn.sRC_LBRR, frame_terminator, Silk_tables_other.SKP_Silk_FrameTermination_CDF, 0 ); - } - - /* Restore original Gains */ - System.arraycopy(TempGainsIndices, 0, psEncCtrl.sCmn.GainsIndices, 0, Silk_define.NB_SUBFR); - System.arraycopy(TempGains, 0, psEncCtrl.Gains, 0, Silk_define.NB_SUBFR); - - /* Restore LTP scale index and typeoffset */ - psEncCtrl.sCmn.LTP_scaleIndex = LTP_scaleIndex; - psEnc.sCmn.typeOffsetPrev = typeOffset; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_encode_parameters.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_encode_parameters.java deleted file mode 100644 index df221b690..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_encode_parameters.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Encode parameters to create the payload. - * - * @author Dingxin Xu - */ -public class Silk_encode_parameters -{ - /** - * Encode parameters to create the payload. - * @param psEncC Encoder state. - * @param psEncCtrlC Encoder control. - * @param psRC Range encoder state. - * @param q Quantization indices. - */ - static void SKP_Silk_encode_parameters( - SKP_Silk_encoder_state psEncC, /* I/O Encoder state */ - SKP_Silk_encoder_control psEncCtrlC, /* I/O Encoder control */ - SKP_Silk_range_coder_state psRC, /* I/O Range encoder state */ - byte []q /* I Quantization indices */ - ) - { - int i, k, typeOffset; - final SKP_Silk_NLSF_CB_struct psNLSF_CB; - - - /************************/ - /* Encode sampling rate */ - /************************/ - /* only done for first frame in packet */ - if( psEncC.nFramesInPayloadBuf == 0 ) { - /* get sampling rate index */ - for( i = 0; i < 3; i++ ) { - if( Silk_tables_other.SKP_Silk_SamplingRates_table[ i ] == psEncC.fs_kHz ) { - break; - } - } - Silk_range_coder.SKP_Silk_range_encoder( psRC, i, Silk_tables_other.SKP_Silk_SamplingRates_CDF, 0 ); - } - - /*******************************************/ - /* Encode signal type and quantizer offset */ - /*******************************************/ - typeOffset = 2 * psEncCtrlC.sigtype + psEncCtrlC.QuantOffsetType; - if( psEncC.nFramesInPayloadBuf == 0 ) { - /* first frame in packet: independent coding */ - Silk_range_coder.SKP_Silk_range_encoder( psRC, typeOffset, Silk_tables_type_offset.SKP_Silk_type_offset_CDF, 0); - } else { - /* condidtional coding */ - Silk_range_coder.SKP_Silk_range_encoder( psRC, typeOffset, Silk_tables_type_offset.SKP_Silk_type_offset_joint_CDF[ psEncC.typeOffsetPrev ], 0); - } - psEncC.typeOffsetPrev = typeOffset; - - /****************/ - /* Encode gains */ - /****************/ - /* first subframe */ - if( psEncC.nFramesInPayloadBuf == 0 ) { - /* first frame in packet: independent coding */ - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.GainsIndices[ 0 ], Silk_tables_gain.SKP_Silk_gain_CDF[ psEncCtrlC.sigtype ], 0); - } else { - /* condidtional coding */ - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.GainsIndices[ 0 ], Silk_tables_gain.SKP_Silk_delta_gain_CDF, 0); - } - - /* remaining subframes */ - for( i = 1; i < Silk_define.NB_SUBFR; i++ ) { - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.GainsIndices[ i ], Silk_tables_gain.SKP_Silk_delta_gain_CDF, 0); - } - - - /****************/ - /* Encode NLSFs */ - /****************/ - /* Range encoding of the NLSF path */ - psNLSF_CB = psEncC.psNLSF_CB[ psEncCtrlC.sigtype ]; - Silk_range_coder.SKP_Silk_range_encoder_multi( psRC, psEncCtrlC.NLSFIndices, psNLSF_CB.StartPtr, psNLSF_CB.nStages ); - - /* Encode NLSF interpolation factor */ - assert( psEncC.useInterpolatedNLSFs == 1 || psEncCtrlC.NLSFInterpCoef_Q2 == ( 1 << 2 ) ); - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.NLSFInterpCoef_Q2, Silk_tables_other.SKP_Silk_NLSF_interpolation_factor_CDF, 0); - - - if( psEncCtrlC.sigtype == Silk_define.SIG_TYPE_VOICED ) { - /*********************/ - /* Encode pitch lags */ - /*********************/ - - - /* lag index */ - if( psEncC.fs_kHz == 8 ) { - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.lagIndex, Silk_tables_pitch_lag.SKP_Silk_pitch_lag_NB_CDF, 0); - } else if( psEncC.fs_kHz == 12 ) { - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.lagIndex, Silk_tables_pitch_lag.SKP_Silk_pitch_lag_MB_CDF, 0); - } else if( psEncC.fs_kHz == 16 ) { - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.lagIndex, Silk_tables_pitch_lag.SKP_Silk_pitch_lag_WB_CDF, 0); - } else { - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.lagIndex, Silk_tables_pitch_lag.SKP_Silk_pitch_lag_SWB_CDF, 0); - } - - - /* countour index */ - if( psEncC.fs_kHz == 8 ) { - /* Less codevectors used in 8 khz mode */ - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.contourIndex, Silk_tables_pitch_lag.SKP_Silk_pitch_contour_NB_CDF, 0); - } else { - /* Joint for 12, 16, 24 khz */ - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.contourIndex, Silk_tables_pitch_lag.SKP_Silk_pitch_contour_CDF, 0); - } - - /********************/ - /* Encode LTP gains */ - /********************/ - - /* PERIndex value */ - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.PERIndex, Silk_tables_LTP.SKP_Silk_LTP_per_index_CDF, 0); - - /* Codebook Indices */ - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.LTPIndex[ k ], Silk_tables_LTP.SKP_Silk_LTP_gain_CDF_ptrs[ psEncCtrlC.PERIndex ], 0); - } - - /**********************/ - /* Encode LTP scaling */ - /**********************/ - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.LTP_scaleIndex, Silk_tables_other.SKP_Silk_LTPscale_CDF, 0); - } - - - /***************/ - /* Encode seed */ - /***************/ - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncCtrlC.Seed, Silk_tables_other.SKP_Silk_Seed_CDF, 0); - - /*********************************************/ - /* Encode quantization indices of excitation */ - /*********************************************/ - Silk_encode_pulses.SKP_Silk_encode_pulses( psRC, psEncCtrlC.sigtype, psEncCtrlC.QuantOffsetType, q, psEncC.frame_length ); - - - /*********************************************/ - /* Encode VAD flag */ - /*********************************************/ - Silk_range_coder.SKP_Silk_range_encoder( psRC, psEncC.vadFlag, Silk_tables_other.SKP_Silk_vadflag_CDF, 0); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_encode_pulses.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_encode_pulses.java deleted file mode 100644 index 7a8710591..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_encode_pulses.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Encode quantization indices of excitation. - * - * @author Dingxin Xu - */ -public class Silk_encode_pulses -{ - /** - * - * @param pulses_comb - * @param pulses_in - * @param pulses_in_offset offset of valid data. - * @param max_pulses max value for sum of pulses. - * @param len number of output values. - * @return - */ - static int combine_and_check( /* return ok */ - int []pulses_comb, /* O */ - final int []pulses_in, /* I */ - int pulses_in_offset, - int max_pulses, /* I max value for sum of pulses */ - int len /* I number of output values */ - ) - { - int k, sum; - - for( k = 0; k < len; k++ ) { - sum = pulses_in[ pulses_in_offset + 2 * k ] + pulses_in[ pulses_in_offset+ 2 * k + 1 ]; - if( sum > max_pulses ) { - return 1; - } - pulses_comb[ k ] = sum; - } - return 0; - } - - /** - * Encode quantization indices of excitation. - * @param psRC Range coder state - * @param sigtype Sigtype - * @param QuantOffsetType QuantOffsetType - * @param q quantization - * @param frame_length Frame length - */ - static void SKP_Silk_encode_pulses( - SKP_Silk_range_coder_state psRC, /* I/O Range coder state */ - final int sigtype, /* I Sigtype */ - final int QuantOffsetType,/* I QuantOffsetType */ - final byte q[], /* I quantization indices */ - final int frame_length /* I Frame length */ - ) - { - int i, k, j, iter, bit, nLS, scale_down, RateLevelIndex = 0; - int abs_q, minSumBits_Q6, sumBits_Q6; - int[] abs_pulses = new int[ Silk_define.MAX_FRAME_LENGTH ]; - int[] sum_pulses = new int[ Silk_define.MAX_NB_SHELL_BLOCKS ]; - int[] nRshifts = new int[ Silk_define.MAX_NB_SHELL_BLOCKS ]; - int[] pulses_comb = new int[ 8 ]; - int []abs_pulses_ptr; - int abs_pulses_ptr_offset; - byte []pulses_ptr; - int pulses_ptr_offset; - final int [] cdf_ptr; - short[] nBits_ptr; - - - /****************************/ - /* Prepare for shell coding */ - /****************************/ - /* Calculate number of shell blocks */ - iter = frame_length / Silk_define.SHELL_CODEC_FRAME_LENGTH; - - /* Take the absolute value of the pulses */ - for( i = 0; i < frame_length; i+=4 ) { - abs_pulses[i+0] = q[i+0] > 0 ? q[i+0] : (-q[i+0]); - abs_pulses[i+1] = q[i+1] > 0 ? q[i+1] : (-q[i+1]); - abs_pulses[i+2] = q[i+2] > 0 ? q[i+2] : (-q[i+2]); - abs_pulses[i+3] = q[i+3] > 0 ? q[i+3] : (-q[i+3]); - } - - /* Calc sum pulses per shell code frame */ - abs_pulses_ptr = abs_pulses; - abs_pulses_ptr_offset = 0; - for( i = 0; i < iter; i++ ) { - nRshifts[ i ] = 0; - - while( true ) { - /* 1+1 -> 2 */ - scale_down = combine_and_check( pulses_comb, abs_pulses_ptr, abs_pulses_ptr_offset, - Silk_tables_pulses_per_block.SKP_Silk_max_pulses_table[ 0 ], 8 ); - - /* 2+2 -> 4 */ - scale_down += combine_and_check( pulses_comb, pulses_comb, 0, - Silk_tables_pulses_per_block.SKP_Silk_max_pulses_table[ 1 ], 4 ); - - /* 4+4 -> 8 */ - scale_down += combine_and_check( pulses_comb, pulses_comb, 0, - Silk_tables_pulses_per_block.SKP_Silk_max_pulses_table[ 2 ], 2 ); - - /* 8+8 -> 16 */ - sum_pulses[ i ] = pulses_comb[ 0 ] + pulses_comb[ 1 ]; - if( sum_pulses[ i ] > Silk_tables_pulses_per_block.SKP_Silk_max_pulses_table[ 3 ] ) { - scale_down++; - } - - if( scale_down !=0 ) { - /* We need to down scale the quantization signal */ - nRshifts[ i ]++; - for( k = 0; k < Silk_define.SHELL_CODEC_FRAME_LENGTH; k++ ) { - abs_pulses_ptr[ abs_pulses_ptr_offset + k ] = ( abs_pulses_ptr[ abs_pulses_ptr_offset + k ] >>1 ); - } - } else { - /* Jump out of while(1) loop and go to next shell coding frame */ - break; - } - } - abs_pulses_ptr_offset += Silk_define.SHELL_CODEC_FRAME_LENGTH; - } - - /**************/ - /* Rate level */ - /**************/ - /* find rate level that leads to fewest bits for coding of pulses per block info */ - minSumBits_Q6 = Integer.MAX_VALUE; - for( k = 0; k < Silk_define.N_RATE_LEVELS - 1; k++ ) { - nBits_ptr = Silk_tables_pulses_per_block.SKP_Silk_pulses_per_block_BITS_Q6[ k ]; - sumBits_Q6 = Silk_tables_pulses_per_block.SKP_Silk_rate_levels_BITS_Q6[sigtype][ k ]; - for( i = 0; i < iter; i++ ) { - if( nRshifts[ i ] > 0 ) { - sumBits_Q6 += nBits_ptr[ Silk_define.MAX_PULSES + 1 ]; - } else { - sumBits_Q6 += nBits_ptr[ sum_pulses[ i ] ]; - } - } - if( sumBits_Q6 < minSumBits_Q6 ) { - minSumBits_Q6 = sumBits_Q6; - RateLevelIndex = k; - } - } - Silk_range_coder.SKP_Silk_range_encoder( psRC, RateLevelIndex, - Silk_tables_pulses_per_block.SKP_Silk_rate_levels_CDF[ sigtype ], 0); - - /***************************************************/ - /* Sum-Weighted-Pulses Encoding */ - /***************************************************/ - cdf_ptr = Silk_tables_pulses_per_block.SKP_Silk_pulses_per_block_CDF[ RateLevelIndex ]; - for( i = 0; i < iter; i++ ) { - if( nRshifts[ i ] == 0 ) { - Silk_range_coder.SKP_Silk_range_encoder( psRC, sum_pulses[ i ], cdf_ptr, 0); - } else { - Silk_range_coder.SKP_Silk_range_encoder( psRC, Silk_define.MAX_PULSES + 1, cdf_ptr, 0); - for( k = 0; k < nRshifts[ i ] - 1; k++ ) { - Silk_range_coder.SKP_Silk_range_encoder( psRC, Silk_define.MAX_PULSES + 1, - Silk_tables_pulses_per_block.SKP_Silk_pulses_per_block_CDF[ Silk_define.N_RATE_LEVELS - 1 ], 0); - } - Silk_range_coder.SKP_Silk_range_encoder( psRC, sum_pulses[ i ], - Silk_tables_pulses_per_block.SKP_Silk_pulses_per_block_CDF[ Silk_define.N_RATE_LEVELS - 1 ], 0); - } - } - - /******************/ - /* Shell Encoding */ - /******************/ - for( i = 0; i < iter; i++ ) { - if( sum_pulses[ i ] > 0 ) { - Silk_shell_coder.SKP_Silk_shell_encoder( psRC, abs_pulses, i * Silk_define.SHELL_CODEC_FRAME_LENGTH); - } - } - - /****************/ - /* LSB Encoding */ - /****************/ - for( i = 0; i < iter; i++ ) { - if( nRshifts[ i ] > 0 ) { - pulses_ptr = q; - pulses_ptr_offset = i * Silk_define.SHELL_CODEC_FRAME_LENGTH; - nLS = nRshifts[ i ] - 1; - for( k = 0; k < Silk_define.SHELL_CODEC_FRAME_LENGTH; k++ ) { - abs_q = pulses_ptr[pulses_ptr_offset + k] > 0 ? pulses_ptr[pulses_ptr_offset + k]: (-pulses_ptr[pulses_ptr_offset + k]); - for( j = nLS; j > 0; j-- ) { - bit = ( abs_q >> j ) & 1; - Silk_range_coder.SKP_Silk_range_encoder( psRC, bit, Silk_tables_other.SKP_Silk_lsb_CDF, 0); - } - bit = abs_q & 1; - Silk_range_coder.SKP_Silk_range_encoder( psRC, bit, Silk_tables_other.SKP_Silk_lsb_CDF, 0); - } - } - } - - /****************/ - /* Encode signs */ - /****************/ - Silk_code_signs.SKP_Silk_encode_signs( psRC, q, frame_length, sigtype, QuantOffsetType, RateLevelIndex ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_energy_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_energy_FLP.java deleted file mode 100644 index d31c48e08..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_energy_FLP.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_energy_FLP -{ - /** - * sum of squares of a float array, with result as double. - * @param data - * @param data_offset - * @param dataSize - * @return - */ -//TODO: float or double??? - static double SKP_Silk_energy_FLP - ( - float[] data, - int data_offset, - int dataSize - ) - { - int i, dataSize4; - double result; - - /* 4x unrolled loop */ - result = 0.0f; - dataSize4 = dataSize & 0xFFFC; - for( i = 0; i < dataSize4; i += 4 ) - { - result += data[data_offset+ i + 0 ] * data[data_offset+ i + 0 ] + - data[data_offset+ i + 1 ] * data[data_offset+ i + 1 ] + - data[data_offset+ i + 2 ] * data[data_offset+ i + 2 ] + - data[data_offset+ i + 3 ] * data[data_offset+ i + 3 ]; - } - - /* add any remaining products */ - for( ; i < dataSize; i++ ) - { - result += data[data_offset+ i ] * data[data_offset+ i ]; - } - - assert( result >= 0.0 ); - return result; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_errors.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_errors.java deleted file mode 100644 index 8f8138336..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_errors.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Error messages. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_errors { - /******************/ - /* Error messages */ - /******************/ - static final int SKP_SILK_NO_ERROR = 0; - - /**************************/ - /* Encoder error messages */ - /**************************/ - - /** - * Input length is not a multiplum of 10 ms, or length is longer than the - * packet length. - */ - static final int SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES = -1; - - /** Sampling frequency not 8000, 12000, 16000 or 24000 Hertz */ - static final int SKP_SILK_ENC_FS_NOT_SUPPORTED = -2; - - /** Packet size not 20, 40, 60, 80 or 100 ms */ - static final int SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED = -3; - - /** Allocated payload buffer too short */ - static final int SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT = -4; - - /** Loss rate not between 0 and 100 percent */ - static final int SKP_SILK_ENC_INVALID_LOSS_RATE = -5; - - /** Complexity setting not valid, use 0, 1 or 2 */ - static final int SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING = -6; - - /** Inband FEC setting not valid, use 0 or 1 */ - static final int SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING = -7; - - /** DTX setting not valid, use 0 or 1 */ - static final int SKP_SILK_ENC_INVALID_DTX_SETTING = -8; - - /** Internal encoder error */ - static final int SKP_SILK_ENC_INTERNAL_ERROR = -9; - - /**************************/ - /* Decoder error messages */ - /**************************/ - - /** Output sampling frequency lower than internal decoded sampling frequency */ - static final int SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY = -10; - - /** Payload size exceeded the maximum allowed 1024 bytes */ - static final int SKP_SILK_DEC_PAYLOAD_TOO_LARGE = -11; - - /** Payload has bit errors */ - static final int SKP_SILK_DEC_PAYLOAD_ERROR = -12; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_find_LPC_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_find_LPC_FLP.java deleted file mode 100644 index 1cd0f0dd4..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_find_LPC_FLP.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Dingxin Xu - */ -public class Silk_find_LPC_FLP -{ - /** - * - * @param NLSF NLSFs. - * @param interpIndex NLSF interp. index for NLSF interp. - * @param prev_NLSFq Previous NLSFs, for NLSF interpolation. - * @param useInterpNLSFs Flag. - * @param LPC_order LPC order. - * @param x Input signal. - * @param subfr_length Subframe length incl preceeding samples. - */ - static void SKP_Silk_find_LPC_FLP( - float NLSF[], /* O NLSFs */ - int []interpIndex, /* O NLSF interp. index for NLSF interp. */ - final float prev_NLSFq[], /* I Previous NLSFs, for NLSF interpolation */ - final int useInterpNLSFs, /* I Flag */ - final int LPC_order, /* I LPC order */ - final float x[], /* I Input signal */ - final int subfr_length /* I Subframe length incl preceeding samples */ - ) - { - int k; - float[] a = new float[ Silk_define.MAX_LPC_ORDER ]; - - /* Used only for NLSF interpolation */ - double res_nrg, res_nrg_2nd, res_nrg_interp; - float a_tmp[] = new float[ Silk_define.MAX_LPC_ORDER ], NLSF0[] = new float[ Silk_define.MAX_LPC_ORDER ]; - float LPC_res[] = new float[ ( Silk_define.MAX_FRAME_LENGTH + Silk_define.NB_SUBFR * Silk_define.MAX_LPC_ORDER ) / 2 ]; - - /* Default: No interpolation */ - interpIndex[0] = 4; - - /* Burg AR analysis for the full frame */ - res_nrg = Silk_burg_modified_FLP.SKP_Silk_burg_modified_FLP( a, x, 0, subfr_length, Silk_define.NB_SUBFR, - Silk_define_FLP.FIND_LPC_COND_FAC, LPC_order ); - - if( useInterpNLSFs == 1 ) { - - /* Optimal solution for last 10 ms; subtract residual energy here, as that's easier than */ - /* adding it to the residual energy of the first 10 ms in each iteration of the search below */ - res_nrg -= Silk_burg_modified_FLP.SKP_Silk_burg_modified_FLP( a_tmp, x, ( Silk_define.NB_SUBFR / 2 ) * subfr_length, - subfr_length, Silk_define.NB_SUBFR / 2, Silk_define_FLP.FIND_LPC_COND_FAC, LPC_order ); - - /* Convert to NLSFs */ - Silk_wrappers_FLP.SKP_Silk_A2NLSF_FLP( NLSF, a_tmp, LPC_order ); - - /* Search over interpolation indices to find the one with lowest residual energy */ - res_nrg_2nd = Float.MAX_VALUE; - for( k = 3; k >= 0; k-- ) { - /* Interpolate NLSFs for first half */ - Silk_wrappers_FLP.SKP_Silk_interpolate_wrapper_FLP( NLSF0, prev_NLSFq, NLSF, 0.25f * k, LPC_order ); - - /* Convert to LPC for residual energy evaluation */ - Silk_wrappers_FLP.SKP_Silk_NLSF2A_stable_FLP( a_tmp, NLSF0, LPC_order ); - - /* Calculate residual energy with LSF interpolation */ - Silk_LPC_analysis_filter_FLP.SKP_Silk_LPC_analysis_filter_FLP( LPC_res, a_tmp, x, 0, 2 * subfr_length, LPC_order ); - res_nrg_interp = - Silk_energy_FLP.SKP_Silk_energy_FLP( LPC_res, LPC_order, subfr_length - LPC_order ) + - Silk_energy_FLP.SKP_Silk_energy_FLP( LPC_res, LPC_order + subfr_length, subfr_length - LPC_order ); - - /* Determine whether current interpolated NLSFs are best so far */ - if( res_nrg_interp < res_nrg ) { - /* Interpolation has lower residual energy */ - res_nrg = res_nrg_interp; - interpIndex[0] = k; - } else if( res_nrg_interp > res_nrg_2nd ) { - /* No reason to continue iterating - residual energies will continue to climb */ - break; - } - res_nrg_2nd = res_nrg_interp; - } - } - - if( interpIndex[0] == 4 ) { - /* NLSF interpolation is currently inactive, calculate NLSFs from full frame AR coefficients */ - Silk_wrappers_FLP.SKP_Silk_A2NLSF_FLP( NLSF, a, LPC_order ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_find_LTP_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_find_LTP_FLP.java deleted file mode 100644 index 2decc6024..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_find_LTP_FLP.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_find_LTP_FLP -{ - /** - * - * @param b LTP coefs. - * @param WLTP Weight for LTP quantization. - * @param LTPredCodGain LTP coding gain. - * @param r_first LPC residual, signal + state for 10 ms. - * @param r_last LPC residual, signal + state for 10 ms. - * @param r_last_offset offset of valid data. - * @param lag LTP lags. - * @param Wght Weights. - * @param subfr_length Subframe length. - * @param mem_offset Number of samples in LTP memory. - */ - static void SKP_Silk_find_LTP_FLP( - float b[], /* O LTP coefs */ - float WLTP[], /* O Weight for LTP quantization */ - float LTPredCodGain[], /* O LTP coding gain */ - final float r_first[], /* I LPC residual, signal + state for 10 ms */ - final float r_last[], /* I LPC residual, signal + state for 10 ms */ - int r_last_offset, - final int lag[ ], /* I LTP lags */ - final float Wght[ ], /* I Weights */ - final int subfr_length, /* I Subframe length */ - final int mem_offset /* I Number of samples in LTP memory */ - ) - { - int i,k; - float b_ptr[], temp, WLTP_ptr[]; - float LPC_res_nrg, LPC_LTP_res_nrg; - float d[] = new float[Silk_define.NB_SUBFR], m, g, delta_b[]=new float[Silk_define.LTP_ORDER]; - float w[] = new float[Silk_define.NB_SUBFR], nrg[] = new float[Silk_define.NB_SUBFR], regu; - float Rr[] = new float[Silk_define.LTP_ORDER], rr[] = new float[Silk_define.NB_SUBFR]; - float r_ptr[], lag_ptr[]; - int r_ptr_offset, lag_ptr_offset; - - b_ptr = b; - int b_ptr_offset = 0; - WLTP_ptr = WLTP; - int WLTP_ptr_offset = 0; - r_ptr = r_first; - r_ptr_offset = mem_offset; - - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - if( k == ( Silk_define.NB_SUBFR >> 1 ) ) { /* Shift residual for last 10 ms */ - r_ptr = r_last; - r_ptr_offset = r_last_offset + mem_offset; - } - lag_ptr = r_ptr; - lag_ptr_offset = r_ptr_offset - (lag[k] + Silk_define.LTP_ORDER/2); - - Silk_corrMatrix_FLP.SKP_Silk_corrMatrix_FLP(lag_ptr, lag_ptr_offset, subfr_length, Silk_define.LTP_ORDER, WLTP_ptr, WLTP_ptr_offset); - Silk_corrMatrix_FLP.SKP_Silk_corrVector_FLP(lag_ptr, lag_ptr_offset, r_ptr, r_ptr_offset, subfr_length, Silk_define.LTP_ORDER, Rr); - - - rr[k] = (float) Silk_energy_FLP.SKP_Silk_energy_FLP(r_ptr, r_ptr_offset, subfr_length); - - regu = Silk_define_FLP.LTP_DAMPING * ( rr[ k ] + 1.0f ); - - Silk_regularize_correlations_FLP.SKP_Silk_regularize_correlations_FLP(WLTP_ptr, WLTP_ptr_offset, rr, k, regu, Silk_define.LTP_ORDER); - Silk_solve_LS_FLP.SKP_Silk_solve_LDL_FLP( WLTP_ptr, WLTP_ptr_offset, Silk_define.LTP_ORDER, Rr, b_ptr, b_ptr_offset ); - - /* Calculate residual energy */ - nrg[ k ] = Silk_residual_energy_FLP.SKP_Silk_residual_energy_covar_FLP( b_ptr, b_ptr_offset, - WLTP_ptr, WLTP_ptr_offset, Rr, rr[ k ], Silk_define.LTP_ORDER ); - - temp = Wght[ k ] / ( nrg[ k ] * Wght[ k ] + 0.01f * subfr_length ); - Silk_scale_vector_FLP.SKP_Silk_scale_vector_FLP( WLTP_ptr, WLTP_ptr_offset, temp, Silk_define.LTP_ORDER * Silk_define.LTP_ORDER ); -// w[ k ] = matrix_ptr( WLTP_ptr, LTP_ORDER / 2, LTP_ORDER / 2, LTP_ORDER ); - w[k] = WLTP_ptr[WLTP_ptr_offset + ((Silk_define.LTP_ORDER/2) * Silk_define.LTP_ORDER + Silk_define.LTP_ORDER/2)]; - - r_ptr_offset += subfr_length; - b_ptr_offset += Silk_define.LTP_ORDER; - WLTP_ptr_offset += Silk_define.LTP_ORDER * Silk_define.LTP_ORDER; - } - - /* Compute LTP coding gain */ - if( LTPredCodGain != null ) { - LPC_LTP_res_nrg = 1e-6f; - LPC_res_nrg = 0.0f; - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - LPC_res_nrg += rr[ k ] * Wght[ k ]; - LPC_LTP_res_nrg += nrg[ k ] * Wght[ k ]; - } - - assert( LPC_LTP_res_nrg > 0 ); - LTPredCodGain[0] = 3.0f * Silk_main_FLP.SKP_Silk_log2( LPC_res_nrg / LPC_LTP_res_nrg ); - } - - /* Smoothing */ - /* d = sum( B, 1 ); */ - b_ptr = b; - b_ptr_offset = 0; - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - d[ k ] = 0; - for( i = 0; i < Silk_define.LTP_ORDER; i++ ) { - d[ k ] += b_ptr[ b_ptr_offset + i ]; - } - b_ptr_offset += Silk_define.LTP_ORDER; - } - /* m = ( w * d' ) / ( sum( w ) + 1e-3 ); */ - temp = 1e-3f; - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - temp += w[ k ]; - } - m = 0; - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - m += d[ k ] * w[ k ]; - } - m = m / temp; - - b_ptr = b; - b_ptr_offset = 0; - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - g = Silk_define_FLP.LTP_SMOOTHING / ( Silk_define_FLP.LTP_SMOOTHING + w[ k ] ) * ( m - d[ k ] ); - temp = 0; - for( i = 0; i < Silk_define.LTP_ORDER; i++ ) { - delta_b[ i ] = Math.max( b_ptr[ i ], 0.1f ); - temp += delta_b[ i ]; - } - temp = g / temp; - for( i = 0; i < Silk_define.LTP_ORDER; i++ ) { - b_ptr[ i ] = b_ptr[ i ] + delta_b[ i ] * temp; - } - b_ptr_offset += Silk_define.LTP_ORDER; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_find_pitch_lags_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_find_pitch_lags_FLP.java deleted file mode 100644 index 8bdd4f2c0..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_find_pitch_lags_FLP.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_find_pitch_lags_FLP -{ - /** - * - * @param psEnc Encoder state FLP. - * @param psEncCtrl Encoder control FLP. - * @param res Residual. - * @param x Speech signal. - * @param x_offset offset of valid data. - */ - static void SKP_Silk_find_pitch_lags_FLP( - SKP_Silk_encoder_state_FLP psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP psEncCtrl, /* I/O Encoder control FLP */ - float res[], /* O Residual */ - float x[], /* I Speech signal */ - int x_offset - ) - { - SKP_Silk_predict_state_FLP psPredSt = psEnc.sPred; -// const SKP_float *x_buf_ptr, *x_buf; - float[] x_buf_ptr, x_buf; - int x_buf_ptr_offset, x_buf_offset; - float[] auto_corr = new float[ Silk_define.FIND_PITCH_LPC_ORDER_MAX + 1 ]; - float[] A = new float[ Silk_define.FIND_PITCH_LPC_ORDER_MAX ]; - float[] refl_coef = new float[ Silk_define.FIND_PITCH_LPC_ORDER_MAX ]; - float[] Wsig = new float[ Silk_define.FIND_PITCH_LPC_WIN_MAX ]; - float thrhld; - float[] Wsig_ptr; - int Wsig_ptr_offset; - int buf_len; - - /******************************************/ - /* Setup buffer lengths etc based of Fs */ - /******************************************/ - buf_len = 2 * psEnc.sCmn.frame_length + psEnc.sCmn.la_pitch; - - /* Safty check */ - assert( buf_len >= psPredSt.pitch_LPC_win_length ); - -// x_buf = x - psEnc->sCmn.frame_length; - x_buf = x; - x_buf_offset = x_offset - psEnc.sCmn.frame_length; - - /*************************************/ - /* Estimate LPC AR coeficients */ - /*************************************/ - - /* Calculate windowed signal */ - - /* First LA_LTP samples */ -// x_buf_ptr = x_buf + buf_len - psPredSt->pitch_LPC_win_length; - x_buf_ptr = x_buf; - x_buf_ptr_offset = x_buf_offset + buf_len - psPredSt.pitch_LPC_win_length; - Wsig_ptr = Wsig; - Wsig_ptr_offset=0; - Silk_apply_sine_window_FLP.SKP_Silk_apply_sine_window_FLP( Wsig_ptr,Wsig_ptr_offset, x_buf_ptr,x_buf_ptr_offset, 1, psEnc.sCmn.la_pitch ); - - /* Middle non-windowed samples */ - Wsig_ptr_offset += psEnc.sCmn.la_pitch; - x_buf_ptr_offset += psEnc.sCmn.la_pitch; -// SKP_memcpy( Wsig_ptr, x_buf_ptr, ( psPredSt->pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 ) ) * sizeof( SKP_float ) ); - for(int i_djinn=0; i_djinn< psPredSt.pitch_LPC_win_length - ( psEnc.sCmn.la_pitch << 1 ); i_djinn++) - Wsig_ptr[Wsig_ptr_offset + i_djinn] = x_buf_ptr[x_buf_ptr_offset+i_djinn]; - - /* Last LA_LTP samples */ - Wsig_ptr_offset += psPredSt.pitch_LPC_win_length - ( psEnc.sCmn.la_pitch << 1 ); - x_buf_ptr_offset += psPredSt.pitch_LPC_win_length - ( psEnc.sCmn.la_pitch << 1 ); - Silk_apply_sine_window_FLP.SKP_Silk_apply_sine_window_FLP( Wsig_ptr,Wsig_ptr_offset, x_buf_ptr,x_buf_ptr_offset, 2, psEnc.sCmn.la_pitch ); - - /* Calculate autocorrelation sequence */ - Silk_autocorrelation_FLP.SKP_Silk_autocorrelation_FLP( auto_corr,0, Wsig,0, psPredSt.pitch_LPC_win_length, psEnc.sCmn.pitchEstimationLPCOrder + 1 ); - - /* Add white noise, as a fraction of the energy */ - auto_corr[ 0 ] += auto_corr[ 0 ] * Silk_define_FLP.FIND_PITCH_WHITE_NOISE_FRACTION; - - /* Calculate the reflection coefficients using Schur */ - Silk_schur_FLP.SKP_Silk_schur_FLP( refl_coef,0, auto_corr,0, psEnc.sCmn.pitchEstimationLPCOrder ); - - /* Convert reflection coefficients to prediction coefficients */ - Silk_k2a_FLP.SKP_Silk_k2a_FLP( A, refl_coef, psEnc.sCmn.pitchEstimationLPCOrder ); - - /* Bandwidth expansion */ - Silk_bwexpander_FLP.SKP_Silk_bwexpander_FLP( A,0, psEnc.sCmn.pitchEstimationLPCOrder, Silk_define_FLP.FIND_PITCH_BANDWITH_EXPANSION ); - - /*****************************************/ - /* LPC analysis filtering */ - /*****************************************/ - Silk_LPC_analysis_filter_FLP.SKP_Silk_LPC_analysis_filter_FLP( res, A, x_buf, x_buf_offset, buf_len, psEnc.sCmn.pitchEstimationLPCOrder ); -// SKP_memset( res, 0, psEnc->sCmn.pitchEstimationLPCOrder * sizeof( SKP_float ) ); - for(int i_djinn=0; i_djinn 0.0f ); - invGains[ i ] = 1.0f / psEncCtrl.Gains[ i ]; - Wght[ i ] = invGains[ i ] * invGains[ i ]; - } - - if( psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_VOICED ) - { - /**********/ - /* VOICED */ - /**********/ - assert( psEnc.sCmn.frame_length - psEnc.sCmn.predictLPCOrder >= psEncCtrl.sCmn.pitchL[ 0 ] + Silk_define.LTP_ORDER / 2 ); - - /* LTP analysis */ - float[] LTPredCodGain_ptr = new float[1]; - LTPredCodGain_ptr[0] = psEncCtrl.LTPredCodGain; - Silk_find_LTP_FLP.SKP_Silk_find_LTP_FLP( psEncCtrl.LTPCoef, WLTP, LTPredCodGain_ptr, res_pitch, - res_pitch,( psEnc.sCmn.frame_length >> 1 ), psEncCtrl.sCmn.pitchL, Wght, - psEnc.sCmn.subfr_length, psEnc.sCmn.frame_length ); - psEncCtrl.LTPredCodGain = LTPredCodGain_ptr[0]; - - - /* Quantize LTP gain parameters */ - int[] PERIndex_ptr = new int[1]; - PERIndex_ptr[0] = psEncCtrl.sCmn.PERIndex; - Silk_quant_LTP_gains_FLP.SKP_Silk_quant_LTP_gains_FLP( psEncCtrl.LTPCoef, psEncCtrl.sCmn.LTPIndex, PERIndex_ptr, - WLTP, psEnc.mu_LTP, psEnc.sCmn.LTPQuantLowComplexity ); - psEncCtrl.sCmn.PERIndex = PERIndex_ptr[0]; - - /* Control LTP scaling */ - Silk_LTP_scale_ctrl_FLP.SKP_Silk_LTP_scale_ctrl_FLP( psEnc, psEncCtrl ); - - /* Create LTP residual */ - Silk_LTP_analysis_filter_FLP.SKP_Silk_LTP_analysis_filter_FLP( LPC_in_pre, psEnc.x_buf, psEnc.sCmn.frame_length - psEnc.sCmn.predictLPCOrder, - psEncCtrl.LTPCoef, psEncCtrl.sCmn.pitchL, invGains, psEnc.sCmn.subfr_length, psEnc.sCmn.predictLPCOrder ); - - } else { - /************/ - /* UNVOICED */ - /************/ - /* Create signal with prepended subframes, scaled by inverse gains */ - x_ptr = psEnc.x_buf; - x_ptr_offset = psEnc.sCmn.frame_length - psEnc.sCmn.predictLPCOrder; - - x_pre_ptr = LPC_in_pre; - x_pre_ptr_offset = 0; - for( i = 0; i < Silk_define.NB_SUBFR; i++ ) { - Silk_scale_copy_vector_FLP.SKP_Silk_scale_copy_vector_FLP( x_pre_ptr, x_pre_ptr_offset, x_ptr, x_ptr_offset, invGains[ i ], - psEnc.sCmn.subfr_length + psEnc.sCmn.predictLPCOrder ); - x_pre_ptr_offset += psEnc.sCmn.subfr_length + psEnc.sCmn.predictLPCOrder; - x_ptr_offset += psEnc.sCmn.subfr_length; - } - - Arrays.fill(psEncCtrl.LTPCoef, 0, Silk_define.NB_SUBFR * Silk_define.LTP_ORDER, 0.0f); - psEncCtrl.LTPredCodGain = 0.0f; - } - - /* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered input for unvoiced */ - int[] NLSFInterpCoef_Q2_ptr = new int[1]; - NLSFInterpCoef_Q2_ptr[0] = psEncCtrl.sCmn.NLSFInterpCoef_Q2; - Silk_find_LPC_FLP.SKP_Silk_find_LPC_FLP( NLSF, NLSFInterpCoef_Q2_ptr, psEnc.sPred.prev_NLSFq, - psEnc.sCmn.useInterpolatedNLSFs * ( 1 - psEnc.sCmn.first_frame_after_reset ), psEnc.sCmn.predictLPCOrder, - LPC_in_pre, psEnc.sCmn.subfr_length + psEnc.sCmn.predictLPCOrder ); - psEncCtrl.sCmn.NLSFInterpCoef_Q2 = NLSFInterpCoef_Q2_ptr[0]; - - - /* Quantize LSFs */ -/*TEST************************************************************************/ -// /** -// * Test for NLSF -// */ -// float[] nlsf = new float[ Silk_define.MAX_LPC_ORDER ]; -// String nlsf_filename = "D:/gsoc/nlsf/nlsf"; -// nlsf_filename += frame_cnt; -// DataInputStream nlsf_datain = null; -// try -// { -// nlsf_datain = new DataInputStream( -// new FileInputStream( -// new File(nlsf_filename))); -// byte[] buffer = new byte[4]; -// for(int ii = 0; ii < NLSF.length; ii++ ) -// { -// try -// { -// -// int res = nlsf_datain.read(buffer); -// if(res != 4) -// { -// throw new IOException("Unexpected End of Stream"); -// } -// nlsf[ii] = ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).getFloat(); -// NLSF[ii] = nlsf[ii]; -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// finally -// { -// if(nlsf_datain != null) -// { -// try -// { -// nlsf_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// frame_cnt++; -/*TEST END********************************************************************/ - Silk_process_NLSFs_FLP.SKP_Silk_process_NLSFs_FLP( psEnc, psEncCtrl, NLSF ); - - /* Calculate residual energy using quantized LPC coefficients */ - Silk_residual_energy_FLP.SKP_Silk_residual_energy_FLP( psEncCtrl.ResNrg, LPC_in_pre, psEncCtrl.PredCoef, psEncCtrl.Gains, - psEnc.sCmn.subfr_length, psEnc.sCmn.predictLPCOrder ); - - /* Copy to prediction struct for use in next frame for fluctuation reduction */ - System.arraycopy(NLSF, 0, psEnc.sPred.prev_NLSFq, 0, psEnc.sCmn.predictLPCOrder); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_gain_quant.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_gain_quant.java deleted file mode 100644 index 04682a9a4..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_gain_quant.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_gain_quant -{ - - static final int OFFSET = ( ( Silk_define.MIN_QGAIN_DB * 128 ) / 6 + 16 * 128 ); - static final int SCALE_Q16 = ( ( 65536 * ( Silk_define.N_LEVELS_QGAIN - 1 ) ) / ( ( ( Silk_define.MAX_QGAIN_DB - Silk_define.MIN_QGAIN_DB ) * 128 ) / 6 ) ); - static final int INV_SCALE_Q16 = ( ( 65536 * ( ( ( Silk_define.MAX_QGAIN_DB - Silk_define.MIN_QGAIN_DB ) * 128 ) / 6 ) ) / ( Silk_define.N_LEVELS_QGAIN - 1 ) ); - - /** - * Gain scalar quantization with hysteresis, uniform on log scale. - * @param ind gain indices - * @param gain_Q16 gains (quantized out) - * @param prev_ind last index in previous frame - * @param conditional first gain is delta coded if 1 - */ - static void SKP_Silk_gains_quant( - int ind[], /* O gain indices */ - int gain_Q16[], /* I/O gains (quantized out) */ - int []prev_ind, /* I/O last index in previous frame */ - final int conditional /* I first gain is delta coded if 1 */ - ) - { - int k; - - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - /* Add half of previous quantization error, convert to log scale, scale, floor() */ - ind[ k ] = Silk_macros.SKP_SMULWB( SCALE_Q16, Silk_lin2log.SKP_Silk_lin2log( gain_Q16[ k ] ) - OFFSET ); - - /* Round towards previous quantized gain (hysteresis) */ - if( ind[ k ] < prev_ind[0] ) { - ind[ k ]++; - } - - /* Compute delta indices and limit */ - if( k == 0 && conditional == 0 ) { - /* Full index */ - ind[ k ] = Silk_SigProc_FIX.SKP_LIMIT_int( ind[ k ], 0, Silk_define.N_LEVELS_QGAIN - 1 ); - ind[ k ] = Math.max( ind[ k ], prev_ind[0] + Silk_define.MIN_DELTA_GAIN_QUANT ); - prev_ind[0] = ind[ k ]; - } else { - /* Delta index */ - ind[ k ] = Silk_SigProc_FIX.SKP_LIMIT_int( ind[ k ] - prev_ind[0], Silk_define.MIN_DELTA_GAIN_QUANT, Silk_define.MAX_DELTA_GAIN_QUANT ); - /* Accumulate deltas */ - prev_ind[0] += ind[ k ]; - /* Shift to make non-negative */ - ind[ k ] -= Silk_define.MIN_DELTA_GAIN_QUANT; - } - - /* Convert to linear scale and scale */ - gain_Q16[ k ] = Silk_log2lin.SKP_Silk_log2lin( Math.min( Silk_macros.SKP_SMULWB( INV_SCALE_Q16, prev_ind[0] ) + OFFSET, 3967 ) ); /* 3967 = 31 in Q7 */ - } - } - - /** - * Gains scalar dequantization, uniform on log scale. - * @param gain_Q16 quantized gains. - * @param ind gain indices. - * @param prev_ind last index in previous frame. - * @param conditional first gain is delta coded if 1. - */ - static void SKP_Silk_gains_dequant( - int gain_Q16[ ], /* O quantized gains */ - int ind[ ], /* I gain indices */ - int []prev_ind, /* I/O last index in previous frame */ - final int conditional /* I first gain is delta coded if 1 */ - ) - { - int k; - - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - if( k == 0 && conditional == 0 ) { - prev_ind[0] = ind[ k ]; - } else { - /* Delta index */ - prev_ind[0] += ind[ k ] + Silk_define.MIN_DELTA_GAIN_QUANT; - } - - /* Convert to linear scale and scale */ - gain_Q16[ k ] = Silk_log2lin.SKP_Silk_log2lin( Math.min( Silk_macros.SKP_SMULWB( INV_SCALE_Q16, prev_ind[0] ) + OFFSET, 3967 ) ); /* 3967 = 31 in Q7 */ - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_init_encoder_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_init_encoder_FLP.java deleted file mode 100644 index 5710bf319..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_init_encoder_FLP.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Initialize Silk Encoder state. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_init_encoder_FLP -{ - /** - * Initialize Silk Encoder state. - * @param psEnc - * @return - */ - static int SKP_Silk_init_encoder_FLP( - SKP_Silk_encoder_state_FLP psEnc /* I/O Encoder state FLP */ - ) - { - int ret = 0; - - /* Clear the entire encoder state */ -//TODO: psEnc = new SKP_Silk_encoder_state_FLP(); -// SKP_memset( psEnc, 0, sizeof( SKP_Silk_encoder_state_FLP ) ); - - /* Initialize to 24 kHz API sampling, 24 kHz max internal sampling, 20 ms packets, 25 kbps, 0% packet loss, and init non-zero values */ - ret = Silk_control_codec_FLP.SKP_Silk_control_encoder_FLP( psEnc, 24000, 24, 20, 25, 0, 0, 0, 10, 0 ); - - if(Silk_define.HIGH_PASS_INPUT!=0) - { - psEnc.variable_HP_smth1 = Silk_main_FLP.SKP_Silk_log2( 70.0 ); - psEnc.variable_HP_smth2 = Silk_main_FLP.SKP_Silk_log2( 70.0 ); - } - - /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */ - psEnc.sCmn.first_frame_after_reset = 1; - psEnc.sCmn.fs_kHz_changed = 0; - psEnc.sCmn.LBRR_enabled = 0; - - /* Initialize Silk VAD */ - ret += Silk_VAD.SKP_Silk_VAD_Init( psEnc.sCmn.sVAD ); - - /* Initialize NSQ */ - psEnc.sNSQ.prev_inv_gain_Q16 = 65536; - psEnc.sNSQ_LBRR.prev_inv_gain_Q16 = 65536; - - return( ret ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_inner_product_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_inner_product_FLP.java deleted file mode 100644 index 2c6b553df..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_inner_product_FLP.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * inner product of two SKP_float arrays, with result as double. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_inner_product_FLP -{ - /** - * inner product of two SKP_float arrays, with result as double. - * @param data1 vector1. - * @param data1_offset offset of valid data. - * @param data2 vector2. - * @param data2_offset offset of valid data. - * @param dataSize length of vectors. - * @return result. - */ - static double SKP_Silk_inner_product_FLP( /* O result */ - float[] data1, /* I vector 1 */ - int data1_offset, - float[] data2, /* I vector 2 */ - int data2_offset, - int dataSize /* I length of vectors */ - ) - { - int i, dataSize4; - double result; - - /* 4x unrolled loop */ - result = 0.0f; - dataSize4 = dataSize & 0xFFFC; - for( i = 0; i < dataSize4; i += 4 ) - { - result += data1[ data1_offset + i + 0 ] * data2[ data2_offset + i + 0 ] + - data1[ data1_offset + i + 1 ] * data2[ data2_offset + i + 1 ] + - data1[ data1_offset + i + 2 ] * data2[ data2_offset + i + 2 ] + - data1[ data1_offset + i + 3 ] * data2[ data2_offset + i + 3 ]; - } - - /* add any remaining products */ - for( ; i < dataSize; i++ ) - { - result += data1[ data1_offset+i ] * data2[ data2_offset+i ]; - } - - return result; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_interpolate.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_interpolate.java deleted file mode 100644 index f4d3b3672..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_interpolate.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Interpolate two vectors. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_interpolate -{ - /** - * Interpolate two vectors. - * - * @param xi interpolated vector. - * @param x0 first vector. - * @param x1 second vector. - * @param ifact_Q2 interp. factor, weight on 2nd vector. - * @param d number of parameters. - */ - static void SKP_Silk_interpolate( - int[] xi, /* O interpolated vector */ - int[] x0, /* I first vector */ - int[] x1, /* I second vector */ - final int ifact_Q2, /* I interp. factor, weight on 2nd vector */ - final int d /* I number of parameters */ - ) - { - int i; - - assert( ifact_Q2 >= 0 ); - assert( ifact_Q2 <= ( 1 << 2 ) ); - - for( i = 0; i < d; i++ ) - { - xi[ i ] = ( x0[ i ] + ( ( x1[ i ] - x0[ i ] ) * ifact_Q2 >> 2 ) ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_k2a_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_k2a_FLP.java deleted file mode 100644 index 4d3bc631b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_k2a_FLP.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * step up function, converts reflection coefficients to - * prediction coefficients. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_k2a_FLP -{ - /** - * step up function, converts reflection coefficients to prediction coefficients. - * - * @param A prediction coefficients [order]. - * @param rc reflection coefficients [order]. - * @param order prediction order. - */ - static void SKP_Silk_k2a_FLP( - float[] A, /* O: prediction coefficients [order] */ - float[] rc, /* I: reflection coefficients [order] */ - int order /* I: prediction order */ - ) - { - int k, n; - float[] Atmp = new float[Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC]; - - for( k = 0; k < order; k++ ) - { - for( n = 0; n < k; n++ ) - { - Atmp[ n ] = A[ n ]; - } - for( n = 0; n < k; n++ ) - { - A[ n ] += Atmp[ k - n - 1 ] * rc[ k ]; - } - A[ k ] = -rc[ k ]; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_levinsondurbin_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_levinsondurbin_FLP.java deleted file mode 100644 index 97875292e..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_levinsondurbin_FLP.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_levinsondurbin_FLP -{ - /** - * Solve the normal equations using the Levinson-Durbin recursion. - * - * @param A prediction coefficients [order]. - * @param A_offset offset of valid data. - * @param corr input auto-correlations [order + 1]. - * @param order prediction order. - * @return prediction error energy. - */ - static float SKP_Silk_levinsondurbin_FLP( /* O prediction error energy */ - float A[], /* O prediction coefficients [order] */ - int A_offset, - float corr[], /* I input auto-correlations [order + 1] */ - final int order /* I prediction order */ - ) - { - int i, mHalf, m; - float min_nrg, nrg, t, km, Atmp1, Atmp2; - - min_nrg = 1e-12f * corr[ 0 ] + 1e-9f; - nrg = corr[ 0 ]; - nrg = Math.max(min_nrg, nrg); - A[ A_offset ] = corr[ 1 ] / nrg; - nrg -= A[ A_offset ] * corr[ 1 ]; - nrg = Math.max(min_nrg, nrg); - - for( m = 1; m < order; m++ ) - { - t = corr[ m + 1 ]; - for( i = 0; i < m; i++ ) - { - t -= A[ A_offset+i ] * corr[ m - i ]; - } - - /* reflection coefficient */ - km = t / nrg; - - /* residual energy */ - nrg -= km * t; - nrg = Math.max(min_nrg, nrg); - - mHalf = m >> 1; - for( i = 0; i < mHalf; i++ ) - { - Atmp1 = A[ A_offset+i ]; - Atmp2 = A[ A_offset + m - i - 1 ]; - A[ A_offset + m - i - 1 ] -= km * Atmp1; - A[ A_offset+i ] -= km * Atmp2; - } - if( (m & 1) != 0) - { - A[ A_offset+mHalf ] -= km * A[ A_offset+mHalf ]; - } - A[ A_offset+m ] = km; - } - - /* return the residual energy */ - return nrg; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_lin2log.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_lin2log.java deleted file mode 100644 index f909803ba..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_lin2log.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Convert input to a log scale - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_lin2log -{ - /** - * Approximation of 128 * log2() (very close inverse of approx 2^() below) - * Convert input to a log scale. - * - * @param inLin Input in linear scale - * @return - */ - static int SKP_Silk_lin2log( final int inLin ) /* I: Input in linear scale */ - { - int lz, frac_Q7; - - int[] lz_ptr = new int[1]; - int[] frac_Q7_ptr = new int[1]; - - Silk_Inlines.SKP_Silk_CLZ_FRAC( inLin, lz_ptr, frac_Q7_ptr ); - lz = lz_ptr[0]; - frac_Q7 = frac_Q7_ptr[0]; - - /* Piece-wise parabolic approximation */ - return( Silk_SigProc_FIX.SKP_LSHIFT( 31 - lz, 7 ) + Silk_macros.SKP_SMLAWB( frac_Q7, Silk_SigProc_FIX.SKP_MUL( frac_Q7, 128 - frac_Q7 ), 179 ) ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_log2lin.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_log2lin.java deleted file mode 100644 index 7e76fa01d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_log2lin.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Convert input to a linear scale. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_log2lin -{ - /** - * Approximation of 2^() (very close inverse of Silk_lin2log.SKP_Silk_lin2log()) - * Convert input to a linear scale. - * - * @param inLog_Q7 Input on log scale - * @return - */ - static int SKP_Silk_log2lin( final int inLog_Q7 ) /* I: Input on log scale */ - { - int out, frac_Q7; - - if( inLog_Q7 < 0 ) { - return 0; - } - - out = ( 1 << ( inLog_Q7 >> 7 ) ); - - frac_Q7 = inLog_Q7 & 0x7F; - if( inLog_Q7 < 2048 ) { - /* Piece-wise parabolic approximation */ - out = Silk_SigProc_FIX.SKP_ADD_RSHIFT( out, Silk_SigProc_FIX.SKP_MUL( out, Silk_macros.SKP_SMLAWB( frac_Q7, Silk_SigProc_FIX.SKP_MUL( frac_Q7, 128 - frac_Q7 ), -174 ) ), 7 ); - } else { - /* Piece-wise parabolic approximation */ - out = Silk_SigProc_FIX.SKP_MLA( out, Silk_SigProc_FIX.SKP_RSHIFT( out, 7 ), Silk_macros.SKP_SMLAWB( frac_Q7, Silk_SigProc_FIX.SKP_MUL( frac_Q7, 128 - frac_Q7 ), -174 ) ); - } - return out; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_lowpass_int.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_lowpass_int.java deleted file mode 100644 index a1f8c776b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_lowpass_int.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * First order low-pass filter, with input as SKP_int32, running at - * 48 kHz - * - * @author Dingxin Xu - */ -public class Silk_lowpass_int -{ - /** - * First order low-pass filter, with input as SKP_int32, running at 48 kHz - * @param in Q25 48 kHz signal; length = len - * @param in_offset offset of valid data. - * @param S Q25 state; length = 1 - * @param S_offset offset of valid data. - * @param out Q25 48 kHz signal; length = len - * @param out_offset offset of valid data. - * @param len Number of samples - */ - static void SKP_Silk_lowpass_int( - final int []in, /* I: Q25 48 kHz signal; length = len */ - int in_offset, - int []S, /* I/O: Q25 state; length = 1 */ - int S_offset, - int []out, /* O: Q25 48 kHz signal; length = len */ - int out_offset, - final int len /* I: Number of samples */ - ) - { - int k; - int in_tmp, out_tmp, state; - - state = S[ S_offset + 0 ]; - for( k = len; k > 0; k-- ) { - in_tmp = in[in_offset++]; - in_tmp -= ( in_tmp >> 2 ); /* multiply by 0.75 */ - out_tmp = state + in_tmp; /* zero at nyquist */ - state = in_tmp - ( out_tmp >> 1 ); /* pole */ - out[out_offset++] = out_tmp; - } - S[ S_offset + 0 ] = state; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_lowpass_short.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_lowpass_short.java deleted file mode 100644 index 8b0022564..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_lowpass_short.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * First order low-pass filter, with input as SKP_int16, running at - * 48 kHz - * - * @author Dingxin Xu - */ -public class Silk_lowpass_short -{ - /** - * First order low-pass filter, with input as SKP_int16, running at 48 kHz. - * @param in Q15 48 kHz signal; [len] - * @param in_offset offset of valid data. - * @param S Q25 state; length = 1 - * @param S_offset offset of valid data. - * @param out Q25 48 kHz signal; [len] - * @param out_offset offset of valid data. - * @param len Signal length - */ - static void SKP_Silk_lowpass_short( - final short []in, /* I: Q15 48 kHz signal; [len] */ - int in_offset, - int []S, /* I/O: Q25 state; length = 1 */ - int S_offset, - int []out, /* O: Q25 48 kHz signal; [len] */ - int out_offset, - final int len /* O: Signal length */ - ) - { - int k; - int in_tmp, out_tmp, state; - - state = S[ S_offset + 0 ]; - for( k = 0; k < len; k++ ) { - in_tmp = ( 768 * in[in_offset + k] ); /* multiply by 0.75, going from Q15 to Q25 */ - out_tmp = state + in_tmp; /* zero at nyquist */ - state = in_tmp - ( out_tmp >> 1 ); /* pole */ - out[ out_offset + k ] = out_tmp; - } - S[ S_offset + 0 ] = state; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_macros.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_macros.java deleted file mode 100644 index 0e990aeed..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_macros.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Translated from what is an inline header file for general platform. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_macros -{ - // (a32 * (SKP_int32)((SKP_int16)(b32))) >> 16 output have to be 32bit int - static int SKP_SMULWB(int a32, int b32) - { - return ((((a32) >> 16) * ((short)(b32))) + ((((a32) & 0x0000FFFF) * ((short)(b32))) >> 16)); - } - - // a32 + (b32 * (SKP_int32)((SKP_int16)(c32))) >> 16 output have to be 32bit int - static int SKP_SMLAWB(int a32, int b32, int c32) - { - return ((a32) + ((((b32) >> 16) * ((short)(c32))) + ((((b32) & 0x0000FFFF) * ((short)(c32))) >> 16))); - } - - // (a32 * (b32 >> 16)) >> 16 - static int SKP_SMULWT(int a32, int b32) - { - return (((a32) >> 16) * ((b32) >> 16) + ((((a32) & 0x0000FFFF) * ((b32) >> 16)) >> 16)); - } - - // a32 + (b32 * (c32 >> 16)) >> 16 - static int SKP_SMLAWT(int a32, int b32, int c32) - { - return ((a32) + (((b32) >> 16) * ((c32) >> 16)) + ((((b32) & 0x0000FFFF) * ((c32) >> 16)) >> 16)); - } - - // (SKP_int32)((SKP_int16)(a3))) * (SKP_int32)((SKP_int16)(b32)) output have to be 32bit int - static int SKP_SMULBB(int a32, int b32) - { - return (((short)(a32)) * ((short)(b32))); - } - - // a32 + (SKP_int32)((SKP_int16)(b32)) * (SKP_int32)((SKP_int16)(c32)) output have to be 32bit int - static int SKP_SMLABB(int a32, int b32, int c32) - { - return ((a32) + (((short)(b32))) * ((short)(c32))); - } - - // (SKP_int32)((SKP_int16)(a32)) * (b32 >> 16) - static int SKP_SMULBT(int a32, int b32) - { - return (((short)(a32)) * ((b32) >> 16)); - } - - // a32 + (SKP_int32)((SKP_int16)(b32)) * (c32 >> 16) - static int SKP_SMLABT(int a32, int b32, int c32) - { - return ((a32) + (((short)(b32))) * ((c32) >> 16)); - } - - // a64 + (b32 * c32) - static long SKP_SMLAL(long a64, int b32, int c32) - { - return a64 + (long)b32 * (long)c32; - } - - // (a32 * b32) >> 16 - static int SKP_SMULWW(int a32, int b32) - { - return SKP_SMULWB(a32, b32) + a32 * Silk_SigProc_FIX.SKP_RSHIFT_ROUND(b32, 16); - } - - // a32 + ((b32 * c32) >> 16) - static int SKP_SMLAWW(int a32, int b32, int c32) - { - return SKP_SMLAWB(a32, b32, c32) + b32 * Silk_SigProc_FIX.SKP_RSHIFT_ROUND(c32, 16); - } - - /* add/subtract with output saturated */ - static int SKP_ADD_SAT32(int a, int b) - { - if( ((a + b) & 0x80000000) == 0 ) - return ((a & b) & 0x80000000) != 0 ? Integer.MIN_VALUE : a+b; - else - return ((a | b) & 0x80000000) == 0 ? Integer.MAX_VALUE : a+b; - } - - static int SKP_SUB_SAT32(int a, int b) - { - if( ((a - b) & 0x80000000) == 0 ) - return ( a & (b^0x80000000) & 0x80000000) != 0 ? Integer.MIN_VALUE : a-b; - else - return ( (a^0x80000000) & b & 0x80000000) != 0 ? Integer.MAX_VALUE : a-b; - } - - static int SKP_Silk_CLZ16(short in16) - { - return Integer.numberOfLeadingZeros(in16 & 0x0000FFFF) - 16; - } - - static int SKP_Silk_CLZ32(int in32) - { - return Integer.numberOfLeadingZeros(in32); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_main_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_main_FLP.java deleted file mode 100644 index e6b1c4e07..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_main_FLP.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_main_FLP -{ - /** - * using log2() helps the fixed-point conversion. - * @param x - * @return - */ - static float SKP_Silk_log2( double x ) - { - return ( float )( 3.32192809488736 * Math.log10( x ) ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_noise_shape_analysis_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_noise_shape_analysis_FLP.java deleted file mode 100644 index 09e20c8f8..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_noise_shape_analysis_FLP.java +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_noise_shape_analysis_FLP -{ - /** - * Compute noise shaping coefficients and initial gain values. - * @param psEnc Encoder state FLP - * @param psEncCtrl Encoder control FLP - * @param pitch_res LPC residual from pitch analysis - * @param pitch_res_offset offset of valid data. - * @param x Input signal [frame_length + la_shape] - * @param x_offset offset of valid data. - */ - static void SKP_Silk_noise_shape_analysis_FLP - ( - SKP_Silk_encoder_state_FLP psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP psEncCtrl, /* I/O Encoder control FLP */ - float[] pitch_res, /* I LPC residual from pitch analysis */ - int pitch_res_offset, - float[] x, /* I Input signal [frame_length + la_shape] */ - int x_offset - ) - { - SKP_Silk_shape_state_FLP psShapeSt = psEnc.sShape; - int k, nSamples; - float SNR_adj_dB, HarmBoost, HarmShapeGain, Tilt; - float nrg, pre_nrg=0, log_energy, log_energy_prev, energy_variation; - float delta, BWExp1, BWExp2, gain_mult, gain_add, strength, b; - float[] x_windowed = new float[ Silk_define.SHAPE_LPC_WIN_MAX ]; - float[] auto_corr = new float[ Silk_define.SHAPE_LPC_ORDER_MAX + 1 ]; - float[] x_ptr, pitch_res_ptr; - int x_ptr_offset, pitch_res_ptr_offset=0; - - /* Point to start of first LPC analysis block */ - x_ptr = x; - x_ptr_offset = x_offset + psEnc.sCmn.la_shape - Silk_define.SHAPE_LPC_WIN_MS * psEnc.sCmn.fs_kHz + psEnc.sCmn.subfr_length; - - /****************/ - /* CONTROL SNR */ - /****************/ - /* Reduce SNR_dB values if recent bitstream has exceeded TargetRate */ - psEncCtrl.current_SNR_dB = psEnc.SNR_dB - 0.05f * psEnc.BufferedInChannel_ms; - - /* Reduce SNR_dB if inband FEC used */ - if( psEnc.speech_activity > Silk_define_FLP.LBRR_SPEECH_ACTIVITY_THRES ) - { - psEncCtrl.current_SNR_dB -= psEnc.inBandFEC_SNR_comp; - } - - /****************/ - /* GAIN CONTROL */ - /****************/ - /* Input quality is the average of the quality in the lowest two VAD bands */ - psEncCtrl.input_quality = 0.5f * ( psEncCtrl.input_quality_bands[ 0 ] + psEncCtrl.input_quality_bands[ 1 ] ); - - /* Coding quality level, between 0.0 and 1.0 */ - psEncCtrl.coding_quality = Silk_SigProc_FLP.SKP_sigmoid( 0.25f * ( psEncCtrl.current_SNR_dB - 18.0f ) ); - - /* Reduce coding SNR during low speech activity */ - b = 1.0f - psEnc.speech_activity; - SNR_adj_dB = psEncCtrl.current_SNR_dB - - Silk_perceptual_parameters_FLP.BG_SNR_DECR_dB * psEncCtrl.coding_quality * ( 0.5f + 0.5f * psEncCtrl.input_quality ) * b * b; - - if( psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_VOICED ) - { - /* Reduce gains for periodic signals */ - SNR_adj_dB += Silk_perceptual_parameters_FLP.HARM_SNR_INCR_dB * psEnc.LTPCorr; - } - else - { - /* For unvoiced signals and low-quality input, adjust the quality slower than SNR_dB setting */ - SNR_adj_dB += ( -0.4f * psEncCtrl.current_SNR_dB + 6.0f ) * ( 1.0f - psEncCtrl.input_quality ); - } - - /*************************/ - /* SPARSENESS PROCESSING */ - /*************************/ - /* Set quantizer offset */ - if( psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_VOICED ) - { - /* Initally set to 0; may be overruled in process_gains(..) */ - psEncCtrl.sCmn.QuantOffsetType = 0; - psEncCtrl.sparseness = 0.0f; - } - else - { - /* Sparseness measure, based on relative fluctuations of energy per 2 milliseconds */ - nSamples = 2 * psEnc.sCmn.fs_kHz; - energy_variation = 0.0f; - log_energy_prev = 0.0f; - pitch_res_ptr = pitch_res; - pitch_res_ptr_offset = pitch_res_offset; - for( k = 0; k < Silk_define.FRAME_LENGTH_MS / 2; k++ ) - { - nrg = nSamples + ( float )Silk_energy_FLP.SKP_Silk_energy_FLP( pitch_res_ptr,pitch_res_ptr_offset, nSamples ); - log_energy = Silk_main_FLP.SKP_Silk_log2( nrg ); - if( k > 0 ) - { - energy_variation += Math.abs( log_energy - log_energy_prev ); - } - log_energy_prev = log_energy; - pitch_res_ptr_offset += nSamples; - } - psEncCtrl.sparseness = Silk_SigProc_FLP.SKP_sigmoid( 0.4f * ( energy_variation - 5.0f ) ); - - /* Set quantization offset depending on sparseness measure */ - if( psEncCtrl.sparseness > Silk_perceptual_parameters_FLP.SPARSENESS_THRESHOLD_QNT_OFFSET ) - { - psEncCtrl.sCmn.QuantOffsetType = 0; - } - else - { - psEncCtrl.sCmn.QuantOffsetType = 1; - } - - /* Increase coding SNR for sparse signals */ - SNR_adj_dB += Silk_perceptual_parameters_FLP.SPARSE_SNR_INCR_dB * ( psEncCtrl.sparseness - 0.5f ); - } - - /*******************************/ - /* Control bandwidth expansion */ - /*******************************/ - delta = Silk_perceptual_parameters_FLP.LOW_RATE_BANDWIDTH_EXPANSION_DELTA * ( 1.0f - 0.75f * psEncCtrl.coding_quality ); - BWExp1 = Silk_perceptual_parameters_FLP.BANDWIDTH_EXPANSION - delta; - BWExp2 = Silk_perceptual_parameters_FLP.BANDWIDTH_EXPANSION + delta; - if( psEnc.sCmn.fs_kHz == 24 ) - { - /* Less bandwidth expansion for super wideband */ - BWExp1 = 1.0f - ( 1.0f - BWExp1 ) * Silk_perceptual_parameters_FLP.SWB_BANDWIDTH_EXPANSION_REDUCTION; - BWExp2 = 1.0f - ( 1.0f - BWExp2 ) * Silk_perceptual_parameters_FLP.SWB_BANDWIDTH_EXPANSION_REDUCTION; - } - /* BWExp1 will be applied after BWExp2, so make it relative */ - BWExp1 /= BWExp2; - - /********************************************/ - /* Compute noise shaping AR coefs and gains */ - /********************************************/ - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) - { - /* Apply window */ - Silk_apply_sine_window_FLP.SKP_Silk_apply_sine_window_FLP( x_windowed,0, x_ptr,x_ptr_offset, 0, Silk_define.SHAPE_LPC_WIN_MS * psEnc.sCmn.fs_kHz ); - - /* Update pointer: next LPC analysis block */ - x_ptr_offset += psEnc.sCmn.subfr_length; - - /* Calculate auto correlation */ - Silk_autocorrelation_FLP.SKP_Silk_autocorrelation_FLP(auto_corr,0, x_windowed,0, Silk_define.SHAPE_LPC_WIN_MS * psEnc.sCmn.fs_kHz, psEnc.sCmn.shapingLPCOrder + 1); - - /* Add white noise, as a fraction of energy */ - auto_corr[ 0 ] += auto_corr[ 0 ] * Silk_perceptual_parameters_FLP.SHAPE_WHITE_NOISE_FRACTION; - - /* Convert correlations to prediction coefficients, and compute residual energy */ - nrg = Silk_levinsondurbin_FLP.SKP_Silk_levinsondurbin_FLP( psEncCtrl.AR2,k * Silk_define.SHAPE_LPC_ORDER_MAX, auto_corr, psEnc.sCmn.shapingLPCOrder ); - - /* Bandwidth expansion for synthesis filter shaping */ - Silk_bwexpander_FLP.SKP_Silk_bwexpander_FLP( psEncCtrl.AR2,k * Silk_define.SHAPE_LPC_ORDER_MAX, psEnc.sCmn.shapingLPCOrder, BWExp2 ); - - /* Make sure to fit in Q13 SKP_int16 */ - LPC_fit_int16( psEncCtrl.AR2,k * Silk_define.SHAPE_LPC_ORDER_MAX, 1.0f, psEnc.sCmn.shapingLPCOrder, 3.999f ); - - /* Compute noise shaping filter coefficients */ -// SKP_memcpy( -// &psEncCtrl->AR1[ k * SHAPE_LPC_ORDER_MAX ], -// &psEncCtrl->AR2[ k * SHAPE_LPC_ORDER_MAX ], -// psEnc->sCmn.shapingLPCOrder * sizeof( SKP_float ) ); - for(int i_djinn=0; i_djinnGainsPre[ k ] = 1.0f - 0.7f * ( 1.0f - pre_nrg / nrg ); - } - - /*****************/ - /* Gain tweaking */ - /*****************/ - /* Increase gains during low speech activity and put lower limit on gains */ - gain_mult = ( float )Math.pow( 2.0f, -0.16f * SNR_adj_dB ); - gain_add = ( float )Math.pow( 2.0f, 0.16f * Silk_perceptual_parameters_FLP.NOISE_FLOOR_dB ) + - ( float )Math.pow( 2.0f, 0.16f * Silk_perceptual_parameters_FLP.RELATIVE_MIN_GAIN_dB ) * psEnc.avgGain; - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) - { - psEncCtrl.Gains[ k ] *= gain_mult; - psEncCtrl.Gains[ k ] += gain_add; - psEnc.avgGain += psEnc.speech_activity * Silk_perceptual_parameters_FLP.GAIN_SMOOTHING_COEF * ( psEncCtrl.Gains[ k ] - psEnc.avgGain ); - } - - /************************************************/ - /* Decrease level during fricatives (de-essing) */ - /************************************************/ - gain_mult = 1.0f + Silk_perceptual_parameters_FLP.INPUT_TILT + psEncCtrl.coding_quality * Silk_perceptual_parameters_FLP.HIGH_RATE_INPUT_TILT; - if( psEncCtrl.input_tilt <= 0.0f && psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_UNVOICED ) - { - float essStrength = -psEncCtrl.input_tilt * psEnc.speech_activity * ( 1.0f - psEncCtrl.sparseness ); - if( psEnc.sCmn.fs_kHz == 24 ) - { - gain_mult *= ( float )Math.pow( 2.0f, -0.16f * Silk_perceptual_parameters_FLP.DE_ESSER_COEF_SWB_dB * essStrength ); - } - else if( psEnc.sCmn.fs_kHz == 16 ) - { - gain_mult *= (float)Math.pow( 2.0f, -0.16f * Silk_perceptual_parameters_FLP.DE_ESSER_COEF_WB_dB * essStrength ); - } - else - { - assert( psEnc.sCmn.fs_kHz == 12 || psEnc.sCmn.fs_kHz == 8 ); - } - } - - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) - { - psEncCtrl.GainsPre[ k ] *= gain_mult; - } - - /************************************************/ - /* Control low-frequency shaping and noise tilt */ - /************************************************/ - /* Less low frequency shaping for noisy inputs */ - strength = Silk_perceptual_parameters_FLP.LOW_FREQ_SHAPING * ( 1.0f + Silk_perceptual_parameters_FLP.LOW_QUALITY_LOW_FREQ_SHAPING_DECR * ( psEncCtrl.input_quality_bands[ 0 ] - 1.0f ) ); - if( psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_VOICED ) - { - /* Reduce low frequencies quantization noise for periodic signals, depending on pitch lag */ - /*f = 400; freqz([1, -0.98 + 2e-4 * f], [1, -0.97 + 7e-4 * f], 2^12, Fs); axis([0, 1000, -10, 1])*/ - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) - { - b = 0.2f / psEnc.sCmn.fs_kHz + 3.0f / psEncCtrl.sCmn.pitchL[ k ]; - psEncCtrl.LF_MA_shp[ k ] = -1.0f + b; - psEncCtrl.LF_AR_shp[ k ] = 1.0f - b - b * strength; - } - Tilt = - Silk_perceptual_parameters_FLP.HP_NOISE_COEF - - (1 - Silk_perceptual_parameters_FLP.HP_NOISE_COEF) * Silk_perceptual_parameters_FLP.HARM_HP_NOISE_COEF * psEnc.speech_activity; - } - else - { - b = 1.3f / psEnc.sCmn.fs_kHz; - psEncCtrl.LF_MA_shp[ 0 ] = -1.0f + b; - psEncCtrl.LF_AR_shp[ 0 ] = 1.0f - b - b * strength * 0.6f; - for( k = 1; k < Silk_define.NB_SUBFR; k++ ) - { - psEncCtrl.LF_MA_shp[ k ] = psEncCtrl.LF_MA_shp[ k - 1 ]; - psEncCtrl.LF_AR_shp[ k ] = psEncCtrl.LF_AR_shp[ k - 1 ]; - } - Tilt = -Silk_perceptual_parameters_FLP.HP_NOISE_COEF; - } - - /****************************/ - /* HARMONIC SHAPING CONTROL */ - /****************************/ - /* Control boosting of harmonic frequencies */ - HarmBoost = Silk_perceptual_parameters_FLP.LOW_RATE_HARMONIC_BOOST * ( 1.0f - psEncCtrl.coding_quality ) * psEnc.LTPCorr; - - /* More harmonic boost for noisy input signals */ - HarmBoost += Silk_perceptual_parameters_FLP.LOW_INPUT_QUALITY_HARMONIC_BOOST * ( 1.0f - psEncCtrl.input_quality ); - - if( Silk_define.USE_HARM_SHAPING!=0 && psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_VOICED ) - { - /* Harmonic noise shaping */ - HarmShapeGain = Silk_perceptual_parameters_FLP.HARMONIC_SHAPING; - - /* More harmonic noise shaping for high bitrates or noisy input */ - HarmShapeGain += Silk_perceptual_parameters_FLP.HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING * - ( 1.0f - ( 1.0f - psEncCtrl.coding_quality ) * psEncCtrl.input_quality ); - - /* Less harmonic noise shaping for less periodic signals */ - HarmShapeGain *= ( float )Math.sqrt( psEnc.LTPCorr ); - } - else - { - HarmShapeGain = 0.0f; - } - - /*************************/ - /* Smooth over subframes */ - /*************************/ - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) - { - psShapeSt.HarmBoost_smth += Silk_perceptual_parameters_FLP.SUBFR_SMTH_COEF * ( HarmBoost - psShapeSt.HarmBoost_smth ); - psEncCtrl.HarmBoost[ k ] = psShapeSt.HarmBoost_smth; - psShapeSt.HarmShapeGain_smth += Silk_perceptual_parameters_FLP.SUBFR_SMTH_COEF * ( HarmShapeGain - psShapeSt.HarmShapeGain_smth ); - psEncCtrl.HarmShapeGain[ k ] = psShapeSt.HarmShapeGain_smth; - psShapeSt.Tilt_smth += Silk_perceptual_parameters_FLP.SUBFR_SMTH_COEF * ( Tilt - psShapeSt.Tilt_smth ); - psEncCtrl.Tilt[ k ] = psShapeSt.Tilt_smth; - } - } - - /** - * - * @param a Unstable/stabilized LPC vector [L]. - * @param a_offset offset of valid data. - * @param bwe Bandwidth expansion factor. - * @param L Number of LPC parameters in the input vector. - * @param maxVal Maximum value allowed. - */ - static void LPC_fit_int16( - float[] a, /* I/O: Unstable/stabilized LPC vector [L] */ - int a_offset, - final float bwe, /* I: Bandwidth expansion factor */ - final int L, /* I: Number of LPC parameters in the input vector */ - float maxVal /* I Maximum value allowed */ - ) - { - float maxabs, absval, sc; - int k, i, idx = 0; - float[] invGain = new float[1]; - - Silk_bwexpander_FLP.SKP_Silk_bwexpander_FLP( a,a_offset, L, bwe ); - - /***************************/ - /* Limit range of the LPCs */ - /***************************/ - /* Limit the maximum absolute value of the prediction coefficients */ - for( k = 0; k < 1000; k++ ) - { - /* Find maximum absolute value and its index */ - maxabs = -1.0f; - for( i = 0; i < L; i++ ) - { - absval = Math.abs( a[ a_offset+i ] ); - if( absval > maxabs ) { - maxabs = absval; - idx = i; - } - } - - if( maxabs >= maxVal ) - { - /* Reduce magnitude of prediction coefficients */ - sc = 0.995f * ( 1.0f - ( 1.0f - maxVal / maxabs ) / ( idx + 1 ) ); - Silk_bwexpander_FLP.SKP_Silk_bwexpander_FLP( a,a_offset, L, sc ); - } - else - { - break; - } - } - /* Reached the last iteration */ - if( k == 1000 ) - { - assert( false ); - } - - /**********************/ - /* Ensure stable LPCs */ - /**********************/ - for( k = 0; k < 1000; k++ ) - { - if( Silk_LPC_inv_pred_gain_FLP.SKP_Silk_LPC_inverse_pred_gain_FLP( invGain, a,a_offset, L ) == 1 ) - { - Silk_bwexpander_FLP.SKP_Silk_bwexpander_FLP( a,a_offset, L, 0.997f ); - } - else - { - break; - } - } - - /* Reached the last iteration */ - if( k == 1000 ) - { - assert( false ); - for( i = 0; i < L; i++ ) - { - a[ i ] = 0.0f; - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_perceptual_parameters_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_perceptual_parameters_FLP.java deleted file mode 100644 index 1327b2b85..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_perceptual_parameters_FLP.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Perceptual parameters. - * - * @author Jing Dai - * @author Dingxin Xu - */ -//TODO: float or double??? -public class Silk_perceptual_parameters_FLP -{ - /* reduction in coding SNR during low speech activity */ - static final float BG_SNR_DECR_dB = 3.0f; - - /* factor for reducing quantization noise during voiced speech */ - static final float HARM_SNR_INCR_dB = 2.0f; - - /* factor for reducing quantization noise for unvoiced sparse signals */ - static final float SPARSE_SNR_INCR_dB = 2.0f; - - /* threshold for sparseness measure above which to use lower quantization offset during unvoiced */ - static final float SPARSENESS_THRESHOLD_QNT_OFFSET = 0.75f; - - - /* noise shaping filter chirp factor */ - static final float BANDWIDTH_EXPANSION = 0.94f; - - /* difference between chirp factors for analysis and synthesis noise shaping filters at low bitrates */ - static final float LOW_RATE_BANDWIDTH_EXPANSION_DELTA = 0.01f; - - /* factor to reduce all bandwdith expansion coefficients for super wideband, relative to wideband */ - static final float SWB_BANDWIDTH_EXPANSION_REDUCTION = 1.0f; - - /* gain reduction for fricatives */ - static final float DE_ESSER_COEF_SWB_dB = 2.0f; - static final float DE_ESSER_COEF_WB_dB = 1.0f; - - - /* extra harmonic boosting (signal shaping) at low bitrates */ - static final float LOW_RATE_HARMONIC_BOOST = 0.1f; - - /* extra harmonic boosting (signal shaping) for noisy input signals */ - static final float LOW_INPUT_QUALITY_HARMONIC_BOOST = 0.1f; - - /* harmonic noise shaping */ - static final float HARMONIC_SHAPING = 0.3f; - - /* extra harmonic noise shaping for high bitrates or noisy input */ - static final float HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING = 0.2f; - - - /* parameter for shaping noise towards higher frequencies */ - static final float HP_NOISE_COEF = 0.3f; - - /* parameter for shaping noise extra towards higher frequencies during voiced speech */ - static final float HARM_HP_NOISE_COEF = 0.45f; - - /* parameter for applying a high-pass tilt to the input signal */ - static final float INPUT_TILT = 0.04f; - - /* parameter for extra high-pass tilt to the input signal at high rates */ - static final float HIGH_RATE_INPUT_TILT = 0.06f; - - /* parameter for reducing noise at the very low frequencies */ - static final float LOW_FREQ_SHAPING = 3.0f; - - /* less reduction of noise at the very low frequencies for signals with low SNR at low frequencies */ - static final float LOW_QUALITY_LOW_FREQ_SHAPING_DECR = 0.5f; - - /* fraction added to first autocorrelation value */ - static final float SHAPE_WHITE_NOISE_FRACTION = 4.7684e-5f; - - /* fraction of first autocorrelation value added to residual energy value; limits prediction gain */ - static final float SHAPE_MIN_ENERGY_RATIO = 1.526e-5f; // 1.526e-5 = 1/65536 - - /* noise floor to put a low limit on the quantization step size */ - static final float NOISE_FLOOR_dB = 4.0f; - - /* noise floor relative to active speech gain level */ - static final float RELATIVE_MIN_GAIN_dB = -50.0f; - - /* subframe smoothing coefficient for determining active speech gain level (lower -> more smoothing) */ - static final float GAIN_SMOOTHING_COEF = 1e-3f; - - /* subframe smoothing coefficient for HarmBoost, HarmShapeGain, Tilt (lower -> more smoothing) */ - static final float SUBFR_SMTH_COEF = 0.4f; - - /* Amount of noise added in prefilter, to simulate quantization noise */ - static final float NOISE_GAIN_VL = 0.12f; - static final float NOISE_GAIN_VH = 0.12f; - static final float NOISE_GAIN_UVL = 0.1f; - static final float NOISE_GAIN_UVH = 0.15f; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_pitch_analysis_core_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_pitch_analysis_core_FLP.java deleted file mode 100644 index dc7c28e74..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_pitch_analysis_core_FLP.java +++ /dev/null @@ -1,712 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Pitch analysis. - * - * @author Jing Dai - * @author Dingxin Xu - */ -//TODO: float or dobule ??? -public class Silk_pitch_analysis_core_FLP -{ - static final int SCRATCH_SIZE = 22; - - static final float eps = 1.192092896e-07f; - - /* using log2() helps the fixed-point conversion */ - static float SKP_P_log2(double x) - { - return (float)(3.32192809488736 * Math.log10(x)); - } - - /** - * CORE PITCH ANALYSIS FUNCTION. - * @param signal signal of length PITCH_EST_FRAME_LENGTH_MS*Fs_kHz - * @param pitch_out 4 pitch lag values - * @param lagIndex lag Index - * @param contourIndex pitch contour Index - * @param LTPCorr normalized correlation; input: value from previous frame - * @param prevLag last lag of previous frame; set to zero is unvoiced - * @param search_thres1 first stage threshold for lag candidates 0 - 1 - * @param search_thres2 final threshold for lag candidates 0 - 1 - * @param Fs_kHz sample frequency (kHz) - * @param complexity Complexity setting, 0-2, where 2 is highest - * @return voicing estimate: 0 voiced, 1 unvoiced - */ - static int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */ - float[] signal, /* I signal of length PITCH_EST_FRAME_LENGTH_MS*Fs_kHz */ - int[] pitch_out, /* O 4 pitch lag values */ - int[] lagIndex, /* O lag Index */ - int[] contourIndex, /* O pitch contour Index */ - float[] LTPCorr, /* I/O normalized correlation; input: value from previous frame */ - int prevLag, /* I last lag of previous frame; set to zero is unvoiced */ - final float search_thres1, /* I first stage threshold for lag candidates 0 - 1 */ - final float search_thres2, /* I final threshold for lag candidates 0 - 1 */ - final int Fs_kHz, /* I sample frequency (kHz) */ - final int complexity /* I Complexity setting, 0-2, where 2 is highest */ - ) - { - float[] signal_8kHz = new float[ Silk_common_pitch_est_defines.PITCH_EST_FRAME_LENGTH_MS * 8 ]; - float[] signal_4kHz = new float[ Silk_common_pitch_est_defines.PITCH_EST_FRAME_LENGTH_MS * 4 ]; - float[] scratch_mem = new float[ Silk_common_pitch_est_defines.PITCH_EST_MAX_FRAME_LENGTH * 3 ]; - float[] filt_state = new float[ Silk_common_pitch_est_defines.PITCH_EST_MAX_DECIMATE_STATE_LENGTH ]; - int i, k, d, j; - float threshold, contour_bias; - float[][] C = new float[Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR][(Silk_common_pitch_est_defines.PITCH_EST_MAX_LAG >> 1) + 5]; /* use to be +2 but then valgrind reported errors for SWB */ - float[] CC = new float[Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE2_EXT]; - float[] target_ptr, basis_ptr; - int target_ptr_offset, basis_ptr_offset; - double cross_corr, normalizer, energy, energy_tmp; - int[] d_srch = new int[Silk_common_pitch_est_defines.PITCH_EST_D_SRCH_LENGTH]; - short[] d_comp = new short[(Silk_common_pitch_est_defines.PITCH_EST_MAX_LAG >> 1) + 5]; - int length_d_srch, length_d_comp; - float Cmax, CCmax, CCmax_b, CCmax_new_b, CCmax_new; - int CBimax, CBimax_new, lag, start_lag, end_lag, lag_new; - int cbk_offset, cbk_size; - float lag_log2, prevLag_log2, delta_lag_log2_sqr; - float[][][] energies_st3 = new float[ Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR ][ Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE3_MAX ][ Silk_common_pitch_est_defines.PITCH_EST_NB_STAGE3_LAGS ]; - float[][][] cross_corr_st3 = new float[ Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR ][ Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE3_MAX ][ Silk_common_pitch_est_defines.PITCH_EST_NB_STAGE3_LAGS ]; - - int diff, lag_counter; - int frame_length, frame_length_8kHz, frame_length_4kHz; - int sf_length, sf_length_8kHz, sf_length_4kHz; - int min_lag, min_lag_8kHz, min_lag_4kHz; - int max_lag, max_lag_8kHz, max_lag_4kHz; - - int nb_cbks_stage2; - - /* Check for valid sampling frequency */ - assert( Fs_kHz == 8 || Fs_kHz == 12 || Fs_kHz == 16 || Fs_kHz == 24 ); - - /* Check for valid complexity setting */ - assert( complexity >= Silk_SigProc_FIX.SKP_Silk_PITCH_EST_MIN_COMPLEX ); - assert( complexity <= Silk_SigProc_FIX.SKP_Silk_PITCH_EST_MAX_COMPLEX ); - - assert( search_thres1 >= 0.0f && search_thres1 <= 1.0f ); - assert( search_thres2 >= 0.0f && search_thres2 <= 1.0f ); - - /* Setup frame lengths max / min lag for the sampling frequency */ - frame_length = Silk_common_pitch_est_defines.PITCH_EST_FRAME_LENGTH_MS * Fs_kHz; - frame_length_4kHz = Silk_common_pitch_est_defines.PITCH_EST_FRAME_LENGTH_MS * 4; - frame_length_8kHz = Silk_common_pitch_est_defines.PITCH_EST_FRAME_LENGTH_MS * 8; - sf_length = frame_length >> 3; - sf_length_4kHz = frame_length_4kHz >> 3; - sf_length_8kHz = frame_length_8kHz >> 3; - min_lag = Silk_common_pitch_est_defines.PITCH_EST_MIN_LAG_MS * Fs_kHz; - min_lag_4kHz = Silk_common_pitch_est_defines.PITCH_EST_MIN_LAG_MS * 4; - min_lag_8kHz = Silk_common_pitch_est_defines.PITCH_EST_MIN_LAG_MS * 8; - max_lag = Silk_common_pitch_est_defines.PITCH_EST_MAX_LAG_MS * Fs_kHz; - max_lag_4kHz = Silk_common_pitch_est_defines.PITCH_EST_MAX_LAG_MS * 4; - max_lag_8kHz = Silk_common_pitch_est_defines.PITCH_EST_MAX_LAG_MS * 8; - - for(int i_djinn=0; i_djinn< Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR; i_djinn++) - for(int j_djinn=0; j_djinn< (Silk_common_pitch_est_defines.PITCH_EST_MAX_LAG >> 1) + 5; j_djinn++) - C[i_djinn][j_djinn] = 0; - - /* Resample from input sampled at Fs_kHz to 8 kHz */ - if( Fs_kHz == 12 ) - { - short[] signal_12 = new short[ 12 * Silk_common_pitch_est_defines.PITCH_EST_FRAME_LENGTH_MS ]; - short[] signal_8 = new short[ 8 * Silk_common_pitch_est_defines.PITCH_EST_FRAME_LENGTH_MS ]; - int[] R23 = new int[ 6 ]; - - /* Resample to 12 -> 8 khz */ - for(int i_djinn=0; i_djinn<6; i_djinn++) - R23[i_djinn] = 0; - Silk_SigProc_FLP.SKP_float2short_array( signal_12,0, signal,0, Silk_common_pitch_est_defines.PITCH_EST_FRAME_LENGTH_MS * 12); - Silk_resampler_down2_3.SKP_Silk_resampler_down2_3( R23,0, signal_8,0, signal_12,0, Silk_common_pitch_est_defines.PITCH_EST_FRAME_LENGTH_MS * 12 ); - Silk_SigProc_FLP.SKP_short2float_array( signal_8kHz,0, signal_8,0, frame_length_8kHz ); - } - else if( Fs_kHz == 16 ) - { - if( complexity == Silk_SigProc_FIX.SKP_Silk_PITCH_EST_MAX_COMPLEX ) - { - assert( 4 <= Silk_common_pitch_est_defines.PITCH_EST_MAX_DECIMATE_STATE_LENGTH ); - for(int i_djinn=0; i_djinn<4; i_djinn++) - filt_state[i_djinn] = 0; - - Silk_decimate2_coarse_FLP.SKP_Silk_decimate2_coarse_FLP( signal,0, filt_state,0, signal_8kHz,0, - scratch_mem,0, frame_length_8kHz ); - } - else - { - assert( 2 <= Silk_common_pitch_est_defines.PITCH_EST_MAX_DECIMATE_STATE_LENGTH ); - for(int i_djinn=0; i_djinn<2; i_djinn++) - filt_state[i_djinn] = 0; - - Silk_decimate2_coarsest_FLP.SKP_Silk_decimate2_coarsest_FLP( signal,0, filt_state,0, signal_8kHz,0, - scratch_mem,0, frame_length_8kHz ); - } - } - else if( Fs_kHz == 24 ) - { - short[] signal_24 = new short[ Silk_common_pitch_est_defines.PITCH_EST_MAX_FRAME_LENGTH ]; - short[] signal_8 = new short[ 8 * Silk_common_pitch_est_defines.PITCH_EST_FRAME_LENGTH_MS ]; - int[] filt_state_fix = new int[ 8 ]; - - /* Resample to 24 -> 8 khz */ - Silk_SigProc_FLP.SKP_float2short_array( signal_24,0, signal,0, 24 * Silk_common_pitch_est_defines.PITCH_EST_FRAME_LENGTH_MS ); - for(int i_djinn=0; i_djinn<8; i_djinn++) - filt_state_fix[i_djinn] = 0; - Silk_resampler_down3.SKP_Silk_resampler_down3( filt_state_fix,0, signal_8,0, signal_24,0, 24 * Silk_common_pitch_est_defines.PITCH_EST_FRAME_LENGTH_MS ); - Silk_SigProc_FLP.SKP_short2float_array( signal_8kHz,0, signal_8,0, frame_length_8kHz ); - } - else - { - assert( Fs_kHz == 8 ); - for(int i_djinn=0; i_djinn 0; i-- ) { - signal_4kHz[ i ] += signal_4kHz[ i - 1 ]; - } - - /****************************************************************************** - * FIRST STAGE, operating in 4 khz - ******************************************************************************/ - target_ptr = signal_4kHz; - target_ptr_offset = frame_length_4kHz >> 1; - for( k = 0; k < 2; k++ ) - { - /* Check that we are within range of the array */ - assert( target_ptr_offset >= 0 ); - assert( target_ptr_offset + sf_length_8kHz <= frame_length_4kHz ); - - basis_ptr = target_ptr; - basis_ptr_offset = target_ptr_offset - min_lag_4kHz; - - /* Check that we are within range of the array */ - assert( basis_ptr_offset >= 0 ); - assert( basis_ptr_offset + sf_length_8kHz <= frame_length_4kHz ); - - /* Calculate first vector products before loop */ - cross_corr = Silk_inner_product_FLP.SKP_Silk_inner_product_FLP( target_ptr,target_ptr_offset, basis_ptr,basis_ptr_offset, sf_length_8kHz ); - normalizer = Silk_energy_FLP.SKP_Silk_energy_FLP( basis_ptr,basis_ptr_offset, sf_length_8kHz ) + 1000.0f; - - C[ 0 ][ min_lag_4kHz ] += (float)(cross_corr / Math.sqrt(normalizer)); - - /* From now on normalizer is computed recursively */ - for(d = min_lag_4kHz + 1; d <= max_lag_4kHz; d++) - { - basis_ptr_offset--; - - /* Check that we are within range of the array */ - assert( basis_ptr_offset >= 0 ); - assert( basis_ptr_offset + sf_length_8kHz <= frame_length_4kHz ); - - cross_corr = Silk_inner_product_FLP.SKP_Silk_inner_product_FLP(target_ptr,target_ptr_offset, basis_ptr,basis_ptr_offset, sf_length_8kHz); - - /* Add contribution of new sample and remove contribution from oldest sample */ -// normalizer += -// basis_ptr[ 0 ] * basis_ptr[ 0 ] - -// basis_ptr[ sf_length_8kHz ] * basis_ptr[ sf_length_8kHz ]; - normalizer += - basis_ptr[ basis_ptr_offset + 0 ] * basis_ptr[ basis_ptr_offset + 0 ] - - basis_ptr[ basis_ptr_offset + sf_length_8kHz ] * basis_ptr[ basis_ptr_offset + sf_length_8kHz ]; - C[ 0 ][ d ] += (float)(cross_corr / Math.sqrt( normalizer )); - } - /* Update target pointer */ - target_ptr_offset += sf_length_8kHz; - } - - /* Apply short-lag bias */ - for( i = max_lag_4kHz; i >= min_lag_4kHz; i-- ) - { - C[ 0 ][ i ] -= C[ 0 ][ i ] * i / 4096.0f; - } - - /* Sort */ - length_d_srch = 5 + complexity; - assert( length_d_srch <= Silk_common_pitch_est_defines.PITCH_EST_D_SRCH_LENGTH ); - Silk_sort_FLP.SKP_Silk_insertion_sort_decreasing_FLP( C[ 0 ],min_lag_4kHz, d_srch, max_lag_4kHz - min_lag_4kHz + 1, length_d_srch ); - - /* Escape if correlation is very low already here */ - Cmax = C[ 0 ][ min_lag_4kHz ]; - target_ptr = signal_4kHz; - target_ptr_offset = frame_length_4kHz >> 1; - energy = 1000.0f; - for( i = 0; i < frame_length_4kHz >> 1; i++ ) - { - energy += target_ptr[target_ptr_offset+i] * target_ptr[target_ptr_offset+i]; - } - threshold = Cmax * Cmax; - if( energy / 16.0f > threshold ) - { - for(int i_djinn=0; i_djinn threshold ) - { - d_srch[ i ] = ( d_srch[ i ] + min_lag_4kHz ) << 1; - } - else - { - length_d_srch = i; - break; - } - } - assert( length_d_srch > 0 ); - - for( i = min_lag_8kHz - 5; i < max_lag_8kHz + 5; i++ ) { - d_comp[ i ] = 0; - } - for( i = 0; i < length_d_srch; i++ ) { - d_comp[ d_srch[ i ] ] = 1; - } - - /* Convolution */ - for( i = max_lag_8kHz + 3; i >= min_lag_8kHz; i-- ) { - d_comp[ i ] += d_comp[ i - 1 ] + d_comp[ i - 2 ]; - } - - length_d_srch = 0; - for( i = min_lag_8kHz; i < max_lag_8kHz + 1; i++ ) { - if( d_comp[ i + 1 ] > 0 ) { - d_srch[ length_d_srch ] = i; - length_d_srch++; - } - } - - /* Convolution */ - for( i = max_lag_8kHz + 3; i >= min_lag_8kHz; i-- ) { - d_comp[ i ] += d_comp[ i - 1 ] + d_comp[ i - 2 ] + d_comp[ i - 3 ]; - } - - length_d_comp = 0; - for( i = min_lag_8kHz; i < max_lag_8kHz + 4; i++ ) - { - if( d_comp[ i ] > 0 ) { - d_comp[ length_d_comp ] = (short)(i - 2); - length_d_comp++; - } - } - - /********************************************************************************** - ** SECOND STAGE, operating at 8 kHz, on lag sections with high correlation - *************************************************************************************/ - /********************************************************************************* - * Find energy of each subframe projected onto its history, for a range of delays - *********************************************************************************/ - for(int i_djinn=0; i_djinn< Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR; i_djinn++) - for(int j_djinn=0; j_djinn< ((Silk_common_pitch_est_defines.PITCH_EST_MAX_LAG >> 1) + 5); j_djinn++) - C[i_djinn][j_djinn] = 0; - - target_ptr = signal_8kHz; /* point to middle of frame */ - target_ptr_offset = frame_length_4kHz; - for( k = 0; k < Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR; k++ ) - { - /* Check that we are within range of the array */ - assert( target_ptr_offset >= 0 ); - assert( target_ptr_offset + sf_length_8kHz <= frame_length_8kHz ); - - energy_tmp = Silk_energy_FLP.SKP_Silk_energy_FLP( target_ptr,target_ptr_offset, sf_length_8kHz ); - for( j = 0; j < length_d_comp; j++ ) - { - d = d_comp[ j ]; - basis_ptr = target_ptr; - basis_ptr_offset = target_ptr_offset - d; - - /* Check that we are within range of the array */ - assert( basis_ptr_offset >= 0 ); - assert( basis_ptr_offset + sf_length_8kHz <= frame_length_8kHz ); - - cross_corr = Silk_inner_product_FLP.SKP_Silk_inner_product_FLP( basis_ptr,basis_ptr_offset, target_ptr,target_ptr_offset, sf_length_8kHz ); - energy = Silk_energy_FLP.SKP_Silk_energy_FLP( basis_ptr,basis_ptr_offset, sf_length_8kHz ); - if (cross_corr > 0.0f) - { - C[ k ][ d ] = (float)(cross_corr * cross_corr / (energy * energy_tmp + eps)); - } - else - { - C[ k ][ d ] = 0.0f; - } - } - target_ptr_offset += sf_length_8kHz; - } - - /* search over lag range and lags codebook */ - /* scale factor for lag codebook, as a function of center lag */ - - CCmax = 0.0f; /* This value doesn't matter */ - CCmax_b = -1000.0f; - - CBimax = 0; /* To avoid returning undefined lag values */ - lag = -1; /* To check if lag with strong enough correlation has been found */ - - if( prevLag > 0 ) { - if( Fs_kHz == 12 ) - { - prevLag = ( prevLag<<1 ) / 3; - } - else if( Fs_kHz == 16 ) - { - prevLag = prevLag>>1; - } - else if( Fs_kHz == 24 ) - { - prevLag = prevLag / 3; - } - prevLag_log2 = SKP_P_log2(prevLag); - } - else - { - prevLag_log2 = 0; - } - - /* If input is 8 khz use a larger codebook here because it is last stage */ - if( Fs_kHz == 8 && complexity > Silk_SigProc_FIX.SKP_Silk_PITCH_EST_MIN_COMPLEX ) - { - nb_cbks_stage2 = Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE2_EXT; - } - else - { - nb_cbks_stage2 = Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE2; - } - - for( k = 0; k < length_d_srch; k++ ) - { - d = d_srch[ k ]; - for( j = 0; j < nb_cbks_stage2; j++ ) - { - CC[j] = 0.0f; - for( i = 0; i < Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR; i++ ) { - /* Try all codebooks */ - CC[ j ] += C[ i ][ d + Silk_pitch_est_tables.SKP_Silk_CB_lags_stage2[ i ][ j ] ]; - } - } - /* Find best codebook */ - CCmax_new = -1000.0f; - CBimax_new = 0; - for( i = 0; i < nb_cbks_stage2; i++ ) - { - if( CC[ i ] > CCmax_new ) - { - CCmax_new = CC[ i ]; - CBimax_new = i; - } - } - CCmax_new = Math.max(CCmax_new, 0.0f); /* To avoid taking square root of negative number later */ - CCmax_new_b = CCmax_new; - - /* Bias towards shorter lags */ - lag_log2 = SKP_P_log2(d); - CCmax_new_b -= Silk_pitch_est_defines_FLP.PITCH_EST_FLP_SHORTLAG_BIAS * Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR * lag_log2; - - /* Bias towards previous lag */ - if ( prevLag > 0 ) - { - delta_lag_log2_sqr = lag_log2 - prevLag_log2; - delta_lag_log2_sqr *= delta_lag_log2_sqr; - CCmax_new_b -= Silk_pitch_est_defines_FLP.PITCH_EST_FLP_PREVLAG_BIAS * Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR * LTPCorr[0] * delta_lag_log2_sqr / (delta_lag_log2_sqr + 0.5f); - } - - if ( CCmax_new_b > CCmax_b && CCmax_new > Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR * search_thres2 * search_thres2 ) - { - CCmax_b = CCmax_new_b; - CCmax = CCmax_new; - lag = d; - CBimax = CBimax_new; - } - } - - if( lag == -1 ) - { - /* No suitable candidate found */ - for(int i_djinn=0; i_djinn 8 ) { - /* Search in original signal */ - - /* Compensate for decimation */ - assert( lag == Silk_SigProc_FIX.SKP_SAT16( lag ) ); - if( Fs_kHz == 12 ) - { - lag = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( Silk_macros.SKP_SMULBB( lag, 3 ), 1 ); - } - else if( Fs_kHz == 16 ) - { - lag = lag<<1; - } - else - { - lag = Silk_macros.SKP_SMULBB( lag, 3 ); - } - - lag = Silk_SigProc_FIX.SKP_LIMIT_int( lag, min_lag, max_lag ); - start_lag = Math.max( lag - 2, min_lag ); - end_lag = Math.min( lag + 2, max_lag ); - lag_new = lag; /* to avoid undefined lag */ - CBimax = 0; /* to avoid undefined lag */ - assert( CCmax >= 0.0f ); - LTPCorr[0] = (float)Math.sqrt( CCmax / Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR ); // Output normalized correlation - - CCmax = -1000.0f; - - /* Calculate the correlations and energies needed in stage 3 */ - SKP_P_Ana_calc_corr_st3( cross_corr_st3, signal,0, start_lag, sf_length, complexity ); - SKP_P_Ana_calc_energy_st3( energies_st3, signal,0, start_lag, sf_length, complexity ); - - lag_counter = 0; - assert( lag == Silk_SigProc_FIX.SKP_SAT16( lag ) ); - contour_bias = Silk_pitch_est_defines_FLP.PITCH_EST_FLP_FLATCONTOUR_BIAS / lag; - - /* Setup cbk parameters acording to complexity setting */ - cbk_size = Silk_pitch_est_tables.SKP_Silk_cbk_sizes_stage3[ complexity ]; - cbk_offset = Silk_pitch_est_tables.SKP_Silk_cbk_offsets_stage3[ complexity ]; - - for( d = start_lag; d <= end_lag; d++ ) - { - for( j = cbk_offset; j < ( cbk_offset + cbk_size ); j++ ) - { - cross_corr = 0.0; - energy = eps; - for( k = 0; k < Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR; k++ ) - { - energy += energies_st3[ k ][ j ][ lag_counter ]; - cross_corr += cross_corr_st3[ k ][ j ][ lag_counter ]; - } - if( cross_corr > 0.0 ) - { - CCmax_new = (float)(cross_corr * cross_corr / energy); - /* Reduce depending on flatness of contour */ - diff = j - ( Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE3_MAX >> 1 ); - CCmax_new *= ( 1.0f - contour_bias * diff * diff ); - } - else - { - CCmax_new = 0.0f; - } - - if( CCmax_new > CCmax ) - { - CCmax = CCmax_new; - lag_new = d; - CBimax = j; - } - } - lag_counter++; - } - - for( k = 0; k < Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR; k++ ) - { - pitch_out[k] = lag_new + Silk_pitch_est_tables.SKP_Silk_CB_lags_stage3[ k ][ CBimax ]; - } - lagIndex[0] = lag_new - min_lag; - contourIndex[0] = CBimax; - } - else - { - /* Save Lags and correlation */ - assert( CCmax >= 0.0f ); - LTPCorr[0] = (float)Math.sqrt(CCmax / Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR); /* Output normalized correlation */ - for( k = 0; k < Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR; k++ ) - { - pitch_out[ k ] = lag + Silk_pitch_est_tables.SKP_Silk_CB_lags_stage2[ k ][ CBimax ]; - } - lagIndex[0] = lag - min_lag; - contourIndex[0] = CBimax; - } - assert( lagIndex[0] >= 0 ); - /* return as voiced */ - return 0; - } - - /** - * Internally used functions. - * - * @param cross_corr_st3 3 DIM correlation array. - * @param signal vector to correlate. - * @param signal_offset offset of valid data. - * @param start_lag start lag. - * @param sf_length sub frame length. - * @param complexity Complexity setting. - */ - static void SKP_P_Ana_calc_corr_st3 - ( - float[][][] cross_corr_st3, - float signal[], /* I vector to correlate */ - int signal_offset, - int start_lag, /* I start lag */ - int sf_length, /* I sub frame length */ - int complexity /* I Complexity setting */ - ) - /*********************************************************************** - Calculates the correlations used in stage 3 search. In order to cover - the whole lag codebook for all the searched offset lags (lag +- 2), - the following correlations are needed in each sub frame: - - sf1: lag range [-8,...,7] total 16 correlations - sf2: lag range [-4,...,4] total 9 correlations - sf3: lag range [-3,....4] total 8 correltions - sf4: lag range [-6,....8] total 15 correlations - - In total 48 correlations. The direct implementation computed in worst case - 4*12*5 = 240 correlations, but more likely around 120. - **********************************************************************/ - { - float[] target_ptr, basis_ptr; - int target_ptr_offset, basis_ptr_offset; - int i, j, k, lag_counter; - int cbk_offset, cbk_size, delta, idx; - float[] scratch_mem = new float[ SCRATCH_SIZE ]; - - assert( complexity >= Silk_SigProc_FIX.SKP_Silk_PITCH_EST_MIN_COMPLEX ); - assert( complexity <= Silk_SigProc_FIX.SKP_Silk_PITCH_EST_MAX_COMPLEX ); - - cbk_offset = Silk_pitch_est_tables.SKP_Silk_cbk_offsets_stage3[ complexity ]; - cbk_size = Silk_pitch_est_tables.SKP_Silk_cbk_sizes_stage3[ complexity ]; - - target_ptr = signal;/* Pointer to middle of frame */ - target_ptr_offset = signal_offset+( sf_length << 2 ); - for( k = 0; k < Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR; k++ ) - { - lag_counter = 0; - - /* Calculate the correlations for each subframe */ - for( j = Silk_pitch_est_tables.SKP_Silk_Lag_range_stage3[ complexity ][ k ][ 0 ]; j <= Silk_pitch_est_tables.SKP_Silk_Lag_range_stage3[ complexity ][ k ][ 1 ]; j++ ) - { - basis_ptr = target_ptr; - basis_ptr_offset = target_ptr_offset - ( start_lag + j ); - assert( lag_counter < SCRATCH_SIZE ); - scratch_mem[ lag_counter ] = (float)Silk_inner_product_FLP.SKP_Silk_inner_product_FLP( target_ptr,target_ptr_offset, basis_ptr,basis_ptr_offset, sf_length ); - lag_counter++; - } - - delta = Silk_pitch_est_tables.SKP_Silk_Lag_range_stage3[ complexity ][ k ][ 0 ]; - for( i = cbk_offset; i < ( cbk_offset + cbk_size ); i++ ) - { - /* Fill out the 3 dim array that stores the correlations for */ - /* each code_book vector for each start lag */ - idx = Silk_pitch_est_tables.SKP_Silk_CB_lags_stage3[ k ][ i ] - delta; - for( j = 0; j < Silk_common_pitch_est_defines.PITCH_EST_NB_STAGE3_LAGS; j++ ) - { - assert( idx + j < SCRATCH_SIZE ); - assert( idx + j < lag_counter ); - cross_corr_st3[ k ][ i ][ j ] = scratch_mem[ idx + j ]; - } - } - target_ptr_offset += sf_length; - } - } - - /** - * @param energies_st3 3 DIM correlation array. - * @param signal vector to correlate. - * @param signal_offset offset of valid data. - * @param start_lag start lag. - * @param sf_length sub frame length. - * @param complexity Complexity setting. - */ - static void SKP_P_Ana_calc_energy_st3 - ( - float[][][] energies_st3, - float signal[], /* I vector to correlate */ - int signal_offset, - int start_lag, /* I start lag */ - int sf_length, /* I sub frame length */ - int complexity /* I Complexity setting */ - ) - /**************************************************************** - Calculate the energies for first two subframes. The energies are - calculated recursively. - ****************************************************************/ - { - float[] target_ptr, basis_ptr; - int target_ptr_offset, basis_ptr_offset; - double energy; - int k, i, j, lag_counter; - int cbk_offset, cbk_size, delta, idx; - float[] scratch_mem = new float[ SCRATCH_SIZE ]; - - assert( complexity >= Silk_SigProc_FIX.SKP_Silk_PITCH_EST_MIN_COMPLEX ); - assert( complexity <= Silk_SigProc_FIX.SKP_Silk_PITCH_EST_MAX_COMPLEX ); - - cbk_offset = Silk_pitch_est_tables.SKP_Silk_cbk_offsets_stage3[ complexity ]; - cbk_size = Silk_pitch_est_tables.SKP_Silk_cbk_sizes_stage3[ complexity ]; - - target_ptr = signal; - target_ptr_offset = signal_offset+( sf_length << 2 ); - for( k = 0; k < Silk_common_pitch_est_defines.PITCH_EST_NB_SUBFR; k++ ) - { - lag_counter = 0; - - /* Calculate the energy for first lag */ - basis_ptr = target_ptr; - basis_ptr_offset = target_ptr_offset - ( start_lag + Silk_pitch_est_tables.SKP_Silk_Lag_range_stage3[complexity ][ k ][ 0 ]); - energy = Silk_energy_FLP.SKP_Silk_energy_FLP( basis_ptr,basis_ptr_offset, sf_length ) + 1e-3; - assert( energy >= 0.0 ); - scratch_mem[lag_counter] = (float)energy; - lag_counter++; - - for( i = 1; i < ( Silk_pitch_est_tables.SKP_Silk_Lag_range_stage3[ complexity ][ k ][ 1 ] - Silk_pitch_est_tables.SKP_Silk_Lag_range_stage3[ complexity ][ k ][ 0 ] + 1 ); i++ ) - { - /* remove part outside new window */ - energy -= basis_ptr[basis_ptr_offset + sf_length - i] * basis_ptr[basis_ptr_offset + sf_length - i]; - assert( energy >= 0.0 ); - - /* add part that comes into window */ - energy += basis_ptr[ basis_ptr_offset -i ] * basis_ptr[ basis_ptr_offset-i ]; - assert( energy >= 0.0 ); - assert( lag_counter < SCRATCH_SIZE ); - scratch_mem[lag_counter] = (float)energy; - lag_counter++; - } - - delta = Silk_pitch_est_tables.SKP_Silk_Lag_range_stage3[ complexity ][ k ][ 0 ]; - for( i = cbk_offset; i < ( cbk_offset + cbk_size ); i++ ) - { - /* Fill out the 3 dim array that stores the correlations for */ - /* each code_book vector for each start lag */ - idx = Silk_pitch_est_tables.SKP_Silk_CB_lags_stage3[ k ][ i ] - delta; - for(j = 0; j < Silk_common_pitch_est_defines.PITCH_EST_NB_STAGE3_LAGS; j++) - { - assert( idx + j < SCRATCH_SIZE ); - assert( idx + j < lag_counter ); - energies_st3[ k ][ i ][ j ] = scratch_mem[ idx + j ]; - assert( energies_st3[ k ][ i ][ j ] >= 0.0f ); - } - } - target_ptr_offset += sf_length; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_pitch_est_defines.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_pitch_est_defines.java deleted file mode 100644 index 5502b9654..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_pitch_est_defines.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Definitions For Fix pitch estimator - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_pitch_est_defines -{ - static final int PITCH_EST_SHORTLAG_BIAS_Q15 = 6554; /* 0.2f. for logarithmic weighting */ - static final int PITCH_EST_PREVLAG_BIAS_Q15 = 6554; /* Prev lag bias */ - static final int PITCH_EST_FLATCONTOUR_BIAS_Q20 = 52429; /* 0.05f */ -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_pitch_est_defines_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_pitch_est_defines_FLP.java deleted file mode 100644 index f11e8bb18..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_pitch_est_defines_FLP.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Definitions For FLP pitch estimator. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_pitch_est_defines_FLP -{ - static final float PITCH_EST_FLP_SHORTLAG_BIAS = 0.2f; /* for logarithmic weighting */ - static final float PITCH_EST_FLP_PREVLAG_BIAS = 0.2f; /* for logarithmic weighting */ - static final float PITCH_EST_FLP_FLATCONTOUR_BIAS = 0.05f; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_pitch_est_tables.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_pitch_est_tables.java deleted file mode 100644 index 6ab10f27b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_pitch_est_tables.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Auto Generated File from generate_pitch_est_tables.m - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_pitch_est_tables -{ - static short[][] SKP_Silk_CB_lags_stage2 = - { - {0, 2,-1,-1,-1, 0, 0, 1, 1, 0, 1}, - {0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0}, - {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0}, - {0,-1, 2, 1, 0, 1, 1, 0, 0,-1,-1} - }; - - static short[][] SKP_Silk_CB_lags_stage3 = - { - {-9,-7,-6,-5,-5,-4,-4,-3,-3,-2,-2,-2,-1,-1,-1, 0, 0, 0, 1, 1, 0, 1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 5, 6, 8}, - {-3,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0,-1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 2, 1, 2, 2, 2, 2, 3}, - { 3, 3, 2, 2, 2, 2, 1, 2, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,-1, 0, 0,-1,-1,-1,-1,-1,-2,-2,-2}, - { 9, 8, 6, 5, 6, 5, 4, 4, 3, 3, 2, 2, 2, 1, 0, 1, 1, 0, 0, 0,-1,-1,-1,-2,-2,-2,-3,-3,-4,-4,-5,-5,-6,-7} - }; - - static short[][][] SKP_Silk_Lag_range_stage3 = - { - /* Lags to search for low number of stage3 cbks */ - { - {-2,6}, - {-1,5}, - {-1,5}, - {-2,7} - }, - /* Lags to search for middle number of stage3 cbks */ - { - {-4,8}, - {-1,6}, - {-1,6}, - {-4,9} - }, - /* Lags to search for max number of stage3 cbks */ - { - {-9,12}, - {-3,7}, - {-2,7}, - {-7,13} - } - }; - - static short[] SKP_Silk_cbk_sizes_stage3 = - { - Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE3_MIN, - Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE3_MID, - Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE3_MAX - }; - - static short[] SKP_Silk_cbk_offsets_stage3 = - { - ((Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE3_MAX - Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE3_MIN) >> 1), - ((Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE3_MAX - Silk_common_pitch_est_defines.PITCH_EST_NB_CBKS_STAGE3_MID) >> 1), - 0 - }; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_prefilter_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_prefilter_FLP.java deleted file mode 100644 index 1169acf02..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_prefilter_FLP.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * - * @author Dingxin Xu - */ -public class Silk_prefilter_FLP -{ - /** - * SKP_Silk_prefilter. Main Prefilter Function. - * @param psEnc Encoder state FLP. - * @param psEncCtrl Encoder control FLP. - * @param xw Weighted signal. - * @param x Speech signal. - * @param x_offset offset of valid data. - */ - static void SKP_Silk_prefilter_FLP( - SKP_Silk_encoder_state_FLP psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP psEncCtrl, /* I Encoder control FLP */ - float xw[], /* O Weighted signal */ - float x[], /* I Speech signal */ - int x_offset - ) - { - SKP_Silk_prefilter_state_FLP P = psEnc.sPrefilt; - int j, k, lag; - float HarmShapeGain, Tilt, LF_MA_shp, LF_AR_shp; - float[] B = new float[ 2 ]; - float[] AR1_shp = new float[ Silk_define.NB_SUBFR * Silk_define.SHAPE_LPC_ORDER_MAX ]; - float[] px; - int px_offset; - float[] pxw, pst_res; - int pxw_offset; - int pst_res_offset; - float[] HarmShapeFIR = new float[ 3 ]; - float[] st_res = new float[ Silk_define.MAX_FRAME_LENGTH / Silk_define.NB_SUBFR + Silk_define.MAX_LPC_ORDER ]; - - /* Setup pointers */ - px = x; - px_offset = x_offset; - pxw = xw; - pxw_offset = 0; - lag = P.lagPrev; - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) - { - /* Update Variables that change per sub frame */ - if( psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_VOICED ) - { - lag = psEncCtrl.sCmn.pitchL[ k ]; - } - - /* Noise shape parameters */ - HarmShapeGain = psEncCtrl.HarmShapeGain[ k ] * ( 1.0f - psEncCtrl.HarmBoost[ k ] ); - HarmShapeFIR[ 0 ] = Silk_tables_other_FLP.SKP_Silk_HarmShapeFIR_FLP[ 0 ] * HarmShapeGain; - HarmShapeFIR[ 1 ] = Silk_tables_other_FLP.SKP_Silk_HarmShapeFIR_FLP[ 1 ] * HarmShapeGain; - HarmShapeFIR[ 2 ] = Silk_tables_other_FLP.SKP_Silk_HarmShapeFIR_FLP[ 2 ] * HarmShapeGain; - Tilt = psEncCtrl.Tilt[ k ]; - LF_MA_shp = psEncCtrl.LF_MA_shp[ k ]; - LF_AR_shp = psEncCtrl.LF_AR_shp[ k ]; -//TODO: copy the psEncCtrl.AR1 to a local buffer or use a reference(pointer) to the struct??? -// AR1_shp = psEncCtrl.AR1; -// AR1_shp_offset = k * Silk_define.SHAPE_LPC_ORDER_MAX; - Arrays.fill(AR1_shp, 0); - System.arraycopy(psEncCtrl.AR1, k * Silk_define.SHAPE_LPC_ORDER_MAX, - AR1_shp, 0, psEncCtrl.AR1.length-k * Silk_define.SHAPE_LPC_ORDER_MAX); - - /* Short term FIR filtering*/ - Silk_LPC_analysis_filter_FLP.SKP_Silk_LPC_analysis_filter_FLP( st_res, AR1_shp, - px, px_offset - psEnc.sCmn.shapingLPCOrder, - psEnc.sCmn.subfr_length + psEnc.sCmn.shapingLPCOrder, psEnc.sCmn.shapingLPCOrder ); - - pst_res = st_res; - pst_res_offset = psEnc.sCmn.shapingLPCOrder; // Point to first sample - - /* reduce (mainly) low frequencies during harmonic emphasis */ - B[ 0 ] = psEncCtrl.GainsPre[ k ]; - B[ 1 ] = -psEncCtrl.GainsPre[ k ] * - ( psEncCtrl.HarmBoost[ k ] * HarmShapeGain + Silk_perceptual_parameters_FLP.INPUT_TILT + - psEncCtrl.coding_quality * Silk_perceptual_parameters_FLP.HIGH_RATE_INPUT_TILT ); - pxw[ pxw_offset + 0 ] = B[ 0 ] * pst_res[ pst_res_offset + 0 ] + B[ 1 ] * P.sHarmHP; - for( j = 1; j < psEnc.sCmn.subfr_length; j++ ) { - pxw[ pxw_offset + j ] = B[ 0 ] * pst_res[ pst_res_offset + j ] + B[ 1 ] * pst_res[ pst_res_offset + j - 1 ]; - } - P.sHarmHP = pst_res[ pst_res_offset + psEnc.sCmn.subfr_length - 1 ]; - - SKP_Silk_prefilt_FLP( P, pxw, pxw_offset, pxw, pxw_offset, HarmShapeFIR, Tilt, LF_MA_shp, LF_AR_shp, lag, psEnc.sCmn.subfr_length ); - - px_offset += psEnc.sCmn.subfr_length; - pxw_offset += psEnc.sCmn.subfr_length; - } - P.lagPrev = psEncCtrl.sCmn.pitchL[ Silk_define.NB_SUBFR - 1 ]; - } - - /** - * SKP_Silk_prefilter_part1. Prefilter for finding Quantizer input signal. - * @param P - * @param st_res - * @param st_res_offset - * @param xw - * @param xw_offset - * @param HarmShapeFIR - * @param Tilt - * @param LF_MA_shp - * @param LF_AR_shp - * @param lag - * @param length - */ - static void SKP_Silk_prefilt_FLP( - SKP_Silk_prefilter_state_FLP P,/* (I/O) state */ - float st_res[], /* (I) */ - int st_res_offset, - float xw[], /* (O) */ - int xw_offset, - float []HarmShapeFIR, /* (I) */ - float Tilt, /* (I) */ - float LF_MA_shp, /* (I) */ - float LF_AR_shp, /* (I) */ - int lag, /* (I) */ - int length /* (I) */ - ) - { - int i; - int idx, LTP_shp_buf_idx; - float n_Tilt, n_LF, n_LTP; - float sLF_AR_shp, sLF_MA_shp; - float []LTP_shp_buf; - - /* To speed up use temp variables instead of using the struct */ - LTP_shp_buf = P.sLTP_shp1; - LTP_shp_buf_idx = P.sLTP_shp_buf_idx1; - sLF_AR_shp = P.sLF_AR_shp1; - sLF_MA_shp = P.sLF_MA_shp1; - - for( i = 0; i < length; i++ ) { - if( lag > 0 ) { - assert( Silk_define.HARM_SHAPE_FIR_TAPS == 3 ); - idx = lag + LTP_shp_buf_idx; - n_LTP = LTP_shp_buf[ ( idx - Silk_define.HARM_SHAPE_FIR_TAPS / 2 - 1) & Silk_define.LTP_MASK ] * HarmShapeFIR[ 0 ]; - n_LTP += LTP_shp_buf[ ( idx - Silk_define.HARM_SHAPE_FIR_TAPS / 2 ) & Silk_define.LTP_MASK ] * HarmShapeFIR[ 1 ]; - n_LTP += LTP_shp_buf[ ( idx - Silk_define.HARM_SHAPE_FIR_TAPS / 2 + 1) & Silk_define.LTP_MASK ] * HarmShapeFIR[ 2 ]; - } else { - n_LTP = 0; - } - - n_Tilt = sLF_AR_shp * Tilt; - n_LF = sLF_AR_shp * LF_AR_shp + sLF_MA_shp * LF_MA_shp; - - sLF_AR_shp = st_res[ st_res_offset + i ] - n_Tilt; - sLF_MA_shp = sLF_AR_shp - n_LF; - - LTP_shp_buf_idx = ( LTP_shp_buf_idx - 1 ) & Silk_define.LTP_MASK; - LTP_shp_buf[ LTP_shp_buf_idx ] = sLF_MA_shp; - xw[ xw_offset + i ] = sLF_MA_shp - n_LTP; - } - /* Copy temp variable back to state */ - P.sLF_AR_shp1 = sLF_AR_shp; - P.sLF_MA_shp1 = sLF_MA_shp; - P.sLTP_shp_buf_idx1 = LTP_shp_buf_idx; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_process_NLSFs_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_process_NLSFs_FLP.java deleted file mode 100644 index 7990b75b9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_process_NLSFs_FLP.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Limit, stabilize, convert and quantize NLSFs. - * - * @author Dingxin Xu - */ -public class Silk_process_NLSFs_FLP -{ - /** - * Limit, stabilize, convert and quantize NLSFs. - * @param psEnc Encoder state FLP - * @param psEncCtrl Encoder control FLP - * @param pNLSF NLSFs (quantized output) - */ - static void SKP_Silk_process_NLSFs_FLP( - SKP_Silk_encoder_state_FLP psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP psEncCtrl, /* I/O Encoder control FLP */ - float []pNLSF /* I/O NLSFs (quantized output) */ - ) - { - boolean doInterpolate; - float pNLSFW[] = new float[ Silk_define.MAX_LPC_ORDER ]; - float NLSF_mu, NLSF_mu_fluc_red, i_sqr, NLSF_interpolation_factor = 0.0f; - final SKP_Silk_NLSF_CB_FLP psNLSF_CB_FLP; - - - /* Used only for NLSF interpolation */ - float pNLSF0_temp[] = new float[ Silk_define.MAX_LPC_ORDER ]; - float pNLSFW0_temp[] = new float[ Silk_define.MAX_LPC_ORDER ]; - int i; - - assert( psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_VOICED || psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_UNVOICED ); - - /***********************/ - /* Calculate mu values */ - /***********************/ - if( psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_VOICED ) { - NLSF_mu = 0.002f - 0.001f * psEnc.speech_activity; - NLSF_mu_fluc_red = 0.1f - 0.05f * psEnc.speech_activity; - } else { - NLSF_mu = 0.005f - 0.004f * psEnc.speech_activity; - NLSF_mu_fluc_red = 0.2f - 0.1f * ( psEnc.speech_activity + psEncCtrl.sparseness ); - } - - /* Calculate NLSF weights */ - Silk_NLSF_VQ_weights_laroia_FLP.SKP_Silk_NLSF_VQ_weights_laroia_FLP( pNLSFW, pNLSF, psEnc.sCmn.predictLPCOrder ); - - /* Update NLSF weights for interpolated NLSFs */ - doInterpolate = ( psEnc.sCmn.useInterpolatedNLSFs == 1 ) && ( psEncCtrl.sCmn.NLSFInterpCoef_Q2 < ( 1 << 2 ) ); - if( doInterpolate ) { - - /* Calculate the interpolated NLSF vector for the first half */ - NLSF_interpolation_factor = 0.25f * psEncCtrl.sCmn.NLSFInterpCoef_Q2; - Silk_wrappers_FLP.SKP_Silk_interpolate_wrapper_FLP( pNLSF0_temp, psEnc.sPred.prev_NLSFq, pNLSF, - NLSF_interpolation_factor, psEnc.sCmn.predictLPCOrder ); - - /* Calculate first half NLSF weights for the interpolated NLSFs */ - Silk_NLSF_VQ_weights_laroia_FLP.SKP_Silk_NLSF_VQ_weights_laroia_FLP( pNLSFW0_temp, pNLSF0_temp, psEnc.sCmn.predictLPCOrder ); - - /* Update NLSF weights with contribution from first half */ - i_sqr = NLSF_interpolation_factor * NLSF_interpolation_factor; - for( i = 0; i < psEnc.sCmn.predictLPCOrder; i++ ) { - pNLSFW[ i ] = 0.5f * ( pNLSFW[ i ] + i_sqr * pNLSFW0_temp[ i ] ); - } - } - - /* Set pointer to the NLSF codebook for the current signal type and LPC order */ - psNLSF_CB_FLP = psEnc.psNLSF_CB_FLP[ psEncCtrl.sCmn.sigtype ]; - - /* Quantize NLSF parameters given the trained NLSF codebooks */ - Silk_NLSF_MSVQ_encode_FLP.SKP_Silk_NLSF_MSVQ_encode_FLP( psEncCtrl.sCmn.NLSFIndices, pNLSF, psNLSF_CB_FLP, psEnc.sPred.prev_NLSFq, - pNLSFW, NLSF_mu, NLSF_mu_fluc_red, psEnc.sCmn.NLSF_MSVQ_Survivors, - psEnc.sCmn.predictLPCOrder, psEnc.sCmn.first_frame_after_reset ); - - /* Convert quantized NLSFs back to LPC coefficients */ - Silk_wrappers_FLP.SKP_Silk_NLSF2A_stable_FLP( psEncCtrl.PredCoef[ 1 ], pNLSF, psEnc.sCmn.predictLPCOrder ); - - if( doInterpolate ) { - /* Calculate the interpolated, quantized NLSF vector for the first half */ - Silk_wrappers_FLP.SKP_Silk_interpolate_wrapper_FLP( pNLSF0_temp, psEnc.sPred.prev_NLSFq, pNLSF, - NLSF_interpolation_factor, psEnc.sCmn.predictLPCOrder ); - - /* Convert back to LPC coefficients */ - Silk_wrappers_FLP.SKP_Silk_NLSF2A_stable_FLP( psEncCtrl.PredCoef[ 0 ], pNLSF0_temp, psEnc.sCmn.predictLPCOrder ); - - } else { - /* Copy LPC coefficients for first half from second half */ - System.arraycopy(psEncCtrl.PredCoef[1], 0, psEncCtrl.PredCoef[0], 0, psEnc.sCmn.predictLPCOrder); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_process_gains_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_process_gains_FLP.java deleted file mode 100644 index d452679ef..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_process_gains_FLP.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * processing of gains. - * - * @author Dingxin Xu - */ -public class Silk_process_gains_FLP -{ - /** - * Processing of gains. - * @param psEnc Encoder state FLP - * @param psEncCtrl Encoder control FLP - */ - static void SKP_Silk_process_gains_FLP( - SKP_Silk_encoder_state_FLP psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP psEncCtrl /* I/O Encoder control FLP */ - ) - { - SKP_Silk_shape_state_FLP psShapeSt = psEnc.sShape; - int k; - int pGains_Q16[] = new int[ Silk_define.NB_SUBFR ]; - float s, InvMaxSqrVal, gain; - - /* Gain reduction when LTP coding gain is high */ - if( psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_VOICED ) { - s = 1.0f - 0.5f * Silk_SigProc_FLP.SKP_sigmoid( 0.25f * ( psEncCtrl.LTPredCodGain - 12.0f ) ); - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - psEncCtrl.Gains[ k ] *= s; - } - } - - /* Limit the quantized signal */ - InvMaxSqrVal = ( float )( Math.pow( 2.0f, 0.33f * ( 21.0f - psEncCtrl.current_SNR_dB ) ) / psEnc.sCmn.subfr_length ); - - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - /* Soft limit on ratio residual energy and squared gains */ - gain = psEncCtrl.Gains[ k ]; - gain = ( float )Math.sqrt( gain * gain + psEncCtrl.ResNrg[ k ] * InvMaxSqrVal ); - psEncCtrl.Gains[ k ] = ( gain < 32767.0f ? gain : 32767.0f ); - } - - /* Prepare gains for noise shaping quantization */ - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - pGains_Q16[ k ] = ( int ) ( psEncCtrl.Gains[ k ] * 65536.0f ); - } - - /* Noise shaping quantization */ - int[] LastGainIndex_ptr = new int[1]; - LastGainIndex_ptr[0] = psShapeSt.LastGainIndex; - Silk_gain_quant.SKP_Silk_gains_quant( psEncCtrl.sCmn.GainsIndices, pGains_Q16, - LastGainIndex_ptr, psEnc.sCmn.nFramesInPayloadBuf ); - psShapeSt.LastGainIndex = LastGainIndex_ptr[0]; - /* Overwrite unquantized gains with quantized gains and convert back to Q0 from Q16 */ - for( k = 0; k < Silk_define.NB_SUBFR; k++ ) { - psEncCtrl.Gains[ k ] = pGains_Q16[ k ] / 65536.0f; - } - - /* Set quantizer offset for voiced signals. Larger offset when LTP coding gain is low or tilt is high (ie low-pass) */ - if( psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_VOICED ) { - if( psEncCtrl.LTPredCodGain + psEncCtrl.input_tilt > 1.0f ) { - psEncCtrl.sCmn.QuantOffsetType = 0; - } else { - psEncCtrl.sCmn.QuantOffsetType = 1; - } - } - - /* Quantizer boundary adjustment */ - if( psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_VOICED ) { - psEncCtrl.Lambda = 1.2f - 0.4f * psEnc.speech_activity - - 0.3f * psEncCtrl.input_quality - + 0.2f * psEncCtrl.sCmn.QuantOffsetType - - 0.1f * psEncCtrl.coding_quality; - } else { - psEncCtrl.Lambda = 1.2f - 0.4f * psEnc.speech_activity - - 0.4f * psEncCtrl.input_quality - + 0.4f * psEncCtrl.sCmn.QuantOffsetType - - 0.1f * psEncCtrl.coding_quality; - } - - assert( psEncCtrl.Lambda >= 0.0f ); - assert( psEncCtrl.Lambda < 2.0f ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_quant_LTP_gains_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_quant_LTP_gains_FLP.java deleted file mode 100644 index 2c8f3798d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_quant_LTP_gains_FLP.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Dingxin Xu - */ -public class Silk_quant_LTP_gains_FLP -{ - - /** - * - * @param B (Un-)quantized LTP gains - * @param cbk_index Codebook index - * @param periodicity_index Periodicity index - * @param W Error weights - * @param mu Mu value (R/D tradeoff) - * @param lowComplexity Flag for low complexity - */ - static void SKP_Silk_quant_LTP_gains_FLP( - float B[], /* I/O (Un-)quantized LTP gains */ - int cbk_index[], /* O Codebook index */ - int []periodicity_index, /* O Periodicity index */ - final float W[], /* I Error weights */ - final float mu, /* I Mu value (R/D tradeoff) */ - final int lowComplexity /* I Flag for low complexity */ - ) - { -// SKP_int j, k, temp_idx[ NB_SUBFR ], cbk_size; -// const SKP_uint16 *cdf_ptr; -// const SKP_int16 *cl_ptr; -// const SKP_int16 *cbk_ptr_Q14; -// const SKP_float *b_ptr, *W_ptr; -// SKP_float rate_dist_subfr, rate_dist, min_rate_dist; - int j,k,cbk_size; - int[] temp_idx = new int[Silk_define.NB_SUBFR]; - int[] cdf_ptr; int cdf_ptr_offset; - short[] cl_ptr; int cl_ptr_offset; - short[] cbk_ptr_Q14; int cbk_ptr_Q14_offset; - float b_ptr[]; - float W_ptr[]; int b_ptr_offset,W_ptr_offset; - float rate_dist_subfr = 0, rate_dist, min_rate_dist; - - - - /***************************************************/ - /* Iterate over different codebooks with different */ - /* rates/distortions, and choose best */ - /***************************************************/ -// min_rate_dist = SKP_float_MAX; - min_rate_dist = Float.MAX_VALUE; - for( k = 0; k < 3; k++ ) { - cdf_ptr = Silk_tables_LTP.SKP_Silk_LTP_gain_CDF_ptrs[ k ]; - cl_ptr = Silk_tables_LTP.SKP_Silk_LTP_gain_BITS_Q6_ptrs[ k ]; - cbk_ptr_Q14 = Silk_tables_LTP.SKP_Silk_LTP_vq_ptrs_Q14[ k ]; - cbk_size = Silk_tables_LTP.SKP_Silk_LTP_vq_sizes[ k ]; - - - /* Setup pointer to first subframe */ - W_ptr = W; - W_ptr_offset = 0; - b_ptr = B; - b_ptr_offset = 0; - - rate_dist = 0.0f; - for( j = 0; j < Silk_define.NB_SUBFR; j++ ) { - - float [] rate_dist_subfr_ptr = new float[1]; - rate_dist_subfr_ptr[0] = rate_dist_subfr; - - Silk_VQ_nearest_neighbor_FLP.SKP_Silk_VQ_WMat_EC_FLP( - temp_idx, /* O index of best codebook vector */ - j, - rate_dist_subfr_ptr, /* O best weighted quantization error + mu * rate */ - b_ptr, /* I input vector to be quantized */ - b_ptr_offset, - W_ptr, /* I weighting matrix */ - W_ptr_offset, - cbk_ptr_Q14, /* I codebook */ - cl_ptr, /* I code length for each codebook vector */ - mu, /* I tradeoff between weighted error and rate */ - cbk_size /* I number of vectors in codebook */ - ); - rate_dist_subfr = rate_dist_subfr_ptr[0]; -// Silk_VQ_nearest_neighbor_FLP.SKP_Silk_VQ_WMat_EC_FLP( -// &temp_idx[ j ], /* O index of best codebook vector */ -// &rate_dist_subfr, /* O best weighted quantization error + mu * rate */ -// b_ptr, /* I input vector to be quantized */ -// W_ptr, /* I weighting matrix */ -// cbk_ptr_Q14, /* I codebook */ -// cl_ptr, /* I code length for each codebook vector */ -// mu, /* I tradeoff between weighted error and rate */ -// cbk_size /* I number of vectors in codebook */ -// ); - - - rate_dist += rate_dist_subfr; - -// b_ptr += LTP_ORDER; -// W_ptr += LTP_ORDER * LTP_ORDER; - b_ptr_offset += Silk_define.LTP_ORDER; - W_ptr_offset += Silk_define.LTP_ORDER * Silk_define.LTP_ORDER; - } - - if( rate_dist < min_rate_dist ) { - min_rate_dist = rate_dist; -// SKP_memcpy( cbk_index, temp_idx, NB_SUBFR * sizeof( SKP_int ) ); -// *periodicity_index = k; - System.arraycopy(temp_idx, 0, cbk_index, 0, Silk_define.NB_SUBFR); - periodicity_index[0] = k; - } - - /* Break early in low-complexity mode if rate distortion is below threshold */ - if( lowComplexity != 0 && ( rate_dist * 16384.0f < Silk_tables_LTP.SKP_Silk_LTP_gain_middle_avg_RD_Q14 ) ) { - break; - } - } - -// cbk_ptr_Q14 = SKP_Silk_LTP_vq_ptrs_Q14[ *periodicity_index ]; - cbk_ptr_Q14 = Silk_tables_LTP.SKP_Silk_LTP_vq_ptrs_Q14[periodicity_index[0]]; - - for( j = 0; j < Silk_define.NB_SUBFR; j++ ) { -// SKP_short2float_array( &B[ j * LTP_ORDER ], -// &cbk_ptr_Q14[ cbk_index[ j ] * LTP_ORDER ], -// LTP_ORDER ); - Silk_SigProc_FLP.SKP_short2float_array(B, j*Silk_define.LTP_ORDER, - cbk_ptr_Q14, cbk_index[ j ] * Silk_define.LTP_ORDER, - Silk_define.LTP_ORDER); - } - - for( j = 0; j < Silk_define.NB_SUBFR * Silk_define.LTP_ORDER; j++ ) { - B[ j ] *= Silk_define_FLP.Q14_CONVERSION_FAC; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_range_coder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_range_coder.java deleted file mode 100644 index 034304133..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_range_coder.java +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Range coder - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_range_coder -{ - /** - * Range encoder for one symbol. - * @param psRC compressor data structure. - * @param data uncompressed data. - * @param prob cumulative density functions. - * @param prob_offset offset of valid data. - */ - static void SKP_Silk_range_encoder( - SKP_Silk_range_coder_state psRC, /* I/O compressor data structure */ - final int data, /* I uncompressed data */ - int prob[], /* I cumulative density functions */ - int prob_offset - ) - { - long low_Q16, high_Q16; - long base_tmp, range_Q32; - - /* Copy structure data */ - long base_Q32 = psRC.base_Q32; - long range_Q16 = psRC.range_Q16; - int bufferIx = psRC.bufferIx; - byte[] buffer = psRC.buffer; - - if( psRC.error!=0 ) - { - return; - } - - /* Update interval */ - low_Q16 = prob[ prob_offset + data ]; - high_Q16 = prob[ prob_offset + data + 1 ]; - base_tmp = base_Q32; /* save current base, to test for carry */ - -//TODO: base_Q32 should be 32-bit -// base_Q32 += ( range_Q16 * low_Q16 ) & 0xFFFFFFFFL; - base_Q32 += ( range_Q16 * low_Q16 ) & 0xFFFFFFFFL; - base_Q32 = base_Q32 & 0xFFFFFFFFL; - - range_Q32 = ( range_Q16 * (high_Q16 - low_Q16) )& 0xFFFFFFFFL; - - /* Check for carry */ - if( base_Q32 < base_tmp ) - { - /* Propagate carry in buffer */ - int bufferIx_tmp = bufferIx; - while( ( ++buffer[ --bufferIx_tmp ] ) == 0 ); - } - - /* Check normalization */ - if( (range_Q32 & 0xFF000000L)!=0 ) -// if( (range_Q32 & 0xFF000000)!=0 ) - { - /* No normalization */ -// range_Q16 = ( range_Q32 >> 16 ); - range_Q16 = ( range_Q32 >>> 16 ); - - } - else - { - if( (range_Q32 & 0xFFFF0000L)!=0 ) -// if( (range_Q32 & 0xFFFF0000)!=0 ) - { - /* Normalization of 8 bits shift */ -// range_Q16 = ( range_Q32 >> 8 ); - range_Q16 = ( range_Q32 >>> 8 ); - } - else - { - /* Normalization of 16 bits shift */ - range_Q16 = range_Q32; - /* Make sure not to write beyond buffer */ - if( bufferIx >= psRC.bufferLength ) - { - psRC.error = Silk_define.RANGE_CODER_WRITE_BEYOND_BUFFER; - return; - } - /* Write one byte to buffer */ - buffer[ bufferIx++ ] = (byte)( base_Q32 >>> 24 ); -// base_Q32 = base_Q32 << 8; - base_Q32 = (base_Q32 << 8)&0xFFFFFFFFL; - - } - /* Make sure not to write beyond buffer */ - if( bufferIx >= psRC.bufferLength ) - { - psRC.error = Silk_define.RANGE_CODER_WRITE_BEYOND_BUFFER; - return; - } - /* Write one byte to buffer */ - buffer[ bufferIx++ ] = (byte)( base_Q32 >>> 24 ); -// base_Q32 = base_Q32 << 8; - base_Q32 = (base_Q32 << 8)&0xFFFFFFFFL; - } - - /* Copy structure data back */ - psRC.base_Q32 = base_Q32; - psRC.range_Q16 = range_Q16; - psRC.bufferIx = bufferIx; - } - - /** - * Range encoder for multiple symbols. - * @param psRC compressor data structure. - * @param data uncompressed data [nSymbols]. - * @param prob cumulative density functions. - * @param nSymbols number of data symbols. - */ - static void SKP_Silk_range_encoder_multi( - SKP_Silk_range_coder_state psRC, /* I/O compressor data structure */ - int[] data, /* I uncompressed data [nSymbols] */ - int[][] prob, /* I cumulative density functions */ - final int nSymbols /* I number of data symbols */ - ) - { - int k; - for( k = 0; k < nSymbols; k++ ) - { - SKP_Silk_range_encoder( psRC, data[ k ], prob[ k ], 0 ); - } - } - - /** - * Range decoder for one symbol. - * @param data uncompressed data. - * @param data_offset offset of valid data. - * @param psRC compressor data structure. - * @param prob cumulative density function. - * @param prob_offset offset of valid data. - * @param probIx initial (middle) entry of cdf. - */ - static void SKP_Silk_range_decoder( - int data[], /* O uncompressed data */ - int data_offset, - SKP_Silk_range_coder_state psRC, /* I/O compressor data structure */ - final int prob[], /* I cumulative density function */ - int prob_offset, - int probIx /* I initial (middle) entry of cdf */ - ) - { - long low_Q16, high_Q16; - long base_tmp, range_Q32; - - /* Copy structure data */ - long base_Q32 = psRC.base_Q32; - long range_Q16 = psRC.range_Q16; - int bufferIx = psRC.bufferIx; - byte[] buffer = psRC.buffer; - int buffer_offset = 4; - - if( psRC.error != 0) { - /* Set output to zero */ - data[data_offset + 0] = 0; - return; - } - - high_Q16 = prob[prob_offset + probIx]; - -//TODO base_tmp = Silk_SigProc_FIX.SKP_MUL_uint( range_Q16, high_Q16 ); - base_tmp = ( range_Q16 * high_Q16 ) & 0xFFFFFFFFL; - - if( base_tmp > base_Q32 ) { - while( true ) { - low_Q16 = prob[ --probIx + prob_offset ]; -// base_tmp = Silk_SigProc_FIX.SKP_MUL_uint( range_Q16, low_Q16 ); - base_tmp = (range_Q16 * low_Q16 ) & 0xFFFFFFFFL; - if( base_tmp <= base_Q32 ) { - break; - } - high_Q16 = low_Q16; - /* Test for out of range */ - if( high_Q16 == 0 ) { - psRC.error = Silk_define.RANGE_CODER_CDF_OUT_OF_RANGE; - /* Set output to zero */ - data[data_offset + 0] = 0; - return; - } - } - } else { - while( true ) { - low_Q16 = high_Q16; - high_Q16 = prob[ ++probIx + prob_offset ]; -// base_tmp = Silk_SigProc_FIX.SKP_MUL_uint( range_Q16, high_Q16 ); - base_tmp = (range_Q16 * high_Q16) & 0xFFFFFFFFL; - if( base_tmp > base_Q32 ) { - probIx--; - break; - } - /* Test for out of range */ - if( high_Q16 == 0xFFFF ) { - psRC.error = Silk_define.RANGE_CODER_CDF_OUT_OF_RANGE; - /* Set output to zero */ - data[data_offset + 0] = 0; - return; - } - } - } - data[data_offset + 0] = probIx; - -// base_Q32 -= Silk_SigProc_FIX.SKP_MUL_uint( range_Q16, low_Q16 ); - base_Q32 -= (range_Q16 * low_Q16) & 0xFFFFFFFFL; - base_Q32 = base_Q32 & 0xFFFFFFFFL; -// range_Q32 = Silk_SigProc_FIX.SKP_MUL_uint( range_Q16, high_Q16 - low_Q16 ); - range_Q32 = (range_Q16 * (high_Q16 - low_Q16)) & 0xFFFFFFFFL; - range_Q32 = range_Q32 & 0xFFFFFFFFL; - - /* Check normalization */ -//TODO:or if( (range_Q32 & 0xFF000000) != 0 ) { - if( (range_Q32 & 0xFF000000L) != 0 ) { - /* No normalization */ - range_Q16 = range_Q32>>>16; - } else { -//TODO:or if( (range_Q32 & 0xFFFF0000) != 0 ) { - if( (range_Q32 & 0xFFFF0000L) != 0 ) { - /* Normalization of 8 bits shift */ - range_Q16 = ( range_Q32 >>> 8 ); - /* Check for errors */ - if( ( base_Q32 >>> 24 ) != 0) { - psRC.error = Silk_define.RANGE_CODER_NORMALIZATION_FAILED; - /* Set output to zero */ - data[data_offset + 0] = 0; - return; - } - } else { - /* Normalization of 16 bits shift */ - range_Q16 = range_Q32; - /* Check for errors */ -//TODO: if( ( base_Q32 >> 16 ) != 0 ) { - if((base_Q32 >>>16) != 0) { - psRC.error = Silk_define.RANGE_CODER_NORMALIZATION_FAILED; - /* Set output to zero */ - data[data_offset + 0] = 0; - return; - } - /* Update base */ - base_Q32 = ( base_Q32 << 8 ); - base_Q32 = base_Q32 & 0xFFFFFFFFL; - /* Make sure not to read beyond buffer */ - if( bufferIx < psRC.bufferLength ) { - /* Read one byte from buffer */ - base_Q32 |= (buffer[buffer_offset + bufferIx++ ])&0xFF; - } - } - /* Update base */ - base_Q32 = ( base_Q32 << 8 ); - base_Q32 = base_Q32 & 0xFFFFFFFFL; - /* Make sure not to read beyond buffer */ - if( bufferIx < psRC.bufferLength ) { - /* Read one byte from buffer */ - base_Q32 |= (buffer[ buffer_offset + bufferIx++ ])&0xFF; - } - } - - /* Check for zero interval length */ - if( range_Q16 == 0 ) { - psRC.error = Silk_define.RANGE_CODER_ZERO_INTERVAL_WIDTH; - /* Set output to zero */ - data[data_offset + 0] = 0; - return; - } - - /* Copy structure data back */ - psRC.base_Q32 = base_Q32; - psRC.range_Q16 = range_Q16; - psRC.bufferIx = bufferIx; - } - - /** - * Range decoder for multiple symbols. - * @param data uncompressed data [nSymbols]. - * @param psRC compressor data structure. - * @param prob cumulative density functions. - * @param probStartIx initial (middle) entries of cdfs [nSymbols]. - * @param nSymbols number of data symbols. - */ - static void SKP_Silk_range_decoder_multi( - int data[], /* O uncompressed data [nSymbols] */ - SKP_Silk_range_coder_state psRC, /* I/O compressor data structure */ - int[][] prob, /* I cumulative density functions */ - int probStartIx[], /* I initial (middle) entries of cdfs [nSymbols] */ - final int nSymbols /* I number of data symbols */ - ) - { - int k; - for( k = 0; k < nSymbols; k++ ) { - SKP_Silk_range_decoder( data, k, psRC, prob[ k ], 0, probStartIx[ k ] ); - } - } - - /** - * Initialize range encoder. - * @param psRC compressor data structure. - */ - static void SKP_Silk_range_enc_init( - SKP_Silk_range_coder_state psRC /* O compressor data structure */ - ) - { - /* Initialize structure */ - psRC.bufferLength = Silk_define.MAX_ARITHM_BYTES; - psRC.range_Q16 = 0x0000FFFF; - psRC.bufferIx = 0; - psRC.base_Q32 = 0; - psRC.error = 0; - } - - /** - * Initialize range decoder. - * @param psRC compressor data structure. - * @param buffer buffer for compressed data [bufferLength]. - * @param buffer_offset offset of valid data. - * @param bufferLength buffer length (in bytes). - */ - static void SKP_Silk_range_dec_init( - SKP_Silk_range_coder_state psRC, /* O compressor data structure */ - byte buffer[], /* I buffer for compressed data [bufferLength] */ - int buffer_offset, - final int bufferLength /* I buffer length (in bytes) */ - ) - { - /* check input */ - if( bufferLength > Silk_define.MAX_ARITHM_BYTES ) { - psRC.error = Silk_define.RANGE_CODER_DEC_PAYLOAD_TOO_LONG; - return; - } - /* Initialize structure */ - /* Copy to internal buffer */ - System.arraycopy(buffer, buffer_offset, psRC.buffer, 0, bufferLength); - - psRC.bufferLength = bufferLength; - psRC.bufferIx = 0; - psRC.base_Q32 = - ( - ( (buffer[ buffer_offset + 0 ] & 0xFF) << 24 ) | - ( (buffer[ buffer_offset + 1 ] & 0xFF) << 16 ) | - ( (buffer[ buffer_offset + 2 ] & 0xFF) << 8 ) | - (buffer[ buffer_offset + 3 ] & 0xFF) - )&0xFFFFFFFFL; - psRC.range_Q16 = 0x0000FFFF; - psRC.error = 0; - } - - /** - * Determine length of bitstream. - * @param psRC compressed data structure. - * @param nBytes number of BYTES in stream. - * @return returns number of BITS in stream. - */ - static int SKP_Silk_range_coder_get_length( /* O returns number of BITS in stream */ - SKP_Silk_range_coder_state psRC, /* I compressed data structure */ - int[] nBytes /* O number of BYTES in stream */ - ) - { - int nBits; - - /* Number of bits in stream */ - nBits = ( psRC.bufferIx << 3 ) + Silk_macros.SKP_Silk_CLZ32((int) (psRC.range_Q16 - 1) ) - 14; - - nBytes [0] = (( nBits + 7)>> 3 ); - /* Return number of bits in bitstream */ - return nBits; - } - - /** - * Write shortest uniquely decodable stream to buffer, and determine its length. - * @param psRC ompressed data structure. - */ - static void SKP_Silk_range_enc_wrap_up( - SKP_Silk_range_coder_state psRC /* I/O compressed data structure */ - ) - { - int bufferIx_tmp, bits_to_store, bits_in_stream, nBytes, mask; - long base_Q24; - - /* Lower limit of interval, shifted 8 bits to the right */ - base_Q24 = psRC.base_Q32 >>> 8; - - int[] nBytes_ptr = new int[1]; - bits_in_stream = SKP_Silk_range_coder_get_length( psRC, nBytes_ptr ); - nBytes = nBytes_ptr[0]; - - /* Number of additional bits (1..9) required to be stored to stream */ -//TODO: bits_to_store = bits_in_stream - psRC.bufferIx << 3 ; - bits_to_store = bits_in_stream - (psRC.bufferIx << 3) ; - - /* Round up to required resolution */ -//TODO:base_Q24 should be 32-bit long. -// base_Q24 += 0x00800000 >>> ( bits_to_store - 1 ); - base_Q24 += 0x00800000 >>> ( bits_to_store - 1 ); - base_Q24 = base_Q24 & 0xFFFFFFFFL; -// base_Q24 &= 0xFFFFFFFF << ( 24 - bits_to_store ); - base_Q24 &= 0xFFFFFFFF << ( 24 - bits_to_store ); - - - /* Check for carry */ - if( (base_Q24 & 0x01000000) != 0 ) - { - /* Propagate carry in buffer */ - bufferIx_tmp = psRC.bufferIx; - while( ( ++( psRC.buffer[ --bufferIx_tmp ] ) ) == 0 ); - } - - /* Store to stream, making sure not to write beyond buffer */ - if( psRC.bufferIx < psRC.bufferLength ) - { - psRC.buffer[ psRC.bufferIx++ ] = (byte) ( base_Q24>>> 16 ); - if( bits_to_store > 8 ) - { - if( psRC.bufferIx < psRC.bufferLength ) - { - psRC.buffer[ psRC.bufferIx++ ] = (byte) ( base_Q24 >>> 8 ); - } - } - } - - /* Fill up any remaining bits in the last byte with 1s */ - if( (bits_in_stream & 7) != 0 ) - { - mask = 0xFF >> ( bits_in_stream & 7 ); - if( nBytes - 1 < psRC.bufferLength ) - { - psRC.buffer[ nBytes - 1 ] |= mask; - } - } - } - - /** - * Check that any remaining bits in the last byte are set to 1. - * @param psRC compressed data structure. - */ - static void SKP_Silk_range_coder_check_after_decoding( - SKP_Silk_range_coder_state psRC /* I/O compressed data structure */ - ) - { - int bits_in_stream, nBytes, mask; - int nBytes_ptr[] = new int[1]; - - bits_in_stream = SKP_Silk_range_coder_get_length( psRC, nBytes_ptr ); - nBytes = nBytes_ptr[0]; - - /* Make sure not to read beyond buffer */ - if( nBytes - 1 >= psRC.bufferLength ) { - psRC.error = Silk_define.RANGE_CODER_DECODER_CHECK_FAILED; - return; - } - - /* Test any remaining bits in last byte */ - if( (bits_in_stream & 7) != 0 ) { - mask = ( 0xFF >>( bits_in_stream & 7) ); - - if( ( psRC.buffer[ nBytes - 1 ] & mask ) != mask ) { - psRC.error = Silk_define.RANGE_CODER_DECODER_CHECK_FAILED; - return; - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_regularize_correlations_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_regularize_correlations_FLP.java deleted file mode 100644 index 03b9a9c2c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_regularize_correlations_FLP.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Dingxin Xu - */ -public class Silk_regularize_correlations_FLP -{ - /** - * - * @param XX Correlation matrices - * @param xx Correlation values - * @param xx_offset offset of valid data. - * @param noise Noise energy to add - * @param D Dimension of XX - */ - static void SKP_Silk_regularize_correlations_FLP( - float []XX, /* I/O Correlation matrices */ - int XX_offset, - float []xx, /* I/O Correlation values */ - int xx_offset, - float noise, /* I Noise energy to add */ - int D /* I Dimension of XX */ - ) - { - int i; - - for( i = 0; i < D; i++ ) { - XX[XX_offset + i*D+i] += noise; - } - xx[ xx_offset ] += noise; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler.java deleted file mode 100644 index a859c4418..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler.java +++ /dev/null @@ -1,513 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * Interface to collection of resamplers. - * - * @author Jing Dai - * @author Dingxin Xu - */ -/* Matrix of resampling methods used: - * Fs_out (kHz) - * 8 12 16 24 32 44.1 48 - * - * 8 C UF U UF UF UF UF - * 12 AF C UF U UF UF UF - * 16 D AF C UF U UF UF - * Fs_in (kHz) 24 AIF D AF C UF UF U - * 32 UF AF D AF C UF UF - * 44.1 AMI AMI AMI AMI AMI C UF - * 48 DAF DAF AF D AF UF C - * - * default method: UF - * - * C -> Copy (no resampling) - * D -> Allpass-based 2x downsampling - * U -> Allpass-based 2x upsampling - * DAF -> Allpass-based 2x downsampling followed by AR2 filter followed by FIR interpolation - * UF -> Allpass-based 2x upsampling followed by FIR interpolation - * AMI -> ARMA4 filter followed by FIR interpolation - * AF -> AR2 filter followed by FIR interpolation - * - * Input signals sampled above 48 kHz are first downsampled to at most 48 kHz. - * Output signals sampled above 48 kHz are upsampled from at most 48 kHz. - */ -public class Silk_resampler -{ - /** - * Greatest common divisor. - * @param a - * @param b - */ - static int gcd(int a, int b) - { - int tmp; - while( b > 0 ) - { - tmp = a - b * (a/b); - a = b; - b = tmp; - } - return a; - } - - /** - * Initialize/reset the resampler state for a given pair of input/output sampling rates. - * @param S resampler state. - * @param Fs_Hz_in Input sampling rate (Hz). - * @param Fs_Hz_out Output sampling rate (Hz). - * @return - */ - static int SKP_Silk_resampler_init( - SKP_Silk_resampler_state_struct S, /* I/O: Resampler state */ - int Fs_Hz_in, /* I: Input sampling rate (Hz) */ - int Fs_Hz_out /* I: Output sampling rate (Hz) */ - ) - { - int cycleLen, cyclesPerBatch, up2 = 0, down2 = 0; - - /* Clear state */ -//TODO:how to set all fields of S to 0? - //S = new SKP_Silk_resampler_state_struct(); - S.memZero(); - - /* Input checking */ - if(Silk_resampler_structs.RESAMPLER_SUPPORT_ABOVE_48KHZ != 0) - { - if( Fs_Hz_in < 8000 || Fs_Hz_in > 192000 || Fs_Hz_out < 8000 || Fs_Hz_out > 192000 ) - { - assert( false ); - return -1; - } - } - else - { - if( Fs_Hz_in < 8000 || Fs_Hz_in > 48000 || Fs_Hz_out < 8000 || Fs_Hz_out > 48000 ) - { - assert( false ); - return -1; - } - } - - if(Silk_resampler_structs.RESAMPLER_SUPPORT_ABOVE_48KHZ != 0) - { - /* Determine pre downsampling and post upsampling */ - if( Fs_Hz_in > 96000 ) - { - S.nPreDownsamplers = 2; - S.down_pre_function = "SKP_Silk_resampler_private_down4"; - S.downPreCB = new DownPreImplDown4(); - } - else if( Fs_Hz_in > 48000 ) - { - S.nPreDownsamplers = 1; - S.down_pre_function = "SKP_Silk_resampler_down2"; - S.downPreCB = new DownPreImplDown2(); - } - else - { - S.nPreDownsamplers = 0; - S.down_pre_function = null; - S.downPreCB = null; - } - - if( Fs_Hz_out > 96000 ) - { - S.nPostUpsamplers = 2; - S.up_post_function = "SKP_Silk_resampler_private_up4"; - S.upPostCB = new UpPostImplUp4(); - } - else if( Fs_Hz_out > 48000 ) - { - S.nPostUpsamplers = 1; - S.up_post_function = "SKP_Silk_resampler_up2"; - S.upPostCB = new UpPostImplUp2(); - } - else - { - S.nPostUpsamplers = 0; - S.up_post_function = null; - S.upPostCB = null; - } - - if( S.nPreDownsamplers + S.nPostUpsamplers > 0 ) - { - /* Ratio of output/input samples */ - S.ratio_Q16 = ( ( Fs_Hz_out<<13 ) / Fs_Hz_in )<<3; - /* Make sure the ratio is rounded up */ - while( Silk_macros.SKP_SMULWW( S.ratio_Q16, Fs_Hz_in ) < Fs_Hz_out ) - S.ratio_Q16++; - - /* Batch size is 10 ms */ - S.batchSizePrePost = Fs_Hz_in/100 ; - - /* Convert sampling rate to those after pre-downsampling and before post-upsampling */ - Fs_Hz_in = Fs_Hz_in >> S.nPreDownsamplers ; - Fs_Hz_out = Fs_Hz_out >> S.nPostUpsamplers ; - } - } - - /* Number of samples processed per batch */ - /* First, try 10 ms frames */ - S.batchSize = Fs_Hz_in/100; - if( ( S.batchSize*100 != Fs_Hz_in ) || ( Fs_Hz_in % 100 != 0 ) ) - { - /* No integer number of input or output samples with 10 ms frames, use greatest common divisor */ - cycleLen = Fs_Hz_in / gcd( Fs_Hz_in, Fs_Hz_out ); - cyclesPerBatch = Silk_resampler_private.RESAMPLER_MAX_BATCH_SIZE_IN / cycleLen; - if( cyclesPerBatch == 0 ) - { - /* cycleLen too big, let's just use the maximum batch size. Some distortion will result. */ - S.batchSize = Silk_resampler_private.RESAMPLER_MAX_BATCH_SIZE_IN; - assert( false ); - } - else - { - S.batchSize = cyclesPerBatch * cycleLen; - } - } - - /* Find resampler with the right sampling ratio */ - if( Fs_Hz_out > Fs_Hz_in ) - { - /* Upsample */ - if( Fs_Hz_out == Fs_Hz_in * 2 ) - { /* Fs_out : Fs_in = 2 : 1 */ - /* Special case: directly use 2x upsampler */ - S.resampler_function = "SKP_Silk_resampler_private_up2_HQ_wrapper"; - S.resamplerCB = new ResamplerImplWrapper(); - } - else - { - /* Default resampler */ - S.resampler_function = "SKP_Silk_resampler_private_IIR_FIR"; - S.resamplerCB = new ResamplerImplIIRFIR(); - up2 = 1; - if( Fs_Hz_in > 24000 ) - { - /* Low-quality all-pass upsampler */ - S.up2_function = "SKP_Silk_resampler_up2"; - S.up2CB = new Up2ImplUp2(); - - } - else - { - /* High-quality all-pass upsampler */ - S.up2_function = "SKP_Silk_resampler_private_up2_HQ"; - S.up2CB = new Up2ImplHQ(); - - } - } - } - else if ( Fs_Hz_out < Fs_Hz_in ) - { - /* Downsample */ - if( Fs_Hz_out * 4 == Fs_Hz_in * 3 ) - { /* Fs_out : Fs_in = 3 : 4 */ - S.FIR_Fracs = 3; - S.Coefs = Silk_resampler_rom.SKP_Silk_Resampler_3_4_COEFS; - S.resampler_function = "SKP_Silk_resampler_private_down_FIR"; - S.resamplerCB = new ResamplerImplDownFIR(); - } - else if( Fs_Hz_out * 3 == Fs_Hz_in * 2 ) - { /* Fs_out : Fs_in = 2 : 3 */ - S.FIR_Fracs = 2; - S.Coefs = Silk_resampler_rom.SKP_Silk_Resampler_2_3_COEFS; - S.resampler_function = "SKP_Silk_resampler_private_down_FIR"; - S.resamplerCB = new ResamplerImplDownFIR(); - } - else if( Fs_Hz_out * 2 == Fs_Hz_in ) - { /* Fs_out : Fs_in = 1 : 2 */ - S.FIR_Fracs = 1; - S.Coefs = Silk_resampler_rom.SKP_Silk_Resampler_1_2_COEFS; - S.resampler_function = "SKP_Silk_resampler_private_down_FIR"; - S.resamplerCB = new ResamplerImplDownFIR(); - } - else if( Fs_Hz_out * 8 == Fs_Hz_in * 3 ) - { /* Fs_out : Fs_in = 3 : 8 */ - S.FIR_Fracs = 3; - S.Coefs = Silk_resampler_rom.SKP_Silk_Resampler_3_8_COEFS; - S.resampler_function = "SKP_Silk_resampler_private_down_FIR"; - S.resamplerCB = new ResamplerImplDownFIR(); - } - else if( Fs_Hz_out * 3 == Fs_Hz_in ) - { /* Fs_out : Fs_in = 1 : 3 */ - S.FIR_Fracs = 1; - S.Coefs = Silk_resampler_rom.SKP_Silk_Resampler_1_3_COEFS; - S.resampler_function = "SKP_Silk_resampler_private_down_FIR"; - S.resamplerCB = new ResamplerImplDownFIR(); - } - else if( Fs_Hz_out * 4 == Fs_Hz_in ) - { /* Fs_out : Fs_in = 1 : 4 */ - S.FIR_Fracs = 1; - down2 = 1; - S.Coefs = Silk_resampler_rom.SKP_Silk_Resampler_1_2_COEFS; - S.resampler_function = "SKP_Silk_resampler_private_down_FIR"; - S.resamplerCB = new ResamplerImplDownFIR(); - } - else if( Fs_Hz_out * 6 == Fs_Hz_in ) - { /* Fs_out : Fs_in = 1 : 6 */ - S.FIR_Fracs = 1; - down2 = 1; - S.Coefs = Silk_resampler_rom.SKP_Silk_Resampler_1_3_COEFS; - S.resampler_function = "SKP_Silk_resampler_private_down_FIR"; - S.resamplerCB = new ResamplerImplDownFIR(); - } - else if( Fs_Hz_out * 441 == Fs_Hz_in * 80 ) - { /* Fs_out : Fs_in = 80 : 441 */ - S.Coefs = Silk_resampler_rom.SKP_Silk_Resampler_80_441_ARMA4_COEFS; - S.resampler_function = "SKP_Silk_resampler_private_IIR_FIR"; - S.resamplerCB = new ResamplerImplIIRFIR(); - } - else if( Fs_Hz_out * 441 == Fs_Hz_in * 120 ) - { /* Fs_out : Fs_in = 120 : 441 */ - S.Coefs = Silk_resampler_rom.SKP_Silk_Resampler_120_441_ARMA4_COEFS; - S.resampler_function = "SKP_Silk_resampler_private_IIR_FIR"; - S.resamplerCB = new ResamplerImplIIRFIR(); - } - else if( Fs_Hz_out * 441 == Fs_Hz_in * 160 ) - { /* Fs_out : Fs_in = 160 : 441 */ - S.Coefs = Silk_resampler_rom.SKP_Silk_Resampler_160_441_ARMA4_COEFS; - S.resampler_function = "SKP_Silk_resampler_private_IIR_FIR"; - S.resamplerCB = new ResamplerImplIIRFIR(); - } - else if( Fs_Hz_out * 441 == Fs_Hz_in * 240 ) - { /* Fs_out : Fs_in = 240 : 441 */ - S.Coefs = Silk_resampler_rom.SKP_Silk_Resampler_240_441_ARMA4_COEFS; - S.resampler_function = "SKP_Silk_resampler_private_IIR_FIR"; - S.resamplerCB = new ResamplerImplIIRFIR(); - } - else if( Fs_Hz_out * 441 == Fs_Hz_in * 320 ) - { /* Fs_out : Fs_in = 320 : 441 */ - S.Coefs = Silk_resampler_rom.SKP_Silk_Resampler_320_441_ARMA4_COEFS; - S.resampler_function = "SKP_Silk_resampler_private_IIR_FIR"; - S.resamplerCB = new ResamplerImplIIRFIR(); - } - else - { - /* Default resampler */ - S.resampler_function = "SKP_Silk_resampler_private_IIR_FIR"; - S.resamplerCB = new ResamplerImplIIRFIR(); - up2 = 1; - if( Fs_Hz_in > 24000 ) - { - /* Low-quality all-pass upsampler */ - S.up2_function = "SKP_Silk_resampler_up2"; - S.up2CB = new Up2ImplUp2(); - } - else - { - /* High-quality all-pass upsampler */ - S.up2_function = "SKP_Silk_resampler_private_up2_HQ"; - S.up2CB = new Up2ImplHQ(); - } - } - } - else - { - /* Input and output sampling rates are equal: copy */ - S.resampler_function = "SKP_Silk_resampler_private_copy"; - S.resamplerCB = new ResamplerImplCopy(); - } - - S.input2x = up2 | down2; - - /* Ratio of input/output samples */ - S.invRatio_Q16 = ( ( Fs_Hz_in << 14 + up2 - down2 ) / Fs_Hz_out ) << 2 ; - /* Make sure the ratio is rounded up */ - while( Silk_macros.SKP_SMULWW( S.invRatio_Q16, Fs_Hz_out << down2 ) < ( Fs_Hz_in << up2 ) ) - { - S.invRatio_Q16++; - } - - S.magic_number = 123456789; - - return 0; - } - - /** - * Clear the states of all resampling filters, without resetting sampling rate ratio. - * @param S Resampler state. - * @return - */ - static int SKP_Silk_resampler_clear( - SKP_Silk_resampler_state_struct S /* I/O: Resampler state */ - ) - { - Arrays.fill(S.sDown2, 0); - Arrays.fill(S.sIIR, 0); - Arrays.fill(S.sFIR, 0); - if (Silk_resampler_structs.RESAMPLER_SUPPORT_ABOVE_48KHZ != 0) - { - Arrays.fill(S.sDownPre, 0); - Arrays.fill(S.sUpPost, 0); - } - return 0; - } - - /** - * Resampler: convert from one sampling rate to another. - * @param S Resampler state. - * @param out Output signal. - * @param out_offset offset of vaild data. - * @param in Input signal. - * @param in_offset offset of valid data. - * @param inLen Number of input samples - * @return - */ - static int SKP_Silk_resampler( - SKP_Silk_resampler_state_struct S, /* I/O: Resampler state */ - short[] out, /* O: Output signal */ - int out_offset, - short[] in, /* I: Input signal */ - int in_offset, - int inLen /* I: Number of input samples */ - ) - { - /* Verify that state was initialized and has not been corrupted */ - if( S.magic_number != 123456789 ) - { - assert( false ); - return -1; - } - - if (Silk_resampler_structs.RESAMPLER_SUPPORT_ABOVE_48KHZ != 0) - { - if( S.nPreDownsamplers + S.nPostUpsamplers > 0 ) { - /* The input and/or output sampling rate is above 48000 Hz */ - int nSamplesIn, nSamplesOut; - short[] in_buf = new short[ 480 ]; - short[] out_buf = new short[ 480 ]; - - while( inLen > 0 ) { - /* Number of input and output samples to process */ - nSamplesIn = Silk_SigProc_FIX.SKP_min( inLen, S.batchSizePrePost ); - nSamplesOut = Silk_macros.SKP_SMULWB( S.ratio_Q16, nSamplesIn ); - - Silk_typedef.SKP_assert( ( nSamplesIn >> S.nPreDownsamplers ) <= 480 ); - Silk_typedef.SKP_assert( ( nSamplesOut >> S.nPostUpsamplers ) <= 480 ); - - if( S.nPreDownsamplers > 0 ) { - S.down_pre_function(S.sDownPre, in_buf, 0, in, in_offset, nSamplesIn); - - if( S.nPostUpsamplers > 0 ) { - S.resampler_function(S, out_buf, 0, in_buf, 0, ( nSamplesIn >> S.nPreDownsamplers )); - S.up_post_function(S.sUpPost, out, out_offset, out_buf, 0, ( nSamplesOut >> S.nPostUpsamplers )); - } else { - S.resampler_function( S, out, out_offset, in_buf, 0, ( nSamplesIn >> S.nPreDownsamplers )); - } - } else { - S.resampler_function( S, out_buf, 0, in, in_offset, ( nSamplesIn >> S.nPreDownsamplers )); - S.up_post_function( S.sUpPost, out, out_offset, out_buf, 0, ( nSamplesOut >> S.nPostUpsamplers )); - } - - in_offset += nSamplesIn; - out_offset += nSamplesOut; - inLen -= nSamplesIn; - } - } else { - /* Input and output sampling rate are at most 48000 Hz */ - S.resampler_function( S, out, out_offset, in, in_offset, inLen); - } - } - else{ - /* Input and output sampling rate are at most 48000 Hz */ - S.resampler_function( S, out, out_offset, in, in_offset, inLen); - } - return 0; - } -} -/*************************************************************************************/ -class DownPreImplDown4 implements DownPreFP -{ - public void down_pre_function(int[] state, short[] out, int outOffset, - short[] in, int inOffset, int len) { - Silk_resampler_private_down4.SKP_Silk_resampler_private_down4(state, 0, - out, outOffset, in, inOffset, len); - } -} -class DownPreImplDown2 implements DownPreFP -{ - public void down_pre_function(int[] state, short[] out, int outOffset, - short[] in, int inOffset, int len) { - Silk_resampler_down2.SKP_Silk_resampler_down2(state, 0, - out, outOffset, in, inOffset, len); - } -} -/*----------------------------------------------------------------*/ -class UpPostImplUp4 implements UpPostFP -{ - public void up_post_function(int[] state, short[] out, int outOffset, - short[] in, int inOffset, int len) { - Silk_resampler_private_up4.SKP_Silk_resampler_private_up4(state, 0, - out, outOffset, in, inOffset, len); - } - -} -class UpPostImplUp2 implements UpPostFP -{ - public void up_post_function(int[] state, short[] out, int outOffset, - short[] in, int inOffset, int len) { - Silk_resampler_up2.SKP_Silk_resampler_up2(state, 0, - out, outOffset, in, inOffset, len); - } -} -/*----------------------------------------------------------------*/ -class ResamplerImplWrapper implements ResamplerFP -{ - public void resampler_function(Object state, short[] out, int outOffset, - short[] in, int inOffset, int len) { - Silk_resampler_private_up2_HQ.SKP_Silk_resampler_private_up2_HQ_wrapper(state, - out, outOffset, in, inOffset, len); - } -} -class ResamplerImplIIRFIR implements ResamplerFP -{ - public void resampler_function(Object state, short[] out, int outOffset, - short[] in, int inOffset, int len) { - Silk_resampler_private_IIR_FIR.SKP_Silk_resampler_private_IIR_FIR(state, - out, outOffset, in, inOffset, len); - } -} -class ResamplerImplDownFIR implements ResamplerFP -{ - public void resampler_function(Object state, short[] out, int outOffset, - short[] in, int inOffset, int len) { - Silk_resampler_private_down_FIR.SKP_Silk_resampler_private_down_FIR(state, - out, outOffset, in, inOffset, len); - } -} -class ResamplerImplCopy implements ResamplerFP -{ - public void resampler_function(Object state, short[] out, int outOffset, - short[] in, int inOffset, int len) { - Silk_resampler_private_copy.SKP_Silk_resampler_private_copy(state, out, outOffset, in, inOffset, len); - } - -} -/*----------------------------------------------------------------*/ -class Up2ImplUp2 implements Up2FP -{ - public void up2_function(int[] state, short[] out, int outOffset, - short[] in, int inOffset, int len) { - Silk_resampler_up2.SKP_Silk_resampler_up2(state, 0, - out, outOffset, in, inOffset, len); - } -} -class Up2ImplHQ implements Up2FP -{ - public void up2_function(int[] state, short[] out, int outOffset, - short[] in, int inOffset, int len) { - Silk_resampler_private_up2_HQ.SKP_Silk_resampler_private_up2_HQ(state, 0, - out, outOffset, in, inOffset, len); - } - -} -/*************************************************************************************/ diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_down2.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_down2.java deleted file mode 100644 index 05b33f535..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_down2.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Downsample by a factor 2, mediocre quality. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_resampler_down2 -{ - /** - * Downsample by a factor 2, mediocre quality. - * @param S State vector [ 2 ]. - * @param S_offset offset of valid data. - * @param out Output signal [ len ]. - * @param out_offset offset of valid data. - * @param in Input signal [ floor(len/2) ]. - * @param in_offset offset of valid data. - * @param inLen Number of input samples. - */ - static void SKP_Silk_resampler_down2( - int[] S, /* I/O: State vector [ 2 ] */ - int S_offset, - short[] out, /* O: Output signal [ len ] */ - int out_offset, - short[] in, /* I: Input signal [ floor(len/2) ] */ - int in_offset, - int inLen /* I: Number of input samples */ - ) - { - int k, len2 = inLen>>1; - int in32, out32, Y, X; - - assert( Silk_resampler_rom.SKP_Silk_resampler_down2_0 > 0 ); - assert( Silk_resampler_rom.SKP_Silk_resampler_down2_1 < 0 ); - - /* Internal variables and state are in Q10 format */ - for( k = 0; k < len2; k++ ) { - /* Convert to Q10 */ - in32 = in[ in_offset + 2 * k ] << 10; - - /* All-pass section for even input sample */ - Y = in32 - S[ S_offset ]; - X = Silk_macros.SKP_SMLAWB( Y, Y, Silk_resampler_rom.SKP_Silk_resampler_down2_1 ); - out32 = S[ S_offset ] + X; - S[ S_offset ] = in32 + X; - - /* Convert to Q10 */ - in32 = in[ in_offset + 2 * k + 1 ] << 10; - - /* All-pass section for odd input sample, and add to output of previous section */ - Y = in32 - S[ S_offset+1 ]; - X = Silk_macros.SKP_SMULWB( Y, Silk_resampler_rom.SKP_Silk_resampler_down2_0 ); - out32 = out32 + S[ S_offset+1 ]; - out32 = out32 + X; - S[ S_offset+1 ] = in32 + X; - - /* Add, convert back to int16 and store to output */ - out[ out_offset + k ] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32, 11 ) ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_down2_3.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_down2_3.java deleted file mode 100644 index 5caeaa464..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_down2_3.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Downsample by a factor 2/3, low quality. - * - * @author Jing Dai. - * @author Dingxin Xu - */ -public class Silk_resampler_down2_3 -{ - static final int ORDER_FIR = 4; - - /** - * Downsample by a factor 2/3, low quality. - * @param S State vector [ 6 ] - * @param S_offset offset of valid data. - * @param out Output signal [ floor(2*inLen/3) ] - * @param out_offset offset of valid data. - * @param in Input signal [ inLen ] - * @param in_offset offset of valid data. - * @param inLen Number of input samples - */ - static void SKP_Silk_resampler_down2_3( - int[] S, /* I/O: State vector [ 6 ] */ - int S_offset, - short[] out, /* O: Output signal [ floor(2*inLen/3) ] */ - int out_offset, - short[] in, /* I: Input signal [ inLen ] */ - int in_offset, - int inLen /* I: Number of input samples */ - ) - { - int nSamplesIn, counter, res_Q6; - int[] buf = new int[ Silk_resampler_private.RESAMPLER_MAX_BATCH_SIZE_IN + ORDER_FIR ]; - int buf_ptr; - - /* Copy buffered samples to start of buffer */ - for(int i_djinn=0; i_djinn 2 ) - { - /* Inner product */ - res_Q6 = Silk_macros.SKP_SMULWB( buf[ buf_ptr ], Silk_resampler_rom.SKP_Silk_Resampler_2_3_COEFS_LQ[ 2 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf[ buf_ptr+1 ], Silk_resampler_rom.SKP_Silk_Resampler_2_3_COEFS_LQ[ 3 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf[ buf_ptr+2 ], Silk_resampler_rom.SKP_Silk_Resampler_2_3_COEFS_LQ[ 5 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf[ buf_ptr+3 ], Silk_resampler_rom.SKP_Silk_Resampler_2_3_COEFS_LQ[ 4 ] ); - - /* Scale down, saturate and store in output array */ - out[out_offset++] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( res_Q6, 6 ) ); - - res_Q6 = Silk_macros.SKP_SMULWB( buf[ buf_ptr+1 ], Silk_resampler_rom.SKP_Silk_Resampler_2_3_COEFS_LQ[ 4 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf[ buf_ptr+2 ], Silk_resampler_rom.SKP_Silk_Resampler_2_3_COEFS_LQ[ 5 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf[ buf_ptr+3 ], Silk_resampler_rom.SKP_Silk_Resampler_2_3_COEFS_LQ[ 3 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf[ buf_ptr+4 ], Silk_resampler_rom.SKP_Silk_Resampler_2_3_COEFS_LQ[ 2 ] ); - - /* Scale down, saturate and store in output array */ - out[out_offset++] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( res_Q6, 6 ) ); - - buf_ptr += 3; - counter -= 3; - } - - in_offset += nSamplesIn; - inLen -= nSamplesIn; - - if( inLen > 0 ) - { - /* More iterations to do; copy last part of filtered signal to beginning of buffer */ - for(int i_djinn=0; i_djinn 2 ) - { - /* Inner product */ - res_Q6 = Silk_macros.SKP_SMULWB( buf[ buf_ptr ] + buf[ buf_ptr+5 ], Silk_resampler_rom.SKP_Silk_Resampler_1_3_COEFS_LQ[ 2 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf[ buf_ptr+1 ] + buf[ buf_ptr+4 ], Silk_resampler_rom.SKP_Silk_Resampler_1_3_COEFS_LQ[ 3 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf[ buf_ptr+2 ] + buf[ buf_ptr+3 ], Silk_resampler_rom.SKP_Silk_Resampler_1_3_COEFS_LQ[ 4 ] ); - - /* Scale down, saturate and store in output array */ - out[out_offset++] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( res_Q6, 6 ) ); - - buf_ptr += 3; - counter -= 3; - } - - in_offset += nSamplesIn; - inLen -= nSamplesIn; - - if( inLen > 0 ) - { - /* More iterations to do; copy last part of filtered signal to beginning of buffer */ - for(int i_djinn=0; i_djinn> 2, out1_Q8, Coef[ Coef_offset+3 ] ); - S[ S_offset+3 ] = Silk_macros.SKP_SMLAWB( out1_Q8 >> 2 , out2_Q8, Coef[ Coef_offset+5 ] ); - - /* Apply gain and store to output. The coefficient is in Q16 */ - out[ out_offset+k ] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_macros.SKP_SMLAWB( 128, out2_Q8, Coef[ Coef_offset+6 ] ) >> 8 ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_private_IIR_FIR.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_private_IIR_FIR.java deleted file mode 100644 index 03ee46d73..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_private_IIR_FIR.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Upsample using a combination of allpass-based 2x upsampling and FIR interpolation. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_resampler_private_IIR_FIR -{ - /** - * Upsample using a combination of allpass-based 2x upsampling and FIR interpolation. - * @param SS Resampler state. - * @param out Output signal. - * @param out_offset offset of valid data. - * @param in Input signal. - * @param in_offset offset of valid data. - * @param inLen Number of input samples. - */ - static void SKP_Silk_resampler_private_IIR_FIR( - Object SS, /* I/O: Resampler state */ - short[] out, /* O: Output signal */ - int out_offset, - short[] in, /* I: Input signal */ - int in_offset, - int inLen /* I: Number of input samples */ - ) - { - SKP_Silk_resampler_state_struct S = (SKP_Silk_resampler_state_struct )SS; - - int nSamplesIn, table_index; - int max_index_Q16, index_Q16, index_increment_Q16, res_Q15; - short[] buf = new short[ 2 * Silk_resampler_private.RESAMPLER_MAX_BATCH_SIZE_IN + Silk_resampler_rom.RESAMPLER_ORDER_FIR_144 ]; - int buf_ptr; - - /* Copy buffered samples to start of buffer */ -//TODO:litter-endian or big-endian??? -// SKP_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_144 * sizeof( SKP_int32 ) ); - for(int i_djinn=0; i_djinn>>16); -// buf[2*i_djinn+1] = (short)(S.sFIR[i_djinn]&0x0000FFFF); -//littel-endian - buf[2*i_djinn] = (short)(S.sFIR[i_djinn]&0x0000FFFF); - buf[2*i_djinn+1] = (short)(S.sFIR[i_djinn]>>>16); - } - - /* Iterate over blocks of frameSizeIn input samples */ - index_increment_Q16 = S.invRatio_Q16; - while( true ) - { - nSamplesIn = Math.min( inLen, S.batchSize ); - - if( S.input2x == 1 ) - { - /* Upsample 2x */ - S.up2_function(S.sIIR, buf, Silk_resampler_rom.RESAMPLER_ORDER_FIR_144, in, in_offset, nSamplesIn); - } - else - { - /* Fourth-order ARMA filter */ - Silk_resampler_private_ARMA4.SKP_Silk_resampler_private_ARMA4( S.sIIR,0, buf,Silk_resampler_rom.RESAMPLER_ORDER_FIR_144, in,in_offset, S.Coefs,0, nSamplesIn ); - } - - max_index_Q16 = nSamplesIn << ( 16 + S.input2x ); /* +1 if 2x upsampling */ - - /* Interpolate upsampled signal and store in output array */ - for( index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16 ) - { - table_index = Silk_macros.SKP_SMULWB( index_Q16 & 0xFFFF, 144 ); - buf_ptr = index_Q16 >> 16; - res_Q15 = Silk_macros.SKP_SMULBB( buf[ buf_ptr ], Silk_resampler_rom.SKP_Silk_resampler_frac_FIR_144[ table_index ][ 0 ] ); - res_Q15 = Silk_macros.SKP_SMLABB( res_Q15, buf[ buf_ptr+1 ], Silk_resampler_rom.SKP_Silk_resampler_frac_FIR_144[ table_index ][ 1 ] ); - res_Q15 = Silk_macros.SKP_SMLABB( res_Q15, buf[ buf_ptr+2 ], Silk_resampler_rom.SKP_Silk_resampler_frac_FIR_144[ table_index ][ 2 ] ); - res_Q15 = Silk_macros.SKP_SMLABB( res_Q15, buf[ buf_ptr+3 ], Silk_resampler_rom.SKP_Silk_resampler_frac_FIR_144[ 143 - table_index ][ 2 ] ); - res_Q15 = Silk_macros.SKP_SMLABB( res_Q15, buf[ buf_ptr+4 ], Silk_resampler_rom.SKP_Silk_resampler_frac_FIR_144[ 143 - table_index ][ 1 ] ); - res_Q15 = Silk_macros.SKP_SMLABB( res_Q15, buf[ buf_ptr+5 ], Silk_resampler_rom.SKP_Silk_resampler_frac_FIR_144[ 143 - table_index ][ 0 ] ); - out[out_offset++] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( res_Q15, 15 ) ); - } - in_offset += nSamplesIn; - inLen -= nSamplesIn; - - if( inLen > 0 ) - { - /* More iterations to do; copy last part of filtered signal to beginning of buffer */ -//TODO:litter-endian or big-endian??? -// SKP_memcpy( buf, &buf[ nSamplesIn << S->input2x ], RESAMPLER_ORDER_FIR_144 * sizeof( SKP_int32 ) ); - for(int i_djinn=0; i_djinnsFIR, &buf[nSamplesIn << S->input2x ], RESAMPLER_ORDER_FIR_144 * sizeof( SKP_int32 ) ); - for(int i_djinn=0; i_djinn>8)&0xFF)<<8)&0x0000FF00; - S.sFIR[i_djinn] |= (((buf[(nSamplesIn << S.input2x) + 2*i_djinn + 1]>>0)&0xFF)<<16)&0x00FF0000; - S.sFIR[i_djinn] |= (((buf[(nSamplesIn << S.input2x) + 2*i_djinn + 1 ]>>8)&0xFF)<<24)&0xFF000000; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_private_copy.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_private_copy.java deleted file mode 100644 index ee723e3ce..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_private_copy.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Simple opy. - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_resampler_private_copy -{ - /** - * Simple copy. - * @param SS Resampler state (unused). - * @param out Output signal - * @param out_offset offset of valid data. - * @param in Input signal - * @param in_offset offset of valid data. - * @param inLen Number of input samples - */ - static void SKP_Silk_resampler_private_copy( - Object SS, /* I/O: Resampler state (unused) */ - short[] out, /* O: Output signal */ - int out_offset, - short[] in, /* I: Input signal */ - int in_offset, - int inLen /* I: Number of input samples */ - ) - { - for(int k=0; k> 2; - int in32, out32, Y, X; - - assert( Silk_resampler_rom.SKP_Silk_resampler_down2_0 > 0 ); - assert( Silk_resampler_rom.SKP_Silk_resampler_down2_1 < 0 ); - - /* Internal variables and state are in Q10 format */ - for( k = 0; k < len4; k++ ) - { - /* Add two input samples and convert to Q10 */ - in32 = ( in[ in_offset + 4 * k ] + in[ in_offset + 4 * k + 1 ] ) << 9 ; - - /* All-pass section for even input sample */ - Y = in32 - S[ S_offset ]; - X = Silk_macros.SKP_SMLAWB( Y, Y, Silk_resampler_rom.SKP_Silk_resampler_down2_1 ); - out32 = S[ S_offset ] + X; - S[ S_offset ] = in32 + X; - - /* Add two input samples and convert to Q10 */ - in32 = ( in[ in_offset + 4 * k + 2 ] + in[ in_offset + 4 * k + 3 ] ) << 9; - - /* All-pass section for odd input sample */ - Y = in32 - S[ S_offset+1 ]; - X = Silk_macros.SKP_SMULWB( Y, Silk_resampler_rom.SKP_Silk_resampler_down2_0 ); - out32 = out32 + S[ S_offset+1 ]; - out32 = out32 + X; - S[ S_offset+1 ] = in32 + X; - - /* Add, convert back to int16 and store to output */ - out[ out_offset+k ] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32, 11 ) ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_private_down_FIR.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_private_down_FIR.java deleted file mode 100644 index 50b7713ea..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_private_down_FIR.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Resample with a 2x downsampler (optional), a 2nd order AR filter followed by FIR interpolation. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_resampler_private_down_FIR -{ - /** - * Resample with a 2x downsampler (optional), - * a 2nd order AR filter followed by FIR interpolation. - * @param SS Resampler state. - * @param out Output signal. - * @param out_offset offset of valid data. - * @param in Input signal. - * @param in_offset offset of valid data. - * @param inLen Number of input samples. - */ - static void SKP_Silk_resampler_private_down_FIR( - Object SS, /* I/O: Resampler state */ - short[] out, /* O: Output signal */ - int out_offset, - short[] in, /* I: Input signal */ - int in_offset, - int inLen /* I: Number of input samples */ - ) - { - SKP_Silk_resampler_state_struct S = (SKP_Silk_resampler_state_struct)SS; - int nSamplesIn, interpol_ind; - int max_index_Q16, index_Q16, index_increment_Q16, res_Q6; - short[] buf1 = new short[ Silk_resampler_private.RESAMPLER_MAX_BATCH_SIZE_IN / 2 ]; - int[] buf2 = new int[ Silk_resampler_private.RESAMPLER_MAX_BATCH_SIZE_IN + Silk_resampler_rom.RESAMPLER_DOWN_ORDER_FIR ]; - int[] buf_ptr; - int buf_ptr_offset; - short[] interpol_ptr, FIR_Coefs; - int interpol_ptr_offset, FIR_Coefs_offset; - - /* Copy buffered samples to start of buffer */ -//TODO: arrayCopy(); -// SKP_memcpy( buf2, S->sFIR, RESAMPLER_DOWN_ORDER_FIR * sizeof( SKP_int32 ) ); - for(int i_djinn=0; i_djinn> 1; - - /* Second-order AR filter (output in Q8) */ - Silk_resampler_private_AR2.SKP_Silk_resampler_private_AR2( S.sIIR,0, buf2,Silk_resampler_rom.RESAMPLER_DOWN_ORDER_FIR, buf1,0, S.Coefs,0, nSamplesIn ); - } - else - { - /* Second-order AR filter (output in Q8) */ - Silk_resampler_private_AR2.SKP_Silk_resampler_private_AR2( S.sIIR,0, buf2,Silk_resampler_rom.RESAMPLER_DOWN_ORDER_FIR, in,in_offset, S.Coefs,0, nSamplesIn ); - } - - max_index_Q16 = nSamplesIn << 16; - - /* Interpolate filtered signal */ - if( S.FIR_Fracs == 1 ) - { - for( index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16 ) - { - /* Integer part gives pointer to buffered input */ - buf_ptr = buf2; - buf_ptr_offset = index_Q16 >> 16; - - /* Inner product */ - res_Q6 = Silk_macros.SKP_SMULWB( buf_ptr[ buf_ptr_offset ]+buf_ptr[ buf_ptr_offset+11 ], FIR_Coefs[ FIR_Coefs_offset ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+1 ]+buf_ptr[ buf_ptr_offset+10 ], FIR_Coefs[ FIR_Coefs_offset+1 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+2 ]+buf_ptr[ buf_ptr_offset+9 ], FIR_Coefs[ FIR_Coefs_offset+2 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+3 ]+buf_ptr[ buf_ptr_offset+8 ], FIR_Coefs[ FIR_Coefs_offset+3 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+4 ]+buf_ptr[ buf_ptr_offset+7 ], FIR_Coefs[ FIR_Coefs_offset+4 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+5 ]+buf_ptr[ buf_ptr_offset+6 ], FIR_Coefs[ FIR_Coefs_offset+5 ] ); - - /* Scale down, saturate and store in output array */ - out[out_offset++] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( res_Q6, 6 ) ); - } - } - else - { - for( index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16 ) - { - /* Integer part gives pointer to buffered input */ - buf_ptr = buf2; - buf_ptr_offset = index_Q16 >> 16; - - /* Fractional part gives interpolation coefficients */ - interpol_ind = Silk_macros.SKP_SMULWB( index_Q16 & 0xFFFF, S.FIR_Fracs ); - - /* Inner product */ - interpol_ptr = FIR_Coefs; -//BugFix interpol_ptr_offset = Silk_resampler_rom.RESAMPLER_DOWN_ORDER_FIR / 2 * interpol_ind; - interpol_ptr_offset = FIR_Coefs_offset + Silk_resampler_rom.RESAMPLER_DOWN_ORDER_FIR / 2 * interpol_ind; - res_Q6 = Silk_macros.SKP_SMULWB( buf_ptr[ buf_ptr_offset ], interpol_ptr[ interpol_ptr_offset ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+1 ], interpol_ptr[ interpol_ptr_offset+1 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+2 ], interpol_ptr[ interpol_ptr_offset+2 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+3 ], interpol_ptr[ interpol_ptr_offset+3 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+4 ], interpol_ptr[ interpol_ptr_offset+4 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+5 ], interpol_ptr[ interpol_ptr_offset+5 ] ); - interpol_ptr = FIR_Coefs; -//BugFix interpol_ptr_offset = Silk_resampler_rom.RESAMPLER_DOWN_ORDER_FIR / 2 * ( S.FIR_Fracs - 1 - interpol_ind ); - interpol_ptr_offset = FIR_Coefs_offset + Silk_resampler_rom.RESAMPLER_DOWN_ORDER_FIR / 2 * ( S.FIR_Fracs - 1 - interpol_ind ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+11 ], interpol_ptr[ interpol_ptr_offset ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+10 ], interpol_ptr[ interpol_ptr_offset+1 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+9 ], interpol_ptr[ interpol_ptr_offset+2 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+8 ], interpol_ptr[ interpol_ptr_offset+3 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+7 ], interpol_ptr[ interpol_ptr_offset+4 ] ); - res_Q6 = Silk_macros.SKP_SMLAWB( res_Q6, buf_ptr[ buf_ptr_offset+6 ], interpol_ptr[ interpol_ptr_offset+5 ] ); - - /* Scale down, saturate and store in output array */ - out[out_offset++] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( res_Q6, 6 ) ); - } - } - - in_offset += nSamplesIn << S.input2x; - inLen -= nSamplesIn << S.input2x; - - if( inLen > S.input2x ) - { - /* More iterations to do; copy last part of filtered signal to beginning of buffer */ -//TODO: arrayCopy(); -// SKP_memcpy( buf2, &buf2[ nSamplesIn ], RESAMPLER_DOWN_ORDER_FIR * sizeof( SKP_int32 ) ); - for(int i_djinn=0; i_djinnsFIR, &buf2[ nSamplesIn ], RESAMPLER_DOWN_ORDER_FIR * sizeof( SKP_int32 ) ); - for(int i_djinn=0; i_djinn 0 ); - assert( Silk_resampler_rom.SKP_Silk_resampler_up2_hq_0[ 1 ] < 0 ); - assert( Silk_resampler_rom.SKP_Silk_resampler_up2_hq_1[ 0 ] > 0 ); - assert( Silk_resampler_rom.SKP_Silk_resampler_up2_hq_1[ 1 ] < 0 ); - - /* Internal variables and state are in Q10 format */ - for( k = 0; k < len; k++ ) - { - /* Convert to Q10 */ - in32 = in[ in_offset+k ] << 10; - - /* First all-pass section for even output sample */ - Y = in32 - S[ S_offset ]; - X = Silk_macros.SKP_SMULWB( Y, Silk_resampler_rom.SKP_Silk_resampler_up2_hq_0[ 0 ] ); - out32_1 = S[ S_offset ] + X; - S[ S_offset ] = in32 + X; - - /* Second all-pass section for even output sample */ - Y = out32_1 - S[ S_offset+1 ]; - X = Silk_macros.SKP_SMLAWB( Y, Y, Silk_resampler_rom.SKP_Silk_resampler_up2_hq_0[ 1 ] ); - out32_2 = S[ S_offset+1 ] + X; - S[ S_offset+1 ] = out32_1 + X; - - /* Biquad notch filter */ - out32_2 = Silk_macros.SKP_SMLAWB( out32_2, S[ S_offset+5 ], Silk_resampler_rom.SKP_Silk_resampler_up2_hq_notch[ 2 ] ); - out32_2 = Silk_macros.SKP_SMLAWB( out32_2, S[ S_offset+4 ], Silk_resampler_rom.SKP_Silk_resampler_up2_hq_notch[ 1 ] ); - out32_1 = Silk_macros.SKP_SMLAWB( out32_2, S[ S_offset+4 ], Silk_resampler_rom.SKP_Silk_resampler_up2_hq_notch[ 0 ] ); - S[ S_offset+5 ] = out32_2 - S[ S_offset+5 ]; - - /* Apply gain in Q15, convert back to int16 and store to output */ - out[ out_offset + 2 * k ] = (short)Silk_SigProc_FIX.SKP_SAT16( - Silk_macros.SKP_SMLAWB( 256, out32_1, Silk_resampler_rom.SKP_Silk_resampler_up2_hq_notch[ 3 ] ) >> 9 ); - - /* First all-pass section for odd output sample */ - Y = in32 - S[ S_offset+2 ]; - X = Silk_macros.SKP_SMULWB( Y, Silk_resampler_rom.SKP_Silk_resampler_up2_hq_1[ 0 ] ); - out32_1 = S[ S_offset+2 ] + X; - S[ S_offset+2 ] = in32 + X; - - /* Second all-pass section for odd output sample */ - Y = out32_1 - S[ S_offset+3 ]; - X = Silk_macros.SKP_SMLAWB( Y, Y, Silk_resampler_rom.SKP_Silk_resampler_up2_hq_1[ 1 ] ); - out32_2 = S[ S_offset+3 ] + X; - S[ S_offset+3 ] = out32_1 + X; - - /* Biquad notch filter */ - out32_2 = Silk_macros.SKP_SMLAWB( out32_2, S[ S_offset+4 ], Silk_resampler_rom.SKP_Silk_resampler_up2_hq_notch[ 2 ] ); - out32_2 = Silk_macros.SKP_SMLAWB( out32_2, S[ S_offset+5 ], Silk_resampler_rom.SKP_Silk_resampler_up2_hq_notch[ 1 ] ); - out32_1 = Silk_macros.SKP_SMLAWB( out32_2, S[ S_offset+5 ], Silk_resampler_rom.SKP_Silk_resampler_up2_hq_notch[ 0 ] ); - S[ S_offset+4 ] = out32_2 - S[ S_offset+4 ]; - - /* Apply gain in Q15, convert back to int16 and store to output */ - out[ out_offset + 2 * k + 1 ] = (short)Silk_SigProc_FIX.SKP_SAT16( - Silk_macros.SKP_SMLAWB( 256, out32_1, Silk_resampler_rom.SKP_Silk_resampler_up2_hq_notch[ 3 ] ) >> 9 ); - } - } - - /** - * the wrapper method. - * @param SS Resampler state (unused). - * @param out Output signal [ 2 * len ]. - * @param out_offset offset of valid data. - * @param in Input signal [ len ]. - * @param in_offset offset of valid data. - * @param len Number of input samples. - */ - static void SKP_Silk_resampler_private_up2_HQ_wrapper( - Object SS, /* I/O: Resampler state (unused) */ - short[] out, /* O: Output signal [ 2 * len ] */ - int out_offset, - short[] in, /* I: Input signal [ len ] */ - int in_offset, - int len /* I: Number of input samples */ - ) - { - SKP_Silk_resampler_state_struct S = (SKP_Silk_resampler_state_struct )SS; - SKP_Silk_resampler_private_up2_HQ( S.sIIR,0, out,out_offset, in,in_offset, len ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_private_up4.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_private_up4.java deleted file mode 100644 index f4a41d11b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_private_up4.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Upsample by a factor 4. - * Note: very low quality, only use with output sampling rates above 96 kHz. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_resampler_private_up4 -{ - /** - * Upsample by a factor 4. - * Note: very low quality, only use with output sampling rates above 96 kHz. - * @param S State vector [ 2 ]. - * @param S_offset offset of valid data. - * @param out Output signal [ 4 * len ]. - * @param out_offset offset of valid data. - * @param in Input signal [ len ]. - * @param in_offset offset of valid data. - * @param len Number of INPUT samples. - */ - static void SKP_Silk_resampler_private_up4( - int[] S, /* I/O: State vector [ 2 ] */ - int S_offset, - short[] out, /* O: Output signal [ 4 * len ] */ - int out_offset, - short[] in, /* I: Input signal [ len ] */ - int in_offset, - int len /* I: Number of INPUT samples */ - ) - { - int k; - int in32, out32, Y, X; - int out16; - - assert( Silk_resampler_rom.SKP_Silk_resampler_up2_lq_0 > 0 ); - assert( Silk_resampler_rom.SKP_Silk_resampler_up2_lq_1 < 0 ); - - /* Internal variables and state are in Q10 format */ - for( k = 0; k < len; k++ ) - { - /* Convert to Q10 */ - in32 = in[ in_offset+k ] << 10; - - /* All-pass section for even output sample */ - Y = in32 - S[ S_offset + 0 ]; - X = Silk_macros.SKP_SMULWB( Y, Silk_resampler_rom.SKP_Silk_resampler_up2_lq_0 ); - out32 = S[ S_offset + 0 ] + X; - S[ S_offset + 0 ] = in32 + X; - - /* Convert back to int16 and store to output */ - out16 = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32, 10 ) ); - out[ out_offset + 4 * k ] = (short)out16; - out[ out_offset + 4 * k + 1 ] = (short)out16; - - /* All-pass section for odd output sample */ - Y = in32 - S[ S_offset + 1 ]; - X = Silk_macros.SKP_SMLAWB( Y, Y, Silk_resampler_rom.SKP_Silk_resampler_up2_lq_1 ); - out32 = S[ S_offset + 1 ] + X; - S[ S_offset + 1 ] = in32 + X; - - /* Convert back to int16 and store to output */ - out16 = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32, 10 ) ); - out[ out_offset + 4 * k + 2 ] = (short)out16; - out[ out_offset + 4 * k + 3 ] = (short)out16; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_rom.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_rom.java deleted file mode 100644 index e2bdce471..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_rom.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Filter coefficients for IIR/FIR polyphase resampling. - * Total size: 550 Words (1.1 kB). - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_resampler_rom -{ - static final int RESAMPLER_DOWN_ORDER_FIR = 12; - static final int RESAMPLER_ORDER_FIR_144 = 6; - - /* Tables for 2x downsampler. Values above 32767 intentionally wrap to a negative value. */ - static final short SKP_Silk_resampler_down2_0 = 9872; - static final short SKP_Silk_resampler_down2_1 = (short) 39809; - - /* Tables for 2x upsampler, low quality. Values above 32767 intentionally wrap to a negative value. */ - static final short SKP_Silk_resampler_up2_lq_0 = 8102; - static final short SKP_Silk_resampler_up2_lq_1 = (short) 36783; - - /* Tables for 2x upsampler, high quality. Values above 32767 intentionally wrap to a negative value. */ - static short[] SKP_Silk_resampler_up2_hq_0 = { 4280, (short) 33727 }; - static short[] SKP_Silk_resampler_up2_hq_1 = { 16295, (short) 54015 }; - /* Matlab code for the notch filter coefficients: */ - /* B = [1, 0.12, 1]; A = [1, 0.055, 0.8]; G = 0.87; freqz(G * B, A, 2^14, 16e3); axis([0, 8000, -10, 1]); */ - /* fprintf('\t%6d, %6d, %6d, %6d\n', round(B(2)*2^16), round(-A(2)*2^16), round((1-A(3))*2^16), round(G*2^15)) */ - static short[] SKP_Silk_resampler_up2_hq_notch = { 7864, -3604, 13107, 28508 }; - - /* Tables with IIR and FIR coefficients for fractional downsamplers (70 Words) */ - static short[] SKP_Silk_Resampler_3_4_COEFS = - { - -18249, -12532, - -97, 284, -495, 309, 10268, 20317, - -94, 156, -48, -720, 5984, 18278, - -45, -4, 237, -847, 2540, 14662, - }; - - static short[] SKP_Silk_Resampler_2_3_COEFS = - { - -11891, -12486, - 20, 211, -657, 688, 8423, 15911, - -44, 197, -152, -653, 3855, 13015, - }; - - static short[] SKP_Silk_Resampler_1_2_COEFS = - { - 2415, -13101, - 158, -295, -400, 1265, 4832, 7968, - }; - - static short[] SKP_Silk_Resampler_3_8_COEFS = - { - 13270, -13738, - -294, -123, 747, 2043, 3339, 3995, - -151, -311, 414, 1583, 2947, 3877, - -33, -389, 143, 1141, 2503, 3653, - }; - - static short[] SKP_Silk_Resampler_1_3_COEFS = - { - 16643, -14000, - -331, 19, 581, 1421, 2290, 2845, - }; - - static short[] SKP_Silk_Resampler_2_3_COEFS_LQ = - { - -2797, -6507, - 4697, 10739, - 1567, 8276, - }; - - static short[] SKP_Silk_Resampler_1_3_COEFS_LQ = - { - 16777, -9792, - 890, 1614, 2148, - }; - - /* Tables with coefficients for 4th order ARMA filter (35 Words), in a packed format: */ - /* { B1_Q14[1], B2_Q14[1], -A1_Q14[1], -A1_Q14[2], -A2_Q14[1], -A2_Q14[2], gain_Q16 } */ - /* where it is assumed that B*_Q14[0], B*_Q14[2], A*_Q14[0] are all 16384 */ - static short[] SKP_Silk_Resampler_320_441_ARMA4_COEFS = - { - 31454, 24746, -9706, -3386, -17911, -13243, 24797 - }; - - static short[] SKP_Silk_Resampler_240_441_ARMA4_COEFS = - { - 28721, 11254, 3189, -2546, -1495, -12618, 11562 - }; - - static short[] SKP_Silk_Resampler_160_441_ARMA4_COEFS = - { - 23492, -6457, 14358, -4856, 14654, -13008, 4456 - }; - - static short[] SKP_Silk_Resampler_120_441_ARMA4_COEFS = - { - 19311, -15569, 19489, -6950, 21441, -13559, 2370 - }; - - static short[] SKP_Silk_Resampler_80_441_ARMA4_COEFS = - { - 13248, -23849, 24126, -9486, 26806, -14286, 1065 - }; - - /* Table with interplation fractions of 1/288 : 2/288 : 287/288 (432 Words) */ - static short[][] SKP_Silk_resampler_frac_FIR_144 = - { - { -647, 1884, 30078}, - { -625, 1736, 30044}, - { -603, 1591, 30005}, - { -581, 1448, 29963}, - { -559, 1308, 29917}, - { -537, 1169, 29867}, - { -515, 1032, 29813}, - { -494, 898, 29755}, - { -473, 766, 29693}, - { -452, 636, 29627}, - { -431, 508, 29558}, - { -410, 383, 29484}, - { -390, 260, 29407}, - { -369, 139, 29327}, - { -349, 20, 29242}, - { -330, -97, 29154}, - { -310, -211, 29062}, - { -291, -324, 28967}, - { -271, -434, 28868}, - { -253, -542, 28765}, - { -234, -647, 28659}, - { -215, -751, 28550}, - { -197, -852, 28436}, - { -179, -951, 28320}, - { -162, -1048, 28200}, - { -144, -1143, 28077}, - { -127, -1235, 27950}, - { -110, -1326, 27820}, - { -94, -1414, 27687}, - { -77, -1500, 27550}, - { -61, -1584, 27410}, - { -45, -1665, 27268}, - { -30, -1745, 27122}, - { -15, -1822, 26972}, - { 0, -1897, 26820}, - { 15, -1970, 26665}, - { 29, -2041, 26507}, - { 44, -2110, 26346}, - { 57, -2177, 26182}, - { 71, -2242, 26015}, - { 84, -2305, 25845}, - { 97, -2365, 25673}, - { 110, -2424, 25498}, - { 122, -2480, 25320}, - { 134, -2534, 25140}, - { 146, -2587, 24956}, - { 157, -2637, 24771}, - { 168, -2685, 24583}, - { 179, -2732, 24392}, - { 190, -2776, 24199}, - { 200, -2819, 24003}, - { 210, -2859, 23805}, - { 220, -2898, 23605}, - { 229, -2934, 23403}, - { 238, -2969, 23198}, - { 247, -3002, 22992}, - { 255, -3033, 22783}, - { 263, -3062, 22572}, - { 271, -3089, 22359}, - { 279, -3114, 22144}, - { 286, -3138, 21927}, - { 293, -3160, 21709}, - { 300, -3180, 21488}, - { 306, -3198, 21266}, - { 312, -3215, 21042}, - { 318, -3229, 20816}, - { 323, -3242, 20589}, - { 328, -3254, 20360}, - { 333, -3263, 20130}, - { 338, -3272, 19898}, - { 342, -3278, 19665}, - { 346, -3283, 19430}, - { 350, -3286, 19194}, - { 353, -3288, 18957}, - { 356, -3288, 18718}, - { 359, -3286, 18478}, - { 362, -3283, 18238}, - { 364, -3279, 17996}, - { 366, -3273, 17753}, - { 368, -3266, 17509}, - { 369, -3257, 17264}, - { 371, -3247, 17018}, - { 372, -3235, 16772}, - { 372, -3222, 16525}, - { 373, -3208, 16277}, - { 373, -3192, 16028}, - { 373, -3175, 15779}, - { 373, -3157, 15529}, - { 372, -3138, 15279}, - { 371, -3117, 15028}, - { 370, -3095, 14777}, - { 369, -3072, 14526}, - { 368, -3048, 14274}, - { 366, -3022, 14022}, - { 364, -2996, 13770}, - { 362, -2968, 13517}, - { 359, -2940, 13265}, - { 357, -2910, 13012}, - { 354, -2880, 12760}, - { 351, -2848, 12508}, - { 348, -2815, 12255}, - { 344, -2782, 12003}, - { 341, -2747, 11751}, - { 337, -2712, 11500}, - { 333, -2676, 11248}, - { 328, -2639, 10997}, - { 324, -2601, 10747}, - { 320, -2562, 10497}, - { 315, -2523, 10247}, - { 310, -2482, 9998}, - { 305, -2442, 9750}, - { 300, -2400, 9502}, - { 294, -2358, 9255}, - { 289, -2315, 9009}, - { 283, -2271, 8763}, - { 277, -2227, 8519}, - { 271, -2182, 8275}, - { 265, -2137, 8032}, - { 259, -2091, 7791}, - { 252, -2045, 7550}, - { 246, -1998, 7311}, - { 239, -1951, 7072}, - { 232, -1904, 6835}, - { 226, -1856, 6599}, - { 219, -1807, 6364}, - { 212, -1758, 6131}, - { 204, -1709, 5899}, - { 197, -1660, 5668}, - { 190, -1611, 5439}, - { 183, -1561, 5212}, - { 175, -1511, 4986}, - { 168, -1460, 4761}, - { 160, -1410, 4538}, - { 152, -1359, 4317}, - { 145, -1309, 4098}, - { 137, -1258, 3880}, - { 129, -1207, 3664}, - { 121, -1156, 3450}, - { 113, -1105, 3238}, - { 105, -1054, 3028}, - { 97, -1003, 2820}, - { 89, -952, 2614}, - { 81, -901, 2409}, - { 73, -851, 2207}, - }; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_structs.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_structs.java deleted file mode 100644 index 63c7e3750..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_structs.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * Classes for IIR/FIR resamplers. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_resampler_structs -{ - /** - * Flag to enable support for input/output sampling rates above 48 kHz. Turn off for embedded devices. - */ - static final int RESAMPLER_SUPPORT_ABOVE_48KHZ = 1; - - static final int SKP_Silk_RESAMPLER_MAX_FIR_ORDER = 16; - static final int SKP_Silk_RESAMPLER_MAX_IIR_ORDER = 6; -} - - class SKP_Silk_resampler_state_struct - { - int[] sIIR = new int[ Silk_resampler_structs.SKP_Silk_RESAMPLER_MAX_IIR_ORDER ]; /* this must be the first element of this struct */ - int[] sFIR = new int[ Silk_resampler_structs.SKP_Silk_RESAMPLER_MAX_FIR_ORDER ]; - int[] sDown2 = new int[ 2 ]; - - String resampler_function; - ResamplerFP resamplerCB; - void resampler_function( Object state, short[] out, int out_offset, short[] in, int in_offset, int len ) - { - resamplerCB.resampler_function(state, out, out_offset, in, in_offset, len); - } - - String up2_function; - Up2FP up2CB; - void up2_function( int[] state, short[] out, int out_offset, short[] in, int in_offset, int len ) - { - up2CB.up2_function(state, out, out_offset, in, in_offset, len); - - } - - int batchSize; - int invRatio_Q16; - int FIR_Fracs; - int input2x; - short[] Coefs; - - int[] sDownPre = new int[ 2 ]; - int[] sUpPost = new int[ 2 ]; - - String down_pre_function; - DownPreFP downPreCB; - void down_pre_function ( int[] state, short[] out, int out_offset, short[] in, int in_offset, int len ) - { - downPreCB.down_pre_function(state, out, out_offset, in, in_offset, len); - } - - String up_post_function; - UpPostFP upPostCB; - void up_post_function ( int[] state, short[] out, int out_offset, short[] in, int in_offset, int len ) - { - upPostCB.up_post_function(state, out, out_offset, in, in_offset, len); - } - int batchSizePrePost; - int ratio_Q16; - int nPreDownsamplers; - int nPostUpsamplers; - int magic_number; - - /** - * set all fields of the instance to zero. - */ - public void memZero() - { -// { -// if(this.Coefs != null) -// { -// Arrays.fill(this.Coefs, (short)0); -// } -// } - this.Coefs = null; - - Arrays.fill(this.sDown2, 0); - Arrays.fill(this.sDownPre, 0); - Arrays.fill(this.sFIR, 0); - Arrays.fill(this.sIIR, 0); - Arrays.fill(this.sUpPost, 0); - - this.batchSize = 0; - this.batchSizePrePost = 0; - this.down_pre_function = null; - this.downPreCB = null; - this.FIR_Fracs = 0; - this.input2x = 0; - this.invRatio_Q16 = 0; - this.magic_number = 0; - this.nPostUpsamplers = 0; - this.nPreDownsamplers = 0; - this.ratio_Q16 = 0; - this.resampler_function = null; - this.resamplerCB = null; - this.up2_function = null; - this.up2CB = null; - this.up_post_function = null; - this.upPostCB = null; - } -} - /*************************************************************************************/ - interface ResamplerFP - { - void resampler_function( Object state, short[] out, int out_offset, short[] in, int in_offset, int len ); - } - interface Up2FP - { - void up2_function( int[] state, short[] out, int out_offset, short[] in, int in_offset, int len ); - } - interface DownPreFP - { - void down_pre_function ( int[] state, short[] out, int out_offset, short[] in, int in_offset, int len ); - } - interface UpPostFP - { - void up_post_function ( int[] state, short[] out, int out_offset, short[] in, int in_offset, int len ); - } - /*************************************************************************************/ - \ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_up2.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_up2.java deleted file mode 100644 index 578aa08f9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_resampler_up2.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Up-sample by a factor 2, low quality. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_resampler_up2 -{ - /** - * Up-sample by a factor 2, low quality. - * @param S State vector [ 2 ]. - * @param S_offset offset of valid data. - * @param out Output signal [ 2 * len ]. - * @param out_offset offset of valid data. - * @param in Input signal [ len ]. - * @param in_offset offset of valid data. - * @param len Number of input samples. - */ - static void SKP_Silk_resampler_up2( - int[] S, /* I/O: State vector [ 2 ] */ - int S_offset, - short[] out, /* O: Output signal [ 2 * len ] */ - int out_offset, - short[] in, /* I: Input signal [ len ] */ - int in_offset, - int len /* I: Number of input samples */ - ) - { - int k; - int in32, out32, Y, X; - - assert( Silk_resampler_rom.SKP_Silk_resampler_up2_lq_0 > 0 ); - assert( Silk_resampler_rom.SKP_Silk_resampler_up2_lq_1 < 0 ); - /* Internal variables and state are in Q10 format */ - for( k = 0; k < len; k++ ) - { - /* Convert to Q10 */ - in32 = in[ in_offset+k ] << 10; - - /* All-pass section for even output sample */ - Y = in32 - S[ S_offset + 0 ]; - X = Silk_macros.SKP_SMULWB( Y, Silk_resampler_rom.SKP_Silk_resampler_up2_lq_0 ); - out32 = S[ S_offset + 0 ] + X; - S[ S_offset + 0 ] = in32 + X; - - /* Convert back to int16 and store to output */ - out[ out_offset + 2 * k ] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32, 10 ) ); - - /* All-pass section for odd output sample */ - Y = in32 - S[ S_offset + 1 ]; - X = Silk_macros.SKP_SMLAWB( Y, Y, Silk_resampler_rom.SKP_Silk_resampler_up2_lq_1 ); - out32 = S[ S_offset + 1 ] + X; - S[ S_offset + 1 ] = in32 + X; - - /* Convert back to int16 and store to output */ - out[ out_offset + 2 * k + 1 ] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FIX.SKP_RSHIFT_ROUND( out32, 10 ) ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_residual_energy_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_residual_energy_FLP.java deleted file mode 100644 index 50a707e8c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_residual_energy_FLP.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Residual energy. - * - * @author Dingxin Xu - */ -public class Silk_residual_energy_FLP -{ - - - static final int MAX_ITERATIONS_RESIDUAL_NRG = 10; - static final float REGULARIZATION_FACTOR = 1e-8f; - - - /** - * Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c. - * @param c Filter coefficients - * @param c_offset offset of valid data. - * @param wXX Weighted correlation matrix, reg. out - * @param wXX_offset offset of valid data. - * @param wXx Weighted correlation vector - * @param wxx Weighted correlation value - * @param D Dimension - * @return Weighted residual energy - */ - static float SKP_Silk_residual_energy_covar_FLP( /* O Weighted residual energy */ - final float []c, /* I Filter coefficients */ - int c_offset, - float []wXX, /* I/O Weighted correlation matrix, reg. out */ - int wXX_offset, - final float []wXx, /* I Weighted correlation vector */ - final float wxx, /* I Weighted correlation value */ - final int D /* I Dimension */ - ) - { - int i, j, k; - float tmp, nrg = 0, regularization; - - /* Safety checks */ - assert( D >= 0 ); - - regularization = REGULARIZATION_FACTOR * ( wXX[ wXX_offset + 0 ] + wXX[ wXX_offset + D * D - 1 ] ); - for( k = 0; k < MAX_ITERATIONS_RESIDUAL_NRG; k++ ) { - nrg = wxx; - - tmp = 0.0f; - for( i = 0; i < D; i++ ) { - tmp += wXx[ i ] * c[ c_offset + i ]; - } - nrg -= 2.0f * tmp; - - /* compute c' * wXX * c, assuming wXX is symmetric */ - for( i = 0; i < D; i++ ) { - tmp = 0.0f; - for( j = i + 1; j < D; j++ ) { -// tmp += matrix_c_ptr( wXX, i, j, D ) * c[ j ]; - tmp += wXX[wXX_offset + i+j*D] * c[c_offset + j]; - } -// nrg += c[ i ] * ( 2.0f * tmp + matrix_c_ptr( wXX, i, i, D ) * c[ i ] ); - nrg += c[ c_offset + i ] * ( 2.0f * tmp + wXX[wXX_offset + i + D*i] * c[ c_offset + i ] ); - } - if( nrg > 0 ) { - break; - } else { - /* Add white noise */ - for( i = 0; i < D; i++ ) { -// matrix_c_ptr( wXX, i, i, D ) += regularization; - wXX[wXX_offset + i + D*i] += regularization; - } - /* Increase noise for next run */ - regularization *= 2.0f; - } - } - if( k == MAX_ITERATIONS_RESIDUAL_NRG ) { - assert( nrg == 0 ); - nrg = 1.0f; - } - - return nrg; - } - - /** - * Calculates residual energies of input subframes where all subframes have LPC_order - * of preceeding samples - * @param nrgs Residual energy per subframe - * @param x Input signal - * @param a AR coefs for each frame half - * @param gains Quantization gains - * @param subfr_length Subframe length - * @param LPC_order LPC order - */ - static void SKP_Silk_residual_energy_FLP( - float nrgs[], /* O Residual energy per subframe */ - final float x[], /* I Input signal */ - final float a[][ ], /* I AR coefs for each frame half */ - final float gains[], /* I Quantization gains */ - final int subfr_length, /* I Subframe length */ - final int LPC_order /* I LPC order */ - ) - { - int shift; -// SKP_float *LPC_res_ptr, LPC_res[ ( MAX_FRAME_LENGTH + NB_SUBFR * MAX_LPC_ORDER ) / 2 ]; - float LPC_res_ptr[], LPC_res[] = new float[ ( Silk_define.MAX_FRAME_LENGTH + Silk_define.NB_SUBFR * Silk_define.MAX_LPC_ORDER ) / 2 ]; - -// LPC_res_ptr = LPC_res + LPC_order; - LPC_res_ptr = LPC_res; - int LPC_res_ptr_offset = LPC_order; - shift = LPC_order + subfr_length; - - /* Filter input to create the LPC residual for each frame half, and measure subframe energies */ - Silk_LPC_analysis_filter_FLP.SKP_Silk_LPC_analysis_filter_FLP( LPC_res, a[ 0 ], x, 0 + 0 * shift, 2 * shift, LPC_order ); - nrgs[ 0 ] = (float) ( gains[ 0 ] * gains[ 0 ] * Silk_energy_FLP.SKP_Silk_energy_FLP( LPC_res_ptr, LPC_res_ptr_offset + 0 * shift, subfr_length ) ); - nrgs[ 1 ] = (float) ( gains[ 1 ] * gains[ 1 ] * Silk_energy_FLP.SKP_Silk_energy_FLP( LPC_res_ptr, LPC_res_ptr_offset + 1 * shift, subfr_length ) ); - - Silk_LPC_analysis_filter_FLP.SKP_Silk_LPC_analysis_filter_FLP( LPC_res, a[ 1 ], x, 0 + 2 * shift, 2 * shift, LPC_order ); - nrgs[ 2 ] = ( float )( gains[ 2 ] * gains[ 2 ] * Silk_energy_FLP.SKP_Silk_energy_FLP( LPC_res_ptr, LPC_res_ptr_offset + 0 * shift, subfr_length ) ); - nrgs[ 3 ] = ( float )( gains[ 3 ] * gains[ 3 ] * Silk_energy_FLP.SKP_Silk_energy_FLP( LPC_res_ptr, LPC_res_ptr_offset + 1 * shift, subfr_length ) ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_scale_copy_vector_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_scale_copy_vector_FLP.java deleted file mode 100644 index f1333dc55..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_scale_copy_vector_FLP.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * copy and multiply a vector by a constant - * - * @author Dingxin Xu - */ -public class Silk_scale_copy_vector_FLP -{ - /** - * copy and multiply a vector by a constant. - * @param data_out - * @param data_out_offset - * @param data_in - * @param data_in_offset - * @param gain - * @param dataSize - */ - static void SKP_Silk_scale_copy_vector_FLP( - float []data_out, - int data_out_offset, - final float []data_in, - int data_in_offset, - float gain, - int dataSize - ) - { - int i, dataSize4; - - /* 4x unrolled loop */ - dataSize4 = dataSize & 0xFFFC; - for( i = 0; i < dataSize4; i += 4 ) { - data_out[ data_out_offset + i + 0 ] = gain * data_in[ data_in_offset + i + 0 ]; - data_out[ data_out_offset + i + 1 ] = gain * data_in[ data_in_offset + i + 1 ]; - data_out[ data_out_offset + i + 2 ] = gain * data_in[ data_in_offset + i + 2 ]; - data_out[ data_out_offset + i + 3 ] = gain * data_in[ data_in_offset + i + 3 ]; - } - - /* any remaining elements */ - for( ; i < dataSize; i++ ) { - data_out[ data_out_offset + i ] = gain * data_in[ data_in_offset + i ]; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_scale_vector_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_scale_vector_FLP.java deleted file mode 100644 index 4377229e2..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_scale_vector_FLP.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * scale a vector. - * - * @author Dingxin Xu - */ -public class Silk_scale_vector_FLP -{ - /** - * multiply a vector by a constant. - * @param data1 - * @param gain - * @param dataSize - */ - static void SKP_Silk_scale_vector_FLP( - float []data1, - int data1_offset, - float gain, - int dataSize - ) - { - int i, dataSize4; - - /* 4x unrolled loop */ - dataSize4 = dataSize & 0xFFFC; - for( i = 0; i < dataSize4; i += 4 ) { - data1[ data1_offset + i + 0 ] *= gain; - data1[ data1_offset + i + 1 ] *= gain; - data1[ data1_offset + i + 2 ] *= gain; - data1[ data1_offset + i + 3 ] *= gain; - } - - /* any remaining elements */ - for( ; i < dataSize; i++ ) { - data1[ data1_offset + i ] *= gain; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_schur_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_schur_FLP.java deleted file mode 100644 index 4f669c143..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_schur_FLP.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_schur_FLP -{ - /** - * - * @param refl_coef reflection coefficients (length order) - * @param ref1_coef_offset offset of valid data. - * @param auto_corr autotcorreation sequence (length order+1) - * @param auto_corr_offset offset of valid data. - * @param order order - */ - static void SKP_Silk_schur_FLP( - float refl_coef[], /* O reflection coefficients (length order) */ - int ref1_coef_offset, - float auto_corr[], /* I autotcorreation sequence (length order+1) */ - int auto_corr_offset, - int order /* I order */ - ) - { - int k, n; - float[][] C = new float[Silk_SigProc_FIX.SKP_Silk_MAX_ORDER_LPC + 1][2]; - float Ctmp1, Ctmp2, rc_tmp; - - /* copy correlations */ - for (k = 0; k < order + 1; k++) - { - C[k][0] = C[k][1] = auto_corr[auto_corr_offset + k]; - } - - for (k = 0; k < order; k++) - { - /* get reflection coefficient */ - rc_tmp = -C[k + 1][0] / Math.max(C[0][1], 1e-9f); - - /* save the output */ - refl_coef[ref1_coef_offset + k] = rc_tmp; - - /* update correlations */ - for (n = 0; n < order - k; n++) - { - Ctmp1 = C[n + k + 1][0]; - Ctmp2 = C[n][1]; - C[n + k + 1][0] = Ctmp1 + Ctmp2 * rc_tmp; - C[n][1] = Ctmp2 + Ctmp1 * rc_tmp; - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_shell_coder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_shell_coder.java deleted file mode 100644 index 3f03e06c2..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_shell_coder.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * shell coder; pulse-subframe length is hardcoded. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_shell_coder -{ - /** - * - * @param out combined pulses vector [len] - * @param out_offset offset of valid data. - * @param in input vector [2 * len] - * @param in_offset offset of valid data. - * @param len number of OUTPUT samples - */ - static void combine_pulses( - int []out, /* O: combined pulses vector [len] */ - int out_offset, - int []in, /* I: input vector [2 * len] */ - int in_offset, - final int len /* I: number of OUTPUT samples */ - ) - { - int k; - for( k = 0; k < len; k++ ) { - out[ out_offset + k ] = in[ in_offset + 2 * k ] + in[ in_offset + 2 * k + 1 ]; - } - } - - /** - * - * @param sRC compressor data structure - * @param p_child1 pulse amplitude of first child subframe - * @param p pulse amplitude of current subframe - * @param shell_table table of shell cdfs - */ - static void encode_split( - SKP_Silk_range_coder_state sRC, /* I/O: compressor data structure */ - final int p_child1, /* I: pulse amplitude of first child subframe */ - final int p, /* I: pulse amplitude of current subframe */ - final int[] shell_table - ) - { - final int[] cdf; - int cdf_offset; - - if( p > 0 ) - { - cdf = shell_table; - cdf_offset = Silk_tables_pulses_per_block.SKP_Silk_shell_code_table_offsets[ p ] ; - Silk_range_coder.SKP_Silk_range_encoder( sRC, p_child1, cdf, cdf_offset ); - } - } - - /** - * - * @param p_child1 pulse amplitude of first child subframe - * @param p_child1_offset offset of valid data. - * @param p_child2 pulse amplitude of second child subframe - * @param p_child2_offset offset of valid data. - * @param sRC compressor data structure - * @param p pulse amplitude of current subframe - * @param shell_table table of shell cdfs - */ - static void decode_split( - int []p_child1, /* O: pulse amplitude of first child subframe */ - int p_child1_offset, - int []p_child2, /* O: pulse amplitude of second child subframe */ - int p_child2_offset, - SKP_Silk_range_coder_state sRC, /* I/O: compressor data structure */ - final int p, /* I: pulse amplitude of current subframe */ - int[] shell_table /* I: table of shell cdfs */ - ) - { - int cdf_middle; - final int[] cdf; - int cdf_offset; - - if( p > 0 ) - { - cdf_middle = ( p >> 1 ); - cdf = shell_table; - cdf_offset = Silk_tables_pulses_per_block.SKP_Silk_shell_code_table_offsets[ p ]; - - Silk_range_coder.SKP_Silk_range_decoder( p_child1, p_child1_offset, sRC, cdf, cdf_offset, cdf_middle ); - p_child2[ p_child2_offset + 0 ] = p - p_child1[ p_child1_offset + 0 ]; - } - else - { - p_child1[ p_child1_offset + 0 ] = 0; - p_child2[ p_child2_offset + 0 ] = 0; - } - } - - /** - * Shell encoder, operates on one shell code frame of 16 pulses. - * @param sRC compressor data structure. - * @param pulses0 data: nonnegative pulse amplitudes. - * @param pulses0_offset valid data - */ - static void SKP_Silk_shell_encoder( - SKP_Silk_range_coder_state sRC, /* I/O compressor data structure */ - int[] pulses0, /* I data: nonnegative pulse amplitudes */ - int pulses0_offset - ) - { - int[] pulses1 = new int[ 8 ], pulses2 = new int[ 4 ], pulses3 = new int[ 2 ], pulses4 = new int[ 1 ]; - - /* this function operates on one shell code frame of 16 pulses */ - assert( Silk_define.SHELL_CODEC_FRAME_LENGTH == 16 ); - - /* tree representation per pulse-subframe */ - combine_pulses( pulses1,0, pulses0,pulses0_offset, 8 ); - combine_pulses( pulses2,0, pulses1,0, 4 ); - combine_pulses( pulses3,0, pulses2,0, 2 ); - combine_pulses( pulses4,0, pulses3,0, 1 ); - - encode_split( sRC, pulses3[ 0 ], pulses4[ 0 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table3 ); - - encode_split( sRC, pulses2[ 0 ], pulses3[ 0 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table2 ); - - encode_split( sRC, pulses1[ 0 ], pulses2[ 0 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table1 ); - encode_split( sRC, pulses0[ pulses0_offset + 0 ], pulses1[ 0 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - encode_split( sRC, pulses0[ pulses0_offset + 2 ], pulses1[ 1 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - - encode_split( sRC, pulses1[ 2 ], pulses2[ 1 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table1 ); - encode_split( sRC, pulses0[ pulses0_offset + 4 ], pulses1[ 2 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - encode_split( sRC, pulses0[ pulses0_offset + 6 ], pulses1[ 3 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - - encode_split( sRC, pulses2[ 2 ], pulses3[ 1 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table2 ); - - encode_split( sRC, pulses1[ 4 ], pulses2[ 2 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table1 ); - encode_split( sRC, pulses0[ pulses0_offset + 8 ], pulses1[ 4 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - encode_split( sRC, pulses0[ pulses0_offset + 10 ], pulses1[ 5 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - - encode_split( sRC, pulses1[ 6 ], pulses2[ 3 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table1 ); - encode_split( sRC, pulses0[ pulses0_offset + 12 ], pulses1[ 6 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - encode_split( sRC, pulses0[ pulses0_offset + 14 ], pulses1[ 7 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - } - - /** - * Shell decoder, operates on one shell code frame of 16 pulses. - * @param pulses0 data: nonnegative pulse amplitudes - * @param pulses0_offset offset of valid data. - * @param sRC compressor data structure - * @param pulses4 number of pulses per pulse-subframe - */ - static void SKP_Silk_shell_decoder( - int []pulses0, /* O data: nonnegative pulse amplitudes */ - int pulses0_offset, - SKP_Silk_range_coder_state sRC, /* I/O compressor data structure */ - final int pulses4 /* I number of pulses per pulse-subframe */ - ) - { - int[] pulses3 = new int[ 2 ], pulses2 = new int[ 4 ], pulses1 = new int[ 8 ]; - - /* this function operates on one shell code frame of 16 pulses */ - Silk_typedef.SKP_assert( Silk_define.SHELL_CODEC_FRAME_LENGTH == 16 ); - - decode_split( pulses3, 0, pulses3, 1, sRC, pulses4, Silk_tables_pulses_per_block.SKP_Silk_shell_code_table3 ); - - decode_split( pulses2, 0, pulses2, 1, sRC, pulses3[ 0 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table2 ); - - decode_split( pulses1, 0, pulses1, 1, sRC, pulses2[ 0 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table1 ); - decode_split( pulses0, pulses0_offset + 0, pulses0, pulses0_offset + 1, sRC, pulses1[ 0 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - decode_split( pulses0, pulses0_offset + 2, pulses0, pulses0_offset + 3, sRC, pulses1[ 1 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - - decode_split( pulses1, 2, pulses1, 3, sRC, pulses2[ 1 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table1 ); - decode_split( pulses0, pulses0_offset + 4, pulses0, pulses0_offset + 5, sRC, pulses1[ 2 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - decode_split( pulses0, pulses0_offset + 6, pulses0, pulses0_offset + 7, sRC, pulses1[ 3 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - - decode_split( pulses2, 2, pulses2, 3, sRC, pulses3[ 1 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table2 ); - - decode_split( pulses1, 4, pulses1, 5, sRC, pulses2[ 2 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table1 ); - decode_split( pulses0, pulses0_offset + 8, pulses0, pulses0_offset + 9, sRC, pulses1[ 4 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - decode_split( pulses0, pulses0_offset + 10,pulses0, pulses0_offset + 11, sRC, pulses1[ 5 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - - decode_split( pulses1, 6, pulses1, 7, sRC, pulses2[ 3 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table1 ); - decode_split( pulses0, pulses0_offset + 12, pulses0, pulses0_offset + 13, sRC, pulses1[ 6 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - decode_split( pulses0, pulses0_offset + 14, pulses0, pulses0_offset + 15, sRC, pulses1[ 7 ], Silk_tables_pulses_per_block.SKP_Silk_shell_code_table0 ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_sigm_Q15.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_sigm_Q15.java deleted file mode 100644 index 3fdadb66a..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_sigm_Q15.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * approximate sigmoid function. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_sigm_Q15 -{ - /* fprintf(1, '%d, ', round(1024 * ([1 ./ (1 + exp(-(1:5))), 1] - 1 ./ (1 + exp(-(0:5)))))); */ - static int[] sigm_LUT_slope_Q10 = - { - 237, 153, 73, 30, 12, 7 - }; - /* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp(-(0:5))))); */ - static int[] sigm_LUT_pos_Q15 = - { - 16384, 23955, 28861, 31213, 32178, 32548 - }; - /* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp((0:5))))); */ - static int[] sigm_LUT_neg_Q15 = - { - 16384, 8812, 3906, 1554, 589, 219 - }; - - static int SKP_Silk_sigm_Q15( int in_Q5 ) - { - int ind; - - if( in_Q5 < 0 ) - { - /* Negative input */ - in_Q5 = -in_Q5; - if( in_Q5 >= 6 * 32 ) - { - return 0; /* Clip */ - } - else - { - /* Linear interpolation of look up table */ - ind = in_Q5 >> 5; - return( sigm_LUT_neg_Q15[ ind ] - Silk_macros.SKP_SMULBB( sigm_LUT_slope_Q10[ ind ], in_Q5 & 0x1F ) ); - } - } - else - { - /* Positive input */ - if( in_Q5 >= 6 * 32 ) - { - return 32767; /* clip */ - } - else - { - /* Linear interpolation of look up table */ - ind = in_Q5 >> 5; - return( sigm_LUT_pos_Q15[ ind ] + Silk_macros.SKP_SMULBB( sigm_LUT_slope_Q10[ ind ], in_Q5 & 0x1F ) ); - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_solve_LS_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_solve_LS_FLP.java deleted file mode 100644 index 05eae418b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_solve_LS_FLP.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -public class Silk_solve_LS_FLP -{ - /** - * Function to solve linear equation Ax = b, when A is a MxM - * symmetric square matrix - using LDL factorisation. - * @param A Symmetric square matrix, out: reg. - * @param A_offset offset of valid data. - * @param M Size of matrix - * @param b Pointer to b vector - * @param x Pointer to x solution vector - * @param x_offset offset of valid data. - */ - static void SKP_Silk_solve_LDL_FLP( - float []A, /* I/O Symmetric square matrix, out: reg. */ - int A_offset, - final int M, /* I Size of matrix */ - final float []b, /* I Pointer to b vector */ - float []x, /* O Pointer to x solution vector */ - int x_offset - ) - { - int i; -// float L[][] = new float[Silk_define.MAX_MATRIX_SIZE][Silk_define.MAX_MATRIX_SIZE]; -//TODO:change L from two dimension to one dimension. - float L_tmp[] = new float[Silk_define.MAX_MATRIX_SIZE*Silk_define.MAX_MATRIX_SIZE]; - float T[] = new float[Silk_define.MAX_MATRIX_SIZE]; - float Dinv[] = new float[Silk_define.MAX_MATRIX_SIZE];// inverse diagonal elements of D - - assert( M <= Silk_define.MAX_MATRIX_SIZE ); - - /*************************************************** - Factorize A by LDL such that A = L*D*(L^T), - where L is lower triangular with ones on diagonal - ****************************************************/ -// SKP_Silk_LDL_FLP( A, M, &L[ 0 ][ 0 ], Dinv ); - SKP_Silk_LDL_FLP(A, A_offset, M, L_tmp, Dinv); - - /**************************************************** - * substitute D*(L^T) = T. ie: - L*D*(L^T)*x = b => L*T = b <=> T = inv(L)*b - ******************************************************/ -// SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP( &L[ 0 ][ 0 ], M, b, T ); - SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP( L_tmp, M, b, T ); - - /**************************************************** - D*(L^T)*x = T <=> (L^T)*x = inv(D)*T, because D is - diagonal just multiply with 1/d_i - ****************************************************/ - for( i = 0; i < M; i++ ) { - T[ i ] = T[ i ] * Dinv[ i ]; - } - /**************************************************** - x = inv(L') * inv(D) * T - *****************************************************/ -// SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( &L[ 0 ][ 0 ], M, T, x ); - SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( L_tmp, M, T, x, x_offset ); - - } - - /** - * Function to solve linear equation (A^T)x = b, when A is a MxM lower - * triangular, with ones on the diagonal. (ie then A^T is upper triangular) - * @param L Pointer to Lower Triangular Matrix - * @param M Dim of Matrix equation - * @param b b Vector - * @param x x Vector - * @param x_offset offset of valid data. - */ - static void SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( - final float []L, /* (I) Pointer to Lower Triangular Matrix */ - int M, /* (I) Dim of Matrix equation */ - final float []b, /* (I) b Vector */ - float []x, /* (O) x Vector */ - int x_offset - ) - { -// SKP_int i, j; -// SKP_float temp; -// const SKP_float *ptr1; - int i,j; - float temp; -//TODO:ignore const - float []ptr1; - int ptr1_offset; - - for( i = M - 1; i >= 0; i-- ) { -// ptr1 = matrix_adr( L, 0, i, M ); - ptr1 = L; - ptr1_offset = i; - temp = 0; - for( j = M - 1; j > i ; j-- ) { - temp += ptr1[ ptr1_offset + j * M ] * x[ x_offset + j ]; - } - temp = b[ i ] - temp; - x[ x_offset + i ] = temp; - } - } - - /** - * Function to solve linear equation Ax = b, when A is a MxM lower - * triangular matrix, with ones on the diagonal. - * @param L Pointer to Lower Triangular Matrix - * @param M Pointer to Lower Triangular Matrix - * @param b b Vector - * @param x x Vector - */ - static void SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP( - final float []L, /* (I) Pointer to Lower Triangular Matrix */ - int M, /* (I) Pointer to Lower Triangular Matrix */ - final float []b, /* (I) b Vector */ - float []x /* (O) x Vector */ - ) - { -// SKP_int i, j; -// SKP_float temp; -// const SKP_float *ptr1; - int i,j; - float temp; -//TODO:ignore const - float []ptr1; - int ptr1_offset; - - for( i = 0; i < M; i++ ) { -// ptr1 = matrix_adr( L, i, 0, M ); - ptr1 = L; - ptr1_offset = i*M; - temp = 0; - for( j = 0; j < i; j++ ) { - temp += ptr1[ ptr1_offset + j ] * x[ j ]; - } - temp = b[ i ] - temp; - x[ i ] = temp; - } - } - - /** - * LDL Factorisation. Finds the upper triangular matrix L and the diagonal - * Matrix D (only the diagonal elements returned in a vector)such that - * the symmetric matric A is given by A = L*D*L'. - * @param A Pointer to Symetric Square Matrix - * @param A_offset offset of valid data. - * @param M Size of Matrix - * @param L Pointer to Square Upper triangular Matrix - * @param Dinv Pointer to vector holding the inverse diagonal elements of D - */ - static void SKP_Silk_LDL_FLP( - float []A, /* (I/O) Pointer to Symetric Square Matrix */ - int A_offset, - int M, /* (I) Size of Matrix */ - float []L, /* (I/O) Pointer to Square Upper triangular Matrix */ - float []Dinv /* (I/O) Pointer to vector holding the inverse diagonal elements of D */ - ) - { -/* SKP_int i, j, k, loop_count, err = 1; - SKP_float *ptr1, *ptr2; - double temp, diag_min_value; - SKP_float v[ MAX_MATRIX_SIZE ], D[ MAX_MATRIX_SIZE ]; // temp arrays -*/ - int i, j, k, loop_count, err = 1; - float ptr1[], ptr2[]; - int ptr1_offset, ptr2_offset; - double temp, diag_min_value; - float v[] = new float[ Silk_define.MAX_MATRIX_SIZE ], D[] = new float[ Silk_define.MAX_MATRIX_SIZE ]; // temp arrays - - assert( M <= Silk_define.MAX_MATRIX_SIZE ); - - diag_min_value = Silk_define_FLP.FIND_LTP_COND_FAC * 0.5f * ( A[ A_offset + 0 ] + A[ A_offset + M * M - 1 ] ); - for( loop_count = 0; loop_count < M && err == 1; loop_count++ ) { - err = 0; - for( j = 0; j < M; j++ ) { -// ptr1 = matrix_adr( L, j, 0, M ); -// temp = matrix_ptr( A, j, j, M ); // element in row j column j - ptr1 = L; - ptr1_offset = j*M + 0; - temp = A[A_offset + j*M + j]; - for( i = 0; i < j; i++ ) { - v[ i ] = ptr1[ ptr1_offset + i ] * D[ i ]; - temp -= ptr1[ ptr1_offset + i ] * v[ i ]; - } - if( temp < diag_min_value ) { - /* Badly conditioned matrix: add white noise and run again */ - temp = ( loop_count + 1 ) * diag_min_value - temp; - for( i = 0; i < M; i++ ) { -// matrix_ptr( A, i, i, M ) += ( SKP_float )temp; - A[A_offset + i*M+i] += temp; - } - err = 1; - break; - } - D[ j ] = ( float )temp; - Dinv[ j ] = ( float )( 1.0f / temp ); -// matrix_ptr( L, j, j, M ) = 1.0f; - L[j*M+j] = 1.0f; - -// ptr1 = matrix_adr( A, j, 0, M ); -// ptr2 = matrix_adr( L, j + 1, 0, M); - ptr1 = A; - ptr1_offset = A_offset + j*M; - ptr2 = L; - ptr2_offset = (j+1)*M; - - for( i = j + 1; i < M; i++ ) { - temp = 0.0; - for( k = 0; k < j; k++ ) { - temp += ptr2[ ptr2_offset + k ] * v[ k ]; - } -// matrix_ptr( L, i, j, M ) = ( SKP_float )( ( ptr1[ i ] - temp ) * Dinv[ j ] ); - L[i*M+j] = (float) ( ( ptr1[ ptr1_offset + i ] - temp ) * Dinv[ j ] ); - ptr2_offset += M; // go to next column - } - } - } - assert( err == 0 ); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_sort.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_sort.java deleted file mode 100644 index f15e43224..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_sort.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Insertion sort (fast for already almost sorted arrays): - * Best case: O(n) for an already sorted array - * Worst case: O(n^2) for an inversely sorted array - * Shell short: http://en.wikipedia.org/wiki/Shell_sort - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_sort -{ - /** - * - * @param a Unsorted / Sorted vector - * @param index Index vector for the sorted elements - * @param L Vector length - * @param K Number of correctly sorted positions - */ - static void SKP_Silk_insertion_sort_increasing( - int []a, /* I/O: Unsorted / Sorted vector */ - int []index, /* O: Index vector for the sorted elements */ - final int L, /* I: Vector length */ - final int K /* I: Number of correctly sorted positions */ - ) - { - int value; - int i, j; - - /* Safety checks */ - assert( K > 0 ); - assert( L > 0 ); - assert( L >= K ); - - /* Write start indices in index vector */ - for( i = 0; i < K; i++ ) { - index[ i ] = i; - } - - /* Sort vector elements by value, increasing order */ - for( i = 1; i < K; i++ ) { - value = a[ i ]; - for( j = i - 1; ( j >= 0 ) && ( value < a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ - } - a[ j + 1 ] = value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ - } - - /* If less than L values are asked for, check the remaining values, */ - /* but only spend CPU to ensure that the K first values are correct */ - for( i = K; i < L; i++ ) { - value = a[ i ]; - if( value < a[ K - 1 ] ) { - for( j = K - 2; ( j >= 0 ) && ( value < a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ - } - a[ j + 1 ] = value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ - } - } - } - - /** - * - * @param a Unsorted / Sorted vector - * @param index Index vector for the sorted elements - * @param L Vector length - * @param K Number of correctly sorted positions - */ - static void SKP_Silk_insertion_sort_decreasing( - int []a, /* I/O: Unsorted / Sorted vector */ - int []index, /* O: Index vector for the sorted elements */ - final int L, /* I: Vector length */ - final int K /* I: Number of correctly sorted positions */ - ) - { - int value; - int i, j; - - /* Safety checks */ - assert( K > 0 ); - assert( L > 0 ); - assert( L >= K ); - - /* Write start indices in index vector */ - for( i = 0; i < K; i++ ) { - index[ i ] = i; - } - - /* Sort vector elements by value, decreasing order */ - for( i = 1; i < K; i++ ) { - value = a[ i ]; - for( j = i - 1; ( j >= 0 ) && ( value > a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ - } - a[ j + 1 ] = value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ - } - - /* If less than L values are asked for, check the remaining values, */ - /* but only spend CPU to ensure that the K first values are correct */ - for( i = K; i < L; i++ ) { - value = a[ i ]; - if( value > a[ K - 1 ] ) { - for( j = K - 2; ( j >= 0 ) && ( value > a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ - } - a[ j + 1 ] = value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ - } - } - } - - /** - * - * @param a Unsorted / Sorted vector - * @param index Index vector for the sorted elements - * @param L Vector length - * @param K Number of correctly sorted positions - */ - static void SKP_Silk_insertion_sort_decreasing_int16( - short []a, /* I/O: Unsorted / Sorted vector */ - int []index, /* O: Index vector for the sorted elements */ - final int L, /* I: Vector length */ - final int K /* I: Number of correctly sorted positions */ - ) - { - int i, j; - int value; - - /* Safety checks */ - assert( K > 0 ); - assert( L > 0 ); - assert( L >= K ); - - /* Write start indices in index vector */ - for( i = 0; i < K; i++ ) { - index[ i ] = i; - } - - /* Sort vector elements by value, decreasing order */ - for( i = 1; i < K; i++ ) { - value = a[ i ]; - for( j = i - 1; ( j >= 0 ) && ( value > a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ - } - a[ j + 1 ] = (short) value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ - } - - /* If less than L values are asked for, check the remaining values, */ - /* but only spend CPU to ensure that the K first values are correct */ - for( i = K; i < L; i++ ) { - value = a[ i ]; - if( value > a[ K - 1 ] ) { - for( j = K - 2; ( j >= 0 ) && ( value > a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ - } - a[ j + 1 ] = (short) value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ - } - } - } - - /** - * - * @param a Unsorted / Sorted vector - * @param a_offset offset of valid data. - * @param L Vector length - */ - static void SKP_Silk_insertion_sort_increasing_all_values( - int []a, /* I/O: Unsorted / Sorted vector */ - int a_offset, - final int L /* I: Vector length */ - ) - { - int value; - int i, j; - - /* Safety checks */ - Silk_typedef.SKP_assert( L > 0 ); - - /* Sort vector elements by value, increasing order */ - for( i = 1; i < L; i++ ) { - value = a[ a_offset+i ]; - for( j = i - 1; ( j >= 0 ) && ( value < a[ a_offset+j ] ); j-- ) { - a[ a_offset+j + 1 ] = a[ a_offset+j ]; /* Shift value */ - } - a[ a_offset+j + 1 ] = value; /* Write value */ - } - } - - /** - * - * @param a Unsorted / Sorted vector - * @param index Index vector for the sorted elements - * @param L Vector length - * @param K Number of correctly sorted positions - */ - static void SKP_Silk_shell_insertion_sort_increasing( - int []a, /* I/O: Unsorted / Sorted vector */ - int []index, /* O: Index vector for the sorted elements */ - final int L, /* I: Vector length */ - final int K /* I: Number of correctly sorted positions */ - ) - { - int value, inc_Q16_tmp; - int i, j, inc, idx; - - /* Safety checks */ - Silk_typedef.SKP_assert( K > 0 ); - Silk_typedef.SKP_assert( L > 0 ); - Silk_typedef.SKP_assert( L >= K ); - - /* Calculate initial step size */ - inc_Q16_tmp = ( L << 15 ); -// inc = SKP_RSHIFT( inc_Q16_tmp, 16 ); - inc = ( inc_Q16_tmp >> 16 ); - - /* Write start indices in index vector */ - for( i = 0; i < K; i++ ) { - index[ i ] = i; - } - - /* Shell sort first values */ - while( inc > 0 ) { - for( i = inc; i < K; i++ ) { - value = a[ i ]; - idx = index[ i ]; - for( j = i - inc; ( j >= 0 ) && ( value < a[ j ] ); j -= inc ) { - a[ j + inc ] = a[ j ]; /* Shift value */ - index[ j + inc ] = index[ j ]; /* Shift index */ - } - a[ j + inc ] = value; /* Write value */ - index[ j + inc ] = idx; /* Write index */ - } -// inc_Q16_tmp = SKP_SMULWB( inc_Q16_tmp, 29789 ); // 29789_Q16 = 2.2^(-1)_Q0 - inc_Q16_tmp = Silk_macros.SKP_SMULWB( inc_Q16_tmp, 29789 ); // 29789_Q16 = 2.2^(-1)_Q0 - -// inc = SKP_RSHIFT_ROUND( inc_Q16_tmp, 16 ); - inc = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( inc_Q16_tmp, 16 ); - - } - - /* If less than L values are asked for, check the remaining values, */ - /* but only spend CPU to ensure that the K first values are correct */ - /* Insertion sort remaining values */ - for( i = K; i < L; i++ ) { - value = a[ i ]; - if( value < a[ K - 1 ] ) { - for( j = K - 2; ( j >= 0 ) && ( value < a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ - } - a[ j + 1 ] = value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ - } - } - } - - /** - * - * @param a Unsorted / Sorted vector. - * @param index Index vector for the sorted elements. - * @param L Vector length. - */ - static void SKP_Silk_shell_sort_increasing_all_values( - int []a, /* I/O: Unsorted / Sorted vector */ - int []index, /* O: Index vector for the sorted elements */ - final int L /* I: Vector length */ - ) - { - int value, inc_Q16_tmp; - int i, j, inc, idx; - - /* Safety checks */ - Silk_typedef.SKP_assert( L > 0 ); - - /* Calculate initial step size */ -// inc_Q16_tmp = SKP_LSHIFT( (int)L, 15 ); - inc_Q16_tmp = ( L << 15 ); -// inc = SKP_RSHIFT( inc_Q16_tmp, 16 ); - inc = ( inc_Q16_tmp >> 16 ); - - - /* Write start indices in index vector */ - for( i = 0; i < L; i++ ) { - index[ i ] = i; - } - - /* Sort vector elements by value, increasing order */ - while( inc > 0 ) { - for( i = inc; i < L; i++ ) { - value = a[ i ]; - idx = index[ i ]; - for( j = i - inc; ( j >= 0 ) && ( value < a[ j ] ); j -= inc ) { - a[ j + inc ] = a[ j ]; /* Shift value */ - index[ j + inc ] = index[ j ]; /* Shift index */ - } - a[ j + inc ] = value; /* Write value */ - index[ j + inc ] = idx; /* Write index */ - } -// inc_Q16_tmp = SKP_SMULWB( inc_Q16_tmp, 29789 ); // 29789_Q16 = 2.2^(-1)_Q0 - inc_Q16_tmp = Silk_macros.SKP_SMULWB( inc_Q16_tmp, 29789 ); // 29789_Q16 = 2.2^(-1)_Q0 - -// inc = SKP_RSHIFT_ROUND( inc_Q16_tmp, 16 ); - inc = Silk_SigProc_FIX.SKP_RSHIFT_ROUND( inc_Q16_tmp, 16 ); - - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_sort_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_sort_FLP.java deleted file mode 100644 index 28b905c1b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_sort_FLP.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * Insertion sort (fast for already almost sorted arrays): - * Best case: O(n) for an already sorted array - * Worst case: O(n^2) for an inversely sorted array - * - * To be implemented: - * Shell short: http://en.wikipedia.org/wiki/Shell_sort - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_sort_FLP -{ - /** - * - * @param a Unsorted / Sorted vector - * @param a_offset - * @param index Index vector for the sorted elements - * @param L Vector length - * @param K Number of correctly sorted positions - */ - static void SKP_Silk_insertion_sort_increasing_FLP - ( - float[] a, /* I/O: Unsorted / Sorted vector */ - int a_offset, - int[] index, /* O: Index vector for the sorted elements */ - final int L, /* I: Vector length */ - final int K /* I: Number of correctly sorted positions */ - ) - { - float value; - int i, j; - - /* Safety checks */ - assert (K > 0); - assert (L > 0); - assert (L >= K); - - /* Write start indices in index vector */ - for (i = 0; i < K; i++) - { - index[i] = i; - } - - /* Sort vector elements by value, increasing order */ - for (i = 1; i < K; i++) - { - value = a[a_offset + i]; - for (j = i - 1; (j >= 0) && (value < a[a_offset + j]); j--) - { - a[a_offset + j + 1] = a[a_offset + j]; /* Shift value */ - index[j + 1] = index[j]; /* Shift index */ - } - a[a_offset + j + 1] = value; /* Write value */ - index[j + 1] = i; /* Write index */ - } - - /* If less than L values are asked check the remaining values, */ - /* but only spend CPU to ensure that the K first values are correct */ - for (i = K; i < L; i++) - { - value = a[a_offset + i]; - if (value < a[a_offset + K - 1]) - { - for (j = K - 2; (j >= 0) && (value < a[a_offset + j]); j--) - { - a[a_offset + j + 1] = a[a_offset + j]; /* Shift value */ - index[j + 1] = index[j]; /* Shift index */ - } - a[a_offset + j + 1] = value; /* Write value */ - index[j + 1] = i; /* Write index */ - } - } - } - - /** - * - * @param a Unsorted / Sorted vector. - * @param a_offset offset of valid data. - * @param index Index vector for the sorted elements. - * @param L Vector length. - * @param K Number of correctly sorted positions. - */ - static void SKP_Silk_insertion_sort_decreasing_FLP - ( - float[] a, /* I/O: Unsorted / Sorted vector */ - int a_offset, - int[] index, /* O: Index vector for the sorted elements */ - final int L, /* I: Vector length */ - final int K /* I: Number of correctly sorted positions */ - ) - { - float value; - int i, j; - - /* Safety checks */ - assert (K > 0); - assert (L > 0); - assert (L >= K); - - /* Write start indices in index vector */ - for (i = 0; i < K; i++) - { - index[i] = i; - } - - /* Sort vector elements by value, decreasing order */ - for (i = 1; i < K; i++) - { - value = a[a_offset + i]; - for (j = i - 1; (j >= 0) && (value > a[a_offset + j]); j--) - { - a[a_offset + j + 1] = a[a_offset + j]; /* Shift value */ - index[j + 1] = index[j]; /* Shift index */ - } - a[a_offset + j + 1] = value; /* Write value */ - index[j + 1] = i; /* Write index */ - } - - /* If less than L values are asked check the remaining values, */ - /* but only spend CPU to ensure that the K first values are correct */ - for (i = K; i < L; i++) - { - value = a[a_offset + i]; - if (value > a[a_offset + K - 1]) - { - for (j = K - 2; (j >= 0) && (value > a[a_offset + j]); j--) - { - a[a_offset + j + 1] = a[a_offset + j]; /* Shift value */ - index[j + 1] = index[j]; /* Shift index */ - } - a[a_offset + j + 1] = value; /* Write value */ - index[j + 1] = i; /* Write index */ - } - } - } - - /** - * - * @param a Unsorted / Sorted vector - * @param a_offset offset of valid data. - * @param L Vector length - */ - static void SKP_Silk_insertion_sort_increasing_all_values_FLP - ( - float[] a, /* I/O: Unsorted / Sorted vector */ - int a_offset, - final int L /* I: Vector length */ - ) - { - float value; - int i, j; - - /* Safety checks */ - assert (L > 0); - - /* Sort vector elements by value, increasing order */ - for (i = 1; i < L; i++) - { - value = a[a_offset + i]; - for (j = i - 1; (j >= 0) && (value < a[a_offset + j]); j--) - { - a[a_offset + j + 1] = a[a_offset + j]; /* Shift value */ - } - a[a_offset + j + 1] = value; /* Write value */ - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_structs.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_structs.java deleted file mode 100644 index 8957614ef..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_structs.java +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -import java.util.*; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_structs -{ - -} - -/** - * Noise shaping quantization state. - * - * @author Jing Dai - * @author Dingxin Xu - */ -class SKP_Silk_nsq_state implements Cloneable -{ - short[] xq = new short[2 * Silk_define.MAX_FRAME_LENGTH]; /* Buffer for quantized output signal */ - int[] sLTP_shp_Q10 = new int[ 2 * Silk_define.MAX_FRAME_LENGTH ]; - int[] sLPC_Q14 = new int[ Silk_define.MAX_FRAME_LENGTH / Silk_define.NB_SUBFR + Silk_define.MAX_LPC_ORDER ]; - int[] sAR2_Q14 = new int[ Silk_define.SHAPE_LPC_ORDER_MAX ]; - int sLF_AR_shp_Q12; - int lagPrev; - int sLTP_buf_idx; - int sLTP_shp_buf_idx; - int rand_seed; - int prev_inv_gain_Q16; - int rewhite_flag; - - /** - * override clone mthod. - */ - //TODO: - public Object clone() - { - SKP_Silk_nsq_state clone = null; - try { - clone = (SKP_Silk_nsq_state) super.clone(); - } catch (CloneNotSupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return clone; - } - - /** - * set all fields of the instance to zero - */ - public void memZero() - { - Arrays.fill(this.sAR2_Q14, 0); - Arrays.fill(this.sLPC_Q14, 0); - Arrays.fill(this.sLTP_shp_Q10, 0); - Arrays.fill(this.xq, (short)0); - - this.lagPrev = 0; - this.prev_inv_gain_Q16 = 0; - this.rand_seed = 0; - this.rewhite_flag = 0; - this.sLF_AR_shp_Q12 = 0; - this.sLTP_buf_idx = 0; - this.sLTP_shp_buf_idx = 0; - } -}/* FIX*/ - -/** - * Class for Low BitRate Redundant (LBRR) information. - * - * @author Jing Dai - * @author Dingxin Xu - */ -class SKP_SILK_LBRR_struct -{ - byte[] payload = new byte[Silk_define.MAX_ARITHM_BYTES]; - int nBytes; /* Number of bytes in payload */ - int usage; /* Tells how the payload should be used as FEC */ - - public void memZero() - { - this.nBytes = 0; - this.usage = 0; - Arrays.fill(this.payload, (byte)0); - } -} - -/** - * VAD state. - * - * @author Jing Dai - * @author Dingxin Xu - */ -class SKP_Silk_VAD_state -{ - int[] AnaState = new int[ 2 ]; /* Analysis filterbank state: 0-8 kHz */ - int[] AnaState1 = new int[ 2 ]; /* Analysis filterbank state: 0-4 kHz */ - int[] AnaState2 = new int[ 2 ]; /* Analysis filterbank state: 0-2 kHz */ - int[] XnrgSubfr = new int[ Silk_define.VAD_N_BANDS ]; /* Subframe energies */ - int[] NrgRatioSmth_Q8 = new int[ Silk_define.VAD_N_BANDS ]; /* Smoothed energy level in each band */ - short HPstate; /* State of differentiator in the lowest band */ - int[] NL = new int[ Silk_define.VAD_N_BANDS ]; /* Noise energy level in each band */ - int[] inv_NL = new int[ Silk_define.VAD_N_BANDS ]; /* Inverse noise energy level in each band */ - int[] NoiseLevelBias = new int[ Silk_define.VAD_N_BANDS ]; /* Noise level estimator bias/offset */ - int counter; /* Frame counter used in the initial phase */ -} - -/** - * Range encoder/decoder state. - * - * @author Jing Dai - * @author Dingxin Xu - */ -class SKP_Silk_range_coder_state -{ - int bufferLength; - int bufferIx; - long base_Q32; - long range_Q16; - int error; - byte[] buffer = new byte[Silk_define.MAX_ARITHM_BYTES];/* Buffer containing payload */ -} - -/** - * Input frequency range detection struct. - * - * @author Jing Dai - * @author Dingxin Xu - */ -class SKP_Silk_detect_SWB_state -{ - int[][] S_HP_8_kHz = new int[ Silk_define.NB_SOS ][ 2 ]; /* HP filter State */ - int ConsecSmplsAboveThres; - int ActiveSpeech_ms; /* Accumulated time with active speech */ - int SWB_detected; /* Flag to indicate SWB input */ - int WB_detected; /* Flag to indicate WB input */ -} - -/** - * Variable cut-off low-pass filter state. - * - * @author Jing Dai - * @author Dingxin Xu - */ -class SKP_Silk_LP_state -{ - int[] In_LP_State = new int[ 2 ]; /* Low pass filter state */ - int transition_frame_no; /* Counter which is mapped to a cut-off frequency */ - int mode; /* Operating mode, 0: switch down, 1: switch up */ -} - -/** - * Class for one stage of MSVQ. - * - * @author Jing Dai - * @author Dingxin Xu - */ -class SKP_Silk_NLSF_CBS -{ - public SKP_Silk_NLSF_CBS(int nVectors, short[] CB_NLSF_Q15, short[] Rates_Q5) - { - this.CB_NLSF_Q15 = CB_NLSF_Q15; - this.nVectors = nVectors; - this.Rates_Q5 = Rates_Q5; - } - public SKP_Silk_NLSF_CBS(int nVectors, short[] SKP_Silk_NLSF_MSVQ_CB0_10_Q15, int Q15_offset, - short[] SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q5, int Q5_offset) - { - this.nVectors = nVectors; - this.CB_NLSF_Q15 = new short[SKP_Silk_NLSF_MSVQ_CB0_10_Q15.length-Q15_offset]; - System.arraycopy( SKP_Silk_NLSF_MSVQ_CB0_10_Q15, Q15_offset, this.CB_NLSF_Q15, 0, this.CB_NLSF_Q15.length); - this.Rates_Q5 = new short[SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q5.length - Q5_offset]; - System.arraycopy(SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q5, Q5_offset, this.Rates_Q5, 0, this.Rates_Q5.length); - } - public SKP_Silk_NLSF_CBS() - { - super(); - } - //TODO: the three fields are constant in C. - int nVectors; - short[] CB_NLSF_Q15; - short[] Rates_Q5; -} - -/** - * Class containing NLSF MSVQ codebook. - * - * @author Jing Dai - * @author Dingxin Xu - */ -class SKP_Silk_NLSF_CB_struct -{ - public SKP_Silk_NLSF_CB_struct(int nStates, SKP_Silk_NLSF_CBS[] CBStages, int[] NDeltaMin_Q15, - int[] CDF, int[][] StartPtr, int[] MiddleIx) - { - this.CBStages = CBStages; - this.CDF = CDF; - this.MiddleIx = MiddleIx; - this.NDeltaMin_Q15 = NDeltaMin_Q15; - this.nStages = nStates; - this.StartPtr = StartPtr; - - } - public SKP_Silk_NLSF_CB_struct() - { - super(); - } -//TODO: this filed is constant in C. - int nStages; - - /* Fields for (de)quantizing */ -//TODO:CBStates should be defined as an array or an object reference? - SKP_Silk_NLSF_CBS[] CBStages; - int[] NDeltaMin_Q15; - - /* Fields for arithmetic (de)coding */ - int[] CDF; - int[][] StartPtr; - int[] MiddleIx; -} - -/** - * Encoder state. - * - * @author Jing Dai - * @author Dingxin Xu - */ -class SKP_Silk_encoder_state -{ - SKP_Silk_range_coder_state sRC = new SKP_Silk_range_coder_state(); /* Range coder state */ - SKP_Silk_range_coder_state sRC_LBRR = new SKP_Silk_range_coder_state(); /* Range coder state (for low bitrate redundancy) */ - int[] In_HP_State = new int[ 2 ]; /* High pass filter state */ - SKP_Silk_LP_state sLP = new SKP_Silk_LP_state(); /* Low pass filter state */ - SKP_Silk_VAD_state sVAD = new SKP_Silk_VAD_state(); /* Voice activity detector state */ - - int LBRRprevLastGainIndex; - int prev_sigtype; - int typeOffsetPrev; /* Previous signal type and quantization offset */ - int prevLag; - int prev_lagIndex; - int API_fs_Hz; /* API sampling frequency (Hz) */ - int prev_API_fs_Hz; /* Previous API sampling frequency (Hz) */ - int maxInternal_fs_kHz; /* Maximum internal sampling frequency (kHz) */ - int fs_kHz; /* Internal sampling frequency (kHz) */ - int fs_kHz_changed; /* Did we switch yet? */ - int frame_length; /* Frame length (samples) */ - int subfr_length; /* Subframe length (samples) */ - int la_pitch; /* Look-ahead for pitch analysis (samples) */ - int la_shape; /* Look-ahead for noise shape analysis (samples) */ - int TargetRate_bps; /* Target bitrate (bps) */ - int PacketSize_ms; /* Number of milliseconds to put in each packet */ - int PacketLoss_perc; /* Packet loss rate measured by farend */ - int frameCounter; - int Complexity; /* Complexity setting: 0-> low; 1-> medium; 2->high */ - int nStatesDelayedDecision; /* Number of states in delayed decision quantization */ - int useInterpolatedNLSFs; /* Flag for using NLSF interpolation */ - int shapingLPCOrder; /* Filter order for noise shaping filters */ - int predictLPCOrder; /* Filter order for prediction filters */ - int pitchEstimationComplexity; /* Complexity level for pitch estimator */ - int pitchEstimationLPCOrder; /* Whitening filter order for pitch estimator */ - int LTPQuantLowComplexity; /* Flag for low complexity LTP quantization */ - int NLSF_MSVQ_Survivors; /* Number of survivors in NLSF MSVQ */ - int first_frame_after_reset; /* Flag for deactivating NLSF interp. and fluc. reduction after resets */ - - /* Input/output buffering */ - short[] inputBuf = new short[ Silk_define.MAX_FRAME_LENGTH ]; /* buffer containin input signal */ - int inputBufIx; - int nFramesInPayloadBuf; /* number of frames sitting in outputBuf */ - int nBytesInPayloadBuf; /* number of bytes sitting in outputBuf */ - - /* Parameters For LTP scaling Control */ - int frames_since_onset; - - SKP_Silk_NLSF_CB_struct[] psNLSF_CB = new SKP_Silk_NLSF_CB_struct[ 2 ]; /* Pointers to voiced/unvoiced NLSF codebooks */ - - /* Struct for Inband LBRR */ - SKP_SILK_LBRR_struct[] LBRR_buffer = new SKP_SILK_LBRR_struct[ Silk_define.MAX_LBRR_DELAY ]; - /* - * LBRR_buffer is an array of references, which has to be created manually. - */ - { - for(int LBRR_bufferIni_i=0; LBRR_bufferIni_i>> 2 ); - nrg = (int)( ((nrg)&0xFFFFFFFFL) >>> 2 ); - shft = 2; - break; - } - } - for( ; i < len; i += 2 ) { - /* Load two values at once */ - in32 = x[x_offset + i]; - nrg_tmp = Silk_macros.SKP_SMULBB( in32, in32 ); - nrg_tmp = Silk_SigProc_FIX.SKP_SMLATT_ovflw( nrg_tmp, in32, in32 ); -// TODO: ??? -// nrg = (int)SKP_ADD_RSHIFT_uint( nrg, (SKP_uint32)nrg_tmp, shft ); - nrg = nrg + (nrg_tmp>>>shft); -//or nrg = (int)( nrg + (((long)nrg_tmp)&0xFFFFFFFFL) >>> shft ); - - if( nrg < 0 ) { - /* Scale down */ - nrg = ( nrg >>> 2 ); - shft += 2; - } - } - if( i == len ) { - /* One sample left to process */ - nrg_tmp = Silk_macros.SKP_SMULBB( x[ x_offset + i ], x[ x_offset + i ] ); -//TODO: -// nrg = (int)SKP_ADD_RSHIFT_uint( nrg, nrg_tmp, shft ); - nrg = ( nrg + (nrg_tmp >>> shft) ); - } - - /* Make sure to have at least one extra leading zero (two leading zeros in total) */ - if( (nrg & 0xC0000000) != 0 ) { - nrg = ( nrg >>> 2 ); - shft += 2; - } - - /* Output arguments */ - shift[0] = shft; - energy[0] = nrg; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables.java deleted file mode 100644 index 9b308c3e4..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -public class Silk_tables -{ - static final int PITCH_EST_MAX_LAG_MS = 18; /* 18 ms -> 56 Hz */ - static final int PITCH_EST_MIN_LAG_MS = 2; /* 2 ms -> 500 Hz */ - - /** - * Copies the specified range of the specified array into a new array. The - * initial index of the range (from) must lie between zero and - * original.length, inclusive. The value at original[from] - * is placed into the initial element of the copy (unless - * from == original.length or from == to). Values from - * subsequent elements in the original array are placed into subsequent - * elements in the copy. The final index of the range (to), which - * must be greater than or equal to from, may be greater than - * original.length, in which case 0 is placed in all - * elements of the copy whose index is greater than or equal to - * original.length - from. The length of the returned array will be - * to - from. - * - * @param original the array from which a range is to be copied - * @param from the initial index of the range to be copied, inclusive - * @param to the final index of the range to be copied, exclusive. (This - * index may lie outside the array.) - * @return a new array containing the specified range from the original - * array, truncated or padded with zeros to obtain the required length - * @throws ArrayIndexOutOfBoundsException if from < 0 or - * from > original.length() - * @throws IllegalArgumentException if from > to - * @throws NullPointerException if original is null - */ - static int[] copyOfRange(int[] original, int from, int to) - { - if ((from < 0) || (from > original.length)) - throw new ArrayIndexOutOfBoundsException(from); - if (from > to) - throw new IllegalArgumentException("to"); - - int length = to - from; - int[] copy = new int[length]; - - for (int c = 0, o = from; c < length; c++, o++) - copy[c] = (o < original.length) ? original[o] : 0; - - return copy; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_LTP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_LTP.java deleted file mode 100644 index cd31cb2dc..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_LTP.java +++ /dev/null @@ -1,530 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_tables_LTP -{ - static int[] SKP_Silk_LTP_per_index_CDF = { - 0, 20992, 40788, 65535 - }; - - static final int SKP_Silk_LTP_per_index_CDF_offset = 1; - - static int[] SKP_Silk_LTP_gain_CDF_0 = { - 0, 49380, 54463, 56494, 58437, 60101, 61683, 62985, - 64066, 64823, 65535 - }; - - static int[] SKP_Silk_LTP_gain_CDF_1 = { - 0, 25290, 30654, 35710, 40386, 42937, 45250, 47459, - 49411, 51348, 52974, 54517, 55976, 57423, 58865, 60285, - 61667, 62895, 63827, 64724, 65535 - }; - - static int[] SKP_Silk_LTP_gain_CDF_2 = { - 0, 4958, 9439, 13581, 17638, 21651, 25015, 28025, - 30287, 32406, 34330, 36240, 38130, 39790, 41281, 42764, - 44229, 45676, 47081, 48431, 49675, 50849, 51932, 52966, - 53957, 54936, 55869, 56789, 57708, 58504, 59285, 60043, - 60796, 61542, 62218, 62871, 63483, 64076, 64583, 65062, - 65535 - }; - - static int[] SKP_Silk_LTP_gain_CDF_offsets = { - 1, 3, 10 - }; - - static final int SKP_Silk_LTP_gain_middle_avg_RD_Q14 = 11010; - - static short[] SKP_Silk_LTP_gain_BITS_Q6_0 = { - 26, 236, 321, 325, 339, 344, 362, 379, - 412, 418 - }; - - static short[] SKP_Silk_LTP_gain_BITS_Q6_1 = { - 88, 231, 237, 244, 300, 309, 313, 324, - 325, 341, 346, 351, 352, 352, 354, 356, - 367, 393, 396, 406 - }; - - static short[] SKP_Silk_LTP_gain_BITS_Q6_2 = { - 238, 248, 255, 257, 258, 274, 284, 311, - 317, 326, 326, 327, 339, 349, 350, 351, - 352, 355, 358, 366, 371, 379, 383, 387, - 388, 393, 394, 394, 407, 409, 412, 412, - 413, 422, 426, 432, 434, 449, 454, 455 - }; - - static int[][] SKP_Silk_LTP_gain_CDF_ptrs = { - SKP_Silk_LTP_gain_CDF_0, - SKP_Silk_LTP_gain_CDF_1, - SKP_Silk_LTP_gain_CDF_2 - }; - - static short[][] SKP_Silk_LTP_gain_BITS_Q6_ptrs = { - SKP_Silk_LTP_gain_BITS_Q6_0, - SKP_Silk_LTP_gain_BITS_Q6_1, - SKP_Silk_LTP_gain_BITS_Q6_2 - }; - - static short[][] SKP_Silk_LTP_gain_vq_0_Q14 = - { - { - 594, 984, 2840, 1021, 669 - }, - { - 10, 35, 304, -1, 23 - }, - { - -694, 1923, 4603, 2975, 2335 - }, - { - 2437, 3176, 3778, 1940, 481 - }, - { - 214, -46, 7870, 4406, -521 - }, - { - -896, 4818, 8501, 1623, -887 - }, - { - -696, 3178, 6480, -302, 1081 - }, - { - 517, 599, 1002, 567, 560 - }, - { - -2075, -834, 4712, -340, 896 - }, - { - 1435, -644, 3993, -612, -2063 - } - }; - - static short[][] SKP_Silk_LTP_gain_vq_1_Q14 = - { - { - 1655, 2918, 5001, 3010, 1775 - }, - { - 113, 198, 856, 176, 178 - }, - { - -843, 2479, 7858, 5371, 574 - }, - { - 59, 5356, 7648, 2850, -315 - }, - { - 3840, 4851, 6527, 1583, -1233 - }, - { - 1620, 1760, 2330, 1876, 2045 - }, - { - -545, 1854, 11792, 1547, -307 - }, - { - -604, 689, 5369, 5074, 4265 - }, - { - 521, -1331, 9829, 6209, -1211 - }, - { - -1315, 6747, 9929, -1410, 546 - }, - { - 117, -144, 2810, 1649, 5240 - }, - { - 5392, 3476, 2425, -38, 633 - }, - { - 14, -449, 5274, 3547, -171 - }, - { - -98, 395, 9114, 1676, 844 - }, - { - -908, 3843, 8861, -957, 1474 - }, - { - 396, 6747, 5379, -329, 1269 - }, - { - -335, 2830, 4281, 270, -54 - }, - { - 1502, 5609, 8958, 6045, 2059 - }, - { - -370, 479, 5267, 5726, 1174 - }, - { - 5237, -1144, 6510, 455, 512 - } - }; - - static short[][] SKP_Silk_LTP_gain_vq_2_Q14 = - { - { - -278, 415, 9345, 7106, -431 - }, - { - -1006, 3863, 9524, 4724, -871 - }, - { - -954, 4624, 11722, 973, -300 - }, - { - -117, 7066, 8331, 1959, -901 - }, - { - 593, 3412, 6070, 4914, 1567 - }, - { - 54, -51, 12618, 4228, -844 - }, - { - 3157, 4822, 5229, 2313, 717 - }, - { - -244, 1161, 14198, 779, 69 - }, - { - -1218, 5603, 12894, -2301, 1001 - }, - { - -132, 3960, 9526, 577, 1806 - }, - { - -1633, 8815, 10484, -2452, 895 - }, - { - 235, 450, 1243, 667, 437 - }, - { - 959, -2630, 10897, 8772, -1852 - }, - { - 2420, 2046, 8893, 4427, -1569 - }, - { - 23, 7091, 8356, -1285, 1508 - }, - { - -1133, 835, 7662, 6043, 2800 - }, - { - 439, 391, 11016, 2253, 1362 - }, - { - -1020, 2876, 13436, 4015, -3020 - }, - { - 1060, -2690, 13512, 5565, -1394 - }, - { - -1420, 8007, 11421, -152, -1672 - }, - { - -893, 2895, 15434, -1490, 159 - }, - { - -1054, 428, 12208, 8538, -3344 - }, - { - 1772, -1304, 7593, 6185, 561 - }, - { - 525, -1207, 6659, 11151, -1170 - }, - { - 439, 2667, 4743, 2359, 5515 - }, - { - 2951, 7432, 7909, -230, -1564 - }, - { - -72, 2140, 5477, 1391, 1580 - }, - { - 476, -1312, 15912, 2174, -1027 - }, - { - 5737, 441, 2493, 2043, 2757 - }, - { - 228, -43, 1803, 6663, 7064 - }, - { - 4596, 9182, 1917, -200, 203 - }, - { - -704, 12039, 5451, -1188, 542 - }, - { - 1782, -1040, 10078, 7513, -2767 - }, - { - -2626, 7747, 9019, 62, 1710 - }, - { - 235, -233, 2954, 10921, 1947 - }, - { - 10854, 2814, 1232, -111, 222 - }, - { - 2267, 2778, 12325, 156, -1658 - }, - { - -2950, 8095, 16330, 268, -3626 - }, - { - 67, 2083, 7950, -80, -2432 - }, - { - 518, -66, 1718, 415, 11435 - } - }; - - private static final short[] SKP_Silk_LTP_gain_vq_0_Q14_00 = - { -// { - 594, 984, 2840, 1021, 669, -// }, -// { - 10, 35, 304, -1, 23, -// }, -// { - -694, 1923, 4603, 2975, 2335, -// }, -// { - 2437, 3176, 3778, 1940, 481, -// }, -// { - 214, -46, 7870, 4406, -521, -// }, -// { - -896, 4818, 8501, 1623, -887, -// }, -// { - -696, 3178, 6480, -302, 1081, -// }, -// { - 517, 599, 1002, 567, 560, -// }, -// { - -2075, -834, 4712, -340, 896, -// }, -// { - 1435, -644, 3993, -612, -2063 -// } - }; - private static final short[] SKP_Silk_LTP_gain_vq_1_Q14_00 = - { -// { - 1655, 2918, 5001, 3010, 1775, -// }, -// { - 113, 198, 856, 176, 178, -// }, -// { - -843, 2479, 7858, 5371, 574, -// }, -// { - 59, 5356, 7648, 2850, -315, -// }, -// { - 3840, 4851, 6527, 1583, -1233, -// }, -// { - 1620, 1760, 2330, 1876, 2045, -// }, -// { - -545, 1854, 11792, 1547, -307, -// }, -// { - -604, 689, 5369, 5074, 4265, -// }, -// { - 521, -1331, 9829, 6209, -1211, -// }, -// { - -1315, 6747, 9929, -1410, 546, -// }, -// { - 117, -144, 2810, 1649, 5240, -// }, -// { - 5392, 3476, 2425, -38, 633, -// }, -// { - 14, -449, 5274, 3547, -171, -// }, -// { - -98, 395, 9114, 1676, 844, -// }, -// { - -908, 3843, 8861, -957, 1474, -// }, -// { - 396, 6747, 5379, -329, 1269, -// }, -// { - -335, 2830, 4281, 270, -54, -// }, -// { - 1502, 5609, 8958, 6045, 2059, -// }, -// { - -370, 479, 5267, 5726, 1174, -// }, -// { - 5237, -1144, 6510, 455, 512 -// } - }; - private static final short[] SKP_Silk_LTP_gain_vq_2_Q14_00 = - { -// { - -278, 415, 9345, 7106, -431, -// }, -// { - -1006, 3863, 9524, 4724, -871, -// }, -// { - -954, 4624, 11722, 973, -300, -// }, -// { - -117, 7066, 8331, 1959, -901, -// }, -// { - 593, 3412, 6070, 4914, 1567, -// }, -// { - 54, -51, 12618, 4228, -844, -// }, -// { - 3157, 4822, 5229, 2313, 717, -// }, -// { - -244, 1161, 14198, 779, 69, -// }, -// { - -1218, 5603, 12894, -2301, 1001, -// }, -// { - -132, 3960, 9526, 577, 1806, -// }, -// { - -1633, 8815, 10484, -2452, 895, -// }, -// { - 235, 450, 1243, 667, 437, -// }, -// { - 959, -2630, 10897, 8772, -1852, -// }, -// { - 2420, 2046, 8893, 4427, -1569, -// }, -// { - 23, 7091, 8356, -1285, 1508, -// }, -// { - -1133, 835, 7662, 6043, 2800, -// }, -// { - 439, 391, 11016, 2253, 1362, -// }, -// { - -1020, 2876, 13436, 4015, -3020, -// }, -// { - 1060, -2690, 13512, 5565, -1394, -// }, -// { - -1420, 8007, 11421, -152, -1672, -// }, -// { - -893, 2895, 15434, -1490, 159, -// }, -// { - -1054, 428, 12208, 8538, -3344, -// }, -// { - 1772, -1304, 7593, 6185, 561, -// }, -// { - 525, -1207, 6659, 11151, -1170, -// }, -// { - 439, 2667, 4743, 2359, 5515, -// }, -// { - 2951, 7432, 7909, -230, -1564, -// }, -// { - -72, 2140, 5477, 1391, 1580, -// }, -// { - 476, -1312, 15912, 2174, -1027, -// }, -// { - 5737, 441, 2493, 2043, 2757, -// }, -// { - 228, -43, 1803, 6663, 7064, -// }, -// { - 4596, 9182, 1917, -200, 203, -// }, -// { - -704, 12039, 5451, -1188, 542, -// }, -// { - 1782, -1040, 10078, 7513, -2767, -// }, -// { - -2626, 7747, 9019, 62, 1710, -// }, -// { - 235, -233, 2954, 10921, 1947, -// }, -// { - 10854, 2814, 1232, -111, 222, -// }, -// { - 2267, 2778, 12325, 156, -1658, -// }, -// { - -2950, 8095, 16330, 268, -3626, -// }, -// { - 67, 2083, 7950, -80, -2432, -// }, -// { - 518, -66, 1718, 415, 11435 -// } - }; - - static short[][] SKP_Silk_LTP_vq_ptrs_Q14 = { - SKP_Silk_LTP_gain_vq_0_Q14_00, - SKP_Silk_LTP_gain_vq_1_Q14_00, - SKP_Silk_LTP_gain_vq_2_Q14_00 - }; - - static int[] SKP_Silk_LTP_vq_sizes = { - 10, 20, 40 - }; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB0_10.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB0_10.java deleted file mode 100644 index 3f1712a75..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB0_10.java +++ /dev/null @@ -1,885 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * This file has been automatically generated - * ROM usage: 0.29 + 2.66 kB - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_tables_NLSF_CB0_10 -{ - static final int NLSF_MSVQ_CB0_10_STAGES = 6; - static final int NLSF_MSVQ_CB0_10_VECTORS = 120; - - static final int[] SKP_Silk_NLSF_MSVQ_CB0_10_CDF = - { - 0, - 2658, - 4420, - 6107, - 7757, - 9408, - 10955, - 12502, - 13983, - 15432, - 16882, - 18331, - 19750, - 21108, - 22409, - 23709, - 25010, - 26256, - 27501, - 28747, - 29965, - 31158, - 32351, - 33544, - 34736, - 35904, - 36997, - 38091, - 39185, - 40232, - 41280, - 42327, - 43308, - 44290, - 45271, - 46232, - 47192, - 48132, - 49032, - 49913, - 50775, - 51618, - 52462, - 53287, - 54095, - 54885, - 55675, - 56449, - 57222, - 57979, - 58688, - 59382, - 60076, - 60726, - 61363, - 61946, - 62505, - 63052, - 63543, - 63983, - 64396, - 64766, - 65023, - 65279, - 65535, - 0, - 4977, - 9542, - 14106, - 18671, - 23041, - 27319, - 31596, - 35873, - 39969, - 43891, - 47813, - 51652, - 55490, - 59009, - 62307, - 65535, - 0, - 8571, - 17142, - 25529, - 33917, - 42124, - 49984, - 57844, - 65535, - 0, - 8732, - 17463, - 25825, - 34007, - 42189, - 50196, - 58032, - 65535, - 0, - 8948, - 17704, - 25733, - 33762, - 41791, - 49821, - 57678, - 65535, - 0, - 4374, - 8655, - 12936, - 17125, - 21313, - 25413, - 29512, - 33611, - 37710, - 41809, - 45820, - 49832, - 53843, - 57768, - 61694, - 65535 - }; - static private int [] SKP_Silk_NLSF_MSVQ_CB0_10_CDF_0 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_10_CDF, 0, SKP_Silk_NLSF_MSVQ_CB0_10_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_10_CDF_65 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_10_CDF, 65, SKP_Silk_NLSF_MSVQ_CB0_10_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_10_CDF_82 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_10_CDF, 82, SKP_Silk_NLSF_MSVQ_CB0_10_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_10_CDF_91 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_10_CDF, 91, SKP_Silk_NLSF_MSVQ_CB0_10_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_10_CDF_100 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_10_CDF, 100, SKP_Silk_NLSF_MSVQ_CB0_10_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_10_CDF_109 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_10_CDF, 109, SKP_Silk_NLSF_MSVQ_CB0_10_CDF.length); - - static final int[][] SKP_Silk_NLSF_MSVQ_CB0_10_CDF_start_ptr = - { - SKP_Silk_NLSF_MSVQ_CB0_10_CDF_0, - SKP_Silk_NLSF_MSVQ_CB0_10_CDF_65, - SKP_Silk_NLSF_MSVQ_CB0_10_CDF_82, - SKP_Silk_NLSF_MSVQ_CB0_10_CDF_91, - SKP_Silk_NLSF_MSVQ_CB0_10_CDF_100, - SKP_Silk_NLSF_MSVQ_CB0_10_CDF_109 - }; - - static final int[] SKP_Silk_NLSF_MSVQ_CB0_10_CDF_middle_idx = - { - 23, - 8, - 5, - 5, - 5, - 9 - }; - - static final short[] SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q5 = - { - 148, 167, - 169, 170, - 170, 173, - 173, 175, - 176, 176, - 176, 177, - 179, 181, - 181, 181, - 183, 183, - 183, 184, - 185, 185, - 185, 185, - 186, 189, - 189, 189, - 191, 191, - 191, 194, - 194, 194, - 195, 195, - 196, 198, - 199, 200, - 201, 201, - 202, 203, - 204, 204, - 205, 205, - 206, 209, - 210, 210, - 213, 214, - 218, 220, - 221, 226, - 231, 234, - 239, 256, - 256, 256, - 119, 123, - 123, 123, - 125, 126, - 126, 126, - 128, 130, - 130, 131, - 131, 135, - 138, 139, - 94, 94, - 95, 95, - 96, 98, - 98, 99, - 93, 93, - 95, 96, - 96, 97, - 98, 100, - 92, 93, - 97, 97, - 97, 97, - 98, 98, - 125, 126, - 126, 127, - 127, 128, - 128, 128, - 128, 128, - 129, 129, - 129, 130, - 130, 131 - }; - - static final int[] SKP_Silk_NLSF_MSVQ_CB0_10_ndelta_min_Q15 = - { - 563, - 3, - 22, - 20, - 3, - 3, - 132, - 119, - 358, - 86, - 964 - }; - - static final short[] SKP_Silk_NLSF_MSVQ_CB0_10_Q15 = - { - 2210, 4023, - 6981, 9260, - 12573, 15687, - 19207, 22383, - 25981, 29142, - 3285, 4172, - 6116, 10856, - 15289, 16826, - 19701, 22010, - 24721, 29313, - 1554, 2511, - 6577, 10337, - 13837, 16511, - 20086, 23214, - 26480, 29464, - 3062, 4017, - 5771, 10037, - 13365, 14952, - 20140, 22891, - 25229, 29603, - 2085, 3457, - 5934, 8718, - 11501, 13670, - 17997, 21817, - 24935, 28745, - 2776, 4093, - 6421, 10413, - 15111, 16806, - 20825, 23826, - 26308, 29411, - 2717, 4034, - 5697, 8463, - 14301, 16354, - 19007, 23413, - 25812, 28506, - 2872, 3702, - 5881, 11034, - 17141, 18879, - 21146, 23451, - 25817, 29600, - 2999, 4015, - 7357, 11219, - 12866, 17307, - 20081, 22644, - 26774, 29107, - 2942, 3866, - 5918, 11915, - 13909, 16072, - 20453, 22279, - 27310, 29826, - 2271, 3527, - 6606, 9729, - 12943, 17382, - 20224, 22345, - 24602, 28290, - 2207, 3310, - 5844, 9339, - 11141, 15651, - 18576, 21177, - 25551, 28228, - 3963, 4975, - 6901, 11588, - 13466, 15577, - 19231, 21368, - 25510, 27759, - 2749, 3549, - 6966, 13808, - 15653, 17645, - 20090, 22599, - 26467, 28537, - 2126, 3504, - 5109, 9954, - 12550, 14620, - 19703, 21687, - 26457, 29106, - 3966, 5745, - 7442, 9757, - 14468, 16404, - 19135, 23048, - 25375, 28391, - 3197, 4751, - 6451, 9298, - 13038, 14874, - 17962, 20627, - 23835, 28464, - 3195, 4081, - 6499, 12252, - 14289, 16040, - 18357, 20730, - 26980, 29309, - 1533, 2471, - 4486, 7796, - 12332, 15758, - 19567, 22298, - 25673, 29051, - 2002, 2971, - 4985, 8083, - 13181, 15435, - 18237, 21517, - 24595, 28351, - 3808, 4925, - 6710, 10201, - 12011, 14300, - 18457, 20391, - 26525, 28956, - 2281, 3418, - 4979, 8726, - 15964, 18104, - 20250, 22771, - 25286, 28954, - 3051, 5479, - 7290, 9848, - 12744, 14503, - 18665, 23684, - 26065, 28947, - 2364, 3565, - 5502, 9621, - 14922, 16621, - 19005, 20996, - 26310, 29302, - 4093, 5212, - 6833, 9880, - 16303, 18286, - 20571, 23614, - 26067, 29128, - 2941, 3996, - 6038, 10638, - 12668, 14451, - 16798, 19392, - 26051, 28517, - 3863, 5212, - 7019, 9468, - 11039, 13214, - 19942, 22344, - 25126, 29539, - 4615, 6172, - 7853, 10252, - 12611, 14445, - 19719, 22441, - 24922, 29341, - 3566, 4512, - 6985, 8684, - 10544, 16097, - 18058, 22475, - 26066, 28167, - 4481, 5489, - 7432, 11414, - 13191, 15225, - 20161, 22258, - 26484, 29716, - 3320, 4320, - 6621, 9867, - 11581, 14034, - 21168, 23210, - 26588, 29903, - 3794, 4689, - 6916, 8655, - 10143, 16144, - 19568, 21588, - 27557, 29593, - 2446, 3276, - 5918, 12643, - 16601, 18013, - 21126, 23175, - 27300, 29634, - 2450, 3522, - 5437, 8560, - 15285, 19911, - 21826, 24097, - 26567, 29078, - 2580, 3796, - 5580, 8338, - 9969, 12675, - 18907, 22753, - 25450, 29292, - 3325, 4312, - 6241, 7709, - 9164, 14452, - 21665, 23797, - 27096, 29857, - 3338, 4163, - 7738, 11114, - 12668, 14753, - 16931, 22736, - 25671, 28093, - 3840, 4755, - 7755, 13471, - 15338, 17180, - 20077, 22353, - 27181, 29743, - 2504, 4079, - 8351, 12118, - 15046, 18595, - 21684, 24704, - 27519, 29937, - 5234, 6342, - 8267, 11821, - 15155, 16760, - 20667, 23488, - 25949, 29307, - 2681, 3562, - 6028, 10827, - 18458, 20458, - 22303, 24701, - 26912, 29956, - 3374, 4528, - 6230, 8256, - 9513, 12730, - 18666, 20720, - 26007, 28425, - 2731, 3629, - 8320, 12450, - 14112, 16431, - 18548, 22098, - 25329, 27718, - 3481, 4401, - 7321, 9319, - 11062, 13093, - 15121, 22315, - 26331, 28740, - 3577, 4945, - 6669, 8792, - 10299, 12645, - 19505, 24766, - 26996, 29634, - 4058, 5060, - 7288, 10190, - 11724, 13936, - 15849, 18539, - 26701, 29845, - 4262, 5390, - 7057, 8982, - 10187, 15264, - 20480, 22340, - 25958, 28072, - 3404, 4329, - 6629, 7946, - 10121, 17165, - 19640, 22244, - 25062, 27472, - 3157, 4168, - 6195, 9319, - 10771, 13325, - 15416, 19816, - 24672, 27634, - 2503, 3473, - 5130, 6767, - 8571, 14902, - 19033, 21926, - 26065, 28728, - 4133, 5102, - 7553, 10054, - 11757, 14924, - 17435, 20186, - 23987, 26272, - 4972, 6139, - 7894, 9633, - 11320, 14295, - 21737, 24306, - 26919, 29907, - 2958, 3816, - 6851, 9204, - 10895, 18052, - 20791, 23338, - 27556, 29609, - 5234, 6028, - 8034, 10154, - 11242, 14789, - 18948, 20966, - 26585, 29127, - 5241, 6838, - 10526, 12819, - 14681, 17328, - 19928, 22336, - 26193, 28697, - 3412, 4251, - 5988, 7094, - 9907, 18243, - 21669, 23777, - 26969, 29087, - 2470, 3217, - 7797, 15296, - 17365, 19135, - 21979, 24256, - 27322, 29442, - 4939, 5804, - 8145, 11809, - 13873, 15598, - 17234, 19423, - 26476, 29645, - 5051, 6167, - 8223, 9655, - 12159, 17995, - 20464, 22832, - 26616, 28462, - 4987, 5907, - 9319, 11245, - 13132, 15024, - 17485, 22687, - 26011, 28273, - 5137, 6884, - 11025, 14950, - 17191, 19425, - 21807, 24393, - 26938, 29288, - 7057, 7884, - 9528, 10483, - 10960, 14811, - 19070, 21675, - 25645, 28019, - 6759, 7160, - 8546, 11779, - 12295, 13023, - 16627, 21099, - 24697, 28287, - 3863, 9762, - 11068, 11445, - 12049, 13960, - 18085, 21507, - 25224, 28997, - 397, 335, - 651, 1168, - 640, 765, - 465, 331, - 214, -194, - -578, -647, - -657, 750, - 564, 613, - 549, 630, - 304, -52, - 828, 922, - 443, 111, - 138, 124, - 169, 14, - 144, 83, - 132, 58, - -413, -752, - 869, 336, - 385, 69, - 56, 830, - -227, -266, - -368, -440, - -1195, 163, - 126, -228, - 802, 156, - 188, 120, - 376, 59, - -358, -558, - -1326, -254, - -202, -789, - 296, 92, - -70, -129, - -718, -1135, - 292, -29, - -631, 487, - -157, -153, - -279, 2, - -419, -342, - -34, -514, - -799, -1571, - -687, -609, - -546, -130, - -215, -252, - -446, -574, - -1337, 207, - -72, 32, - 103, -642, - 942, 733, - 187, 29, - -211, -814, - 143, 225, - 20, 24, - -268, -377, - 1623, 1133, - 667, 164, - 307, 366, - 187, 34, - 62, -313, - -832, -1482, - -1181, 483, - -42, -39, - -450, -1406, - -587, -52, - -760, 334, - 98, -60, - -500, -488, - -1058, 299, - 131, -250, - -251, -703, - 1037, 568, - -413, -265, - 1687, 573, - 345, 323, - 98, 61, - -102, 31, - 135, 149, - 617, 365, - -39, 34, - -611, 1201, - 1421, 736, - -414, -393, - -492, -343, - -316, -532, - 528, 172, - 90, 322, - -294, -319, - -541, 503, - 639, 401, - 1, -149, - -73, -167, - 150, 118, - 308, 218, - 121, 195, - -143, -261, - -1013, -802, - 387, 436, - 130, -427, - -448, -681, - 123, -87, - -251, -113, - 274, 310, - 445, 501, - 354, 272, - 141, -285, - 569, 656, - 37, -49, - 251, -386, - -263, 1122, - 604, 606, - 336, 95, - 34, 0, - 85, 180, - 207, -367, - -622, 1070, - -6, -79, - -160, -92, - -137, -276, - -323, -371, - -696, -1036, - 407, 102, - -86, -214, - -482, -647, - -28, -291, - -97, -180, - -250, -435, - -18, -76, - -332, 410, - 407, 168, - 539, 411, - 254, 111, - 58, -145, - 200, 30, - 187, 116, - 131, -367, - -475, 781, - -559, 561, - 195, -115, - 8, -168, - 30, 55, - -122, 131, - 82, -5, - -273, -50, - -632, 668, - 4, 32, - -26, -279, - 315, 165, - 197, 377, - 155, -41, - -138, -324, - -109, -617, - 360, 98, - -53, -319, - -114, -245, - -82, 507, - 468, 263, - -137, -389, - 652, 354, - -18, -227, - -462, -135, - 317, 53, - -16, 66, - -72, -126, - -356, -347, - -328, -72, - -337, 324, - 152, 349, - 169, -196, - 179, 254, - 260, 325, - -74, -80, - 75, -31, - 270, 275, - 87, 278, - -446, -301, - 309, 71, - -25, -242, - 516, 161, - -162, -83, - 329, 230, - -311, -259, - 177, -26, - -462, 89, - 257, 6, - -130, -93, - -456, -317, - -221, -206, - -417, -182, - -74, 234, - 48, 261, - 359, 231, - 258, 85, - -282, 252, - -147, -222, - 251, -207, - 443, 123, - -417, -36, - 273, -241, - 240, -112, - 44, -167, - 126, -124, - -77, 58, - -401, 333, - -118, 82, - 126, 151, - -433, 359, - -130, -102, - 131, -244, - 86, 85, - -462, 414, - -240, 16, - 145, 28, - -205, -481, - 373, 293, - -72, -174, - 62, 259, - -8, -18, - 362, 233, - 185, 43, - 278, 27, - 193, 570, - -248, 189, - 92, 31, - -275, -3, - 243, 176, - 438, 209, - 206, -51, - 79, 109, - 168, -185, - -308, -68, - -618, 385, - -310, -108, - -164, 165, - 61, -152, - -101, -412, - -268, -257, - -40, -20, - -28, -158, - -301, 271, - 380, -338, - -367, -132, - 64, 114, - -131, -225, - -156, -260, - -63, -116, - 155, -586, - -202, 254, - -287, 178, - 227, -106, - -294, 164, - 298, -100, - 185, 317, - 193, -45, - 28, 80, - -87, -433, - 22, -48, - 48, -237, - -229, -139, - 120, -364, - 268, -136, - 396, 125, - 130, -89, - -272, 118, - -256, -68, - -451, 488, - 143, -165, - -48, -190, - 106, 219, - 47, 435, - 245, 97, - 75, -418, - 121, -187, - 570, -200, - -351, 225, - -21, -217, - 234, -111, - 194, 14, - 242, 118, - 140, -397, - 355, 361, - -45, -195 - }; - - static final SKP_Silk_NLSF_CBS[] SKP_Silk_NLSF_CB0_10_Stage_info= - { - new SKP_Silk_NLSF_CBS(64, SKP_Silk_NLSF_MSVQ_CB0_10_Q15, 10*0, SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q5, 0), - new SKP_Silk_NLSF_CBS(16, SKP_Silk_NLSF_MSVQ_CB0_10_Q15, 10*64, SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q5, 64), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB0_10_Q15, 10*80, SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q5, 80), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB0_10_Q15, 10*88, SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q5, 88), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB0_10_Q15, 10*96, SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q5, 96), - new SKP_Silk_NLSF_CBS(16, SKP_Silk_NLSF_MSVQ_CB0_10_Q15, 10*104, SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q5, 104) - }; - - static final SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB0_10 = - new SKP_Silk_NLSF_CB_struct( - NLSF_MSVQ_CB0_10_STAGES, - SKP_Silk_NLSF_CB0_10_Stage_info, - SKP_Silk_NLSF_MSVQ_CB0_10_ndelta_min_Q15, - SKP_Silk_NLSF_MSVQ_CB0_10_CDF, - SKP_Silk_NLSF_MSVQ_CB0_10_CDF_start_ptr, - SKP_Silk_NLSF_MSVQ_CB0_10_CDF_middle_idx - ); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB0_10_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB0_10_FLP.java deleted file mode 100644 index edcab768b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB0_10_FLP.java +++ /dev/null @@ -1,740 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * This file has been automatically generated. - * ROM usage: 5.32 kB - * - * @author Dingxin Xu - */ -public class Silk_tables_NLSF_CB0_10_FLP -{ -// const SKP_float SKP_Silk_NLSF_MSVQ_CB0_10_rates[ NLSF_MSVQ_CB0_10_VECTORS ] = - static final float SKP_Silk_NLSF_MSVQ_CB0_10_rates[] = - { - 4.62500000000000000000f, 5.21875000000000000000f, - 5.28125000000000000000f, 5.31250000000000000000f, - 5.31250000000000000000f, 5.40625000000000000000f, - 5.40625000000000000000f, 5.46875000000000000000f, - 5.50000000000000000000f, 5.50000000000000000000f, - 5.50000000000000000000f, 5.53125000000000000000f, - 5.59375000000000000000f, 5.65625000000000000000f, - 5.65625000000000000000f, 5.65625000000000000000f, - 5.71875000000000000000f, 5.71875000000000000000f, - 5.71875000000000000000f, 5.75000000000000000000f, - 5.78125000000000000000f, 5.78125000000000000000f, - 5.78125000000000000000f, 5.78125000000000000000f, - 5.81250000000000000000f, 5.90625000000000000000f, - 5.90625000000000000000f, 5.90625000000000000000f, - 5.96875000000000000000f, 5.96875000000000000000f, - 5.96875000000000000000f, 6.06250000000000000000f, - 6.06250000000000000000f, 6.06250000000000000000f, - 6.09375000000000000000f, 6.09375000000000000000f, - 6.12500000000000000000f, 6.18750000000000000000f, - 6.21875000000000000000f, 6.25000000000000000000f, - 6.28125000000000000000f, 6.28125000000000000000f, - 6.31250000000000000000f, 6.34375000000000000000f, - 6.37500000000000000000f, 6.37500000000000000000f, - 6.40625000000000000000f, 6.40625000000000000000f, - 6.43750000000000000000f, 6.53125000000000000000f, - 6.56250000000000000000f, 6.56250000000000000000f, - 6.65625000000000000000f, 6.68750000000000000000f, - 6.81250000000000000000f, 6.87500000000000000000f, - 6.90625000000000000000f, 7.06250000000000000000f, - 7.21875000000000000000f, 7.31250000000000000000f, - 7.46875000000000000000f, 8.00000000000000000000f, - 8.00000000000000000000f, 8.00000000000000000000f, - 3.71875000000000000000f, 3.84375000000000000000f, - 3.84375000000000000000f, 3.84375000000000000000f, - 3.90625000000000000000f, 3.93750000000000000000f, - 3.93750000000000000000f, 3.93750000000000000000f, - 4.00000000000000000000f, 4.06250000000000000000f, - 4.06250000000000000000f, 4.09375000000000000000f, - 4.09375000000000000000f, 4.21875000000000000000f, - 4.31250000000000000000f, 4.34375000000000000000f, - 2.93750000000000000000f, 2.93750000000000000000f, - 2.96875000000000000000f, 2.96875000000000000000f, - 3.00000000000000000000f, 3.06250000000000000000f, - 3.06250000000000000000f, 3.09375000000000000000f, - 2.90625000000000000000f, 2.90625000000000000000f, - 2.96875000000000000000f, 3.00000000000000000000f, - 3.00000000000000000000f, 3.03125000000000000000f, - 3.06250000000000000000f, 3.12500000000000000000f, - 2.87500000000000000000f, 2.90625000000000000000f, - 3.03125000000000000000f, 3.03125000000000000000f, - 3.03125000000000000000f, 3.03125000000000000000f, - 3.06250000000000000000f, 3.06250000000000000000f, - 3.90625000000000000000f, 3.93750000000000000000f, - 3.93750000000000000000f, 3.96875000000000000000f, - 3.96875000000000000000f, 4.00000000000000000000f, - 4.00000000000000000000f, 4.00000000000000000000f, - 4.00000000000000000000f, 4.00000000000000000000f, - 4.03125000000000000000f, 4.03125000000000000000f, - 4.03125000000000000000f, 4.06250000000000000000f, - 4.06250000000000000000f, 4.09375000000000000000f - }; - -// const SKP_float SKP_Silk_NLSF_MSVQ_CB0_10_ndelta_min[ 10 + 1 ] = - static final float SKP_Silk_NLSF_MSVQ_CB0_10_ndelta_min[] = - { - 0.01718139648437500000f, - 0.00009155273437500000f, - 0.00067138671874999989f, - 0.00061035156250000000f, - 0.00009155273437500000f, - 0.00009155273437500000f, - 0.00402832031250000000f, - 0.00363159179687500000f, - 0.01092529296875000000f, - 0.00262451171875000000f, - 0.02941894531250000300f - }; - -// const SKP_float SKP_Silk_NLSF_MSVQ_CB0_10[ 10 * NLSF_MSVQ_CB0_10_VECTORS ] = - static final float SKP_Silk_NLSF_MSVQ_CB0_10[] = - { - 0.06744384765625000000f, 0.12277221679687500000f, - 0.21304321289062497000f, 0.28259277343750000000f, - 0.38369750976562500000f, 0.47872924804687500000f, - 0.58615112304687500000f, 0.68307495117187489000f, - 0.79287719726562500000f, 0.88934326171875011000f, - 0.10025024414062500000f, 0.12731933593750000000f, - 0.18664550781250003000f, 0.33129882812500000000f, - 0.46658325195312494000f, 0.51348876953125000000f, - 0.60122680664062500000f, 0.67169189453125000000f, - 0.75442504882812500000f, 0.89456176757812500000f, - 0.04742431640624999300f, 0.07662963867187500000f, - 0.20071411132812500000f, 0.31546020507812500000f, - 0.42227172851562494000f, 0.50387573242187500000f, - 0.61297607421875000000f, 0.70843505859375000000f, - 0.80810546875000000000f, 0.89916992187500000000f, - 0.09344482421875000000f, 0.12258911132812500000f, - 0.17611694335937500000f, 0.30630493164062500000f, - 0.40786743164062500000f, 0.45629882812500000000f, - 0.61462402343750000000f, 0.69857788085937500000f, - 0.76992797851562500000f, 0.90341186523437500000f, - 0.06362915039062500000f, 0.10549926757812500000f, - 0.18109130859375000000f, 0.26605224609375000000f, - 0.35098266601562494000f, 0.41717529296875000000f, - 0.54922485351562500000f, 0.66580200195312500000f, - 0.76095581054687489000f, 0.87722778320312500000f, - 0.08471679687500000000f, 0.12490844726562501000f, - 0.19595336914062500000f, 0.31777954101562500000f, - 0.46115112304687500000f, 0.51287841796875000000f, - 0.63552856445312500000f, 0.72711181640625000000f, - 0.80285644531250000000f, 0.89755249023437500000f, - 0.08291625976562498600f, 0.12310791015625000000f, - 0.17385864257812500000f, 0.25827026367187500000f, - 0.43643188476562500000f, 0.49908447265625000000f, - 0.58004760742187500000f, 0.71450805664062500000f, - 0.78771972656249989000f, 0.86993408203125011000f, - 0.08764648437500000000f, 0.11297607421875001000f, - 0.17947387695312500000f, 0.33673095703124994000f, - 0.52310180664062500000f, 0.57614135742187500000f, - 0.64532470703125000000f, 0.71566772460937500000f, - 0.78787231445312500000f, 0.90332031250000000000f, - 0.09152221679687500000f, 0.12252807617187500000f, - 0.22451782226562500000f, 0.34237670898437500000f, - 0.39263916015625000000f, 0.52816772460937500000f, - 0.61282348632812500000f, 0.69104003906250000000f, - 0.81707763671875000000f, 0.88827514648437500000f, - 0.08978271484375000000f, 0.11798095703125000000f, - 0.18060302734375003000f, 0.36361694335937500000f, - 0.42446899414062500000f, 0.49047851562500000000f, - 0.62417602539062500000f, 0.67990112304687500000f, - 0.83343505859375000000f, 0.91021728515625011000f, - 0.06930541992187500000f, 0.10763549804687500000f, - 0.20159912109375000000f, 0.29690551757812500000f, - 0.39498901367187506000f, 0.53045654296875000000f, - 0.61718750000000000000f, 0.68191528320312500000f, - 0.75079345703125000000f, 0.86334228515624989000f, - 0.06735229492187500000f, 0.10101318359375000000f, - 0.17834472656250000000f, 0.28500366210937500000f, - 0.33999633789062500000f, 0.47763061523437506000f, - 0.56689453125000000000f, 0.64627075195312511000f, - 0.77975463867187489000f, 0.86145019531250011000f, - 0.12094116210937500000f, 0.15182495117187500000f, - 0.21060180664062500000f, 0.35363769531250000000f, - 0.41094970703125000000f, 0.47537231445312494000f, - 0.58688354492187500000f, 0.65209960937500000000f, - 0.77850341796875000000f, 0.84713745117187500000f, - 0.08389282226562500000f, 0.10830688476562500000f, - 0.21258544921875000000f, 0.42138671875000000000f, - 0.47769165039062500000f, 0.53848266601562500000f, - 0.61309814453125000000f, 0.68966674804687511000f, - 0.80770874023437500000f, 0.87088012695312489000f, - 0.06488037109375000000f, 0.10693359375000001000f, - 0.15591430664062500000f, 0.30377197265625000000f, - 0.38299560546875006000f, 0.44616699218750000000f, - 0.60128784179687500000f, 0.66183471679687500000f, - 0.80740356445312500000f, 0.88824462890625000000f, - 0.12103271484375000000f, 0.17532348632812500000f, - 0.22711181640625000000f, 0.29776000976562500000f, - 0.44152832031250000000f, 0.50061035156250000000f, - 0.58395385742187500000f, 0.70336914062500000000f, - 0.77438354492187489000f, 0.86642456054687500000f, - 0.09756469726562500000f, 0.14498901367187500000f, - 0.19686889648437500000f, 0.28375244140625000000f, - 0.39788818359374994000f, 0.45391845703125000000f, - 0.54815673828125000000f, 0.62948608398437500000f, - 0.72738647460937500000f, 0.86865234375000000000f, - 0.09750366210937500000f, 0.12454223632812500000f, - 0.19833374023437500000f, 0.37390136718750000000f, - 0.43606567382812500000f, 0.48950195312500000000f, - 0.56021118164062500000f, 0.63262939453125000000f, - 0.82336425781250000000f, 0.89443969726562489000f, - 0.04678344726562500000f, 0.07540893554687500000f, - 0.13690185546875000000f, 0.23791503906250000000f, - 0.37634277343750000000f, 0.48089599609375000000f, - 0.59713745117187500000f, 0.68048095703124989000f, - 0.78347778320312489000f, 0.88656616210937511000f, - 0.06109619140625000000f, 0.09066772460937500000f, - 0.15213012695312500000f, 0.24667358398437497000f, - 0.40225219726562500000f, 0.47103881835937500000f, - 0.55654907226562500000f, 0.65664672851562500000f, - 0.75057983398437500000f, 0.86520385742187500000f, - 0.11621093750000000000f, 0.15029907226562500000f, - 0.20477294921875003000f, 0.31130981445312500000f, - 0.36654663085937500000f, 0.43640136718750000000f, - 0.56326293945312500000f, 0.62228393554687500000f, - 0.80947875976562500000f, 0.88366699218750000000f, - 0.06961059570312500000f, 0.10430908203125000000f, - 0.15194702148437500000f, 0.26629638671875000000f, - 0.48718261718750000000f, 0.55249023437500000000f, - 0.61798095703125000000f, 0.69491577148437500000f, - 0.77166748046875000000f, 0.88360595703125000000f, - 0.09310913085937500000f, 0.16720581054687500000f, - 0.22247314453125000000f, 0.30053710937500000000f, - 0.38891601562500000000f, 0.44259643554687500000f, - 0.56961059570312500000f, 0.72277832031250000000f, - 0.79544067382812511000f, 0.88339233398437500000f, - 0.07214355468750000000f, 0.10879516601562499000f, - 0.16790771484375000000f, 0.29360961914062500000f, - 0.45538330078125000000f, 0.50723266601562500000f, - 0.57998657226562500000f, 0.64074707031250000000f, - 0.80291748046875000000f, 0.89422607421875000000f, - 0.12490844726562501000f, 0.15905761718750000000f, - 0.20852661132812500000f, 0.30151367187500000000f, - 0.49752807617187500000f, 0.55804443359375000000f, - 0.62777709960937500000f, 0.72064208984375000000f, - 0.79550170898437500000f, 0.88891601562500000000f, - 0.08975219726562500000f, 0.12194824218750000000f, - 0.18426513671875000000f, 0.32464599609374994000f, - 0.38659667968750000000f, 0.44100952148437500000f, - 0.51263427734375000000f, 0.59179687500000000000f, - 0.79501342773437500000f, 0.87026977539062489000f, - 0.11788940429687500000f, 0.15905761718750000000f, - 0.21420288085937500000f, 0.28894042968750000000f, - 0.33688354492187500000f, 0.40325927734374994000f, - 0.60858154296875000000f, 0.68188476562500000000f, - 0.76678466796875000000f, 0.90145874023437489000f, - 0.14083862304687500000f, 0.18835449218749997000f, - 0.23965454101562500000f, 0.31286621093750000000f, - 0.38485717773437506000f, 0.44082641601562500000f, - 0.60177612304687500000f, 0.68484497070312500000f, - 0.76055908203125000000f, 0.89541625976562500000f, - 0.10882568359375000000f, 0.13769531250000000000f, - 0.21316528320312500000f, 0.26501464843750000000f, - 0.32177734375000000000f, 0.49124145507812500000f, - 0.55108642578125000000f, 0.68588256835937500000f, - 0.79547119140625000000f, 0.85958862304687500000f, - 0.13674926757812500000f, 0.16751098632812500000f, - 0.22680664062500000000f, 0.34832763671875000000f, - 0.40255737304687500000f, 0.46463012695312500000f, - 0.61526489257812500000f, 0.67926025390625000000f, - 0.80822753906250000000f, 0.90686035156250000000f, - 0.10131835937500000000f, 0.13183593750000000000f, - 0.20205688476562500000f, 0.30111694335937500000f, - 0.35342407226562500000f, 0.42828369140625000000f, - 0.64599609375000000000f, 0.70831298828125000000f, - 0.81140136718750000000f, 0.91256713867187500000f, - 0.11578369140625000000f, 0.14309692382812500000f, - 0.21105957031250000000f, 0.26412963867187500000f, - 0.30953979492187500000f, 0.49267578125000000000f, - 0.59716796875000000000f, 0.65881347656250000000f, - 0.84097290039062500000f, 0.90310668945312489000f, - 0.07464599609375000000f, 0.09997558593750000000f, - 0.18060302734375003000f, 0.38583374023437500000f, - 0.50662231445312500000f, 0.54971313476562500000f, - 0.64471435546875011000f, 0.70724487304687489000f, - 0.83312988281250000000f, 0.90435791015625000000f, - 0.07476806640625000000f, 0.10748291015625000000f, - 0.16592407226562500000f, 0.26123046875000000000f, - 0.46646118164062500000f, 0.60763549804687500000f, - 0.66607666015625000000f, 0.73538208007812500000f, - 0.81076049804687489000f, 0.88739013671875000000f, - 0.07873535156250000000f, 0.11584472656249999000f, - 0.17028808593750000000f, 0.25445556640625000000f, - 0.30422973632812500000f, 0.38681030273437500000f, - 0.57699584960937500000f, 0.69436645507812500000f, - 0.77667236328125000000f, 0.89392089843749989000f, - 0.10147094726562500000f, 0.13159179687500000000f, - 0.19046020507812500000f, 0.23526000976562500000f, - 0.27966308593750000000f, 0.44104003906250000000f, - 0.66116333007812489000f, 0.72622680664062511000f, - 0.82690429687500000000f, 0.91116333007812489000f, - 0.10186767578125000000f, 0.12704467773437500000f, - 0.23614501953125000000f, 0.33917236328125000000f, - 0.38659667968750000000f, 0.45022583007812500000f, - 0.51669311523437500000f, 0.69384765625000000000f, - 0.78341674804687500000f, 0.85733032226562500000f, - 0.11718749999999999000f, 0.14511108398437500000f, - 0.23666381835937500000f, 0.41110229492187506000f, - 0.46807861328125000000f, 0.52429199218750000000f, - 0.61270141601562500000f, 0.68215942382812500000f, - 0.82949829101562500000f, 0.90768432617187500000f, - 0.07641601562500000000f, 0.12448120117187500000f, - 0.25485229492187500000f, 0.36981201171875000000f, - 0.45916748046875000000f, 0.56747436523437500000f, - 0.66174316406250000000f, 0.75390625000000000000f, - 0.83981323242187500000f, 0.91360473632812500000f, - 0.15972900390625000000f, 0.19354248046875000000f, - 0.25228881835937500000f, 0.36074829101562500000f, - 0.46249389648437500000f, 0.51147460937500000000f, - 0.63070678710937500000f, 0.71679687500000000000f, - 0.79190063476562500000f, 0.89437866210937500000f, - 0.08181762695312500000f, 0.10870361328125000000f, - 0.18395996093750003000f, 0.33041381835937506000f, - 0.56329345703125000000f, 0.62432861328125000000f, - 0.68063354492187500000f, 0.75381469726562500000f, - 0.82128906250000000000f, 0.91418457031250000000f, - 0.10296630859375000000f, 0.13818359375000000000f, - 0.19012451171875000000f, 0.25195312500000000000f, - 0.29031372070312500000f, 0.38848876953124994000f, - 0.56964111328125000000f, 0.63232421875000000000f, - 0.79367065429687500000f, 0.86746215820312500000f, - 0.08334350585937500000f, 0.11074829101562500000f, - 0.25390625000000000000f, 0.37994384765625000000f, - 0.43066406250000000000f, 0.50143432617187500000f, - 0.56604003906250000000f, 0.67437744140625000000f, - 0.77297973632812500000f, 0.84588623046875000000f, - 0.10623168945312500000f, 0.13430786132812500000f, - 0.22341918945312503000f, 0.28439331054687500000f, - 0.33758544921875000000f, 0.39956665039062500000f, - 0.46145629882812500000f, 0.68099975585937489000f, - 0.80355834960937500000f, 0.87707519531250000000f, - 0.10916137695312500000f, 0.15090942382812500000f, - 0.20352172851562500000f, 0.26831054687500000000f, - 0.31430053710937500000f, 0.38589477539062506000f, - 0.59524536132812500000f, 0.75579833984375000000f, - 0.82385253906250011000f, 0.90435791015625000000f, - 0.12384033203125000000f, 0.15441894531250000000f, - 0.22241210937500000000f, 0.31097412109375000000f, - 0.35778808593750000000f, 0.42529296875000000000f, - 0.48367309570312500000f, 0.56576538085937500000f, - 0.81484985351562500000f, 0.91079711914062500000f, - 0.13006591796875000000f, 0.16448974609374997000f, - 0.21536254882812503000f, 0.27410888671875000000f, - 0.31088256835937500000f, 0.46582031250000000000f, - 0.62500000000000000000f, 0.68176269531250000000f, - 0.79217529296875000000f, 0.85668945312500000000f, - 0.10388183593750000000f, 0.13211059570312500000f, - 0.20230102539062497000f, 0.24249267578125000000f, - 0.30886840820312500000f, 0.52383422851562500000f, - 0.59936523437500000000f, 0.67883300781249989000f, - 0.76483154296875000000f, 0.83837890625000000000f, - 0.09634399414062501400f, 0.12719726562500000000f, - 0.18905639648437500000f, 0.28439331054687500000f, - 0.32870483398437500000f, 0.40664672851562500000f, - 0.47045898437500000000f, 0.60473632812500000000f, - 0.75292968750000000000f, 0.84332275390625000000f, - 0.07638549804687500000f, 0.10598754882812500000f, - 0.15655517578125000000f, 0.20651245117187500000f, - 0.26156616210937500000f, 0.45477294921875000000f, - 0.58084106445312500000f, 0.66912841796874989000f, - 0.79544067382812511000f, 0.87670898437500000000f, - 0.12612915039062500000f, 0.15570068359375000000f, - 0.23049926757812503000f, 0.30682373046875000000f, - 0.35879516601562500000f, 0.45544433593750000000f, - 0.53207397460937500000f, 0.61602783203125000000f, - 0.73202514648437489000f, 0.80175781249999989000f, - 0.15173339843750000000f, 0.18734741210937500000f, - 0.24090576171875000000f, 0.29397583007812500000f, - 0.34545898437500000000f, 0.43624877929687500000f, - 0.66336059570312500000f, 0.74176025390625000000f, - 0.82150268554687489000f, 0.91268920898437500000f, - 0.09027099609375000000f, 0.11645507812500000000f, - 0.20907592773437500000f, 0.28088378906250000000f, - 0.33248901367187506000f, 0.55090332031250000000f, - 0.63449096679687500000f, 0.71221923828125000000f, - 0.84094238281250000000f, 0.90359497070312500000f, - 0.15972900390625000000f, 0.18395996093750003000f, - 0.24517822265625000000f, 0.30987548828125000000f, - 0.34307861328125000000f, 0.45132446289062500000f, - 0.57824707031250000000f, 0.63983154296875000000f, - 0.81130981445312500000f, 0.88888549804687500000f, - 0.15994262695312503000f, 0.20867919921875000000f, - 0.32122802734375006000f, 0.39120483398437500000f, - 0.44802856445312500000f, 0.52880859375000000000f, - 0.60815429687500000000f, 0.68164062500000000000f, - 0.79934692382812500000f, 0.87576293945312500000f, - 0.10412597656250000000f, 0.12973022460937500000f, - 0.18273925781250000000f, 0.21649169921875000000f, - 0.30233764648437500000f, 0.55673217773437500000f, - 0.66128540039062500000f, 0.72561645507812511000f, - 0.82302856445312500000f, 0.88766479492187500000f, - 0.07537841796875000000f, 0.09817504882812500000f, - 0.23794555664062500000f, 0.46679687499999994000f, - 0.52993774414062500000f, 0.58395385742187500000f, - 0.67074584960937500000f, 0.74023437500000000000f, - 0.83380126953124989000f, 0.89849853515625000000f, - 0.15072631835937500000f, 0.17712402343750000000f, - 0.24856567382812500000f, 0.36038208007812506000f, - 0.42337036132812500000f, 0.47601318359375000000f, - 0.52593994140625000000f, 0.59274291992187500000f, - 0.80798339843750000000f, 0.90469360351562500000f, - 0.15414428710937500000f, 0.18820190429687497000f, - 0.25094604492187500000f, 0.29464721679687500000f, - 0.37106323242187500000f, 0.54916381835937500000f, - 0.62451171875000000000f, 0.69677734375000011000f, - 0.81225585937500000000f, 0.86859130859375000000f, - 0.15219116210937500000f, 0.18026733398437500000f, - 0.28439331054687500000f, 0.34317016601562500000f, - 0.40075683593750000000f, 0.45849609375000000000f, - 0.53359985351562500000f, 0.69235229492187511000f, - 0.79379272460937511000f, 0.86282348632812489000f, - 0.15676879882812500000f, 0.21008300781250000000f, - 0.33645629882812500000f, 0.45623779296875000000f, - 0.52462768554687500000f, 0.59280395507812500000f, - 0.66549682617187489000f, 0.74441528320312511000f, - 0.82208251953125000000f, 0.89379882812500000000f, - 0.21536254882812503000f, 0.24060058593750000000f, - 0.29077148437500000000f, 0.31991577148437500000f, - 0.33447265625000000000f, 0.45199584960937500000f, - 0.58197021484375000000f, 0.66146850585937500000f, - 0.78262329101562511000f, 0.85507202148437500000f, - 0.20626831054687500000f, 0.21850585937500000000f, - 0.26080322265625000000f, 0.35946655273437500000f, - 0.37521362304687500000f, 0.39743041992187500000f, - 0.50741577148437500000f, 0.64389038085937500000f, - 0.75369262695312500000f, 0.86325073242187500000f, - 0.11788940429687500000f, 0.29791259765625000000f, - 0.33776855468749994000f, 0.34927368164062500000f, - 0.36770629882812506000f, 0.42602539062500000000f, - 0.55191040039062500000f, 0.65634155273437500000f, - 0.76977539062500000000f, 0.88491821289062489000f, - 0.01211547851562500000f, 0.01022338867187500000f, - 0.01986694335937500000f, 0.03564453125000000000f, - 0.01953125000000000000f, 0.02334594726562500000f, - 0.01419067382812500000f, 0.01010131835937500000f, - 0.00653076171875000000f, -0.00592041015625000000f, - -0.01763916015625000000f, -0.01974487304687500000f, - -0.02005004882812500000f, 0.02288818359375000000f, - 0.01721191406250000000f, 0.01870727539062500000f, - 0.01675415039062500000f, 0.01922607421875000000f, - 0.00927734375000000000f, -0.00158691406250000020f, - 0.02526855468749999700f, 0.02813720703125000000f, - 0.01351928710937500000f, 0.00338745117187500000f, - 0.00421142578125000000f, 0.00378417968750000000f, - 0.00515747070312500000f, 0.00042724609375000000f, - 0.00439453125000000000f, 0.00253295898437500040f, - 0.00402832031250000000f, 0.00177001953125000000f, - -0.01260375976562500000f, -0.02294921875000000000f, - 0.02651977539062500000f, 0.01025390625000000000f, - 0.01174926757812500200f, 0.00210571289062500000f, - 0.00170898437500000000f, 0.02532958984375000000f, - -0.00692749023437500000f, -0.00811767578125000000f, - -0.01123046875000000000f, -0.01342773437500000000f, - -0.03646850585937500000f, 0.00497436523437500000f, - 0.00384521484375000000f, -0.00695800781250000000f, - 0.02447509765625000000f, 0.00476074218750000000f, - 0.00573730468750000000f, 0.00366210937499999960f, - 0.01147460937500000000f, 0.00180053710937500000f, - -0.01092529296875000000f, -0.01702880859375000000f, - -0.04046630859375000000f, -0.00775146484375000000f, - -0.00616455078125000000f, -0.02407836914062500000f, - 0.00903320312500000000f, 0.00280761718750000000f, - -0.00213623046875000000f, -0.00393676757812500000f, - -0.02191162109375000000f, -0.03463745117187500000f, - 0.00891113281250000000f, -0.00088500976562500000f, - -0.01925659179687500000f, 0.01486206054687500000f, - -0.00479125976562500000f, -0.00466918945312500000f, - -0.00851440429687500000f, 0.00006103515625000000f, - -0.01278686523437500000f, -0.01043701171875000000f, - -0.00103759765625000000f, -0.01568603515625000000f, - -0.02438354492187499700f, -0.04794311523437500000f, - -0.02096557617187500000f, -0.01858520507812500000f, - -0.01666259765625000000f, -0.00396728515625000000f, - -0.00656127929687500000f, -0.00769042968750000000f, - -0.01361083984375000000f, -0.01751708984375000000f, - -0.04080200195312500000f, 0.00631713867187499910f, - -0.00219726562500000000f, 0.00097656250000000000f, - 0.00314331054687500000f, -0.01959228515625000000f, - 0.02874755859375000300f, 0.02236938476562499700f, - 0.00570678710937500090f, 0.00088500976562500000f, - -0.00643920898437500000f, -0.02484130859375000300f, - 0.00436401367187500000f, 0.00686645507812500000f, - 0.00061035156250000000f, 0.00073242187500000000f, - -0.00817871093750000000f, -0.01150512695312500000f, - 0.04953002929687499300f, 0.03457641601562500000f, - 0.02035522460937500000f, 0.00500488281250000000f, - 0.00936889648437500000f, 0.01116943359375000000f, - 0.00570678710937500090f, 0.00103759765625000000f, - 0.00189208984375000000f, -0.00955200195312500000f, - -0.02539062500000000300f, -0.04522705078125000000f, - -0.03604125976562500000f, 0.01473999023437500000f, - -0.00128173828125000000f, -0.00119018554687500000f, - -0.01373291015625000000f, -0.04290771484375000000f, - -0.01791381835937500000f, -0.00158691406250000020f, - -0.02319335937500000000f, 0.01019287109375000000f, - 0.00299072265625000000f, -0.00183105468749999980f, - -0.01525878906249999800f, -0.01489257812500000000f, - -0.03228759765625000000f, 0.00912475585937500000f, - 0.00399780273437500000f, -0.00762939453124999910f, - -0.00765991210937500090f, -0.02145385742187500000f, - 0.03164672851562500000f, 0.01733398437500000000f, - -0.01260375976562500000f, -0.00808715820312500000f, - 0.05148315429687500000f, 0.01748657226562500000f, - 0.01052856445312500000f, 0.00985717773437500000f, - 0.00299072265625000000f, 0.00186157226562500000f, - -0.00311279296875000000f, 0.00094604492187500000f, - 0.00411987304687500000f, 0.00454711914062500000f, - 0.01882934570312500000f, 0.01113891601562500000f, - -0.00119018554687500000f, 0.00103759765625000000f, - -0.01864624023437500000f, 0.03665161132812500000f, - 0.04336547851562500000f, 0.02246093750000000000f, - -0.01263427734374999800f, -0.01199340820312500000f, - -0.01501464843750000000f, -0.01046752929687500200f, - -0.00964355468750000000f, -0.01623535156250000000f, - 0.01611328125000000000f, 0.00524902343750000000f, - 0.00274658203125000000f, 0.00982666015625000000f, - -0.00897216796875000000f, -0.00973510742187500000f, - -0.01651000976562500000f, 0.01535034179687500000f, - 0.01950073242187500000f, 0.01223754882812500000f, - 0.00003051757812500000f, -0.00454711914062500000f, - -0.00222778320312500000f, -0.00509643554687500000f, - 0.00457763671875000000f, 0.00360107421875000000f, - 0.00939941406250000000f, 0.00665283203124999910f, - 0.00369262695312500000f, 0.00595092773437500000f, - -0.00436401367187500000f, -0.00796508789062500000f, - -0.03091430664062500000f, -0.02447509765625000000f, - 0.01181030273437500000f, 0.01330566406249999800f, - 0.00396728515625000000f, -0.01303100585937500200f, - -0.01367187500000000000f, -0.02078247070312500000f, - 0.00375366210937500000f, -0.00265502929687500000f, - -0.00765991210937500090f, -0.00344848632812500000f, - 0.00836181640625000000f, 0.00946044921875000000f, - 0.01358032226562500000f, 0.01528930664062500000f, - 0.01080322265625000200f, 0.00830078125000000000f, - 0.00430297851562500000f, -0.00869750976562500000f, - 0.01736450195312500000f, 0.02001953125000000000f, - 0.00112915039062500000f, -0.00149536132812500000f, - 0.00765991210937500090f, -0.01177978515625000000f, - -0.00802612304687500000f, 0.03424072265625000000f, - 0.01843261718750000000f, 0.01849365234375000000f, - 0.01025390625000000000f, 0.00289916992187500000f, - 0.00103759765625000000f, 0.00000000000000000000f, - 0.00259399414062500000f, 0.00549316406250000000f, - 0.00631713867187499910f, -0.01119995117187500000f, - -0.01898193359375000000f, 0.03265380859375000000f, - -0.00018310546875000000f, -0.00241088867187500000f, - -0.00488281250000000000f, -0.00280761718750000000f, - -0.00418090820312500000f, -0.00842285156250000000f, - -0.00985717773437500000f, -0.01132202148437500000f, - -0.02124023437500000000f, -0.03161621093750000000f, - 0.01242065429687500200f, 0.00311279296875000000f, - -0.00262451171875000000f, -0.00653076171875000000f, - -0.01470947265625000200f, -0.01974487304687500000f, - -0.00085449218750000000f, -0.00888061523437500000f, - -0.00296020507812500000f, -0.00549316406250000000f, - -0.00762939453124999910f, -0.01327514648437500000f, - -0.00054931640625000000f, -0.00231933593750000000f, - -0.01013183593750000200f, 0.01251220703125000000f, - 0.01242065429687500200f, 0.00512695312500000000f, - 0.01644897460937500000f, 0.01254272460937500000f, - 0.00775146484375000000f, 0.00338745117187500000f, - 0.00177001953125000000f, -0.00442504882812500000f, - 0.00610351562500000000f, 0.00091552734374999989f, - 0.00570678710937500090f, 0.00354003906250000000f, - 0.00399780273437500000f, -0.01119995117187500000f, - -0.01449584960937500000f, 0.02383422851562500300f, - -0.01705932617187500000f, 0.01712036132812500000f, - 0.00595092773437500000f, -0.00350952148437500040f, - 0.00024414062500000000f, -0.00512695312500000000f, - 0.00091552734374999989f, 0.00167846679687500000f, - -0.00372314453125000000f, 0.00399780273437500000f, - 0.00250244140625000000f, -0.00015258789062500000f, - -0.00833129882812500000f, -0.00152587890625000000f, - -0.01928710937500000000f, 0.02038574218750000000f, - 0.00012207031250000000f, 0.00097656250000000000f, - -0.00079345703125000011f, -0.00851440429687500000f, - 0.00961303710937500000f, 0.00503540039062499910f, - 0.00601196289062499910f, 0.01150512695312500000f, - 0.00473022460937500000f, -0.00125122070312500000f, - -0.00421142578125000000f, -0.00988769531250000000f, - -0.00332641601562499960f, -0.01882934570312500000f, - 0.01098632812500000000f, 0.00299072265625000000f, - -0.00161743164062500000f, -0.00973510742187500000f, - -0.00347900390625000000f, -0.00747680664062500000f, - -0.00250244140625000000f, 0.01547241210937500000f, - 0.01428222656250000000f, 0.00802612304687500000f, - -0.00418090820312500000f, -0.01187133789062500000f, - 0.01989746093750000000f, 0.01080322265625000200f, - -0.00054931640625000000f, -0.00692749023437500000f, - -0.01409912109375000000f, -0.00411987304687500000f, - 0.00967407226562500000f, 0.00161743164062500000f, - -0.00048828125000000000f, 0.00201416015625000000f, - -0.00219726562500000000f, -0.00384521484375000000f, - -0.01086425781250000000f, -0.01058959960937500000f, - -0.01000976562500000000f, -0.00219726562500000000f, - -0.01028442382812500000f, 0.00988769531250000000f, - 0.00463867187500000000f, 0.01065063476562500000f, - 0.00515747070312500000f, -0.00598144531250000000f, - 0.00546264648437500000f, 0.00775146484375000000f, - 0.00793457031250000000f, 0.00991821289062500000f, - -0.00225830078125000000f, -0.00244140625000000000f, - 0.00228881835937500000f, -0.00094604492187500000f, - 0.00823974609375000000f, 0.00839233398437500000f, - 0.00265502929687500000f, 0.00848388671875000000f, - -0.01361083984375000000f, -0.00918579101562500000f, - 0.00942993164062500000f, 0.00216674804687500000f, - -0.00076293945312500000f, -0.00738525390625000000f, - 0.01574707031250000000f, 0.00491333007812500000f, - -0.00494384765625000000f, -0.00253295898437500040f, - 0.01004028320312500000f, 0.00701904296875000090f, - -0.00949096679687500000f, -0.00790405273437500000f, - 0.00540161132812500090f, -0.00079345703125000011f, - -0.01409912109375000000f, 0.00271606445312500000f, - 0.00784301757812500000f, 0.00018310546875000000f, - -0.00396728515625000000f, -0.00283813476562499960f, - -0.01391601562500000000f, -0.00967407226562500000f, - -0.00674438476562500000f, -0.00628662109375000000f, - -0.01272583007812500000f, -0.00555419921875000000f, - -0.00225830078125000000f, 0.00714111328125000000f, - 0.00146484375000000000f, 0.00796508789062500000f, - 0.01095581054687500000f, 0.00704956054687500000f, - 0.00787353515625000000f, 0.00259399414062500000f, - -0.00860595703125000000f, 0.00769042968750000000f, - -0.00448608398437500000f, -0.00677490234375000000f, - 0.00765991210937500090f, -0.00631713867187499910f, - 0.01351928710937500000f, 0.00375366210937500000f, - -0.01272583007812500000f, -0.00109863281250000000f, - 0.00833129882812500000f, -0.00735473632812500090f, - 0.00732421874999999910f, -0.00341796875000000000f, - 0.00134277343749999980f, -0.00509643554687500000f, - 0.00384521484375000000f, -0.00378417968750000000f, - -0.00234985351562500000f, 0.00177001953125000000f, - -0.01223754882812500000f, 0.01016235351562500000f, - -0.00360107421875000000f, 0.00250244140625000000f, - 0.00384521484375000000f, 0.00460815429687500000f, - -0.01321411132812500000f, 0.01095581054687500000f, - -0.00396728515625000000f, -0.00311279296875000000f, - 0.00399780273437500000f, -0.00744628906250000000f, - 0.00262451171875000000f, 0.00259399414062500000f, - -0.01409912109375000000f, 0.01263427734374999800f, - -0.00732421874999999910f, 0.00048828125000000000f, - 0.00442504882812500000f, 0.00085449218750000000f, - -0.00625610351562500000f, -0.01467895507812500000f, - 0.01138305664062500000f, 0.00894165039062500000f, - -0.00219726562500000000f, -0.00531005859375000000f, - 0.00189208984375000000f, 0.00790405273437500000f, - -0.00024414062500000000f, -0.00054931640625000000f, - 0.01104736328125000000f, 0.00711059570312500000f, - 0.00564575195312500000f, 0.00131225585937500000f, - 0.00848388671875000000f, 0.00082397460937500000f, - 0.00588989257812500000f, 0.01739501953125000000f, - -0.00756835937500000000f, 0.00576782226562500000f, - 0.00280761718750000000f, 0.00094604492187500000f, - -0.00839233398437500000f, -0.00009155273437500000f, - 0.00741577148437500000f, 0.00537109374999999910f, - 0.01336669921875000200f, 0.00637817382812500090f, - 0.00628662109375000000f, -0.00155639648437500000f, - 0.00241088867187500000f, 0.00332641601562499960f, - 0.00512695312500000000f, -0.00564575195312500000f, - -0.00939941406250000000f, -0.00207519531250000000f, - -0.01885986328125000000f, 0.01174926757812500200f, - -0.00946044921875000000f, -0.00329589843750000000f, - -0.00500488281250000000f, 0.00503540039062499910f, - 0.00186157226562500000f, -0.00463867187500000000f, - -0.00308227539062500000f, -0.01257324218750000000f, - -0.00817871093750000000f, -0.00784301757812500000f, - -0.00122070312500000000f, -0.00061035156250000000f, - -0.00085449218750000000f, -0.00482177734375000000f, - -0.00918579101562500000f, 0.00827026367187500000f, - 0.01159667968750000000f, -0.01031494140625000000f, - -0.01119995117187500000f, -0.00402832031250000000f, - 0.00195312500000000000f, 0.00347900390625000000f, - -0.00399780273437500000f, -0.00686645507812500000f, - -0.00476074218750000000f, -0.00793457031250000000f, - -0.00192260742187500000f, -0.00354003906250000000f, - 0.00473022460937500000f, -0.01788330078125000000f, - -0.00616455078125000000f, 0.00775146484375000000f, - -0.00875854492187500000f, 0.00543212890625000000f, - 0.00692749023437500000f, -0.00323486328125000000f, - -0.00897216796875000000f, 0.00500488281250000000f, - 0.00909423828125000000f, -0.00305175781250000000f, - 0.00564575195312500000f, 0.00967407226562500000f, - 0.00588989257812500000f, -0.00137329101562500000f, - 0.00085449218750000000f, 0.00244140625000000000f, - -0.00265502929687500000f, -0.01321411132812500000f, - 0.00067138671874999989f, -0.00146484375000000000f, - 0.00146484375000000000f, -0.00723266601562500000f, - -0.00698852539062499910f, -0.00424194335937500000f, - 0.00366210937499999960f, -0.01110839843750000000f, - 0.00817871093750000000f, -0.00415039062500000000f, - 0.01208496093750000200f, 0.00381469726562499960f, - 0.00396728515625000000f, -0.00271606445312500000f, - -0.00830078125000000000f, 0.00360107421875000000f, - -0.00781250000000000000f, -0.00207519531250000000f, - -0.01376342773437500000f, 0.01489257812500000000f, - 0.00436401367187500000f, -0.00503540039062499910f, - -0.00146484375000000000f, -0.00579833984375000000f, - 0.00323486328125000000f, 0.00668334960937500090f, - 0.00143432617187500000f, 0.01327514648437500000f, - 0.00747680664062500000f, 0.00296020507812500000f, - 0.00228881835937500000f, -0.01275634765625000200f, - 0.00369262695312500000f, -0.00570678710937500090f, - 0.01739501953125000000f, -0.00610351562500000000f, - -0.01071166992187500000f, 0.00686645507812500000f, - -0.00064086914062500000f, -0.00662231445312500000f, - 0.00714111328125000000f, -0.00338745117187500000f, - 0.00592041015625000000f, 0.00042724609375000000f, - 0.00738525390625000000f, 0.00360107421875000000f, - 0.00427246093750000000f, -0.01211547851562500000f, - 0.01083374023437500000f, 0.01101684570312499800f, - -0.00137329101562500000f, -0.00595092773437500000f - }; - -// const SKP_Silk_NLSF_CBS_FLP SKP_Silk_NLSF_CB0_10_Stage_info_FLP[ NLSF_MSVQ_CB0_10_STAGES ] = -// { -// { 64, &SKP_Silk_NLSF_MSVQ_CB0_10[ 10 * 0 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates[ 0 ] }, -// { 16, &SKP_Silk_NLSF_MSVQ_CB0_10[ 10 * 64 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates[ 64 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB0_10[ 10 * 80 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates[ 80 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB0_10[ 10 * 88 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates[ 88 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB0_10[ 10 * 96 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates[ 96 ] }, -// { 16, &SKP_Silk_NLSF_MSVQ_CB0_10[ 10 * 104 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates[ 104 ] } -// }; - static final SKP_Silk_NLSF_CBS_FLP[] SKP_Silk_NLSF_CB0_10_Stage_info_FLP = - { - new SKP_Silk_NLSF_CBS_FLP(64, SKP_Silk_NLSF_MSVQ_CB0_10, 10*0, SKP_Silk_NLSF_MSVQ_CB0_10_rates, 0), - new SKP_Silk_NLSF_CBS_FLP(16, SKP_Silk_NLSF_MSVQ_CB0_10, 10*64, SKP_Silk_NLSF_MSVQ_CB0_10_rates, 64), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB0_10, 10*80, SKP_Silk_NLSF_MSVQ_CB0_10_rates, 80), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB0_10, 10*88, SKP_Silk_NLSF_MSVQ_CB0_10_rates, 88), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB0_10, 10*96, SKP_Silk_NLSF_MSVQ_CB0_10_rates, 96), - new SKP_Silk_NLSF_CBS_FLP(16, SKP_Silk_NLSF_MSVQ_CB0_10, 10*104, SKP_Silk_NLSF_MSVQ_CB0_10_rates, 104) - }; - -// const SKP_Silk_NLSF_CB_FLP SKP_Silk_NLSF_CB0_10_FLP = -// { -// NLSF_MSVQ_CB0_10_STAGES, -// SKP_Silk_NLSF_CB0_10_Stage_info_FLP, -// SKP_Silk_NLSF_MSVQ_CB0_10_ndelta_min, -// SKP_Silk_NLSF_MSVQ_CB0_10_CDF, -// SKP_Silk_NLSF_MSVQ_CB0_10_CDF_start_ptr, -// SKP_Silk_NLSF_MSVQ_CB0_10_CDF_middle_idx -// }; - static final SKP_Silk_NLSF_CB_FLP SKP_Silk_NLSF_CB0_10_FLP = - new SKP_Silk_NLSF_CB_FLP( - Silk_tables_NLSF_CB0_10.NLSF_MSVQ_CB0_10_STAGES, - SKP_Silk_NLSF_CB0_10_Stage_info_FLP, - SKP_Silk_NLSF_MSVQ_CB0_10_ndelta_min, - Silk_tables_NLSF_CB0_10.SKP_Silk_NLSF_MSVQ_CB0_10_CDF, - Silk_tables_NLSF_CB0_10.SKP_Silk_NLSF_MSVQ_CB0_10_CDF_start_ptr, - Silk_tables_NLSF_CB0_10.SKP_Silk_NLSF_MSVQ_CB0_10_CDF_middle_idx - ); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB0_16.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB0_16.java deleted file mode 100644 index f42e661bf..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB0_16.java +++ /dev/null @@ -1,1325 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * This file has been automatically generated - * ROM usage: 0.51 + 7.38 kB - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_tables_NLSF_CB0_16 -{ - static final int NLSF_MSVQ_CB0_16_STAGES = 10; - static final int NLSF_MSVQ_CB0_16_VECTORS = 216; - - static final int[] SKP_Silk_NLSF_MSVQ_CB0_16_CDF = - { - 0, - 1449, - 2749, - 4022, - 5267, - 6434, - 7600, - 8647, - 9695, - 10742, - 11681, - 12601, - 13444, - 14251, - 15008, - 15764, - 16521, - 17261, - 18002, - 18710, - 19419, - 20128, - 20837, - 21531, - 22225, - 22919, - 23598, - 24277, - 24956, - 25620, - 26256, - 26865, - 27475, - 28071, - 28667, - 29263, - 29859, - 30443, - 31026, - 31597, - 32168, - 32727, - 33273, - 33808, - 34332, - 34855, - 35379, - 35902, - 36415, - 36927, - 37439, - 37941, - 38442, - 38932, - 39423, - 39914, - 40404, - 40884, - 41364, - 41844, - 42324, - 42805, - 43285, - 43754, - 44224, - 44694, - 45164, - 45623, - 46083, - 46543, - 46993, - 47443, - 47892, - 48333, - 48773, - 49213, - 49653, - 50084, - 50515, - 50946, - 51377, - 51798, - 52211, - 52614, - 53018, - 53422, - 53817, - 54212, - 54607, - 55002, - 55388, - 55775, - 56162, - 56548, - 56910, - 57273, - 57635, - 57997, - 58352, - 58698, - 59038, - 59370, - 59702, - 60014, - 60325, - 60630, - 60934, - 61239, - 61537, - 61822, - 62084, - 62346, - 62602, - 62837, - 63072, - 63302, - 63517, - 63732, - 63939, - 64145, - 64342, - 64528, - 64701, - 64867, - 65023, - 65151, - 65279, - 65407, - 65535, - 0, - 5099, - 9982, - 14760, - 19538, - 24213, - 28595, - 32976, - 36994, - 41012, - 44944, - 48791, - 52557, - 56009, - 59388, - 62694, - 65535, - 0, - 9955, - 19697, - 28825, - 36842, - 44686, - 52198, - 58939, - 65535, - 0, - 8949, - 17335, - 25720, - 33926, - 41957, - 49987, - 57845, - 65535, - 0, - 9724, - 18642, - 26998, - 35355, - 43532, - 51534, - 59365, - 65535, - 0, - 8750, - 17499, - 26249, - 34448, - 42471, - 50494, - 58178, - 65535, - 0, - 8730, - 17273, - 25816, - 34176, - 42536, - 50203, - 57869, - 65535, - 0, - 8769, - 17538, - 26307, - 34525, - 42742, - 50784, - 58319, - 65535, - 0, - 8736, - 17101, - 25466, - 33653, - 41839, - 50025, - 57864, - 65535, - 0, - 4368, - 8735, - 12918, - 17100, - 21283, - 25465, - 29558, - 33651, - 37744, - 41836, - 45929, - 50022, - 54027, - 57947, - 61782, - 65535 - }; - - static private int [] SKP_Silk_NLSF_MSVQ_CB0_16_CDF_0 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_16_CDF, 0, SKP_Silk_NLSF_MSVQ_CB0_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_16_CDF_129 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_16_CDF, 129, SKP_Silk_NLSF_MSVQ_CB0_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_16_CDF_146 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_16_CDF, 146, SKP_Silk_NLSF_MSVQ_CB0_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_16_CDF_155 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_16_CDF, 155, SKP_Silk_NLSF_MSVQ_CB0_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_16_CDF_164 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_16_CDF, 164, SKP_Silk_NLSF_MSVQ_CB0_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_16_CDF_173 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_16_CDF, 173, SKP_Silk_NLSF_MSVQ_CB0_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_16_CDF_182 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_16_CDF, 182, SKP_Silk_NLSF_MSVQ_CB0_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_16_CDF_191 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_16_CDF, 191, SKP_Silk_NLSF_MSVQ_CB0_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_16_CDF_200 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_16_CDF, 200, SKP_Silk_NLSF_MSVQ_CB0_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB0_16_CDF_209 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB0_16_CDF, 209, SKP_Silk_NLSF_MSVQ_CB0_16_CDF.length); - - static final int[][] SKP_Silk_NLSF_MSVQ_CB0_16_CDF_start_ptr = - { - SKP_Silk_NLSF_MSVQ_CB0_16_CDF_0, - SKP_Silk_NLSF_MSVQ_CB0_16_CDF_129, - SKP_Silk_NLSF_MSVQ_CB0_16_CDF_146, - SKP_Silk_NLSF_MSVQ_CB0_16_CDF_155, - SKP_Silk_NLSF_MSVQ_CB0_16_CDF_164, - SKP_Silk_NLSF_MSVQ_CB0_16_CDF_173, - SKP_Silk_NLSF_MSVQ_CB0_16_CDF_182, - SKP_Silk_NLSF_MSVQ_CB0_16_CDF_191, - SKP_Silk_NLSF_MSVQ_CB0_16_CDF_200, - SKP_Silk_NLSF_MSVQ_CB0_16_CDF_209 - }; - - static final int[] SKP_Silk_NLSF_MSVQ_CB0_16_CDF_middle_idx = - { - 42, - 8, - 4, - 5, - 5, - 5, - 5, - 5, - 5, - 9 - }; - - static final short[] SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q5 = - { - 176, 181, - 182, 183, - 186, 186, - 191, 191, - 191, 196, - 197, 201, - 203, 206, - 206, 206, - 207, 207, - 209, 209, - 209, 209, - 210, 210, - 210, 211, - 211, 211, - 212, 214, - 216, 216, - 217, 217, - 217, 217, - 218, 218, - 219, 219, - 220, 221, - 222, 223, - 223, 223, - 223, 224, - 224, 224, - 225, 225, - 226, 226, - 226, 226, - 227, 227, - 227, 227, - 227, 227, - 228, 228, - 228, 228, - 229, 229, - 229, 230, - 230, 230, - 231, 231, - 231, 231, - 232, 232, - 232, 232, - 233, 234, - 235, 235, - 235, 236, - 236, 236, - 236, 237, - 237, 237, - 237, 240, - 240, 240, - 240, 241, - 242, 243, - 244, 244, - 247, 247, - 248, 248, - 248, 249, - 251, 255, - 255, 256, - 260, 260, - 261, 264, - 264, 266, - 266, 268, - 271, 274, - 276, 279, - 288, 288, - 288, 288, - 118, 120, - 121, 121, - 122, 125, - 125, 129, - 129, 130, - 131, 132, - 136, 137, - 138, 145, - 87, 88, - 91, 97, - 98, 100, - 105, 106, - 92, 95, - 95, 96, - 97, 97, - 98, 99, - 88, 92, - 95, 95, - 96, 97, - 98, 109, - 93, 93, - 93, 96, - 97, 97, - 99, 101, - 93, 94, - 94, 95, - 95, 99, - 99, 99, - 93, 93, - 93, 96, - 96, 97, - 100, 102, - 93, 95, - 95, 96, - 96, 96, - 98, 99, - 125, 125, - 127, 127, - 127, 127, - 128, 128, - 128, 128, - 128, 128, - 129, 130, - 131, 132 - }; - - static final int[] SKP_Silk_NLSF_MSVQ_CB0_16_ndelta_min_Q15 = - { - 266, - 3, - 40, - 3, - 3, - 16, - 78, - 89, - 107, - 141, - 188, - 146, - 272, - 240, - 235, - 215, - 632 - }; - - static final short[]SKP_Silk_NLSF_MSVQ_CB0_16_Q15 = - { - 1170, 2278, 3658, 5374, - 7666, 9113, 11298, 13304, - 15371, 17549, 19587, 21487, - 23798, 26038, 28318, 30201, - 1628, 2334, 4115, 6036, - 7818, 9544, 11777, 14021, - 15787, 17408, 19466, 21261, - 22886, 24565, 26714, 28059, - 1724, 2670, 4056, 6532, - 8357, 10119, 12093, 14061, - 16491, 18795, 20417, 22402, - 24251, 26224, 28410, 29956, - 1493, 3427, 4789, 6399, - 8435, 10168, 12000, 14066, - 16229, 18210, 20040, 22098, - 24153, 26095, 28183, 30121, - 1119, 2089, 4295, 6245, - 8691, 10741, 12688, 15057, - 17028, 18792, 20717, 22514, - 24497, 26548, 28619, 30630, - 1363, 2417, 3927, 5556, - 7422, 9315, 11879, 13767, - 16143, 18520, 20458, 22578, - 24539, 26436, 28318, 30318, - 1122, 2503, 5216, 7148, - 9310, 11078, 13175, 14800, - 16864, 18700, 20436, 22488, - 24572, 26602, 28555, 30426, - 600, 1317, 2970, 5609, - 7694, 9784, 12169, 14087, - 16379, 18378, 20551, 22686, - 24739, 26697, 28646, 30355, - 941, 1882, 4274, 5540, - 8482, 9858, 11940, 14287, - 16091, 18501, 20326, 22612, - 24711, 26638, 28814, 30430, - 635, 1699, 4376, 5948, - 8097, 10115, 12274, 14178, - 16111, 17813, 19695, 21773, - 23927, 25866, 28022, 30134, - 1408, 2222, 3524, 5615, - 7345, 8849, 10989, 12772, - 15352, 17026, 18919, 21062, - 23329, 25215, 27209, 29023, - 701, 1307, 3548, 6301, - 7744, 9574, 11227, 12978, - 15170, 17565, 19775, 22097, - 24230, 26335, 28377, 30231, - 1752, 2364, 4879, 6569, - 7813, 9796, 11199, 14290, - 15795, 18000, 20396, 22417, - 24308, 26124, 28360, 30633, - 901, 1629, 3356, 4635, - 7256, 8767, 9971, 11558, - 15215, 17544, 19523, 21852, - 23900, 25978, 28133, 30184, - 981, 1669, 3323, 4693, - 6213, 8692, 10614, 12956, - 15211, 17711, 19856, 22122, - 24344, 26592, 28723, 30481, - 1607, 2577, 4220, 5512, - 8532, 10388, 11627, 13671, - 15752, 17199, 19840, 21859, - 23494, 25786, 28091, 30131, - 811, 1471, 3144, 5041, - 7430, 9389, 11174, 13255, - 15157, 16741, 19583, 22167, - 24115, 26142, 28383, 30395, - 1543, 2144, 3629, 6347, - 7333, 9339, 10710, 13596, - 15099, 17340, 20102, 21886, - 23732, 25637, 27818, 29917, - 492, 1185, 2940, 5488, - 7095, 8751, 11596, 13579, - 16045, 18015, 20178, 22127, - 24265, 26406, 28484, 30357, - 1547, 2282, 3693, 6341, - 7758, 9607, 11848, 13236, - 16564, 18069, 19759, 21404, - 24110, 26606, 28786, 30655, - 685, 1338, 3409, 5262, - 6950, 9222, 11414, 14523, - 16337, 17893, 19436, 21298, - 23293, 25181, 27973, 30520, - 887, 1581, 3057, 4318, - 7192, 8617, 10047, 13106, - 16265, 17893, 20233, 22350, - 24379, 26384, 28314, 30189, - 2285, 3745, 5662, 7576, - 9323, 11320, 13239, 15191, - 17175, 19225, 21108, 22972, - 24821, 26655, 28561, 30460, - 1496, 2108, 3448, 6898, - 8328, 9656, 11252, 12823, - 14979, 16482, 18180, 20085, - 22962, 25160, 27705, 29629, - 575, 1261, 3861, 6627, - 8294, 10809, 12705, 14768, - 17076, 19047, 20978, 23055, - 24972, 26703, 28720, 30345, - 1682, 2213, 3882, 6238, - 7208, 9646, 10877, 13431, - 14805, 16213, 17941, 20873, - 23550, 25765, 27756, 29461, - 888, 1616, 3924, 5195, - 7206, 8647, 9842, 11473, - 16067, 18221, 20343, 22774, - 24503, 26412, 28054, 29731, - 805, 1454, 2683, 4472, - 7936, 9360, 11398, 14345, - 16205, 17832, 19453, 21646, - 23899, 25928, 28387, 30463, - 1640, 2383, 3484, 5082, - 6032, 8606, 11640, 12966, - 15842, 17368, 19346, 21182, - 23638, 25889, 28368, 30299, - 1632, 2204, 4510, 7580, - 8718, 10512, 11962, 14096, - 15640, 17194, 19143, 22247, - 24563, 26561, 28604, 30509, - 2043, 2612, 3985, 6851, - 8038, 9514, 10979, 12789, - 15426, 16728, 18899, 20277, - 22902, 26209, 28711, 30618, - 2224, 2798, 4465, 5320, - 7108, 9436, 10986, 13222, - 14599, 18317, 20141, 21843, - 23601, 25700, 28184, 30582, - 835, 1541, 4083, 5769, - 7386, 9399, 10971, 12456, - 15021, 18642, 20843, 23100, - 25292, 26966, 28952, 30422, - 1795, 2343, 4809, 5896, - 7178, 8545, 10223, 13370, - 14606, 16469, 18273, 20736, - 23645, 26257, 28224, 30390, - 1734, 2254, 4031, 5188, - 6506, 7872, 9651, 13025, - 14419, 17305, 19495, 22190, - 24403, 26302, 28195, 30177, - 1841, 2349, 3968, 4764, - 6376, 9825, 11048, 13345, - 14682, 16252, 18183, 21363, - 23918, 26156, 28031, 29935, - 1432, 2047, 5631, 6927, - 8198, 9675, 11358, 13506, - 14802, 16419, 18339, 22019, - 24124, 26177, 28130, 30586, - 1730, 2320, 3744, 4808, - 6007, 9666, 10997, 13622, - 15234, 17495, 20088, 22002, - 23603, 25400, 27379, 29254, - 1267, 1915, 5483, 6812, - 8229, 9919, 11589, 13337, - 14747, 17965, 20552, 22167, - 24519, 26819, 28883, 30642, - 1526, 2229, 4240, 7388, - 8953, 10450, 11899, 13718, - 16861, 18323, 20379, 22672, - 24797, 26906, 28906, 30622, - 2175, 2791, 4104, 6875, - 8612, 9798, 12152, 13536, - 15623, 17682, 19213, 21060, - 24382, 26760, 28633, 30248, - 454, 1231, 4339, 5738, - 7550, 9006, 10320, 13525, - 16005, 17849, 20071, 21992, - 23949, 26043, 28245, 30175, - 2250, 2791, 4230, 5283, - 6762, 10607, 11879, 13821, - 15797, 17264, 20029, 22266, - 24588, 26437, 28244, 30419, - 1696, 2216, 4308, 8385, - 9766, 11030, 12556, 14099, - 16322, 17640, 19166, 20590, - 23967, 26858, 28798, 30562, - 2452, 3236, 4369, 6118, - 7156, 9003, 11509, 12796, - 15749, 17291, 19491, 22241, - 24530, 26474, 28273, 30073, - 1811, 2541, 3555, 5480, - 9123, 10527, 11894, 13659, - 15262, 16899, 19366, 21069, - 22694, 24314, 27256, 29983, - 1553, 2246, 4559, 5500, - 6754, 7874, 11739, 13571, - 15188, 17879, 20281, 22510, - 24614, 26649, 28786, 30755, - 1982, 2768, 3834, 5964, - 8732, 9908, 11797, 14813, - 16311, 17946, 21097, 22851, - 24456, 26304, 28166, 29755, - 1824, 2529, 3817, 5449, - 6854, 8714, 10381, 12286, - 14194, 15774, 19524, 21374, - 23695, 26069, 28096, 30212, - 2212, 2854, 3947, 5898, - 9930, 11556, 12854, 14788, - 16328, 17700, 20321, 22098, - 23672, 25291, 26976, 28586, - 2023, 2599, 4024, 4916, - 6613, 11149, 12457, 14626, - 16320, 17822, 19673, 21172, - 23115, 26051, 28825, 30758, - 1628, 2206, 3467, 4364, - 8679, 10173, 11864, 13679, - 14998, 16938, 19207, 21364, - 23850, 26115, 28124, 30273, - 2014, 2603, 4114, 7254, - 8516, 10043, 11822, 13503, - 16329, 17826, 19697, 21280, - 23151, 24661, 26807, 30161, - 2376, 2980, 4422, 5770, - 7016, 9723, 11125, 13516, - 15485, 16985, 19160, 20587, - 24401, 27180, 29046, 30647, - 2454, 3502, 4624, 6019, - 7632, 8849, 10792, 13964, - 15523, 17085, 19611, 21238, - 22856, 25108, 28106, 29890, - 1573, 2274, 3308, 5999, - 8977, 10104, 12457, 14258, - 15749, 18180, 19974, 21253, - 23045, 25058, 27741, 30315, - 1943, 2730, 4140, 6160, - 7491, 8986, 11309, 12775, - 14820, 16558, 17909, 19757, - 21512, 23605, 27274, 29527, - 2021, 2582, 4494, 5835, - 6993, 8245, 9827, 14733, - 16462, 17894, 19647, 21083, - 23764, 26667, 29072, 30990, - 1052, 1775, 3218, 4378, - 7666, 9403, 11248, 13327, - 14972, 17962, 20758, 22354, - 25071, 27209, 29001, 30609, - 2218, 2866, 4223, 5352, - 6581, 9980, 11587, 13121, - 15193, 16583, 18386, 20080, - 22013, 25317, 28127, 29880, - 2146, 2840, 4397, 5840, - 7449, 8721, 10512, 11936, - 13595, 17253, 19310, 20891, - 23417, 25627, 27749, 30231, - 1972, 2619, 3756, 6367, - 7641, 8814, 12286, 13768, - 15309, 18036, 19557, 20904, - 22582, 24876, 27800, 30440, - 2005, 2577, 4272, 7373, - 8558, 10223, 11770, 13402, - 16502, 18000, 19645, 21104, - 22990, 26806, 29505, 30942, - 1153, 1822, 3724, 5443, - 6990, 8702, 10289, 11899, - 13856, 15315, 17601, 21064, - 23692, 26083, 28586, 30639, - 1304, 1869, 3318, 7195, - 9613, 10733, 12393, 13728, - 15822, 17474, 18882, 20692, - 23114, 25540, 27684, 29244, - 2093, 2691, 4018, 6658, - 7947, 9147, 10497, 11881, - 15888, 17821, 19333, 21233, - 23371, 25234, 27553, 29998, - 575, 1331, 5304, 6910, - 8425, 10086, 11577, 13498, - 16444, 18527, 20565, 22847, - 24914, 26692, 28759, 30157, - 1435, 2024, 3283, 4156, - 7611, 10592, 12049, 13927, - 15459, 18413, 20495, 22270, - 24222, 26093, 28065, 30099, - 1632, 2168, 5540, 7478, - 8630, 10391, 11644, 14321, - 15741, 17357, 18756, 20434, - 22799, 26060, 28542, 30696, - 1407, 2245, 3405, 5639, - 9419, 10685, 12104, 13495, - 15535, 18357, 19996, 21689, - 24351, 26550, 28853, 30564, - 1675, 2226, 4005, 8223, - 9975, 11155, 12822, 14316, - 16504, 18137, 19574, 21050, - 22759, 24912, 28296, 30634, - 1080, 1614, 3622, 7565, - 8748, 10303, 11713, 13848, - 15633, 17434, 19761, 21825, - 23571, 25393, 27406, 29063, - 1693, 2229, 3456, 4354, - 5670, 10890, 12563, 14167, - 15879, 17377, 19817, 21971, - 24094, 26131, 28298, 30099, - 2042, 2959, 4195, 5740, - 7106, 8267, 11126, 14973, - 16914, 18295, 20532, 21982, - 23711, 25769, 27609, 29351, - 984, 1612, 3808, 5265, - 6885, 8411, 9547, 10889, - 12522, 16520, 19549, 21639, - 23746, 26058, 28310, 30374, - 2036, 2538, 4166, 7761, - 9146, 10412, 12144, 13609, - 15588, 17169, 18559, 20113, - 21820, 24313, 28029, 30612, - 1871, 2355, 4061, 5143, - 7464, 10129, 11941, 15001, - 16680, 18354, 19957, 22279, - 24861, 26872, 28988, 30615, - 2566, 3161, 4643, 6227, - 7406, 9970, 11618, 13416, - 15889, 17364, 19121, 20817, - 22592, 24720, 28733, 31082, - 1700, 2327, 4828, 5939, - 7567, 9154, 11087, 12771, - 14209, 16121, 20222, 22671, - 24648, 26656, 28696, 30745, - 3169, 3873, 5046, 6868, - 8184, 9480, 12335, 14068, - 15774, 17971, 20231, 21711, - 23520, 25245, 27026, 28730, - 1564, 2391, 4229, 6730, - 8905, 10459, 13026, 15033, - 17265, 19809, 21849, 23741, - 25490, 27312, 29061, 30527, - 2864, 3559, 4719, 6441, - 9592, 11055, 12763, 14784, - 16428, 18164, 20486, 22262, - 24183, 26263, 28383, 30224, - 2673, 3449, 4581, 5983, - 6863, 8311, 12464, 13911, - 15738, 17791, 19416, 21182, - 24025, 26561, 28723, 30440, - 2419, 3049, 4274, 6384, - 8564, 9661, 11288, 12676, - 14447, 17578, 19816, 21231, - 23099, 25270, 26899, 28926, - 1278, 2001, 3000, 5353, - 9995, 11777, 13018, 14570, - 16050, 17762, 19982, 21617, - 23371, 25083, 27656, 30172, - 932, 1624, 2798, 4570, - 8592, 9988, 11552, 13050, - 16921, 18677, 20415, 22810, - 24817, 26819, 28804, 30385, - 2324, 2973, 4156, 5702, - 6919, 8806, 10259, 12503, - 15015, 16567, 19418, 21375, - 22943, 24550, 27024, 29849, - 1564, 2373, 3455, 4907, - 5975, 7436, 11786, 14505, - 16107, 18148, 20019, 21653, - 23740, 25814, 28578, 30372, - 3025, 3729, 4866, 6520, - 9487, 10943, 12358, 14258, - 16174, 17501, 19476, 21408, - 23227, 24906, 27347, 29407, - 1270, 1965, 6802, 7995, - 9204, 10828, 12507, 14230, - 15759, 17860, 20369, 22502, - 24633, 26514, 28535, 30525, - 2210, 2749, 4266, 7487, - 9878, 11018, 12823, 14431, - 16247, 18626, 20450, 22054, - 23739, 25291, 27074, 29169, - 1275, 1926, 4330, 6573, - 8441, 10920, 13260, 15008, - 16927, 18573, 20644, 22217, - 23983, 25474, 27372, 28645, - 3015, 3670, 5086, 6372, - 7888, 9309, 10966, 12642, - 14495, 16172, 18080, 19972, - 22454, 24899, 27362, 29975, - 2882, 3733, 5113, 6482, - 8125, 9685, 11598, 13288, - 15405, 17192, 20178, 22426, - 24801, 27014, 29212, 30811, - 2300, 2968, 4101, 5442, - 6327, 7910, 12455, 13862, - 15747, 17505, 19053, 20679, - 22615, 24658, 27499, 30065, - 2257, 2940, 4430, 5991, - 7042, 8364, 9414, 11224, - 15723, 17420, 19253, 21469, - 23915, 26053, 28430, 30384, - 1227, 2045, 3818, 5011, - 6990, 9231, 11024, 13011, - 17341, 19017, 20583, 22799, - 25195, 26876, 29351, 30805, - 1354, 1924, 3789, 8077, - 10453, 11639, 13352, 14817, - 16743, 18189, 20095, 22014, - 24593, 26677, 28647, 30256, - 3142, 4049, 6197, 7417, - 8753, 10156, 11533, 13181, - 15947, 17655, 19606, 21402, - 23487, 25659, 28123, 30304, - 1317, 2263, 4725, 7611, - 9667, 11634, 14143, 16258, - 18724, 20698, 22379, 24007, - 25775, 27251, 28930, 30593, - 1570, 2323, 3818, 6215, - 9893, 11556, 13070, 14631, - 16152, 18290, 21386, 23346, - 25114, 26923, 28712, 30168, - 2297, 3905, 6287, 8558, - 10668, 12766, 15019, 17102, - 19036, 20677, 22341, 23871, - 25478, 27085, 28851, 30520, - 1915, 2507, 4033, 5749, - 7059, 8871, 10659, 12198, - 13937, 15383, 16869, 18707, - 23175, 25818, 28514, 30501, - 2404, 2918, 5190, 6252, - 7426, 9887, 12387, 14795, - 16754, 18368, 20338, 22003, - 24236, 26456, 28490, 30397, - 1621, 2227, 3479, 5085, - 9425, 12892, 14246, 15652, - 17205, 18674, 20446, 22209, - 23778, 25867, 27931, 30093, - 1869, 2390, 4105, 7021, - 11221, 12775, 14059, 15590, - 17024, 18608, 20595, 22075, - 23649, 25154, 26914, 28671, - 2551, 3252, 4688, 6562, - 7869, 9125, 10475, 11800, - 15402, 18780, 20992, 22555, - 24289, 25968, 27465, 29232, - 2705, 3493, 4735, 6360, - 7905, 9352, 11538, 13430, - 15239, 16919, 18619, 20094, - 21800, 23342, 25200, 29257, - 2166, 2791, 4011, 5081, - 5896, 9038, 13407, 14703, - 16543, 18189, 19896, 21857, - 24872, 26971, 28955, 30514, - 1865, 3021, 4696, 6534, - 8343, 9914, 12789, 14103, - 16533, 17729, 21340, 22439, - 24873, 26330, 28428, 30154, - 3369, 4345, 6573, 8763, - 10309, 11713, 13367, 14784, - 16483, 18145, 19839, 21247, - 23292, 25477, 27555, 29447, - 1265, 2184, 5443, 7893, - 10591, 13139, 15105, 16639, - 18402, 19826, 21419, 22995, - 24719, 26437, 28363, 30125, - 1584, 2004, 3535, 4450, - 8662, 10764, 12832, 14978, - 16972, 18794, 20932, 22547, - 24636, 26521, 28701, 30567, - 3419, 4528, 6602, 7890, - 9508, 10875, 12771, 14357, - 16051, 18330, 20630, 22490, - 25070, 26936, 28946, 30542, - 1726, 2252, 4597, 6950, - 8379, 9823, 11363, 12794, - 14306, 15476, 16798, 18018, - 21671, 25550, 28148, 30367, - 3385, 3870, 5307, 6388, - 7141, 8684, 12695, 14939, - 16480, 18277, 20537, 22048, - 23947, 25965, 28214, 29956, - 2771, 3306, 4450, 5560, - 6453, 9493, 13548, 14754, - 16743, 18447, 20028, 21736, - 23746, 25353, 27141, 29066, - 3028, 3900, 6617, 7893, - 9211, 10480, 12047, 13583, - 15182, 16662, 18502, 20092, - 22190, 24358, 26302, 28957, - 2000, 2550, 4067, 6837, - 9628, 11002, 12594, 14098, - 15589, 17195, 18679, 20099, - 21530, 23085, 24641, 29022, - 2844, 3302, 5103, 6107, - 6911, 8598, 12416, 14054, - 16026, 18567, 20672, 22270, - 23952, 25771, 27658, 30026, - 4043, 5150, 7268, 9056, - 10916, 12638, 14543, 16184, - 17948, 19691, 21357, 22981, - 24825, 26591, 28479, 30233, - 2109, 2625, 4320, 5525, - 7454, 10220, 12980, 14698, - 17627, 19263, 20485, 22381, - 24279, 25777, 27847, 30458, - 1550, 2667, 6473, 9496, - 10985, 12352, 13795, 15233, - 17099, 18642, 20461, 22116, - 24197, 26291, 28403, 30132, - 2411, 3084, 4145, 5394, - 6367, 8154, 13125, 16049, - 17561, 19125, 21258, 22762, - 24459, 26317, 28255, 29702, - 4159, 4516, 5956, 7635, - 8254, 8980, 11208, 14133, - 16210, 17875, 20196, 21864, - 23840, 25747, 28058, 30012, - 2026, 2431, 2845, 3618, - 7950, 9802, 12721, 14460, - 16576, 18984, 21376, 23319, - 24961, 26718, 28971, 30640, - 3429, 3833, 4472, 4912, - 7723, 10386, 12981, 15322, - 16699, 18807, 20778, 22551, - 24627, 26494, 28334, 30482, - 4740, 5169, 5796, 6485, - 6998, 8830, 11777, 14414, - 16831, 18413, 20789, 22369, - 24236, 25835, 27807, 30021, - 150, 168, -17, -107, - -142, -229, -320, -406, - -503, -620, -867, -935, - -902, -680, -398, -114, - -398, -355, 49, 255, - 114, 260, 399, 264, - 317, 431, 514, 531, - 435, 356, 238, 106, - -43, -36, -169, -224, - -391, -633, -776, -970, - -844, -455, -181, -12, - 85, 85, 164, 195, - 122, 85, -158, -640, - -903, 9, 7, -124, - 149, 32, 220, 369, - 242, 115, 79, 84, - -146, -216, -70, 1024, - 751, 574, 440, 377, - 352, 203, 30, 16, - -3, 81, 161, 100, - -148, -176, 933, 750, - 404, 171, -2, -146, - -411, -442, -541, -552, - -442, -269, -240, -52, - 603, 635, 405, 178, - 215, 19, -153, -167, - -290, -219, 151, 271, - 151, 119, 303, 266, - 100, 69, -293, -657, - 939, 659, 442, 351, - 132, 98, -16, -1, - -135, -200, -223, -89, - 167, 154, 172, 237, - -45, -183, -228, -486, - 263, 608, 158, -125, - -390, -227, -118, 43, - -457, -392, -769, -840, - 20, -117, -194, -189, - -173, -173, -33, 32, - 174, 144, 115, 167, - 57, 44, 14, 147, - 96, -54, -142, -129, - -254, -331, 304, 310, - -52, -419, -846, -1060, - -88, -123, -202, -343, - -554, -961, -951, 327, - 159, 81, 255, 227, - 120, 203, 256, 192, - 164, 224, 290, 195, - 216, 209, 128, 832, - 1028, 889, 698, 504, - 408, 355, 218, 32, - -115, -84, -276, -100, - -312, -484, 899, 682, - 465, 456, 241, -12, - -275, -425, -461, -367, - -33, -28, -102, -194, - -527, 863, 906, 463, - 245, 13, -212, -305, - -105, 163, 279, 176, - 93, 67, 115, 192, - 61, -50, -132, -175, - -224, -271, -629, -252, - 1158, 972, 638, 280, - 300, 326, 143, -152, - -214, -287, 53, -42, - -236, -352, -423, -248, - -129, -163, -178, -119, - 85, 57, 514, 382, - 374, 402, 424, 423, - 271, 197, 97, 40, - 39, -97, -191, -164, - -230, -256, -410, 396, - 327, 127, 10, -119, - -167, -291, -274, -141, - -99, -226, -218, -139, - -224, -209, -268, -442, - -413, 222, 58, 521, - 344, 258, 76, -42, - -142, -165, -123, -92, - 47, 8, -3, -191, - -11, -164, -167, -351, - -740, 311, 538, 291, - 184, 29, -105, 9, - -30, -54, -17, -77, - -271, -412, -622, -648, - 476, 186, -66, -197, - -73, -94, -15, 47, - 28, 112, -58, -33, - 65, 19, 84, 86, - 276, 114, 472, 786, - 799, 625, 415, 178, - -35, -26, 5, 9, - 83, 39, 37, 39, - -184, -374, -265, -362, - -501, 337, 716, 478, - -60, -125, -163, 362, - 17, -122, -233, 279, - 138, 157, 318, 193, - 189, 209, 266, 252, - -46, -56, -277, -429, - 464, 386, 142, 44, - -43, 66, 264, 182, - 47, 14, -26, -79, - 49, 15, -128, -203, - -400, -478, 325, 27, - 234, 411, 205, 129, - 12, 58, 123, 57, - 171, 137, 96, 128, - -32, 134, -12, 57, - 119, 26, -22, -165, - -500, -701, -528, -116, - 64, -8, 97, -9, - -162, -66, -156, -194, - -303, -546, -341, 546, - 358, 95, 45, 76, - 270, 403, 205, 100, - 123, 50, -53, -144, - -110, -13, 32, -228, - -130, 353, 296, 56, - -372, -253, 365, 73, - 10, -34, -139, -191, - -96, 5, 44, -85, - -179, -129, -192, -246, - -85, -110, -155, -44, - -27, 145, 138, 79, - 32, -148, -577, -634, - 191, 94, -9, -35, - -77, -84, -56, -171, - -298, -271, -243, -156, - -328, -235, -76, -128, - -121, 129, 13, -22, - 32, 45, -248, -65, - 193, -81, 299, 57, - -147, 192, -165, -354, - -334, -106, -156, -40, - -3, -68, 124, -257, - 78, 124, 170, 412, - 227, 105, -104, 12, - 154, 250, 274, 258, - 4, -27, 235, 152, - 51, 338, 300, 7, - -314, -411, 215, 170, - -9, -93, -77, 76, - 67, 54, 200, 315, - 163, 72, -91, -402, - 158, 187, -156, -91, - 290, 267, 167, 91, - 140, 171, 112, 9, - -42, -177, -440, 385, - 80, 15, 172, 129, - 41, -129, -372, -24, - -75, -30, -170, 10, - -118, 57, 78, -101, - 232, 161, 123, 256, - 277, 101, -192, -629, - -100, -60, -232, 66, - 13, -13, -80, -239, - 239, 37, 32, 89, - -319, -579, 450, 360, - 3, -29, -299, -89, - -54, -110, -246, -164, - 6, -188, 338, 176, - -92, 197, 137, 134, - 12, -2, 56, -183, - 114, -36, -131, -204, - 75, -25, -174, 191, - -15, -290, -429, -267, - 79, 37, 106, 23, - -384, 425, 70, -14, - 212, 105, 15, -2, - -42, -37, -123, 108, - 28, -48, 193, 197, - 173, -33, 37, 73, - -57, 256, 137, -58, - -430, -228, 217, -51, - -10, -58, -6, 22, - 104, 61, -119, 169, - 144, 16, -46, -394, - 60, 454, -80, -298, - -65, 25, 0, -24, - -65, -417, 465, 276, - -3, -194, -13, 130, - 19, -6, -21, -24, - -180, -53, -85, 20, - 118, 147, 113, -75, - -289, 226, -122, 227, - 270, 125, 109, 197, - 125, 138, 44, 60, - 25, -55, -167, -32, - -139, -193, -173, -316, - 287, -208, 253, 239, - 27, -80, -188, -28, - -182, -235, 156, -117, - 128, -48, -58, -226, - 172, 181, 167, 19, - 62, 10, 2, 181, - 151, 108, -16, -11, - -78, -331, 411, 133, - 17, 104, 64, -184, - 24, -30, -3, -283, - 121, 204, -8, -199, - -21, -80, -169, -157, - -191, -136, 81, 155, - 14, -131, 244, 74, - -57, -47, -280, 347, - 111, -77, -128, -142, - -194, -125, -6, -68, - 91, 1, 23, 14, - -154, -34, 23, -38, - -343, 503, 146, -38, - -46, -41, 58, 31, - 63, -48, -117, 45, - 28, 1, -89, -5, - -44, -29, -448, 487, - 204, 81, 46, -106, - -302, 380, 120, -38, - -12, -39, 70, -3, - 25, -65, 30, -11, - 34, -15, 22, -115, - 0, -79, -83, 45, - 114, 43, 150, 36, - 233, 149, 195, 5, - 25, -52, -475, 274, - 28, -39, -8, -66, - -255, 258, 56, 143, - -45, -190, 165, -60, - 20, 2, 125, -129, - 51, -8, -335, 288, - 38, 59, 25, -42, - 23, -118, -112, 11, - -55, -133, -109, 24, - -105, 78, -64, -245, - 202, -65, -127, 162, - 40, -94, 89, -85, - -119, -103, 97, 9, - -70, -28, 194, 86, - -112, -92, -114, 74, - -49, 46, -84, -178, - 113, 52, -205, 333, - 88, 222, 56, -55, - 13, 86, 4, -77, - 224, 114, -105, 112, - 125, -29, -18, -144, - 22, -58, -99, 28, - 114, -66, -32, -169, - -314, 285, 72, -74, - 179, 28, -79, -182, - 13, -55, 147, 13, - 12, -54, 31, -84, - -17, -75, -228, 83, - -375, 436, 110, -63, - -27, -136, 169, -56, - -8, -171, 184, -42, - 148, 68, 204, 235, - 110, -229, 91, 171, - -43, -3, -26, -99, - -111, 71, -170, 202, - -67, 181, -37, 109, - -120, 3, -55, -260, - -16, 152, 91, 142, - 42, 44, 134, 47, - 17, -35, 22, 79, - -169, 41, 46, 277, - -93, -49, -126, 37, - -103, -34, -22, -90, - -134, -205, 92, -9, - 1, -195, -239, 45, - 54, 18, -23, -1, - -80, -98, -20, -261, - 306, 72, 20, -89, - -217, 11, 6, -82, - 89, 13, -129, -89, - 83, -71, -55, 130, - -98, -146, -27, -57, - 53, 275, 17, 170, - -5, -54, 132, -64, - 72, 160, -125, -168, - 72, 40, 170, 78, - 248, 116, 20, 84, - 31, -34, 190, 38, - 13, -106, 225, 27, - -168, 24, -157, -122, - 165, 11, -161, -213, - -12, -51, -101, 42, - 101, 27, 55, 111, - 75, 71, -96, -1, - 65, -277, 393, -26, - -44, -68, -84, -66, - -95, 235, 179, -25, - -41, 27, -91, -128, - -222, 146, -72, -30, - -24, 55, -126, -68, - -58, -127, 13, -97, - -106, 174, -100, 155, - 101, -146, -21, 261, - 22, 38, -66, 65, - 4, 70, 64, 144, - 59, 213, 71, -337, - 303, -52, 51, -56, - 1, 10, -15, -5, - 34, 52, 228, 131, - 161, -127, -214, 238, - 123, 64, -147, -50, - -34, -127, 204, 162, - 85, 41, 5, -140, - 73, -150, 56, -96, - -66, -20, 2, -235, - 59, -22, -107, 150, - -16, -47, -4, 81, - -67, 167, 149, 149, - -157, 288, -156, -27, - -8, 18, 83, -24, - -41, -167, 158, -100, - 93, 53, 201, 15, - 42, 266, 278, -12, - -6, -37, 85, 6, - 20, -188, -271, 107, - -13, -80, 51, 202, - 173, -69, 78, -188, - 46, 4, 153, 12, - -138, 169, 5, -58, - -123, -108, -243, 150, - 10, -191, 246, -15, - 38, 25, -10, 14, - 61, 50, -206, -215, - -220, 90, 5, -149, - -219, 56, 142, 24, - -376, 77, -80, 75, - 6, 42, -101, 16, - 56, 14, -57, 3, - -17, 80, 57, -36, - 88, -59, -97, -19, - -148, 46, -219, 226, - 114, -4, -72, -15, - 37, -49, -28, 247, - 44, 123, 47, -122, - -38, 17, 4, -113, - -32, -224, 154, -134, - 196, 71, -267, -85, - 28, -70, 89, -120, - 99, -2, 64, 76, - -166, -48, 189, -35, - -92, -169, -123, 339, - 38, -25, 38, -35, - 225, -139, -50, -63, - 246, 60, -185, -109, - -49, -53, -167, 51, - 149, 60, -101, -33, - 25, -76, 120, 32, - -30, -83, 102, 91, - -186, -261, 131, -197 - }; - - static final SKP_Silk_NLSF_CBS[] SKP_Silk_NLSF_CB0_16_Stage_info = - { - new SKP_Silk_NLSF_CBS(128, SKP_Silk_NLSF_MSVQ_CB0_16_Q15, 16 * 0, SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q5, 0), - new SKP_Silk_NLSF_CBS(16, SKP_Silk_NLSF_MSVQ_CB0_16_Q15, 16 * 128, SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q5, 128), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB0_16_Q15, 16 * 144, SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q5, 144), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB0_16_Q15, 16 * 152, SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q5, 152), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB0_16_Q15, 16 * 160, SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q5, 160), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB0_16_Q15, 16 * 168, SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q5, 168), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB0_16_Q15, 16 * 176, SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q5, 176), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB0_16_Q15, 16 * 184, SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q5, 184), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB0_16_Q15, 16 * 192, SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q5, 192), - new SKP_Silk_NLSF_CBS(16, SKP_Silk_NLSF_MSVQ_CB0_16_Q15, 16 * 200, SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q5, 200), - }; - - static final SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB0_16 = - new SKP_Silk_NLSF_CB_struct - ( - NLSF_MSVQ_CB0_16_STAGES, - SKP_Silk_NLSF_CB0_16_Stage_info, - SKP_Silk_NLSF_MSVQ_CB0_16_ndelta_min_Q15, - SKP_Silk_NLSF_MSVQ_CB0_16_CDF, - SKP_Silk_NLSF_MSVQ_CB0_16_CDF_start_ptr, - SKP_Silk_NLSF_MSVQ_CB0_16_CDF_middle_idx - ); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB0_16_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB0_16_FLP.java deleted file mode 100644 index b0fc4c368..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB0_16_FLP.java +++ /dev/null @@ -1,1930 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * This file has been automatically generated. - * ROM usage: 14.76 kB. - * - * @author Dingxin Xu - */ -public class Silk_tables_NLSF_CB0_16_FLP -{ -// const SKP_float SKP_Silk_NLSF_MSVQ_CB0_16_rates[ NLSF_MSVQ_CB0_16_VECTORS ] = - static final float SKP_Silk_NLSF_MSVQ_CB0_16_rates[] = - { - 5.50000000000000000000f, 5.65625000000000000000f, - 5.68750000000000000000f, 5.71875000000000000000f, - 5.81250000000000000000f, 5.81250000000000000000f, - 5.96875000000000000000f, 5.96875000000000000000f, - 5.96875000000000000000f, 6.12500000000000000000f, - 6.15625000000000000000f, 6.28125000000000000000f, - 6.34375000000000000000f, 6.43750000000000000000f, - 6.43750000000000000000f, 6.43750000000000000000f, - 6.46875000000000000000f, 6.46875000000000000000f, - 6.53125000000000000000f, 6.53125000000000000000f, - 6.53125000000000000000f, 6.53125000000000000000f, - 6.56250000000000000000f, 6.56250000000000000000f, - 6.56250000000000000000f, 6.59375000000000000000f, - 6.59375000000000000000f, 6.59375000000000000000f, - 6.62500000000000000000f, 6.68750000000000000000f, - 6.75000000000000000000f, 6.75000000000000000000f, - 6.78125000000000000000f, 6.78125000000000000000f, - 6.78125000000000000000f, 6.78125000000000000000f, - 6.81250000000000000000f, 6.81250000000000000000f, - 6.84375000000000000000f, 6.84375000000000000000f, - 6.87500000000000000000f, 6.90625000000000000000f, - 6.93750000000000000000f, 6.96875000000000000000f, - 6.96875000000000000000f, 6.96875000000000000000f, - 6.96875000000000000000f, 7.00000000000000000000f, - 7.00000000000000000000f, 7.00000000000000000000f, - 7.03125000000000000000f, 7.03125000000000000000f, - 7.06250000000000000000f, 7.06250000000000000000f, - 7.06250000000000000000f, 7.06250000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 7.12500000000000000000f, 7.12500000000000000000f, - 7.12500000000000000000f, 7.12500000000000000000f, - 7.15625000000000000000f, 7.15625000000000000000f, - 7.15625000000000000000f, 7.18750000000000000000f, - 7.18750000000000000000f, 7.18750000000000000000f, - 7.21875000000000000000f, 7.21875000000000000000f, - 7.21875000000000000000f, 7.21875000000000000000f, - 7.25000000000000000000f, 7.25000000000000000000f, - 7.25000000000000000000f, 7.25000000000000000000f, - 7.28125000000000000000f, 7.31250000000000000000f, - 7.34375000000000000000f, 7.34375000000000000000f, - 7.34375000000000000000f, 7.37500000000000000000f, - 7.37500000000000000000f, 7.37500000000000000000f, - 7.37500000000000000000f, 7.40625000000000000000f, - 7.40625000000000000000f, 7.40625000000000000000f, - 7.40625000000000000000f, 7.50000000000000000000f, - 7.50000000000000000000f, 7.50000000000000000000f, - 7.50000000000000000000f, 7.53125000000000000000f, - 7.56250000000000000000f, 7.59375000000000000000f, - 7.62500000000000000000f, 7.62500000000000000000f, - 7.71875000000000000000f, 7.71875000000000000000f, - 7.75000000000000000000f, 7.75000000000000000000f, - 7.75000000000000000000f, 7.78125000000000000000f, - 7.84375000000000000000f, 7.96875000000000000000f, - 7.96875000000000000000f, 8.00000000000000000000f, - 8.12500000000000000000f, 8.12500000000000000000f, - 8.15625000000000000000f, 8.25000000000000000000f, - 8.25000000000000000000f, 8.31250000000000000000f, - 8.31250000000000000000f, 8.37500000000000000000f, - 8.46875000000000000000f, 8.56250000000000000000f, - 8.62500000000000000000f, 8.71875000000000000000f, - 9.00000000000000000000f, 9.00000000000000000000f, - 9.00000000000000000000f, 9.00000000000000000000f, - 3.68750000000000000000f, 3.75000000000000000000f, - 3.78125000000000000000f, 3.78125000000000000000f, - 3.81250000000000000000f, 3.90625000000000000000f, - 3.90625000000000000000f, 4.03125000000000000000f, - 4.03125000000000000000f, 4.06250000000000000000f, - 4.09375000000000000000f, 4.12500000000000000000f, - 4.25000000000000000000f, 4.28125000000000000000f, - 4.31250000000000000000f, 4.53125000000000000000f, - 2.71875000000000000000f, 2.75000000000000000000f, - 2.84375000000000000000f, 3.03125000000000000000f, - 3.06250000000000000000f, 3.12500000000000000000f, - 3.28125000000000000000f, 3.31250000000000000000f, - 2.87500000000000000000f, 2.96875000000000000000f, - 2.96875000000000000000f, 3.00000000000000000000f, - 3.03125000000000000000f, 3.03125000000000000000f, - 3.06250000000000000000f, 3.09375000000000000000f, - 2.75000000000000000000f, 2.87500000000000000000f, - 2.96875000000000000000f, 2.96875000000000000000f, - 3.00000000000000000000f, 3.03125000000000000000f, - 3.06250000000000000000f, 3.40625000000000000000f, - 2.90625000000000000000f, 2.90625000000000000000f, - 2.90625000000000000000f, 3.00000000000000000000f, - 3.03125000000000000000f, 3.03125000000000000000f, - 3.09375000000000000000f, 3.15625000000000000000f, - 2.90625000000000000000f, 2.93750000000000000000f, - 2.93750000000000000000f, 2.96875000000000000000f, - 2.96875000000000000000f, 3.09375000000000000000f, - 3.09375000000000000000f, 3.09375000000000000000f, - 2.90625000000000000000f, 2.90625000000000000000f, - 2.90625000000000000000f, 3.00000000000000000000f, - 3.00000000000000000000f, 3.03125000000000000000f, - 3.12500000000000000000f, 3.18750000000000000000f, - 2.90625000000000000000f, 2.96875000000000000000f, - 2.96875000000000000000f, 3.00000000000000000000f, - 3.00000000000000000000f, 3.00000000000000000000f, - 3.06250000000000000000f, 3.09375000000000000000f, - 3.90625000000000000000f, 3.90625000000000000000f, - 3.96875000000000000000f, 3.96875000000000000000f, - 3.96875000000000000000f, 3.96875000000000000000f, - 4.00000000000000000000f, 4.00000000000000000000f, - 4.00000000000000000000f, 4.00000000000000000000f, - 4.00000000000000000000f, 4.00000000000000000000f, - 4.03125000000000000000f, 4.06250000000000000000f, - 4.09375000000000000000f, 4.12500000000000000000f - }; - -// const SKP_float SKP_Silk_NLSF_MSVQ_CB0_16_ndelta_min[ 16 + 1 ] = - static final float SKP_Silk_NLSF_MSVQ_CB0_16_ndelta_min[] = - { - 0.00811767578125000000f, - 0.00009155273437500000f, - 0.00122070312500000000f, - 0.00009155273437500000f, - 0.00009155273437500000f, - 0.00048828125000000000f, - 0.00238037109375000000f, - 0.00271606445312500000f, - 0.00326538085937500000f, - 0.00430297851562500000f, - 0.00573730468750000000f, - 0.00445556640625000000f, - 0.00830078125000000000f, - 0.00732421874999999910f, - 0.00717163085937500000f, - 0.00656127929687500000f, - 0.01928710937500000000f - }; - -// const SKP_float SKP_Silk_NLSF_MSVQ_CB0_16[ 16 * NLSF_MSVQ_CB0_16_VECTORS ] = - static final float SKP_Silk_NLSF_MSVQ_CB0_16[] = - { - 0.03570556640625000000f, 0.06951904296875000000f, - 0.11163330078125001000f, 0.16400146484375000000f, - 0.23394775390625000000f, 0.27810668945312500000f, - 0.34478759765624994000f, 0.40600585937500000000f, - 0.46908569335937500000f, 0.53555297851562500000f, - 0.59774780273437500000f, 0.65573120117187500000f, - 0.72625732421875000000f, 0.79461669921875000000f, - 0.86419677734375000000f, 0.92166137695312500000f, - 0.04968261718750000700f, 0.07122802734375000000f, - 0.12557983398437500000f, 0.18420410156250000000f, - 0.23858642578125000000f, 0.29125976562500000000f, - 0.35940551757812500000f, 0.42788696289062500000f, - 0.48178100585937500000f, 0.53125000000000000000f, - 0.59405517578125000000f, 0.64883422851562500000f, - 0.69842529296875000000f, 0.74966430664062500000f, - 0.81524658203125000000f, 0.85629272460937500000f, - 0.05261230468750000000f, 0.08148193359375000000f, - 0.12377929687500000000f, 0.19934082031250000000f, - 0.25503540039062500000f, 0.30880737304687500000f, - 0.36904907226562506000f, 0.42910766601562500000f, - 0.50326538085937500000f, 0.57357788085937500000f, - 0.62307739257812500000f, 0.68365478515625000000f, - 0.74008178710937511000f, 0.80029296875000011000f, - 0.86700439453125000000f, 0.91418457031250000000f, - 0.04556274414062500000f, 0.10458374023437501000f, - 0.14614868164062500000f, 0.19528198242187500000f, - 0.25741577148437500000f, 0.31030273437500000000f, - 0.36621093750000000000f, 0.42926025390625000000f, - 0.49526977539062500000f, 0.55572509765625000000f, - 0.61157226562500000000f, 0.67437744140625000000f, - 0.73709106445312500000f, 0.79635620117187500000f, - 0.86007690429687500000f, 0.91921997070312489000f, - 0.03414916992187500000f, 0.06375122070312500000f, - 0.13107299804687500000f, 0.19058227539062500000f, - 0.26522827148437500000f, 0.32778930664062500000f, - 0.38720703125000000000f, 0.45950317382812500000f, - 0.51965332031250000000f, 0.57348632812500000000f, - 0.63223266601562500000f, 0.68707275390625011000f, - 0.74758911132812500000f, 0.81018066406250000000f, - 0.87338256835937500000f, 0.93475341796875000000f, - 0.04159545898437500000f, 0.07376098632812500000f, - 0.11984252929687500000f, 0.16955566406249997000f, - 0.22650146484375000000f, 0.28427124023437500000f, - 0.36251831054687500000f, 0.42013549804687500000f, - 0.49264526367187500000f, 0.56518554687500000000f, - 0.62432861328125000000f, 0.68902587890625000000f, - 0.74887084960937500000f, 0.80676269531250000000f, - 0.86419677734375000000f, 0.92523193359375000000f, - 0.03424072265625000000f, 0.07638549804687500000f, - 0.15917968750000000000f, 0.21813964843750000000f, - 0.28411865234375000000f, 0.33807373046874994000f, - 0.40206909179687500000f, 0.45166015625000000000f, - 0.51464843750000000000f, 0.57067871093750000000f, - 0.62365722656250000000f, 0.68627929687499989000f, - 0.74987792968750011000f, 0.81182861328125000000f, - 0.87142944335937500000f, 0.92852783203125000000f, - 0.01831054687500000000f, 0.04019165039062500700f, - 0.09063720703125001400f, 0.17117309570312500000f, - 0.23480224609375000000f, 0.29858398437500000000f, - 0.37136840820312500000f, 0.42990112304687506000f, - 0.49984741210937494000f, 0.56085205078125000000f, - 0.62716674804687500000f, 0.69232177734375000000f, - 0.75497436523437489000f, 0.81472778320312500000f, - 0.87420654296875000000f, 0.92636108398437500000f, - 0.02871704101562500000f, 0.05743408203125000000f, - 0.13043212890625000000f, 0.16906738281250000000f, - 0.25885009765625000000f, 0.30084228515625000000f, - 0.36437988281250000000f, 0.43600463867187494000f, - 0.49105834960937506000f, 0.56460571289062500000f, - 0.62030029296875000000f, 0.69006347656250000000f, - 0.75411987304687511000f, 0.81292724609374989000f, - 0.87933349609375000000f, 0.92864990234375000000f, - 0.01937866210937500000f, 0.05184936523437500000f, - 0.13354492187500000000f, 0.18151855468750000000f, - 0.24710083007812500000f, 0.30868530273437500000f, - 0.37457275390625000000f, 0.43267822265625000000f, - 0.49166870117187500000f, 0.54360961914062500000f, - 0.60104370117187500000f, 0.66445922851562511000f, - 0.73019409179687500000f, 0.78936767578124989000f, - 0.85516357421875000000f, 0.91961669921875000000f, - 0.04296874999999999300f, 0.06781005859375000000f, - 0.10754394531250000000f, 0.17135620117187503000f, - 0.22415161132812497000f, 0.27005004882812500000f, - 0.33535766601562500000f, 0.38977050781250000000f, - 0.46850585937500000000f, 0.51959228515625000000f, - 0.57736206054687500000f, 0.64276123046875000000f, - 0.71194458007812500000f, 0.76950073242187500000f, - 0.83035278320312511000f, 0.88571166992187500000f, - 0.02139282226562500000f, 0.03988647460937500000f, - 0.10827636718750001000f, 0.19229125976562500000f, - 0.23632812500000000000f, 0.29217529296875000000f, - 0.34262084960937494000f, 0.39605712890625000000f, - 0.46295166015625000000f, 0.53604125976562500000f, - 0.60348510742187500000f, 0.67434692382812500000f, - 0.73944091796875000000f, 0.80368041992187500000f, - 0.86599731445312500000f, 0.92257690429687500000f, - 0.05346679687500000700f, 0.07214355468750000000f, - 0.14889526367187500000f, 0.20046997070312500000f, - 0.23843383789062500000f, 0.29895019531250000000f, - 0.34176635742187500000f, 0.43609619140625006000f, - 0.48202514648437500000f, 0.54931640625000000000f, - 0.62243652343750000000f, 0.68411254882812489000f, - 0.74182128906250011000f, 0.79724121093750000000f, - 0.86547851562500000000f, 0.93484497070312500000f, - 0.02749633789062500000f, 0.04971313476562500000f, - 0.10241699218749999000f, 0.14144897460937500000f, - 0.22143554687500000000f, 0.26754760742187500000f, - 0.30429077148437500000f, 0.35272216796875000000f, - 0.46432495117187500000f, 0.53540039062500000000f, - 0.59579467773437500000f, 0.66687011718750000000f, - 0.72937011718750000000f, 0.79278564453125000000f, - 0.85855102539062500000f, 0.92114257812500000000f, - 0.02993774414062500000f, 0.05093383789062500000f, - 0.10140991210937499000f, 0.14321899414062500000f, - 0.18960571289062500000f, 0.26525878906250000000f, - 0.32391357421875006000f, 0.39538574218750000000f, - 0.46420288085937506000f, 0.54049682617187500000f, - 0.60595703125000000000f, 0.67510986328124989000f, - 0.74291992187500000000f, 0.81152343750000000000f, - 0.87655639648437500000f, 0.93020629882812500000f, - 0.04904174804687500000f, 0.07864379882812500000f, - 0.12878417968750000000f, 0.16821289062499997000f, - 0.26037597656250000000f, 0.31701660156250000000f, - 0.35482788085937500000f, 0.41720581054687494000f, - 0.48071289062500000000f, 0.52487182617187500000f, - 0.60546875000000000000f, 0.66708374023437500000f, - 0.71697998046875000000f, 0.78692626953125000000f, - 0.85726928710937500000f, 0.91952514648437500000f, - 0.02474975585937500000f, 0.04489135742187500000f, - 0.09594726562500000000f, 0.15383911132812500000f, - 0.22674560546875000000f, 0.28652954101562500000f, - 0.34100341796875000000f, 0.40451049804687500000f, - 0.46255493164062494000f, 0.51089477539062500000f, - 0.59762573242187500000f, 0.67648315429687500000f, - 0.73593139648437511000f, 0.79779052734375000000f, - 0.86618041992187500000f, 0.92758178710937500000f, - 0.04708862304687499300f, 0.06542968750000000000f, - 0.11074829101562500000f, 0.19369506835937500000f, - 0.22378540039062503000f, 0.28500366210937500000f, - 0.32684326171875000000f, 0.41491699218750006000f, - 0.46078491210937506000f, 0.52917480468750000000f, - 0.61346435546875000000f, 0.66790771484375000000f, - 0.72424316406250000000f, 0.78237915039062500000f, - 0.84893798828125000000f, 0.91299438476562511000f, - 0.01501464843750000000f, 0.03616333007812500000f, - 0.08972167968750000000f, 0.16748046875000003000f, - 0.21652221679687500000f, 0.26705932617187500000f, - 0.35388183593749994000f, 0.41439819335937500000f, - 0.48965454101562500000f, 0.54977416992187500000f, - 0.61578369140625000000f, 0.67526245117187500000f, - 0.74050903320312489000f, 0.80584716796875000000f, - 0.86926269531250000000f, 0.92642211914062500000f, - 0.04721069335937500000f, 0.06964111328125000000f, - 0.11270141601562500000f, 0.19351196289062500000f, - 0.23675537109374997000f, 0.29318237304687500000f, - 0.36157226562500000000f, 0.40393066406250000000f, - 0.50549316406250000000f, 0.55142211914062500000f, - 0.60299682617187500000f, 0.65319824218750011000f, - 0.73577880859375000000f, 0.81195068359375000000f, - 0.87847900390625000000f, 0.93551635742187511000f, - 0.02090454101562500000f, 0.04083251953125000000f, - 0.10403442382812500000f, 0.16058349609375000000f, - 0.21209716796875000000f, 0.28143310546875000000f, - 0.34832763671875000000f, 0.44320678710937500000f, - 0.49856567382812500000f, 0.54605102539062500000f, - 0.59313964843750000000f, 0.64996337890625000000f, - 0.71084594726562500000f, 0.76846313476562500000f, - 0.85366821289062500000f, 0.93139648437500000000f, - 0.02706909179687500300f, 0.04824829101562500000f, - 0.09329223632812500000f, 0.13177490234375000000f, - 0.21948242187500000000f, 0.26296997070312500000f, - 0.30661010742187500000f, 0.39996337890625000000f, - 0.49636840820312500000f, 0.54605102539062500000f, - 0.61746215820312500000f, 0.68206787109375000000f, - 0.74398803710937511000f, 0.80517578125000000000f, - 0.86407470703125000000f, 0.92129516601562489000f, - 0.06973266601562500000f, 0.11428833007812500000f, - 0.17279052734375000000f, 0.23120117187500000000f, - 0.28451538085937500000f, 0.34545898437500000000f, - 0.40402221679687500000f, 0.46359252929687494000f, - 0.52413940429687500000f, 0.58670043945312500000f, - 0.64416503906250000000f, 0.70104980468750000000f, - 0.75747680664062500000f, 0.81344604492187489000f, - 0.87161254882812500000f, 0.92956542968750000000f, - 0.04565429687500000700f, 0.06433105468750000000f, - 0.10522460937500000000f, 0.21051025390625003000f, - 0.25415039062500000000f, 0.29467773437500000000f, - 0.34338378906250000000f, 0.39132690429687500000f, - 0.45712280273437500000f, 0.50299072265625000000f, - 0.55480957031250000000f, 0.61294555664062500000f, - 0.70074462890624989000f, 0.76782226562500000000f, - 0.84548950195312500000f, 0.90420532226562500000f, - 0.01754760742187500000f, 0.03848266601562500000f, - 0.11782836914062500000f, 0.20223999023437500000f, - 0.25311279296875000000f, 0.32986450195312500000f, - 0.38772583007812500000f, 0.45068359375000000000f, - 0.52111816406250000000f, 0.58126831054687500000f, - 0.64019775390624989000f, 0.70358276367187500000f, - 0.76208496093750011000f, 0.81491088867187500000f, - 0.87646484375000000000f, 0.92605590820312500000f, - 0.05133056640625000000f, 0.06753540039062500000f, - 0.11846923828125000000f, 0.19036865234374997000f, - 0.21997070312500000000f, 0.29437255859375000000f, - 0.33193969726562500000f, 0.40988159179687500000f, - 0.45181274414062494000f, 0.49478149414062506000f, - 0.54751586914062500000f, 0.63699340820312489000f, - 0.71868896484375011000f, 0.78628540039062500000f, - 0.84704589843750000000f, 0.89907836914062500000f, - 0.02709960937500000000f, 0.04931640625000000000f, - 0.11975097656250000000f, 0.15853881835937500000f, - 0.21990966796875003000f, 0.26388549804687500000f, - 0.30035400390625000000f, 0.35012817382812500000f, - 0.49032592773437500000f, 0.55606079101562500000f, - 0.62081909179687500000f, 0.69500732421875000000f, - 0.74777221679687500000f, 0.80603027343750000000f, - 0.85614013671875000000f, 0.90731811523437500000f, - 0.02456665039062500000f, 0.04437255859375000000f, - 0.08187866210937500000f, 0.13647460937500000000f, - 0.24218750000000000000f, 0.28564453125000000000f, - 0.34783935546875000000f, 0.43777465820312500000f, - 0.49453735351562500000f, 0.54418945312500000000f, - 0.59365844726562500000f, 0.66058349609375000000f, - 0.72933959960937489000f, 0.79125976562500000000f, - 0.86630249023437511000f, 0.92965698242187500000f, - 0.05004882812500000000f, 0.07272338867187500000f, - 0.10632324218750000000f, 0.15509033203125000000f, - 0.18408203125000000000f, 0.26263427734375000000f, - 0.35522460937499994000f, 0.39569091796875000000f, - 0.48345947265625000000f, 0.53002929687500000000f, - 0.59039306640625000000f, 0.64642333984375000000f, - 0.72137451171875011000f, 0.79006958007812511000f, - 0.86572265625000000000f, 0.92465209960937500000f, - 0.04980468750000000000f, 0.06726074218750000000f, - 0.13763427734375000000f, 0.23132324218750003000f, - 0.26605224609375000000f, 0.32080078125000000000f, - 0.36505126953125000000f, 0.43017578125000000000f, - 0.47729492187500000000f, 0.52471923828125000000f, - 0.58419799804687500000f, 0.67892456054687511000f, - 0.74960327148437489000f, 0.81057739257812500000f, - 0.87292480468750000000f, 0.93106079101562500000f, - 0.06234741210937500000f, 0.07971191406250001400f, - 0.12161254882812500000f, 0.20907592773437500000f, - 0.24530029296875000000f, 0.29034423828125000000f, - 0.33505249023437500000f, 0.39028930664062500000f, - 0.47076416015625000000f, 0.51049804687500000000f, - 0.57675170898437500000f, 0.61880493164062500000f, - 0.69891357421875000000f, 0.79983520507812500000f, - 0.87619018554687500000f, 0.93438720703125011000f, - 0.06787109375000000000f, 0.08538818359375000000f, - 0.13626098632812500000f, 0.16235351562500000000f, - 0.21691894531249997000f, 0.28796386718750000000f, - 0.33526611328125000000f, 0.40350341796875000000f, - 0.44552612304687500000f, 0.55899047851562500000f, - 0.61465454101562500000f, 0.66659545898437500000f, - 0.72024536132812511000f, 0.78430175781250000000f, - 0.86010742187500000000f, 0.93328857421875000000f, - 0.02548217773437500000f, 0.04702758789062500000f, - 0.12460327148437500000f, 0.17605590820312503000f, - 0.22540283203125000000f, 0.28683471679687500000f, - 0.33480834960937500000f, 0.38012695312500000000f, - 0.45840454101562500000f, 0.56890869140625000000f, - 0.63607788085937500000f, 0.70495605468750000000f, - 0.77185058593750000000f, 0.82293701171875000000f, - 0.88354492187500000000f, 0.92840576171875011000f, - 0.05477905273437500000f, 0.07150268554687500000f, - 0.14675903320312500000f, 0.17993164062500003000f, - 0.21905517578125000000f, 0.26077270507812500000f, - 0.31198120117187500000f, 0.40802001953125000000f, - 0.44573974609375000000f, 0.50259399414062500000f, - 0.55764770507812500000f, 0.63281250000000000000f, - 0.72158813476562500000f, 0.80130004882812500000f, - 0.86132812500000000000f, 0.92742919921875000000f, - 0.05291748046875000000f, 0.06878662109375000000f, - 0.12301635742187500000f, 0.15832519531250000000f, - 0.19854736328125000000f, 0.24023437500000000000f, - 0.29452514648437500000f, 0.39749145507812500000f, - 0.44003295898437494000f, 0.52810668945312500000f, - 0.59494018554687500000f, 0.67718505859374989000f, - 0.74472045898437500000f, 0.80267333984375000000f, - 0.86044311523437500000f, 0.92092895507812500000f, - 0.05618286132812500000f, 0.07168579101562500000f, - 0.12109375000000000000f, 0.14538574218750000000f, - 0.19458007812500000000f, 0.29983520507812500000f, - 0.33715820312500000000f, 0.40725708007812500000f, - 0.44805908203125000000f, 0.49597167968750000000f, - 0.55490112304687500000f, 0.65194702148437500000f, - 0.72991943359375000000f, 0.79821777343750000000f, - 0.85543823242187500000f, 0.91354370117187500000f, - 0.04370117187500000000f, 0.06246948242187500000f, - 0.17184448242187500000f, 0.21139526367187500000f, - 0.25018310546875000000f, 0.29525756835937500000f, - 0.34661865234375000000f, 0.41217041015625000000f, - 0.45172119140625000000f, 0.50106811523437500000f, - 0.55966186523437500000f, 0.67196655273437500000f, - 0.73620605468750000000f, 0.79885864257812500000f, - 0.85845947265625000000f, 0.93341064453125000000f, - 0.05279541015625000700f, 0.07080078125000000000f, - 0.11425781250000000000f, 0.14672851562500000000f, - 0.18331909179687500000f, 0.29498291015625000000f, - 0.33560180664062500000f, 0.41571044921875000000f, - 0.46490478515625000000f, 0.53390502929687500000f, - 0.61303710937500000000f, 0.67144775390625000000f, - 0.72030639648437500000f, 0.77514648437500000000f, - 0.83554077148437489000f, 0.89276123046875000000f, - 0.03866577148437500000f, 0.05844116210937500000f, - 0.16732788085937503000f, 0.20788574218750000000f, - 0.25112915039062500000f, 0.30270385742187500000f, - 0.35366821289062494000f, 0.40701293945312500000f, - 0.45004272460937506000f, 0.54824829101562500000f, - 0.62719726562500000000f, 0.67648315429687500000f, - 0.74826049804687500000f, 0.81845092773437500000f, - 0.88143920898437500000f, 0.93511962890625000000f, - 0.04656982421875000000f, 0.06802368164062500000f, - 0.12939453125000000000f, 0.22546386718750000000f, - 0.27322387695312500000f, 0.31890869140625000000f, - 0.36312866210937500000f, 0.41864013671875006000f, - 0.51455688476562500000f, 0.55917358398437500000f, - 0.62191772460937500000f, 0.69189453125000000000f, - 0.75674438476562500000f, 0.82110595703125000000f, - 0.88214111328124989000f, 0.93450927734375000000f, - 0.06637573242187500000f, 0.08517456054687500000f, - 0.12524414062500000000f, 0.20980834960937500000f, - 0.26281738281250000000f, 0.29901123046875000000f, - 0.37084960937500000000f, 0.41308593750000000000f, - 0.47677612304687500000f, 0.53961181640625000000f, - 0.58633422851562500000f, 0.64270019531250000000f, - 0.74407958984375000000f, 0.81665039062499989000f, - 0.87380981445312500000f, 0.92309570312500000000f, - 0.01385498046875000000f, 0.03756713867187500000f, - 0.13241577148437500000f, 0.17510986328125000000f, - 0.23040771484375000000f, 0.27484130859375000000f, - 0.31494140625000000000f, 0.41275024414062506000f, - 0.48843383789062500000f, 0.54470825195312500000f, - 0.61251831054687500000f, 0.67114257812500000000f, - 0.73086547851562500000f, 0.79476928710937500000f, - 0.86196899414062511000f, 0.92086791992187489000f, - 0.06866455078125000000f, 0.08517456054687500000f, - 0.12908935546875000000f, 0.16122436523437500000f, - 0.20635986328125000000f, 0.32369995117187506000f, - 0.36251831054687500000f, 0.42178344726562500000f, - 0.48208618164062494000f, 0.52685546875000000000f, - 0.61123657226562500000f, 0.67950439453125000000f, - 0.75036621093750000000f, 0.80679321289062500000f, - 0.86193847656250000000f, 0.92831420898437489000f, - 0.05175781250000000000f, 0.06762695312500000000f, - 0.13146972656250000000f, 0.25588989257812500000f, - 0.29803466796875000000f, 0.33660888671875000000f, - 0.38317871093750000000f, 0.43026733398437500000f, - 0.49810791015625000000f, 0.53833007812500000000f, - 0.58489990234375000000f, 0.62835693359375000000f, - 0.73141479492187489000f, 0.81964111328125000000f, - 0.87884521484375000000f, 0.93267822265625000000f, - 0.07482910156250000000f, 0.09875488281250000000f, - 0.13333129882812500000f, 0.18670654296875000000f, - 0.21838378906250000000f, 0.27474975585937500000f, - 0.35122680664062500000f, 0.39050292968750000000f, - 0.48062133789062506000f, 0.52767944335937500000f, - 0.59481811523437500000f, 0.67874145507812500000f, - 0.74859619140625000000f, 0.80792236328125000000f, - 0.86282348632812489000f, 0.91775512695312511000f, - 0.05526733398437500000f, 0.07754516601562500000f, - 0.10848999023437500000f, 0.16723632812500000000f, - 0.27841186523437500000f, 0.32125854492187500000f, - 0.36297607421875000000f, 0.41683959960937500000f, - 0.46575927734374994000f, 0.51571655273437500000f, - 0.59100341796875000000f, 0.64297485351562511000f, - 0.69256591796875000000f, 0.74200439453125000000f, - 0.83178710937500000000f, 0.91500854492187500000f, - 0.04739379882812500000f, 0.06854248046875000000f, - 0.13912963867187500000f, 0.16784667968749997000f, - 0.20611572265625003000f, 0.24029541015625000000f, - 0.35824584960937500000f, 0.41415405273437500000f, - 0.46350097656250000000f, 0.54562377929687500000f, - 0.61892700195312500000f, 0.68695068359375000000f, - 0.75115966796875000000f, 0.81326293945312500000f, - 0.87847900390625000000f, 0.93856811523437500000f, - 0.06048583984375000000f, 0.08447265625000000000f, - 0.11700439453125001000f, 0.18200683593750000000f, - 0.26647949218750000000f, 0.30236816406250000000f, - 0.36001586914062500000f, 0.45205688476562500000f, - 0.49777221679687506000f, 0.54766845703125000000f, - 0.64382934570312500000f, 0.69735717773437500000f, - 0.74633789062500000000f, 0.80273437500000000000f, - 0.85955810546875000000f, 0.90805053710937511000f, - 0.05566406250000000000f, 0.07717895507812500000f, - 0.11648559570312500000f, 0.16629028320312500000f, - 0.20916748046875003000f, 0.26593017578125000000f, - 0.31680297851562500000f, 0.37493896484375006000f, - 0.43316650390625000000f, 0.48138427734375000000f, - 0.59582519531250000000f, 0.65228271484375000000f, - 0.72311401367187500000f, 0.79556274414062500000f, - 0.85742187500000000000f, 0.92199707031250011000f, - 0.06750488281250000000f, 0.08709716796875001400f, - 0.12045288085937500000f, 0.17999267578125000000f, - 0.30303955078125000000f, 0.35266113281250000000f, - 0.39227294921875000000f, 0.45129394531249994000f, - 0.49829101562500006000f, 0.54016113281250000000f, - 0.62014770507812500000f, 0.67437744140625000000f, - 0.72241210937500011000f, 0.77182006835937500000f, - 0.82324218750000011000f, 0.87237548828125000000f, - 0.06173706054687500000f, 0.07931518554687500000f, - 0.12280273437500000000f, 0.15002441406250000000f, - 0.20181274414062500000f, 0.34024047851562494000f, - 0.38015747070312500000f, 0.44635009765625000000f, - 0.49804687500000000000f, 0.54388427734375000000f, - 0.60037231445312500000f, 0.64611816406250000000f, - 0.70541381835937500000f, 0.79501342773437500000f, - 0.87966918945312500000f, 0.93865966796875000000f, - 0.04968261718750000700f, 0.06732177734375000000f, - 0.10580444335937500000f, 0.13317871093750000000f, - 0.26486206054687500000f, 0.31045532226562500000f, - 0.36206054687500000000f, 0.41744995117187500000f, - 0.45770263671874994000f, 0.51690673828125000000f, - 0.58615112304687500000f, 0.65197753906249989000f, - 0.72784423828125000000f, 0.79696655273437500000f, - 0.85827636718750000000f, 0.92385864257812500000f, - 0.06146240234375000000f, 0.07943725585937500000f, - 0.12554931640625000000f, 0.22137451171875000000f, - 0.25988769531250000000f, 0.30648803710937500000f, - 0.36077880859375000000f, 0.41207885742187500000f, - 0.49832153320312500000f, 0.54400634765625000000f, - 0.60110473632812500000f, 0.64941406250000000000f, - 0.70651245117187500000f, 0.75259399414062500000f, - 0.81808471679687500000f, 0.92044067382812511000f, - 0.07250976562500000000f, 0.09094238281250000000f, - 0.13494873046875000000f, 0.17608642578125000000f, - 0.21411132812500000000f, 0.29672241210937500000f, - 0.33950805664062506000f, 0.41247558593750000000f, - 0.47256469726562506000f, 0.51834106445312500000f, - 0.58471679687500000000f, 0.62826538085937500000f, - 0.74465942382812500000f, 0.82946777343750000000f, - 0.88641357421875000000f, 0.93527221679687500000f, - 0.07489013671875000000f, 0.10687255859375000000f, - 0.14111328125000000000f, 0.18368530273437500000f, - 0.23291015625000000000f, 0.27005004882812500000f, - 0.32934570312500000000f, 0.42614746093750000000f, - 0.47372436523437500000f, 0.52139282226562500000f, - 0.59848022460937500000f, 0.64813232421875000000f, - 0.69750976562500000000f, 0.76623535156249989000f, - 0.85772705078125011000f, 0.91217041015625000000f, - 0.04800415039062500700f, 0.06939697265625000000f, - 0.10095214843750000000f, 0.18307495117187500000f, - 0.27395629882812500000f, 0.30834960937500000000f, - 0.38015747070312500000f, 0.43511962890625000000f, - 0.48062133789062506000f, 0.55480957031250000000f, - 0.60955810546875000000f, 0.64859008789062500000f, - 0.70327758789062500000f, 0.76470947265625000000f, - 0.84658813476562500000f, 0.92514038085937500000f, - 0.05929565429687500000f, 0.08331298828125000000f, - 0.12634277343750000000f, 0.18798828125000003000f, - 0.22860717773437500000f, 0.27423095703125000000f, - 0.34512329101562500000f, 0.38986206054687500000f, - 0.45227050781250000000f, 0.50531005859375000000f, - 0.54653930664062500000f, 0.60293579101562500000f, - 0.65649414062500011000f, 0.72036743164062500000f, - 0.83233642578124989000f, 0.90109252929687500000f, - 0.06167602539062500000f, 0.07879638671875000000f, - 0.13714599609375000000f, 0.17807006835937503000f, - 0.21340942382812497000f, 0.25161743164062500000f, - 0.29989624023437500000f, 0.44961547851562500000f, - 0.50238037109375000000f, 0.54608154296875000000f, - 0.59957885742187500000f, 0.64340209960937489000f, - 0.72521972656250000000f, 0.81381225585937500000f, - 0.88720703125000000000f, 0.94573974609375000000f, - 0.03210449218750000000f, 0.05416870117187500000f, - 0.09820556640624998600f, 0.13360595703125000000f, - 0.23394775390625000000f, 0.28695678710937500000f, - 0.34326171875000000000f, 0.40670776367187500000f, - 0.45690917968750000000f, 0.54815673828125000000f, - 0.63348388671875000000f, 0.68218994140625000000f, - 0.76510620117187500000f, 0.83035278320312511000f, - 0.88504028320312500000f, 0.93411254882812489000f, - 0.06768798828125000000f, 0.08746337890624998600f, - 0.12887573242187500000f, 0.16333007812500000000f, - 0.20083618164062500000f, 0.30456542968750000000f, - 0.35360717773437500000f, 0.40042114257812500000f, - 0.46365356445312500000f, 0.50607299804687500000f, - 0.56109619140625000000f, 0.61279296875000000000f, - 0.67178344726562500000f, 0.77261352539062500000f, - 0.85836791992187500000f, 0.91186523437500011000f, - 0.06549072265625000000f, 0.08666992187500000000f, - 0.13418579101562500000f, 0.17822265625000000000f, - 0.22732543945312500000f, 0.26614379882812500000f, - 0.32080078125000000000f, 0.36425781250000000000f, - 0.41488647460937500000f, 0.52651977539062500000f, - 0.58929443359375000000f, 0.63754272460937500000f, - 0.71463012695312500000f, 0.78207397460937500000f, - 0.84683227539062500000f, 0.92257690429687500000f, - 0.06018066406250000000f, 0.07992553710937500000f, - 0.11462402343750000000f, 0.19430541992187500000f, - 0.23318481445312503000f, 0.26898193359375000000f, - 0.37493896484375006000f, 0.42016601562500000000f, - 0.46719360351562506000f, 0.55041503906250000000f, - 0.59683227539062500000f, 0.63793945312500000000f, - 0.68914794921875011000f, 0.75915527343750000000f, - 0.84838867187500000000f, 0.92895507812500000000f, - 0.06118774414062500000f, 0.07864379882812500000f, - 0.13037109375000000000f, 0.22500610351562500000f, - 0.26116943359375000000f, 0.31198120117187500000f, - 0.35919189453125000000f, 0.40899658203125000000f, - 0.50360107421875000000f, 0.54931640625000000000f, - 0.59951782226562500000f, 0.64404296875000000000f, - 0.70159912109375000000f, 0.81805419921875000000f, - 0.90042114257812489000f, 0.94427490234375000000f, - 0.03518676757812500000f, 0.05560302734375000000f, - 0.11364746093750001000f, 0.16610717773437500000f, - 0.21331787109375000000f, 0.26556396484375000000f, - 0.31399536132812500000f, 0.36312866210937500000f, - 0.42285156250000000000f, 0.46737670898437500000f, - 0.53713989257812500000f, 0.64282226562500000000f, - 0.72302246093750011000f, 0.79598999023437500000f, - 0.87237548828125000000f, 0.93502807617187500000f, - 0.03979492187500000000f, 0.05703735351562500000f, - 0.10125732421875000000f, 0.21957397460937500000f, - 0.29336547851562500000f, 0.32754516601562500000f, - 0.37820434570312500000f, 0.41894531250000000000f, - 0.48284912109375000000f, 0.53326416015625000000f, - 0.57623291015625000000f, 0.63146972656250000000f, - 0.70538330078125000000f, 0.77941894531250000000f, - 0.84484863281250000000f, 0.89245605468750011000f, - 0.06387329101562500000f, 0.08212280273437500000f, - 0.12261962890625000000f, 0.20318603515625000000f, - 0.24252319335937500000f, 0.27914428710937500000f, - 0.32034301757812500000f, 0.36257934570312500000f, - 0.48486328125000006000f, 0.54385375976562500000f, - 0.58999633789062500000f, 0.64797973632812500000f, - 0.71322631835937489000f, 0.77008056640625000000f, - 0.84085083007812500000f, 0.91546630859375000000f, - 0.01754760742187500000f, 0.04061889648437499300f, - 0.16186523437500000000f, 0.21087646484374997000f, - 0.25711059570312500000f, 0.30780029296875000000f, - 0.35330200195312500000f, 0.41192626953125006000f, - 0.50183105468750000000f, 0.56539916992187500000f, - 0.62759399414062500000f, 0.69723510742187500000f, - 0.76031494140625000000f, 0.81457519531249989000f, - 0.87765502929687500000f, 0.92031860351562500000f, - 0.04379272460937500000f, 0.06176757812500000000f, - 0.10018920898437500000f, 0.12683105468750000000f, - 0.23226928710937500000f, 0.32324218750000000000f, - 0.36770629882812506000f, 0.42501831054687500000f, - 0.47177124023437500000f, 0.56192016601562500000f, - 0.62545776367187500000f, 0.67962646484375000000f, - 0.73919677734375000000f, 0.79629516601562489000f, - 0.85647583007812500000f, 0.91854858398437500000f, - 0.04980468750000000000f, 0.06616210937500000000f, - 0.16906738281250000000f, 0.22821044921875000000f, - 0.26336669921875000000f, 0.31710815429687500000f, - 0.35534667968750000000f, 0.43704223632812494000f, - 0.48037719726562500000f, 0.52969360351562500000f, - 0.57238769531250000000f, 0.62359619140625000000f, - 0.69577026367187500000f, 0.79528808593750000000f, - 0.87103271484375000000f, 0.93676757812500000000f, - 0.04293823242187500000f, 0.06851196289062500000f, - 0.10391235351562501000f, 0.17208862304687500000f, - 0.28744506835937500000f, 0.32608032226562506000f, - 0.36938476562500000000f, 0.41183471679687494000f, - 0.47409057617187500000f, 0.56021118164062500000f, - 0.61022949218750000000f, 0.66189575195312500000f, - 0.74313354492187500000f, 0.81024169921874989000f, - 0.88052368164062500000f, 0.93273925781250011000f, - 0.05111694335937500700f, 0.06793212890625000000f, - 0.12222290039062501000f, 0.25094604492187500000f, - 0.30441284179687500000f, 0.34042358398437500000f, - 0.39129638671875000000f, 0.43688964843750000000f, - 0.50366210937500000000f, 0.55349731445312500000f, - 0.59735107421875000000f, 0.64239501953125000000f, - 0.69454956054687500000f, 0.76025390625000000000f, - 0.86352539062500011000f, 0.93487548828125000000f, - 0.03295898437500000000f, 0.04925537109375000000f, - 0.11053466796875000000f, 0.23086547851562497000f, - 0.26696777343750000000f, 0.31442260742187500000f, - 0.35745239257812500000f, 0.42260742187500000000f, - 0.47708129882812500000f, 0.53204345703125000000f, - 0.60305786132812500000f, 0.66604614257812500000f, - 0.71932983398437500000f, 0.77493286132812500000f, - 0.83636474609375000000f, 0.88693237304687500000f, - 0.05166625976562500000f, 0.06802368164062500000f, - 0.10546875000000000000f, 0.13287353515625000000f, - 0.17303466796875000000f, 0.33233642578125000000f, - 0.38339233398437500000f, 0.43234252929687500000f, - 0.48458862304687500000f, 0.53030395507812500000f, - 0.60476684570312500000f, 0.67050170898437500000f, - 0.73529052734375000000f, 0.79745483398437500000f, - 0.86358642578125000000f, 0.91854858398437500000f, - 0.06231689453125000000f, 0.09030151367187501400f, - 0.12802124023437500000f, 0.17517089843750000000f, - 0.21685791015625000000f, 0.25228881835937500000f, - 0.33953857421875000000f, 0.45693969726562500000f, - 0.51617431640625000000f, 0.55831909179687500000f, - 0.62658691406250000000f, 0.67083740234375000000f, - 0.72360229492187500000f, 0.78640747070312500000f, - 0.84255981445312511000f, 0.89572143554687500000f, - 0.03002929687500000000f, 0.04919433593750000000f, - 0.11621093750000000000f, 0.16067504882812500000f, - 0.21011352539062500000f, 0.25668334960937500000f, - 0.29135131835937500000f, 0.33230590820312500000f, - 0.38214111328125000000f, 0.50415039062500000000f, - 0.59658813476562500000f, 0.66036987304687500000f, - 0.72467041015625011000f, 0.79522705078125000000f, - 0.86395263671874989000f, 0.92694091796875011000f, - 0.06213378906250000000f, 0.07745361328125000000f, - 0.12713623046875000000f, 0.23684692382812500000f, - 0.27911376953125000000f, 0.31774902343750000000f, - 0.37060546875000006000f, 0.41531372070312500000f, - 0.47570800781250000000f, 0.52395629882812500000f, - 0.56637573242187500000f, 0.61380004882812500000f, - 0.66589355468750000000f, 0.74197387695312500000f, - 0.85537719726562489000f, 0.93420410156249989000f, - 0.05709838867187500000f, 0.07186889648437500000f, - 0.12393188476562500000f, 0.15695190429687500000f, - 0.22778320312500000000f, 0.30911254882812500000f, - 0.36441040039062506000f, 0.45779418945312506000f, - 0.50903320312500000000f, 0.56011962890625000000f, - 0.60903930664062500000f, 0.67990112304687500000f, - 0.75869750976562489000f, 0.82006835937500000000f, - 0.88464355468750000000f, 0.93429565429687511000f, - 0.07830810546875000000f, 0.09646606445312500000f, - 0.14169311523437500000f, 0.19003295898437500000f, - 0.22601318359375000000f, 0.30426025390625000000f, - 0.35455322265625000000f, 0.40942382812500000000f, - 0.48489379882812500000f, 0.52990722656250000000f, - 0.58352661132812500000f, 0.63528442382812500000f, - 0.68945312500000000000f, 0.75439453125000000000f, - 0.87686157226562489000f, 0.94854736328125000000f, - 0.05187988281249999300f, 0.07101440429687500000f, - 0.14733886718750000000f, 0.18124389648437500000f, - 0.23092651367187500000f, 0.27935791015625000000f, - 0.33834838867187500000f, 0.38973999023437500000f, - 0.43362426757812506000f, 0.49197387695312500000f, - 0.61712646484375000000f, 0.69186401367187500000f, - 0.75219726562500000000f, 0.81347656250000000000f, - 0.87573242187499989000f, 0.93826293945312500000f, - 0.09671020507812500000f, 0.11819458007812501000f, - 0.15399169921875000000f, 0.20959472656250000000f, - 0.24975585937500000000f, 0.28930664062500000000f, - 0.37643432617187500000f, 0.42932128906250000000f, - 0.48138427734375000000f, 0.54843139648437500000f, - 0.61740112304687500000f, 0.66256713867187500000f, - 0.71777343750000000000f, 0.77041625976562500000f, - 0.82476806640625000000f, 0.87677001953124989000f, - 0.04772949218750000000f, 0.07296752929687500000f, - 0.12905883789062500000f, 0.20538330078125000000f, - 0.27175903320312500000f, 0.31918334960937500000f, - 0.39752197265625000000f, 0.45877075195312500000f, - 0.52688598632812500000f, 0.60452270507812500000f, - 0.66677856445312500000f, 0.72451782226562500000f, - 0.77789306640625000000f, 0.83349609375000000000f, - 0.88687133789062500000f, 0.93161010742187511000f, - 0.08740234375000000000f, 0.10861206054687501000f, - 0.14401245117187500000f, 0.19656372070312503000f, - 0.29272460937500000000f, 0.33737182617187500000f, - 0.38949584960937500000f, 0.45117187500000000000f, - 0.50134277343750000000f, 0.55432128906250000000f, - 0.62518310546875000000f, 0.67938232421875000000f, - 0.73800659179687511000f, 0.80148315429687500000f, - 0.86618041992187500000f, 0.92236328125000000000f, - 0.08157348632812498600f, 0.10525512695312501000f, - 0.13980102539062500000f, 0.18258666992187500000f, - 0.20944213867187500000f, 0.25363159179687500000f, - 0.38037109375000000000f, 0.42453002929687506000f, - 0.48028564453125000000f, 0.54293823242187500000f, - 0.59252929687500000000f, 0.64642333984375000000f, - 0.73318481445312500000f, 0.81057739257812500000f, - 0.87655639648437500000f, 0.92895507812500000000f, - 0.07382202148437500000f, 0.09304809570312500000f, - 0.13043212890625000000f, 0.19482421875000000000f, - 0.26135253906250000000f, 0.29483032226562500000f, - 0.34448242187499994000f, 0.38684082031250000000f, - 0.44088745117187500000f, 0.53643798828125000000f, - 0.60473632812500000000f, 0.64791870117187511000f, - 0.70492553710937500000f, 0.77117919921874989000f, - 0.82089233398437500000f, 0.88275146484374989000f, - 0.03900146484375000000f, 0.06106567382812500000f, - 0.09155273437500000000f, 0.16336059570312500000f, - 0.30502319335937500000f, 0.35940551757812500000f, - 0.39727783203125000000f, 0.44464111328125000000f, - 0.48980712890625000000f, 0.54205322265625000000f, - 0.60980224609375000000f, 0.65969848632812511000f, - 0.71322631835937489000f, 0.76547241210937500000f, - 0.84399414062500000000f, 0.92077636718749989000f, - 0.02844238281250000000f, 0.04956054687500000000f, - 0.08538818359375000000f, 0.13946533203125000000f, - 0.26220703125000000000f, 0.30480957031250000000f, - 0.35253906249999994000f, 0.39825439453125000000f, - 0.51638793945312500000f, 0.56997680664062500000f, - 0.62301635742187500000f, 0.69610595703125000000f, - 0.75735473632812500000f, 0.81845092773437500000f, - 0.87902832031250011000f, 0.92727661132812489000f, - 0.07092285156250000000f, 0.09072875976562500000f, - 0.12683105468750000000f, 0.17401123046875000000f, - 0.21115112304687500000f, 0.26873779296875000000f, - 0.31307983398437500000f, 0.38156127929687494000f, - 0.45822143554687494000f, 0.50558471679687500000f, - 0.59259033203125000000f, 0.65231323242187500000f, - 0.70016479492187500000f, 0.74920654296875000000f, - 0.82470703124999989000f, 0.91091918945312500000f, - 0.04772949218750000000f, 0.07241821289062500000f, - 0.10543823242187499000f, 0.14974975585937500000f, - 0.18234252929687500000f, 0.22692871093750000000f, - 0.35968017578125000000f, 0.44265747070312500000f, - 0.49154663085937500000f, 0.55383300781250000000f, - 0.61093139648437500000f, 0.66079711914062500000f, - 0.72448730468749989000f, 0.78778076171875000000f, - 0.87213134765625000000f, 0.92687988281250000000f, - 0.09231567382812501400f, 0.11380004882812500000f, - 0.14849853515625000000f, 0.19897460937500000000f, - 0.28952026367187500000f, 0.33395385742187500000f, - 0.37713623046875000000f, 0.43511962890625000000f, - 0.49359130859375000000f, 0.53408813476562500000f, - 0.59436035156250000000f, 0.65332031250000000000f, - 0.70883178710937500000f, 0.76007080078125000000f, - 0.83456420898437500000f, 0.89743041992187500000f, - 0.03875732421875000000f, 0.05996704101562500000f, - 0.20758056640625000000f, 0.24398803710937500000f, - 0.28088378906250000000f, 0.33044433593750000000f, - 0.38168334960937500000f, 0.43426513671875000000f, - 0.48092651367187500000f, 0.54504394531250000000f, - 0.62161254882812500000f, 0.68670654296875000000f, - 0.75173950195312500000f, 0.80914306640625000000f, - 0.87081909179687500000f, 0.93154907226562500000f, - 0.06744384765625000000f, 0.08389282226562500000f, - 0.13018798828125000000f, 0.22848510742187503000f, - 0.30145263671875000000f, 0.33624267578125000000f, - 0.39132690429687500000f, 0.44039916992187500000f, - 0.49581909179687494000f, 0.56842041015625000000f, - 0.62408447265625000000f, 0.67303466796875011000f, - 0.72445678710937500000f, 0.77182006835937500000f, - 0.82623291015625000000f, 0.89016723632812500000f, - 0.03890991210937500000f, 0.05877685546875000000f, - 0.13214111328125000000f, 0.20059204101562503000f, - 0.25759887695312500000f, 0.33325195312500000000f, - 0.40466308593750000000f, 0.45800781249999994000f, - 0.51657104492187500000f, 0.56680297851562500000f, - 0.63000488281250000000f, 0.67800903320312500000f, - 0.73190307617187500000f, 0.77740478515625000000f, - 0.83532714843750000000f, 0.87417602539062489000f, - 0.09201049804687500000f, 0.11199951171875000000f, - 0.15521240234375000000f, 0.19445800781250000000f, - 0.24072265625000000000f, 0.28408813476562500000f, - 0.33465576171875006000f, 0.38580322265624994000f, - 0.44235229492187500000f, 0.49353027343750000000f, - 0.55175781250000000000f, 0.60949707031250000000f, - 0.68524169921874989000f, 0.75985717773437500000f, - 0.83502197265624989000f, 0.91476440429687500000f, - 0.08795166015625001400f, 0.11392211914062500000f, - 0.15603637695312500000f, 0.19781494140625000000f, - 0.24795532226562503000f, 0.29556274414062500000f, - 0.35394287109375000000f, 0.40551757812500006000f, - 0.47012329101562500000f, 0.52465820312500000000f, - 0.61578369140625000000f, 0.68438720703125011000f, - 0.75686645507812500000f, 0.82440185546875000000f, - 0.89147949218750000000f, 0.94027709960937511000f, - 0.07019042968750000000f, 0.09057617187500000000f, - 0.12515258789062500000f, 0.16607666015625000000f, - 0.19308471679687500000f, 0.24139404296875000000f, - 0.38009643554687500000f, 0.42303466796875000000f, - 0.48056030273437500000f, 0.53421020507812500000f, - 0.58145141601562500000f, 0.63107299804687500000f, - 0.69015502929687500000f, 0.75250244140625000000f, - 0.83920288085937500000f, 0.91751098632812500000f, - 0.06887817382812500000f, 0.08972167968750000000f, - 0.13519287109375000000f, 0.18283081054687497000f, - 0.21490478515624997000f, 0.25524902343750000000f, - 0.28729248046875000000f, 0.34252929687500000000f, - 0.47982788085937500000f, 0.53161621093750000000f, - 0.58755493164062500000f, 0.65518188476562489000f, - 0.72982788085937500000f, 0.79507446289062500000f, - 0.86761474609375000000f, 0.92724609375000000000f, - 0.03744506835937500000f, 0.06240844726562500000f, - 0.11651611328124999000f, 0.15292358398437500000f, - 0.21331787109375000000f, 0.28170776367187500000f, - 0.33642578124999994000f, 0.39706420898437494000f, - 0.52920532226562500000f, 0.58035278320312500000f, - 0.62814331054687500000f, 0.69577026367187500000f, - 0.76889038085937500000f, 0.82019042968750000000f, - 0.89572143554687500000f, 0.94009399414062489000f, - 0.04132080078125000000f, 0.05871582031250000000f, - 0.11563110351562500000f, 0.24649047851562500000f, - 0.31900024414062500000f, 0.35519409179687500000f, - 0.40747070312500000000f, 0.45217895507812500000f, - 0.51095581054687500000f, 0.55508422851562500000f, - 0.61325073242187500000f, 0.67181396484374989000f, - 0.75051879882812500000f, 0.81411743164062500000f, - 0.87423706054687500000f, 0.92333984375000000000f, - 0.09588623046875000000f, 0.12356567382812501000f, - 0.18911743164062500000f, 0.22634887695312500000f, - 0.26712036132812500000f, 0.30993652343750000000f, - 0.35195922851562500000f, 0.40225219726562500000f, - 0.48666381835937500000f, 0.53878784179687500000f, - 0.59832763671875000000f, 0.65313720703125000000f, - 0.71676635742187500000f, 0.78305053710937511000f, - 0.85824584960937511000f, 0.92480468750000000000f, - 0.04019165039062500700f, 0.06906127929687500000f, - 0.14419555664062500000f, 0.23226928710937500000f, - 0.29501342773437500000f, 0.35504150390625000000f, - 0.43161010742187500000f, 0.49615478515625000000f, - 0.57141113281250000000f, 0.63165283203125000000f, - 0.68295288085937500000f, 0.73263549804687511000f, - 0.78659057617187489000f, 0.83163452148437500000f, - 0.88287353515625000000f, 0.93362426757812500000f, - 0.04791259765625000000f, 0.07089233398437500000f, - 0.11651611328124999000f, 0.18966674804687500000f, - 0.30191040039062500000f, 0.35266113281250000000f, - 0.39886474609375000000f, 0.44650268554687500000f, - 0.49291992187500006000f, 0.55816650390625000000f, - 0.65264892578125000000f, 0.71246337890625000000f, - 0.76641845703125011000f, 0.82162475585937500000f, - 0.87622070312500000000f, 0.92065429687500000000f, - 0.07009887695312500000f, 0.11917114257812500000f, - 0.19186401367187503000f, 0.26116943359375000000f, - 0.32556152343750006000f, 0.38958740234375000000f, - 0.45834350585937500000f, 0.52191162109375000000f, - 0.58093261718750000000f, 0.63101196289062500000f, - 0.68179321289062500000f, 0.72848510742187500000f, - 0.77752685546875000000f, 0.82656860351562500000f, - 0.88046264648437500000f, 0.93139648437500000000f, - 0.05844116210937500000f, 0.07650756835937500000f, - 0.12307739257812499000f, 0.17544555664062500000f, - 0.21542358398437497000f, 0.27072143554687500000f, - 0.32528686523437500000f, 0.37225341796875006000f, - 0.42532348632812500000f, 0.46945190429687500000f, - 0.51480102539062500000f, 0.57089233398437500000f, - 0.70724487304687489000f, 0.78790283203125011000f, - 0.87017822265625000000f, 0.93081665039062500000f, - 0.07336425781250000000f, 0.08905029296875000000f, - 0.15838623046875000000f, 0.19079589843750000000f, - 0.22662353515625003000f, 0.30172729492187500000f, - 0.37802124023437500000f, 0.45150756835937494000f, - 0.51129150390625000000f, 0.56054687500000000000f, - 0.62066650390625000000f, 0.67147827148437511000f, - 0.73962402343750000000f, 0.80737304687500000000f, - 0.86944580078125000000f, 0.92764282226562500000f, - 0.04946899414062500000f, 0.06796264648437500000f, - 0.10617065429687500000f, 0.15518188476562500000f, - 0.28762817382812500000f, 0.39343261718750006000f, - 0.43475341796875006000f, 0.47766113281250000000f, - 0.52505493164062500000f, 0.56988525390625000000f, - 0.62396240234375000000f, 0.67776489257812500000f, - 0.72564697265625000000f, 0.78939819335937500000f, - 0.85238647460937500000f, 0.91836547851562500000f, - 0.05703735351562500000f, 0.07293701171875000000f, - 0.12527465820312500000f, 0.21426391601562500000f, - 0.34243774414062500000f, 0.38986206054687500000f, - 0.42904663085937500000f, 0.47576904296875006000f, - 0.51953125000000000000f, 0.56787109375000000000f, - 0.62850952148437500000f, 0.67367553710937500000f, - 0.72171020507812489000f, 0.76763916015625000000f, - 0.82135009765625000000f, 0.87496948242187500000f, - 0.07785034179687500000f, 0.09924316406250000000f, - 0.14306640625000000000f, 0.20025634765625000000f, - 0.24014282226562500000f, 0.27847290039062500000f, - 0.31967163085937506000f, 0.36010742187500000000f, - 0.47003173828125000000f, 0.57312011718750000000f, - 0.64062500000000000000f, 0.68832397460937500000f, - 0.74124145507812500000f, 0.79248046874999989000f, - 0.83816528320312500000f, 0.89208984375000000000f, - 0.08255004882812500000f, 0.10659790039062501000f, - 0.14450073242187500000f, 0.19409179687500000000f, - 0.24124145507812503000f, 0.28540039062500000000f, - 0.35211181640625006000f, 0.40985107421875000000f, - 0.46505737304687500000f, 0.51632690429687500000f, - 0.56820678710937500000f, 0.61322021484375000000f, - 0.66528320312500000000f, 0.71234130859375000000f, - 0.76904296875000000000f, 0.89285278320312500000f, - 0.06610107421875000000f, 0.08517456054687500000f, - 0.12240600585937499000f, 0.15505981445312500000f, - 0.17993164062500003000f, 0.27581787109375000000f, - 0.40914916992187494000f, 0.44869995117187506000f, - 0.50485229492187500000f, 0.55508422851562500000f, - 0.60717773437500000000f, 0.66702270507812500000f, - 0.75903320312500000000f, 0.82308959960937500000f, - 0.88363647460937500000f, 0.93121337890625000000f, - 0.05691528320312499300f, 0.09219360351562500000f, - 0.14331054687500000000f, 0.19940185546875003000f, - 0.25460815429687500000f, 0.30255126953125000000f, - 0.39028930664062500000f, 0.43038940429687500000f, - 0.50454711914062500000f, 0.54104614257812500000f, - 0.65124511718750000000f, 0.68478393554687500000f, - 0.75906372070312500000f, 0.80352783203125000000f, - 0.86755371093750000000f, 0.92022705078125000000f, - 0.10281372070312500000f, 0.13259887695312500000f, - 0.20059204101562503000f, 0.26742553710937500000f, - 0.31460571289062500000f, 0.35745239257812500000f, - 0.40792846679687500000f, 0.45117187500000000000f, - 0.50302124023437500000f, 0.55374145507812500000f, - 0.60543823242187500000f, 0.64840698242187500000f, - 0.71081542968750000000f, 0.77749633789062489000f, - 0.84091186523437489000f, 0.89865112304687500000f, - 0.03860473632812500000f, 0.06665039062500000000f, - 0.16610717773437500000f, 0.24087524414062500000f, - 0.32321166992187500000f, 0.40097045898437506000f, - 0.46096801757812500000f, 0.50778198242187500000f, - 0.56158447265625000000f, 0.60504150390625000000f, - 0.65365600585937500000f, 0.70175170898437500000f, - 0.75436401367187500000f, 0.80679321289062500000f, - 0.86557006835937500000f, 0.91934204101562500000f, - 0.04833984375000000700f, 0.06115722656250000000f, - 0.10787963867187500000f, 0.13580322265625000000f, - 0.26434326171875000000f, 0.32849121093750000000f, - 0.39160156250000000000f, 0.45709228515625000000f, - 0.51794433593750000000f, 0.57354736328125000000f, - 0.63879394531250000000f, 0.68807983398437500000f, - 0.75183105468750000000f, 0.80935668945312500000f, - 0.87588500976562500000f, 0.93283081054687511000f, - 0.10433959960937500000f, 0.13818359375000000000f, - 0.20147705078124997000f, 0.24078369140624997000f, - 0.29016113281250000000f, 0.33187866210937494000f, - 0.38973999023437500000f, 0.43814086914062500000f, - 0.48983764648437500000f, 0.55938720703125000000f, - 0.62957763671875000000f, 0.68634033203125000000f, - 0.76507568359375000000f, 0.82202148437499989000f, - 0.88336181640625011000f, 0.93206787109375000000f, - 0.05267333984375000000f, 0.06872558593750000000f, - 0.14028930664062500000f, 0.21209716796875000000f, - 0.25570678710937500000f, 0.29977416992187500000f, - 0.34677124023437500000f, 0.39044189453125006000f, - 0.43658447265625000000f, 0.47229003906250000000f, - 0.51263427734375000000f, 0.54986572265625000000f, - 0.66134643554687511000f, 0.77972412109375000000f, - 0.85900878906249989000f, 0.92672729492187500000f, - 0.10330200195312500000f, 0.11810302734375000000f, - 0.16195678710937503000f, 0.19494628906250000000f, - 0.21792602539062500000f, 0.26501464843750000000f, - 0.38742065429687500000f, 0.45590209960937500000f, - 0.50292968750000000000f, 0.55776977539062500000f, - 0.62673950195312500000f, 0.67285156249999989000f, - 0.73080444335937489000f, 0.79238891601562500000f, - 0.86102294921875000000f, 0.91418457031250000000f, - 0.08456420898437500000f, 0.10089111328124999000f, - 0.13580322265625000000f, 0.16967773437500000000f, - 0.19692993164062497000f, 0.28970336914062500000f, - 0.41345214843750000000f, 0.45025634765625006000f, - 0.51095581054687500000f, 0.56295776367187500000f, - 0.61120605468750000000f, 0.66333007812499989000f, - 0.72467041015625011000f, 0.77371215820312500000f, - 0.82827758789062500000f, 0.88702392578125000000f, - 0.09240722656250000000f, 0.11901855468750001000f, - 0.20193481445312503000f, 0.24087524414062500000f, - 0.28109741210937500000f, 0.31982421875000000000f, - 0.36764526367187500000f, 0.41452026367187494000f, - 0.46331787109375000000f, 0.50848388671875000000f, - 0.56463623046875000000f, 0.61315917968750000000f, - 0.67718505859374989000f, 0.74334716796875000000f, - 0.80267333984375000000f, 0.88369750976562489000f, - 0.06103515624999999300f, 0.07781982421875000000f, - 0.12411499023437500000f, 0.20864868164062503000f, - 0.29382324218750000000f, 0.33575439453125000000f, - 0.38433837890625006000f, 0.43023681640625000000f, - 0.47573852539062500000f, 0.52474975585937500000f, - 0.57003784179687500000f, 0.61337280273437500000f, - 0.65704345703125000000f, 0.70449829101562500000f, - 0.75198364257812500000f, 0.88568115234375000000f, - 0.08679199218749998600f, 0.10076904296875000000f, - 0.15573120117187500000f, 0.18637084960937500000f, - 0.21090698242187500000f, 0.26239013671875000000f, - 0.37890625000000000000f, 0.42889404296875000000f, - 0.48907470703125000000f, 0.56661987304687500000f, - 0.63085937500000000000f, 0.67962646484375000000f, - 0.73095703125000000000f, 0.78646850585937500000f, - 0.84405517578125000000f, 0.91632080078125000000f, - 0.12338256835937500000f, 0.15716552734375000000f, - 0.22180175781250000000f, 0.27636718750000000000f, - 0.33312988281250000000f, 0.38568115234375006000f, - 0.44381713867187500000f, 0.49389648437500000000f, - 0.54772949218750000000f, 0.60092163085937500000f, - 0.65176391601562500000f, 0.70132446289062500000f, - 0.75759887695312500000f, 0.81149291992187500000f, - 0.86911010742187500000f, 0.92263793945312500000f, - 0.06436157226562500000f, 0.08010864257812500000f, - 0.13183593750000000000f, 0.16860961914062500000f, - 0.22747802734375000000f, 0.31188964843750000000f, - 0.39611816406250006000f, 0.44854736328125000000f, - 0.53793334960937500000f, 0.58786010742187500000f, - 0.62515258789062500000f, 0.68301391601562500000f, - 0.74093627929687500000f, 0.78665161132812500000f, - 0.84982299804687500000f, 0.92950439453125000000f, - 0.04730224609375000000f, 0.08139038085937501400f, - 0.19754028320312500000f, 0.28979492187500000000f, - 0.33523559570312500000f, 0.37695312500000000000f, - 0.42098999023437500000f, 0.46487426757812500000f, - 0.52182006835937500000f, 0.56890869140625000000f, - 0.62442016601562500000f, 0.67492675781250000000f, - 0.73843383789062489000f, 0.80233764648437500000f, - 0.86679077148437500000f, 0.91955566406250000000f, - 0.07357788085937500000f, 0.09411621093750000000f, - 0.12649536132812500000f, 0.16461181640625000000f, - 0.19430541992187500000f, 0.24884033203124997000f, - 0.40054321289062500000f, 0.48977661132812500000f, - 0.53591918945312500000f, 0.58364868164062500000f, - 0.64874267578125000000f, 0.69464111328125000000f, - 0.74642944335937500000f, 0.80313110351562500000f, - 0.86227416992187500000f, 0.90643310546875000000f, - 0.12692260742187500000f, 0.13781738281250000000f, - 0.18176269531250000000f, 0.23300170898437500000f, - 0.25189208984375000000f, 0.27404785156250000000f, - 0.34204101562500000000f, 0.43130493164062500000f, - 0.49468994140624994000f, 0.54550170898437500000f, - 0.61633300781250000000f, 0.66723632812500011000f, - 0.72753906250000000000f, 0.78573608398437511000f, - 0.85626220703125000000f, 0.91589355468750000000f, - 0.06182861328125000000f, 0.07418823242187500000f, - 0.08682250976562500000f, 0.11041259765625000000f, - 0.24261474609375000000f, 0.29913330078125000000f, - 0.38821411132812500000f, 0.44128417968750000000f, - 0.50585937500000000000f, 0.57934570312500000000f, - 0.65234375000000000000f, 0.71163940429687500000f, - 0.76174926757812500000f, 0.81536865234375000000f, - 0.88412475585937500000f, 0.93505859375000000000f, - 0.10464477539062500000f, 0.11697387695312500000f, - 0.13647460937500000000f, 0.14990234375000000000f, - 0.23568725585937500000f, 0.31695556640625000000f, - 0.39614868164062500000f, 0.46759033203125000000f, - 0.50961303710937500000f, 0.57394409179687500000f, - 0.63409423828125000000f, 0.68820190429687511000f, - 0.75155639648437500000f, 0.80853271484375000000f, - 0.86468505859375000000f, 0.93023681640625000000f, - 0.14465332031250000000f, 0.15774536132812500000f, - 0.17687988281250003000f, 0.19790649414062503000f, - 0.21356201171874997000f, 0.26947021484375000000f, - 0.35940551757812500000f, 0.43988037109375000000f, - 0.51364135742187500000f, 0.56192016601562500000f, - 0.63442993164062500000f, 0.68264770507812489000f, - 0.73962402343750000000f, 0.78842163085937511000f, - 0.84860229492187500000f, 0.91616821289062500000f, - 0.00457763671875000000f, 0.00512695312500000000f, - -0.00051879882812500000f, -0.00326538085937500000f, - -0.00433349609375000000f, -0.00698852539062499910f, - -0.00976562500000000000f, -0.01239013671875000000f, - -0.01535034179687500000f, -0.01892089843750000000f, - -0.02645874023437500000f, -0.02853393554687500000f, - -0.02752685546875000000f, -0.02075195312500000000f, - -0.01214599609375000000f, -0.00347900390625000000f, - -0.01214599609375000000f, -0.01083374023437500000f, - 0.00149536132812500000f, 0.00778198242187500000f, - 0.00347900390625000000f, 0.00793457031250000000f, - 0.01217651367187500000f, 0.00805664062500000000f, - 0.00967407226562500000f, 0.01315307617187500000f, - 0.01568603515625000000f, 0.01620483398437500000f, - 0.01327514648437500000f, 0.01086425781250000000f, - 0.00726318359375000000f, 0.00323486328125000000f, - -0.00131225585937500000f, -0.00109863281250000000f, - -0.00515747070312500000f, -0.00683593750000000000f, - -0.01193237304687500000f, -0.01931762695312500000f, - -0.02368164062500000000f, -0.02960205078125000000f, - -0.02575683593750000000f, -0.01388549804687500000f, - -0.00552368164062500000f, -0.00036621093750000000f, - 0.00259399414062500000f, 0.00259399414062500000f, - 0.00500488281250000000f, 0.00595092773437500000f, - 0.00372314453125000000f, 0.00259399414062500000f, - -0.00482177734375000000f, -0.01953125000000000000f, - -0.02755737304687500000f, 0.00027465820312500000f, - 0.00021362304687500000f, -0.00378417968750000000f, - 0.00454711914062500000f, 0.00097656250000000000f, - 0.00671386718750000000f, 0.01126098632812500000f, - 0.00738525390625000000f, 0.00350952148437500040f, - 0.00241088867187500000f, 0.00256347656250000000f, - -0.00445556640625000000f, -0.00659179687500000000f, - -0.00213623046875000000f, 0.03125000000000000000f, - 0.02291870117187500000f, 0.01751708984375000000f, - 0.01342773437500000000f, 0.01150512695312500000f, - 0.01074218749999999800f, 0.00619506835937500000f, - 0.00091552734374999989f, 0.00048828125000000000f, - -0.00009155273437500000f, 0.00247192382812500000f, - 0.00491333007812500000f, 0.00305175781250000000f, - -0.00451660156250000000f, -0.00537109374999999910f, - 0.02847290039062500000f, 0.02288818359375000000f, - 0.01232910156250000000f, 0.00521850585937500000f, - -0.00006103515625000000f, -0.00445556640625000000f, - -0.01254272460937500000f, -0.01348876953125000000f, - -0.01651000976562500000f, -0.01684570312500000000f, - -0.01348876953125000000f, -0.00820922851562500000f, - -0.00732421874999999910f, -0.00158691406250000020f, - 0.01840209960937500000f, 0.01937866210937500000f, - 0.01235961914062499800f, 0.00543212890625000000f, - 0.00656127929687500000f, 0.00057983398437500000f, - -0.00466918945312500000f, -0.00509643554687500000f, - -0.00885009765625000000f, -0.00668334960937500090f, - 0.00460815429687500000f, 0.00827026367187500000f, - 0.00460815429687500000f, 0.00363159179687500000f, - 0.00924682617187500000f, 0.00811767578125000000f, - 0.00305175781250000000f, 0.00210571289062500000f, - -0.00894165039062500000f, -0.02005004882812500000f, - 0.02865600585937500000f, 0.02011108398437500000f, - 0.01348876953125000000f, 0.01071166992187500000f, - 0.00402832031250000000f, 0.00299072265625000000f, - -0.00048828125000000000f, -0.00003051757812500000f, - -0.00411987304687500000f, -0.00610351562500000000f, - -0.00680541992187500000f, -0.00271606445312500000f, - 0.00509643554687500000f, 0.00469970703125000000f, - 0.00524902343750000000f, 0.00723266601562500000f, - -0.00137329101562500000f, -0.00558471679687500000f, - -0.00695800781250000000f, -0.01483154296875000000f, - 0.00802612304687500000f, 0.01855468750000000000f, - 0.00482177734375000000f, -0.00381469726562499960f, - -0.01190185546875000000f, -0.00692749023437500000f, - -0.00360107421875000000f, 0.00131225585937500000f, - -0.01394653320312500000f, -0.01196289062500000000f, - -0.02346801757812500000f, -0.02563476562500000000f, - 0.00061035156250000000f, -0.00357055664062500000f, - -0.00592041015625000000f, -0.00576782226562500000f, - -0.00527954101562500000f, -0.00527954101562500000f, - -0.00100708007812500000f, 0.00097656250000000000f, - 0.00531005859375000000f, 0.00439453125000000000f, - 0.00350952148437500040f, 0.00509643554687500000f, - 0.00173950195312500000f, 0.00134277343749999980f, - 0.00042724609375000000f, 0.00448608398437500000f, - 0.00292968750000000000f, -0.00164794921875000000f, - -0.00433349609375000000f, -0.00393676757812500000f, - -0.00775146484375000000f, -0.01010131835937500000f, - 0.00927734375000000000f, 0.00946044921875000000f, - -0.00158691406250000020f, -0.01278686523437500000f, - -0.02581787109375000000f, -0.03234863281250000000f, - -0.00268554687499999960f, -0.00375366210937500000f, - -0.00616455078125000000f, -0.01046752929687500200f, - -0.01690673828125000000f, -0.02932739257812500000f, - -0.02902221679687500000f, 0.00997924804687500000f, - 0.00485229492187500000f, 0.00247192382812500000f, - 0.00778198242187500000f, 0.00692749023437500000f, - 0.00366210937499999960f, 0.00619506835937500000f, - 0.00781250000000000000f, 0.00585937500000000000f, - 0.00500488281250000000f, 0.00683593750000000000f, - 0.00885009765625000000f, 0.00595092773437500000f, - 0.00659179687500000000f, 0.00637817382812500090f, - 0.00390625000000000000f, 0.02539062500000000300f, - 0.03137207031250000000f, 0.02713012695312500000f, - 0.02130126953125000000f, 0.01538085937500000000f, - 0.01245117187500000000f, 0.01083374023437500000f, - 0.00665283203124999910f, 0.00097656250000000000f, - -0.00350952148437500040f, -0.00256347656250000000f, - -0.00842285156250000000f, -0.00305175781250000000f, - -0.00952148437500000000f, -0.01477050781250000000f, - 0.02743530273437500000f, 0.02081298828124999700f, - 0.01419067382812500000f, 0.01391601562500000000f, - 0.00735473632812500090f, -0.00036621093750000000f, - -0.00839233398437500000f, -0.01296997070312499800f, - -0.01406860351562500000f, -0.01119995117187500000f, - -0.00100708007812500000f, -0.00085449218750000000f, - -0.00311279296875000000f, -0.00592041015625000000f, - -0.01608276367187500000f, 0.02633666992187500000f, - 0.02764892578125000000f, 0.01412963867187500000f, - 0.00747680664062500000f, 0.00039672851562500005f, - -0.00646972656250000000f, -0.00930786132812500000f, - -0.00320434570312500000f, 0.00497436523437500000f, - 0.00851440429687500000f, 0.00537109374999999910f, - 0.00283813476562499960f, 0.00204467773437500000f, - 0.00350952148437500040f, 0.00585937500000000000f, - 0.00186157226562500000f, -0.00152587890625000000f, - -0.00402832031250000000f, -0.00534057617187499910f, - -0.00683593750000000000f, -0.00827026367187500000f, - -0.01919555664062500000f, -0.00769042968750000000f, - 0.03533935546875000000f, 0.02966308593750000000f, - 0.01947021484375000000f, 0.00854492187500000000f, - 0.00915527343750000000f, 0.00994873046875000000f, - 0.00436401367187500000f, -0.00463867187500000000f, - -0.00653076171875000000f, -0.00875854492187500000f, - 0.00161743164062500000f, -0.00128173828125000000f, - -0.00720214843750000000f, -0.01074218749999999800f, - -0.01290893554687500000f, -0.00756835937500000000f, - -0.00393676757812500000f, -0.00497436523437500000f, - -0.00543212890625000000f, -0.00363159179687500000f, - 0.00259399414062500000f, 0.00173950195312500000f, - 0.01568603515625000000f, 0.01165771484375000000f, - 0.01141357421875000200f, 0.01226806640625000000f, - 0.01293945312500000000f, 0.01290893554687500000f, - 0.00827026367187500000f, 0.00601196289062499910f, - 0.00296020507812500000f, 0.00122070312500000000f, - 0.00119018554687500000f, -0.00296020507812500000f, - -0.00582885742187500000f, -0.00500488281250000000f, - -0.00701904296875000090f, -0.00781250000000000000f, - -0.01251220703125000000f, 0.01208496093750000200f, - 0.00997924804687500000f, 0.00387573242187500000f, - 0.00030517578125000000f, -0.00363159179687500000f, - -0.00509643554687500000f, -0.00888061523437500000f, - -0.00836181640625000000f, -0.00430297851562500000f, - -0.00302124023437500040f, -0.00689697265625000000f, - -0.00665283203124999910f, -0.00424194335937500000f, - -0.00683593750000000000f, -0.00637817382812500090f, - -0.00817871093750000000f, -0.01348876953125000000f, - -0.01260375976562500000f, 0.00677490234375000000f, - 0.00177001953125000000f, 0.01589965820312500000f, - 0.01049804687500000000f, 0.00787353515625000000f, - 0.00231933593750000000f, -0.00128173828125000000f, - -0.00433349609375000000f, -0.00503540039062499910f, - -0.00375366210937500000f, -0.00280761718750000000f, - 0.00143432617187500000f, 0.00024414062500000000f, - -0.00009155273437500000f, -0.00582885742187500000f, - -0.00033569335937499995f, -0.00500488281250000000f, - -0.00509643554687500000f, -0.01071166992187500000f, - -0.02258300781250000000f, 0.00949096679687500000f, - 0.01641845703125000000f, 0.00888061523437500000f, - 0.00561523437500000000f, 0.00088500976562500000f, - -0.00320434570312500000f, 0.00027465820312500000f, - -0.00091552734374999989f, -0.00164794921875000000f, - -0.00051879882812500000f, -0.00234985351562500000f, - -0.00827026367187500000f, -0.01257324218750000000f, - -0.01898193359375000000f, -0.01977539062500000000f, - 0.01452636718750000000f, 0.00567626953124999910f, - -0.00201416015625000000f, -0.00601196289062499910f, - -0.00222778320312500000f, -0.00286865234375000000f, - -0.00045776367187499995f, 0.00143432617187500000f, - 0.00085449218750000000f, 0.00341796875000000000f, - -0.00177001953125000000f, -0.00100708007812500000f, - 0.00198364257812500000f, 0.00057983398437500000f, - 0.00256347656250000000f, 0.00262451171875000000f, - 0.00842285156250000000f, 0.00347900390625000000f, - 0.01440429687500000000f, 0.02398681640625000000f, - 0.02438354492187499700f, 0.01907348632812500000f, - 0.01266479492187500000f, 0.00543212890625000000f, - -0.00106811523437500000f, -0.00079345703125000011f, - 0.00015258789062500000f, 0.00027465820312500000f, - 0.00253295898437500040f, 0.00119018554687500000f, - 0.00112915039062500000f, 0.00119018554687500000f, - -0.00561523437500000000f, -0.01141357421875000200f, - -0.00808715820312500000f, -0.01104736328125000000f, - -0.01528930664062500000f, 0.01028442382812500000f, - 0.02185058593750000000f, 0.01458740234374999800f, - -0.00183105468749999980f, -0.00381469726562499960f, - -0.00497436523437500000f, 0.01104736328125000000f, - 0.00051879882812500000f, -0.00372314453125000000f, - -0.00711059570312500000f, 0.00851440429687500000f, - 0.00421142578125000000f, 0.00479125976562500000f, - 0.00970458984375000000f, 0.00588989257812500000f, - 0.00576782226562500000f, 0.00637817382812500090f, - 0.00811767578125000000f, 0.00769042968750000000f, - -0.00140380859375000000f, -0.00170898437500000000f, - -0.00845336914062500000f, -0.01309204101562500000f, - 0.01416015625000000000f, 0.01177978515625000000f, - 0.00433349609375000000f, 0.00134277343749999980f, - -0.00131225585937500000f, 0.00201416015625000000f, - 0.00805664062500000000f, 0.00555419921875000000f, - 0.00143432617187500000f, 0.00042724609375000000f, - -0.00079345703125000011f, -0.00241088867187500000f, - 0.00149536132812500000f, 0.00045776367187499995f, - -0.00390625000000000000f, -0.00619506835937500000f, - -0.01220703125000000000f, -0.01458740234374999800f, - 0.00991821289062500000f, 0.00082397460937500000f, - 0.00714111328125000000f, 0.01254272460937500000f, - 0.00625610351562500000f, 0.00393676757812500000f, - 0.00036621093750000000f, 0.00177001953125000000f, - 0.00375366210937500000f, 0.00173950195312500000f, - 0.00521850585937500000f, 0.00418090820312500000f, - 0.00292968750000000000f, 0.00390625000000000000f, - -0.00097656250000000000f, 0.00408935546875000000f, - -0.00036621093750000000f, 0.00173950195312500000f, - 0.00363159179687500000f, 0.00079345703125000011f, - -0.00067138671874999989f, -0.00503540039062499910f, - -0.01525878906249999800f, -0.02139282226562500000f, - -0.01611328125000000000f, -0.00354003906250000000f, - 0.00195312500000000000f, -0.00024414062500000000f, - 0.00296020507812500000f, -0.00027465820312500000f, - -0.00494384765625000000f, -0.00201416015625000000f, - -0.00476074218750000000f, -0.00592041015625000000f, - -0.00924682617187500000f, -0.01666259765625000000f, - -0.01040649414062499800f, 0.01666259765625000000f, - 0.01092529296875000000f, 0.00289916992187500000f, - 0.00137329101562500000f, 0.00231933593750000000f, - 0.00823974609375000000f, 0.01229858398437500000f, - 0.00625610351562500000f, 0.00305175781250000000f, - 0.00375366210937500000f, 0.00152587890625000000f, - -0.00161743164062500000f, -0.00439453125000000000f, - -0.00335693359375000000f, -0.00039672851562500005f, - 0.00097656250000000000f, -0.00695800781250000000f, - -0.00396728515625000000f, 0.01077270507812500000f, - 0.00903320312500000000f, 0.00170898437500000000f, - -0.01135253906249999800f, -0.00772094726562500000f, - 0.01113891601562500000f, 0.00222778320312500000f, - 0.00030517578125000000f, -0.00103759765625000000f, - -0.00424194335937500000f, -0.00582885742187500000f, - -0.00292968750000000000f, 0.00015258789062500000f, - 0.00134277343749999980f, -0.00259399414062500000f, - -0.00546264648437500000f, -0.00393676757812500000f, - -0.00585937500000000000f, -0.00750732421875000000f, - -0.00259399414062500000f, -0.00335693359375000000f, - -0.00473022460937500000f, -0.00134277343749999980f, - -0.00082397460937500000f, 0.00442504882812500000f, - 0.00421142578125000000f, 0.00241088867187500000f, - 0.00097656250000000000f, -0.00451660156250000000f, - -0.01760864257812500000f, -0.01934814453125000000f, - 0.00582885742187500000f, 0.00286865234375000000f, - -0.00027465820312500000f, -0.00106811523437500000f, - -0.00234985351562500000f, -0.00256347656250000000f, - -0.00170898437500000000f, -0.00521850585937500000f, - -0.00909423828125000000f, -0.00827026367187500000f, - -0.00741577148437500000f, -0.00476074218750000000f, - -0.01000976562500000000f, -0.00717163085937500000f, - -0.00231933593750000000f, -0.00390625000000000000f, - -0.00369262695312500000f, 0.00393676757812500000f, - 0.00039672851562500005f, -0.00067138671874999989f, - 0.00097656250000000000f, 0.00137329101562500000f, - -0.00756835937500000000f, -0.00198364257812500000f, - 0.00588989257812500000f, -0.00247192382812500000f, - 0.00912475585937500000f, 0.00173950195312500000f, - -0.00448608398437500000f, 0.00585937500000000000f, - -0.00503540039062499910f, -0.01080322265625000200f, - -0.01019287109375000000f, -0.00323486328125000000f, - -0.00476074218750000000f, -0.00122070312500000000f, - -0.00009155273437500000f, -0.00207519531250000000f, - 0.00378417968750000000f, -0.00784301757812500000f, - 0.00238037109375000000f, 0.00378417968750000000f, - 0.00518798828125000000f, 0.01257324218750000000f, - 0.00692749023437500000f, 0.00320434570312500000f, - -0.00317382812500000040f, 0.00036621093750000000f, - 0.00469970703125000000f, 0.00762939453124999910f, - 0.00836181640625000000f, 0.00787353515625000000f, - 0.00012207031250000000f, -0.00082397460937500000f, - 0.00717163085937500000f, 0.00463867187500000000f, - 0.00155639648437500000f, 0.01031494140625000000f, - 0.00915527343750000000f, 0.00021362304687500000f, - -0.00958251953125000000f, -0.01254272460937500000f, - 0.00656127929687500000f, 0.00518798828125000000f, - -0.00027465820312500000f, -0.00283813476562499960f, - -0.00234985351562500000f, 0.00231933593750000000f, - 0.00204467773437500000f, 0.00164794921875000000f, - 0.00610351562500000000f, 0.00961303710937500000f, - 0.00497436523437500000f, 0.00219726562500000000f, - -0.00277709960937500000f, -0.01226806640625000000f, - 0.00482177734375000000f, 0.00570678710937500090f, - -0.00476074218750000000f, -0.00277709960937500000f, - 0.00885009765625000000f, 0.00814819335937500000f, - 0.00509643554687500000f, 0.00277709960937500000f, - 0.00427246093750000000f, 0.00521850585937500000f, - 0.00341796875000000000f, 0.00027465820312500000f, - -0.00128173828125000000f, -0.00540161132812500090f, - -0.01342773437500000000f, 0.01174926757812500200f, - 0.00244140625000000000f, 0.00045776367187499995f, - 0.00524902343750000000f, 0.00393676757812500000f, - 0.00125122070312500000f, -0.00393676757812500000f, - -0.01135253906249999800f, -0.00073242187500000000f, - -0.00228881835937500000f, -0.00091552734374999989f, - -0.00518798828125000000f, 0.00030517578125000000f, - -0.00360107421875000000f, 0.00173950195312500000f, - 0.00238037109375000000f, -0.00308227539062500000f, - 0.00708007812500000000f, 0.00491333007812500000f, - 0.00375366210937500000f, 0.00781250000000000000f, - 0.00845336914062500000f, 0.00308227539062500000f, - -0.00585937500000000000f, -0.01919555664062500000f, - -0.00305175781250000000f, -0.00183105468749999980f, - -0.00708007812500000000f, 0.00201416015625000000f, - 0.00039672851562500005f, -0.00039672851562500005f, - -0.00244140625000000000f, -0.00729370117187499910f, - 0.00729370117187499910f, 0.00112915039062500000f, - 0.00097656250000000000f, 0.00271606445312500000f, - -0.00973510742187500000f, -0.01766967773437500000f, - 0.01373291015625000000f, 0.01098632812500000000f, - 0.00009155273437500000f, -0.00088500976562500000f, - -0.00912475585937500000f, -0.00271606445312500000f, - -0.00164794921875000000f, -0.00335693359375000000f, - -0.00750732421875000000f, -0.00500488281250000000f, - 0.00018310546875000000f, -0.00573730468750000000f, - 0.01031494140625000000f, 0.00537109374999999910f, - -0.00280761718750000000f, 0.00601196289062499910f, - 0.00418090820312500000f, 0.00408935546875000000f, - 0.00036621093750000000f, -0.00006103515625000000f, - 0.00170898437500000000f, -0.00558471679687500000f, - 0.00347900390625000000f, -0.00109863281250000000f, - -0.00399780273437500000f, -0.00622558593750000000f, - 0.00228881835937500000f, -0.00076293945312500000f, - -0.00531005859375000000f, 0.00582885742187500000f, - -0.00045776367187499995f, -0.00885009765625000000f, - -0.01309204101562500000f, -0.00814819335937500000f, - 0.00241088867187500000f, 0.00112915039062500000f, - 0.00323486328125000000f, 0.00070190429687500000f, - -0.01171875000000000000f, 0.01296997070312499800f, - 0.00213623046875000000f, -0.00042724609375000000f, - 0.00646972656250000000f, 0.00320434570312500000f, - 0.00045776367187499995f, -0.00006103515625000000f, - -0.00128173828125000000f, -0.00112915039062500000f, - -0.00375366210937500000f, 0.00329589843750000000f, - 0.00085449218750000000f, -0.00146484375000000000f, - 0.00588989257812500000f, 0.00601196289062499910f, - 0.00527954101562500000f, -0.00100708007812500000f, - 0.00112915039062500000f, 0.00222778320312500000f, - -0.00173950195312500000f, 0.00781250000000000000f, - 0.00418090820312500000f, -0.00177001953125000000f, - -0.01312255859375000000f, -0.00695800781250000000f, - 0.00662231445312500000f, -0.00155639648437500000f, - -0.00030517578125000000f, -0.00177001953125000000f, - -0.00018310546875000000f, 0.00067138671874999989f, - 0.00317382812500000040f, 0.00186157226562500000f, - -0.00363159179687500000f, 0.00515747070312500000f, - 0.00439453125000000000f, 0.00048828125000000000f, - -0.00140380859375000000f, -0.01202392578124999800f, - 0.00183105468749999980f, 0.01385498046875000000f, - -0.00244140625000000000f, -0.00909423828125000000f, - -0.00198364257812500000f, 0.00076293945312500000f, - 0.00000000000000000000f, -0.00073242187500000000f, - -0.00198364257812500000f, -0.01272583007812500000f, - 0.01419067382812500000f, 0.00842285156250000000f, - -0.00009155273437500000f, -0.00592041015625000000f, - -0.00039672851562500005f, 0.00396728515625000000f, - 0.00057983398437500000f, -0.00018310546875000000f, - -0.00064086914062500000f, -0.00073242187500000000f, - -0.00549316406250000000f, -0.00161743164062500000f, - -0.00259399414062500000f, 0.00061035156250000000f, - 0.00360107421875000000f, 0.00448608398437500000f, - 0.00344848632812500000f, -0.00228881835937500000f, - -0.00881958007812500000f, 0.00689697265625000000f, - -0.00372314453125000000f, 0.00692749023437500000f, - 0.00823974609375000000f, 0.00381469726562499960f, - 0.00332641601562499960f, 0.00601196289062499910f, - 0.00381469726562499960f, 0.00421142578125000000f, - 0.00134277343749999980f, 0.00183105468749999980f, - 0.00076293945312500000f, -0.00167846679687500000f, - -0.00509643554687500000f, -0.00097656250000000000f, - -0.00424194335937500000f, -0.00588989257812500000f, - -0.00527954101562500000f, -0.00964355468750000000f, - 0.00875854492187500000f, -0.00634765625000000090f, - 0.00772094726562500000f, 0.00729370117187499910f, - 0.00082397460937500000f, -0.00244140625000000000f, - -0.00573730468750000000f, -0.00085449218750000000f, - -0.00555419921875000000f, -0.00717163085937500000f, - 0.00476074218750000000f, -0.00357055664062500000f, - 0.00390625000000000000f, -0.00146484375000000000f, - -0.00177001953125000000f, -0.00689697265625000000f, - 0.00524902343750000000f, 0.00552368164062500000f, - 0.00509643554687500000f, 0.00057983398437500000f, - 0.00189208984375000000f, 0.00030517578125000000f, - 0.00006103515625000000f, 0.00552368164062500000f, - 0.00460815429687500000f, 0.00329589843750000000f, - -0.00048828125000000000f, -0.00033569335937499995f, - -0.00238037109375000000f, -0.01010131835937500000f, - 0.01254272460937500000f, 0.00405883789062500000f, - 0.00051879882812500000f, 0.00317382812500000040f, - 0.00195312500000000000f, -0.00561523437500000000f, - 0.00073242187500000000f, -0.00091552734374999989f, - -0.00009155273437500000f, -0.00863647460937500000f, - 0.00369262695312500000f, 0.00622558593750000000f, - -0.00024414062500000000f, -0.00607299804687500000f, - -0.00064086914062500000f, -0.00244140625000000000f, - -0.00515747070312500000f, -0.00479125976562500000f, - -0.00582885742187500000f, -0.00415039062500000000f, - 0.00247192382812500000f, 0.00473022460937500000f, - 0.00042724609375000000f, -0.00399780273437500000f, - 0.00744628906250000000f, 0.00225830078125000000f, - -0.00173950195312500000f, -0.00143432617187500000f, - -0.00854492187500000000f, 0.01058959960937500000f, - 0.00338745117187500000f, -0.00234985351562500000f, - -0.00390625000000000000f, -0.00433349609375000000f, - -0.00592041015625000000f, -0.00381469726562499960f, - -0.00018310546875000000f, -0.00207519531250000000f, - 0.00277709960937500000f, 0.00003051757812500000f, - 0.00070190429687500000f, 0.00042724609375000000f, - -0.00469970703125000000f, -0.00103759765625000000f, - 0.00070190429687500000f, -0.00115966796875000000f, - -0.01046752929687500200f, 0.01535034179687500000f, - 0.00445556640625000000f, -0.00115966796875000000f, - -0.00140380859375000000f, -0.00125122070312500000f, - 0.00177001953125000000f, 0.00094604492187500000f, - 0.00192260742187500000f, -0.00146484375000000000f, - -0.00357055664062500000f, 0.00137329101562500000f, - 0.00085449218750000000f, 0.00003051757812500000f, - -0.00271606445312500000f, -0.00015258789062500000f, - -0.00134277343749999980f, -0.00088500976562500000f, - -0.01367187500000000000f, 0.01486206054687500000f, - 0.00622558593750000000f, 0.00247192382812500000f, - 0.00140380859375000000f, -0.00323486328125000000f, - -0.00921630859375000000f, 0.01159667968750000000f, - 0.00366210937499999960f, -0.00115966796875000000f, - -0.00036621093750000000f, -0.00119018554687500000f, - 0.00213623046875000000f, -0.00009155273437500000f, - 0.00076293945312500000f, -0.00198364257812500000f, - 0.00091552734374999989f, -0.00033569335937499995f, - 0.00103759765625000000f, -0.00045776367187499995f, - 0.00067138671874999989f, -0.00350952148437500040f, - 0.00000000000000000000f, -0.00241088867187500000f, - -0.00253295898437500040f, 0.00137329101562500000f, - 0.00347900390625000000f, 0.00131225585937500000f, - 0.00457763671875000000f, 0.00109863281250000000f, - 0.00711059570312500000f, 0.00454711914062500000f, - 0.00595092773437500000f, 0.00015258789062500000f, - 0.00076293945312500000f, -0.00158691406250000020f, - -0.01449584960937500000f, 0.00836181640625000000f, - 0.00085449218750000000f, -0.00119018554687500000f, - -0.00024414062500000000f, -0.00201416015625000000f, - -0.00778198242187500000f, 0.00787353515625000000f, - 0.00170898437500000000f, 0.00436401367187500000f, - -0.00137329101562500000f, -0.00579833984375000000f, - 0.00503540039062499910f, -0.00183105468749999980f, - 0.00061035156250000000f, 0.00006103515625000000f, - 0.00381469726562499960f, -0.00393676757812500000f, - 0.00155639648437500000f, -0.00024414062500000000f, - -0.01022338867187500000f, 0.00878906250000000000f, - 0.00115966796875000000f, 0.00180053710937500000f, - 0.00076293945312500000f, -0.00128173828125000000f, - 0.00070190429687500000f, -0.00360107421875000000f, - -0.00341796875000000000f, 0.00033569335937499995f, - -0.00167846679687500000f, -0.00405883789062500000f, - -0.00332641601562499960f, 0.00073242187500000000f, - -0.00320434570312500000f, 0.00238037109375000000f, - -0.00195312500000000000f, -0.00747680664062500000f, - 0.00616455078125000000f, -0.00198364257812500000f, - -0.00387573242187500000f, 0.00494384765625000000f, - 0.00122070312500000000f, -0.00286865234375000000f, - 0.00271606445312500000f, -0.00259399414062500000f, - -0.00363159179687500000f, -0.00314331054687500000f, - 0.00296020507812500000f, 0.00027465820312500000f, - -0.00213623046875000000f, -0.00085449218750000000f, - 0.00592041015625000000f, 0.00262451171875000000f, - -0.00341796875000000000f, -0.00280761718750000000f, - -0.00347900390625000000f, 0.00225830078125000000f, - -0.00149536132812500000f, 0.00140380859375000000f, - -0.00256347656250000000f, -0.00543212890625000000f, - 0.00344848632812500000f, 0.00158691406250000020f, - -0.00625610351562500000f, 0.01016235351562500000f, - 0.00268554687499999960f, 0.00677490234375000000f, - 0.00170898437500000000f, -0.00167846679687500000f, - 0.00039672851562500005f, 0.00262451171875000000f, - 0.00012207031250000000f, -0.00234985351562500000f, - 0.00683593750000000000f, 0.00347900390625000000f, - -0.00320434570312500000f, 0.00341796875000000000f, - 0.00381469726562499960f, -0.00088500976562500000f, - -0.00054931640625000000f, -0.00439453125000000000f, - 0.00067138671874999989f, -0.00177001953125000000f, - -0.00302124023437500040f, 0.00085449218750000000f, - 0.00347900390625000000f, -0.00201416015625000000f, - -0.00097656250000000000f, -0.00515747070312500000f, - -0.00958251953125000000f, 0.00869750976562500000f, - 0.00219726562500000000f, -0.00225830078125000000f, - 0.00546264648437500000f, 0.00085449218750000000f, - -0.00241088867187500000f, -0.00555419921875000000f, - 0.00039672851562500005f, -0.00167846679687500000f, - 0.00448608398437500000f, 0.00039672851562500005f, - 0.00036621093750000000f, -0.00164794921875000000f, - 0.00094604492187500000f, -0.00256347656250000000f, - -0.00051879882812500000f, -0.00228881835937500000f, - -0.00695800781250000000f, 0.00253295898437500040f, - -0.01144409179687500000f, 0.01330566406249999800f, - 0.00335693359375000000f, -0.00192260742187500000f, - -0.00082397460937500000f, -0.00415039062500000000f, - 0.00515747070312500000f, -0.00170898437500000000f, - -0.00024414062500000000f, -0.00521850585937500000f, - 0.00561523437500000000f, -0.00128173828125000000f, - 0.00451660156250000000f, 0.00207519531250000000f, - 0.00622558593750000000f, 0.00717163085937500000f, - 0.00335693359375000000f, -0.00698852539062499910f, - 0.00277709960937500000f, 0.00521850585937500000f, - -0.00131225585937500000f, -0.00009155273437500000f, - -0.00079345703125000011f, -0.00302124023437500040f, - -0.00338745117187500000f, 0.00216674804687500000f, - -0.00518798828125000000f, 0.00616455078125000000f, - -0.00204467773437500000f, 0.00552368164062500000f, - -0.00112915039062500000f, 0.00332641601562499960f, - -0.00366210937499999960f, 0.00009155273437500000f, - -0.00167846679687500000f, -0.00793457031250000000f, - -0.00048828125000000000f, 0.00463867187500000000f, - 0.00277709960937500000f, 0.00433349609375000000f, - 0.00128173828125000000f, 0.00134277343749999980f, - 0.00408935546875000000f, 0.00143432617187500000f, - 0.00051879882812500000f, -0.00106811523437500000f, - 0.00067138671874999989f, 0.00241088867187500000f, - -0.00515747070312500000f, 0.00125122070312500000f, - 0.00140380859375000000f, 0.00845336914062500000f, - -0.00283813476562499960f, -0.00149536132812500000f, - -0.00384521484375000000f, 0.00112915039062500000f, - -0.00314331054687500000f, -0.00103759765625000000f, - -0.00067138671874999989f, -0.00274658203125000000f, - -0.00408935546875000000f, -0.00625610351562500000f, - 0.00280761718750000000f, -0.00027465820312500000f, - 0.00003051757812500000f, -0.00595092773437500000f, - -0.00729370117187499910f, 0.00137329101562500000f, - 0.00164794921875000000f, 0.00054931640625000000f, - -0.00070190429687500000f, -0.00003051757812500000f, - -0.00244140625000000000f, -0.00299072265625000000f, - -0.00061035156250000000f, -0.00796508789062500000f, - 0.00933837890625000000f, 0.00219726562500000000f, - 0.00061035156250000000f, -0.00271606445312500000f, - -0.00662231445312500000f, 0.00033569335937499995f, - 0.00018310546875000000f, -0.00250244140625000000f, - 0.00271606445312500000f, 0.00039672851562500005f, - -0.00393676757812500000f, -0.00271606445312500000f, - 0.00253295898437500040f, -0.00216674804687500000f, - -0.00167846679687500000f, 0.00396728515625000000f, - -0.00299072265625000000f, -0.00445556640625000000f, - -0.00082397460937500000f, -0.00173950195312500000f, - 0.00161743164062500000f, 0.00839233398437500000f, - 0.00051879882812500000f, 0.00518798828125000000f, - -0.00015258789062500000f, -0.00164794921875000000f, - 0.00402832031250000000f, -0.00195312500000000000f, - 0.00219726562500000000f, 0.00488281250000000000f, - -0.00381469726562499960f, -0.00512695312500000000f, - 0.00219726562500000000f, 0.00122070312500000000f, - 0.00518798828125000000f, 0.00238037109375000000f, - 0.00756835937500000000f, 0.00354003906250000000f, - 0.00061035156250000000f, 0.00256347656250000000f, - 0.00094604492187500000f, -0.00103759765625000000f, - 0.00579833984375000000f, 0.00115966796875000000f, - 0.00039672851562500005f, -0.00323486328125000000f, - 0.00686645507812500000f, 0.00082397460937500000f, - -0.00512695312500000000f, 0.00073242187500000000f, - -0.00479125976562500000f, -0.00372314453125000000f, - 0.00503540039062499910f, 0.00033569335937499995f, - -0.00491333007812500000f, -0.00650024414062500000f, - -0.00036621093750000000f, -0.00155639648437500000f, - -0.00308227539062500000f, 0.00128173828125000000f, - 0.00308227539062500000f, 0.00082397460937500000f, - 0.00167846679687500000f, 0.00338745117187500000f, - 0.00228881835937500000f, 0.00216674804687500000f, - -0.00292968750000000000f, -0.00003051757812500000f, - 0.00198364257812500000f, -0.00845336914062500000f, - 0.01199340820312500000f, -0.00079345703125000011f, - -0.00134277343749999980f, -0.00207519531250000000f, - -0.00256347656250000000f, -0.00201416015625000000f, - -0.00289916992187500000f, 0.00717163085937500000f, - 0.00546264648437500000f, -0.00076293945312500000f, - -0.00125122070312500000f, 0.00082397460937500000f, - -0.00277709960937500000f, -0.00390625000000000000f, - -0.00677490234375000000f, 0.00445556640625000000f, - -0.00219726562500000000f, -0.00091552734374999989f, - -0.00073242187500000000f, 0.00167846679687500000f, - -0.00384521484375000000f, -0.00207519531250000000f, - -0.00177001953125000000f, -0.00387573242187500000f, - 0.00039672851562500005f, -0.00296020507812500000f, - -0.00323486328125000000f, 0.00531005859375000000f, - -0.00305175781250000000f, 0.00473022460937500000f, - 0.00308227539062500000f, -0.00445556640625000000f, - -0.00064086914062500000f, 0.00796508789062500000f, - 0.00067138671874999989f, 0.00115966796875000000f, - -0.00201416015625000000f, 0.00198364257812500000f, - 0.00012207031250000000f, 0.00213623046875000000f, - 0.00195312500000000000f, 0.00439453125000000000f, - 0.00180053710937500000f, 0.00650024414062500000f, - 0.00216674804687500000f, -0.01028442382812500000f, - 0.00924682617187500000f, -0.00158691406250000020f, - 0.00155639648437500000f, -0.00170898437500000000f, - 0.00003051757812500000f, 0.00030517578125000000f, - -0.00045776367187499995f, -0.00015258789062500000f, - 0.00103759765625000000f, 0.00158691406250000020f, - 0.00695800781250000000f, 0.00399780273437500000f, - 0.00491333007812500000f, -0.00387573242187500000f, - -0.00653076171875000000f, 0.00726318359375000000f, - 0.00375366210937500000f, 0.00195312500000000000f, - -0.00448608398437500000f, -0.00152587890625000000f, - -0.00103759765625000000f, -0.00387573242187500000f, - 0.00622558593750000000f, 0.00494384765625000000f, - 0.00259399414062500000f, 0.00125122070312500000f, - 0.00015258789062500000f, -0.00427246093750000000f, - 0.00222778320312500000f, -0.00457763671875000000f, - 0.00170898437500000000f, -0.00292968750000000000f, - -0.00201416015625000000f, -0.00061035156250000000f, - 0.00006103515625000000f, -0.00717163085937500000f, - 0.00180053710937500000f, -0.00067138671874999989f, - -0.00326538085937500000f, 0.00457763671875000000f, - -0.00048828125000000000f, -0.00143432617187500000f, - -0.00012207031250000000f, 0.00247192382812500000f, - -0.00204467773437500000f, 0.00509643554687500000f, - 0.00454711914062500000f, 0.00454711914062500000f, - -0.00479125976562500000f, 0.00878906250000000000f, - -0.00476074218750000000f, -0.00082397460937500000f, - -0.00024414062500000000f, 0.00054931640625000000f, - 0.00253295898437500040f, -0.00073242187500000000f, - -0.00125122070312500000f, -0.00509643554687500000f, - 0.00482177734375000000f, -0.00305175781250000000f, - 0.00283813476562499960f, 0.00161743164062500000f, - 0.00613403320312500000f, 0.00045776367187499995f, - 0.00128173828125000000f, 0.00811767578125000000f, - 0.00848388671875000000f, -0.00036621093750000000f, - -0.00018310546875000000f, -0.00112915039062500000f, - 0.00259399414062500000f, 0.00018310546875000000f, - 0.00061035156250000000f, -0.00573730468750000000f, - -0.00827026367187500000f, 0.00326538085937500000f, - -0.00039672851562500005f, -0.00244140625000000000f, - 0.00155639648437500000f, 0.00616455078125000000f, - 0.00527954101562500000f, -0.00210571289062500000f, - 0.00238037109375000000f, -0.00573730468750000000f, - 0.00140380859375000000f, 0.00012207031250000000f, - 0.00466918945312500000f, 0.00036621093750000000f, - -0.00421142578125000000f, 0.00515747070312500000f, - 0.00015258789062500000f, -0.00177001953125000000f, - -0.00375366210937500000f, -0.00329589843750000000f, - -0.00741577148437500000f, 0.00457763671875000000f, - 0.00030517578125000000f, -0.00582885742187500000f, - 0.00750732421875000000f, -0.00045776367187499995f, - 0.00115966796875000000f, 0.00076293945312500000f, - -0.00030517578125000000f, 0.00042724609375000000f, - 0.00186157226562500000f, 0.00152587890625000000f, - -0.00628662109375000000f, -0.00656127929687500000f, - -0.00671386718750000000f, 0.00274658203125000000f, - 0.00015258789062500000f, -0.00454711914062500000f, - -0.00668334960937500090f, 0.00170898437500000000f, - 0.00433349609375000000f, 0.00073242187500000000f, - -0.01147460937500000000f, 0.00234985351562500000f, - -0.00244140625000000000f, 0.00228881835937500000f, - 0.00018310546875000000f, 0.00128173828125000000f, - -0.00308227539062500000f, 0.00048828125000000000f, - 0.00170898437500000000f, 0.00042724609375000000f, - -0.00173950195312500000f, 0.00009155273437500000f, - -0.00051879882812500000f, 0.00244140625000000000f, - 0.00173950195312500000f, -0.00109863281250000000f, - 0.00268554687499999960f, -0.00180053710937500000f, - -0.00296020507812500000f, -0.00057983398437500000f, - -0.00451660156250000000f, 0.00140380859375000000f, - -0.00668334960937500090f, 0.00689697265625000000f, - 0.00347900390625000000f, -0.00012207031250000000f, - -0.00219726562500000000f, -0.00045776367187499995f, - 0.00112915039062500000f, -0.00149536132812500000f, - -0.00085449218750000000f, 0.00753784179687500000f, - 0.00134277343749999980f, 0.00375366210937500000f, - 0.00143432617187500000f, -0.00372314453125000000f, - -0.00115966796875000000f, 0.00051879882812500000f, - 0.00012207031250000000f, -0.00344848632812500000f, - -0.00097656250000000000f, -0.00683593750000000000f, - 0.00469970703125000000f, -0.00408935546875000000f, - 0.00598144531250000000f, 0.00216674804687500000f, - -0.00814819335937500000f, -0.00259399414062500000f, - 0.00085449218750000000f, -0.00213623046875000000f, - 0.00271606445312500000f, -0.00366210937499999960f, - 0.00302124023437500040f, -0.00006103515625000000f, - 0.00195312500000000000f, 0.00231933593750000000f, - -0.00506591796875000090f, -0.00146484375000000000f, - 0.00576782226562500000f, -0.00106811523437500000f, - -0.00280761718750000000f, -0.00515747070312500000f, - -0.00375366210937500000f, 0.01034545898437500000f, - 0.00115966796875000000f, -0.00076293945312500000f, - 0.00115966796875000000f, -0.00106811523437500000f, - 0.00686645507812500000f, -0.00424194335937500000f, - -0.00152587890625000000f, -0.00192260742187500000f, - 0.00750732421875000000f, 0.00183105468749999980f, - -0.00564575195312500000f, -0.00332641601562499960f, - -0.00149536132812500000f, -0.00161743164062500000f, - -0.00509643554687500000f, 0.00155639648437500000f, - 0.00454711914062500000f, 0.00183105468749999980f, - -0.00308227539062500000f, -0.00100708007812500000f, - 0.00076293945312500000f, -0.00231933593750000000f, - 0.00366210937499999960f, 0.00097656250000000000f, - -0.00091552734374999989f, -0.00253295898437500040f, - 0.00311279296875000000f, 0.00277709960937500000f, - -0.00567626953124999910f, -0.00796508789062500000f, - 0.00399780273437500000f, -0.00601196289062499910f - }; -// const SKP_Silk_NLSF_CBS_FLP SKP_Silk_NLSF_CB0_16_Stage_info_FLP[ NLSF_MSVQ_CB0_16_STAGES ] = -// { -// { 128, &SKP_Silk_NLSF_MSVQ_CB0_16[ 16 * 0 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates[ 0 ] }, -// { 16, &SKP_Silk_NLSF_MSVQ_CB0_16[ 16 * 128 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates[ 128 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB0_16[ 16 * 144 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates[ 144 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB0_16[ 16 * 152 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates[ 152 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB0_16[ 16 * 160 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates[ 160 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB0_16[ 16 * 168 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates[ 168 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB0_16[ 16 * 176 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates[ 176 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB0_16[ 16 * 184 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates[ 184 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB0_16[ 16 * 192 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates[ 192 ] }, -// { 16, &SKP_Silk_NLSF_MSVQ_CB0_16[ 16 * 200 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates[ 200 ] } -// }; - static final SKP_Silk_NLSF_CBS_FLP SKP_Silk_NLSF_CB0_16_Stage_info_FLP[] = - { - new SKP_Silk_NLSF_CBS_FLP(128, SKP_Silk_NLSF_MSVQ_CB0_16, 16*0, SKP_Silk_NLSF_MSVQ_CB0_16_rates, 0), - new SKP_Silk_NLSF_CBS_FLP(16, SKP_Silk_NLSF_MSVQ_CB0_16, 16*128, SKP_Silk_NLSF_MSVQ_CB0_16_rates, 128), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB0_16, 16*144, SKP_Silk_NLSF_MSVQ_CB0_16_rates, 144), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB0_16, 16*152, SKP_Silk_NLSF_MSVQ_CB0_16_rates, 152), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB0_16, 16*160, SKP_Silk_NLSF_MSVQ_CB0_16_rates, 160), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB0_16, 16*168, SKP_Silk_NLSF_MSVQ_CB0_16_rates, 168), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB0_16, 16*176, SKP_Silk_NLSF_MSVQ_CB0_16_rates, 176), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB0_16, 16*184, SKP_Silk_NLSF_MSVQ_CB0_16_rates, 184), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB0_16, 16*192, SKP_Silk_NLSF_MSVQ_CB0_16_rates, 192), - new SKP_Silk_NLSF_CBS_FLP(16, SKP_Silk_NLSF_MSVQ_CB0_16, 16*200, SKP_Silk_NLSF_MSVQ_CB0_16_rates, 200), - }; - -// const SKP_Silk_NLSF_CB_FLP SKP_Silk_NLSF_CB0_16_FLP = -// { -// NLSF_MSVQ_CB0_16_STAGES, -// SKP_Silk_NLSF_CB0_16_Stage_info_FLP, -// SKP_Silk_NLSF_MSVQ_CB0_16_ndelta_min, -// SKP_Silk_NLSF_MSVQ_CB0_16_CDF, -// SKP_Silk_NLSF_MSVQ_CB0_16_CDF_start_ptr, -// SKP_Silk_NLSF_MSVQ_CB0_16_CDF_middle_idx -// }; - - static final SKP_Silk_NLSF_CB_FLP SKP_Silk_NLSF_CB0_16_FLP = - new SKP_Silk_NLSF_CB_FLP( - Silk_tables_NLSF_CB0_16.NLSF_MSVQ_CB0_16_STAGES, - SKP_Silk_NLSF_CB0_16_Stage_info_FLP, - SKP_Silk_NLSF_MSVQ_CB0_16_ndelta_min, - Silk_tables_NLSF_CB0_16.SKP_Silk_NLSF_MSVQ_CB0_16_CDF, - Silk_tables_NLSF_CB0_16.SKP_Silk_NLSF_MSVQ_CB0_16_CDF_start_ptr, - Silk_tables_NLSF_CB0_16.SKP_Silk_NLSF_MSVQ_CB0_16_CDF_middle_idx - ); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB1_10.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB1_10.java deleted file mode 100644 index a4b52b1b3..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB1_10.java +++ /dev/null @@ -1,576 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * This file has been automatically generated - * ROM usage: 0.19 + 1.61 kB. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_tables_NLSF_CB1_10 -{ - static final int NLSF_MSVQ_CB1_10_STAGES = 6; - static final int NLSF_MSVQ_CB1_10_VECTORS = 72; - - static final int[] SKP_Silk_NLSF_MSVQ_CB1_10_CDF = - { - 0, - 17096, - 24130, - 28997, - 33179, - 36696, - 40213, - 42493, - 44252, - 45973, - 47551, - 49095, - 50542, - 51898, - 53196, - 54495, - 55685, - 56851, - 57749, - 58628, - 59435, - 60207, - 60741, - 61220, - 61700, - 62179, - 62659, - 63138, - 63617, - 64097, - 64576, - 65056, - 65535, - 0, - 20378, - 33032, - 40395, - 46721, - 51707, - 56585, - 61157, - 65535, - 0, - 15055, - 25472, - 35447, - 42501, - 48969, - 54773, - 60212, - 65535, - 0, - 12069, - 22440, - 32812, - 40145, - 46870, - 53595, - 59630, - 65535, - 0, - 10839, - 19954, - 27957, - 35961, - 43965, - 51465, - 58805, - 65535, - 0, - 8933, - 17674, - 26415, - 34785, - 42977, - 50820, - 58496, - 65535 - }; - - static private int [] SKP_Silk_NLSF_MSVQ_CB1_10_CDF_0 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_10_CDF, 0, SKP_Silk_NLSF_MSVQ_CB1_10_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_10_CDF_33 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_10_CDF, 33, SKP_Silk_NLSF_MSVQ_CB1_10_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_10_CDF_42 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_10_CDF, 42, SKP_Silk_NLSF_MSVQ_CB1_10_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_10_CDF_51 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_10_CDF, 51, SKP_Silk_NLSF_MSVQ_CB1_10_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_10_CDF_60 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_10_CDF, 60, SKP_Silk_NLSF_MSVQ_CB1_10_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_10_CDF_69 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_10_CDF, 69, SKP_Silk_NLSF_MSVQ_CB1_10_CDF.length); - - static final int[][] SKP_Silk_NLSF_MSVQ_CB1_10_CDF_start_ptr = - { - SKP_Silk_NLSF_MSVQ_CB1_10_CDF_0, - SKP_Silk_NLSF_MSVQ_CB1_10_CDF_33, - SKP_Silk_NLSF_MSVQ_CB1_10_CDF_42, - SKP_Silk_NLSF_MSVQ_CB1_10_CDF_51, - SKP_Silk_NLSF_MSVQ_CB1_10_CDF_60, - SKP_Silk_NLSF_MSVQ_CB1_10_CDF_69 - - }; - - static final int[] SKP_Silk_NLSF_MSVQ_CB1_10_CDF_middle_idx = - { - 5, - 3, - 4, - 4, - 5, - 5 - }; - - static final short[] SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q5 = - { - 62, 103, - 120, 127, - 135, 135, - 155, 167, - 168, 172, - 173, 176, - 179, 181, - 181, 185, - 186, 198, - 199, 203, - 205, 222, - 227, 227, - 227, 227, - 227, 227, - 227, 227, - 227, 227, - 54, 76, - 101, 108, - 119, 120, - 123, 125, - 68, 85, - 87, 103, - 107, 112, - 115, 116, - 78, 85, - 85, 101, - 105, 105, - 110, 111, - 83, 91, - 97, 97, - 97, 100, - 101, 105, - 92, 93, - 93, 95, - 96, 98, - 99, 103 - }; - - static final int[] SKP_Silk_NLSF_MSVQ_CB1_10_ndelta_min_Q15 = - { - 462, - 3, - 64, - 74, - 98, - 50, - 97, - 68, - 120, - 53, - 639 - }; - - static final short[ ] SKP_Silk_NLSF_MSVQ_CB1_10_Q15 = - { - 1877, 4646, - 7712, 10745, - 13964, 17028, - 20239, 23182, - 26471, 29287, - 1612, 3278, - 7086, 9975, - 13228, 16264, - 19596, 22690, - 26037, 28965, - 2169, 3830, - 6460, 8958, - 11960, 14750, - 18408, 21659, - 25018, 28043, - 3680, 6024, - 8986, 12256, - 15201, 18188, - 21741, 24460, - 27484, 30059, - 2584, 5187, - 7799, 10902, - 13179, 15765, - 19017, 22431, - 25891, 28698, - 3731, 5751, - 8650, 11742, - 15090, 17407, - 20391, 23421, - 26228, 29247, - 2107, 6323, - 8915, 12226, - 14775, 17791, - 20664, 23679, - 26829, 29353, - 1677, 2870, - 5386, 8077, - 11817, 15176, - 18657, 22006, - 25513, 28689, - 2111, 3625, - 7027, 10588, - 14059, 17193, - 21137, 24260, - 27577, 30036, - 2428, 4010, - 5765, 9376, - 13805, 15821, - 19444, 22389, - 25295, 29310, - 2256, 4628, - 8377, 12441, - 15283, 19462, - 22257, 25551, - 28432, 30304, - 2352, 3675, - 6129, 11868, - 14551, 16655, - 19624, 21883, - 26526, 28849, - 5243, 7248, - 10558, 13269, - 15651, 17919, - 21141, 23827, - 27102, 29519, - 4422, 6725, - 10449, 13273, - 16124, 19921, - 22826, 26061, - 28763, 30583, - 4508, 6291, - 9504, 11809, - 13827, 15950, - 19077, 22084, - 25740, 28658, - 2540, 4297, - 8579, 13578, - 16634, 19101, - 21547, 23887, - 26777, 29146, - 3377, 6358, - 10224, 14518, - 17905, 21056, - 23637, 25784, - 28161, 30109, - 4177, 5942, - 8159, 10108, - 12130, 15470, - 20191, 23326, - 26782, 29359, - 2492, 3801, - 6144, 9825, - 16000, 18671, - 20893, 23663, - 25899, 28974, - 3011, 4727, - 6834, 10505, - 12465, 14496, - 17065, 20052, - 25265, 28057, - 4149, 7197, - 12338, 15076, - 18002, 20190, - 22187, 24723, - 27083, 29125, - 2975, 4578, - 6448, 8378, - 9671, 13225, - 19502, 22277, - 26058, 28850, - 4102, 5760, - 7744, 9484, - 10744, 12308, - 14677, 19607, - 24841, 28381, - 4931, 9287, - 12477, 13395, - 13712, 14351, - 16048, 19867, - 24188, 28994, - 4141, 7867, - 13140, 17720, - 20064, 21108, - 21692, 22722, - 23736, 27449, - 4011, 8720, - 13234, 16206, - 17601, 18289, - 18524, 19689, - 23234, 27882, - 3420, 5995, - 11230, 15117, - 15907, 16783, - 17762, 23347, - 26898, 29946, - 3080, 6786, - 10465, 13676, - 18059, 23615, - 27058, 29082, - 29563, 29905, - 3038, 5620, - 9266, 12870, - 18803, 19610, - 20010, 20802, - 23882, 29306, - 3314, 6420, - 9046, 13262, - 15869, 23117, - 23667, 24215, - 24487, 25915, - 3469, 6963, - 10103, 15282, - 20531, 23240, - 25024, 26021, - 26736, 27255, - 3041, 6459, - 9777, 12896, - 16315, 19410, - 24070, 29353, - 31795, 32075, - -200, -134, - -113, -204, - -347, -440, - -352, -211, - -418, -172, - -313, 59, - 495, 772, - 721, 614, - 334, 444, - 225, 242, - 161, 16, - 274, 564, - -73, -188, - -395, -171, - 777, 508, - 1340, 1145, - 699, 196, - 223, 173, - 90, 25, - -26, 18, - 133, -105, - -360, -277, - 859, 634, - 41, -557, - -768, -926, - -601, -1021, - -1189, -365, - 225, 107, - 374, -50, - 433, 417, - 156, 39, - -597, -1397, - -1594, -592, - -485, -292, - 253, 87, - -0, -6, - -25, -345, - -240, 120, - 1261, 946, - 166, -277, - 241, 167, - 170, 429, - 518, 714, - 602, 254, - 134, 92, - -152, -324, - -394, 49, - -151, -304, - -724, -657, - -162, -369, - -35, 3, - -2, -312, - -200, -92, - -227, 242, - 628, 565, - -124, 1056, - 770, 101, - -84, -33, - 4, -192, - -272, 5, - -627, -977, - 419, 472, - 53, -103, - 145, 322, - -95, -31, - -100, -303, - -560, -1067, - -413, 714, - 283, 2, - -223, -367, - 523, 360, - -38, -115, - 378, -591, - -718, 448, - -481, -274, - 180, -88, - -581, -157, - -696, -1265, - 394, -479, - -23, 124, - -43, 19, - -113, -236, - -412, -659, - -200, 2, - -69, -342, - 199, 55, - 58, -36, - -51, -62, - 507, 507, - 427, 442, - 36, 601, - -141, 68, - 274, 274, - 68, -12, - -4, 71, - -193, -464, - -425, -383, - 408, 203, - -337, 236, - 410, -59, - -25, -341, - -449, 28, - -9, 90, - 332, -14, - -905, 96, - -540, -242, - 679, -59, - 192, -24, - 60, -217, - 5, -37, - 179, -20, - 311, 519, - 274, 72, - -326, -1030, - -262, 213, - 380, 82, - 328, 411, - -540, 574, - -283, 151, - 181, -402, - -278, -240, - -110, -227, - -264, -89, - -250, -259, - -27, 106, - -239, -98, - -390, 118, - 61, 104, - 294, 532, - 92, -13, - 60, -233, - 335, 541, - 307, -26, - -110, -91, - -231, -460, - 170, 201, - 96, -372, - 132, 435, - -302, 216, - -279, -41, - 74, 190, - 368, 273, - -186, -608, - -157, 159, - 12, 278, - 245, 307, - 25, -187, - -16, 55, - 30, -163, - 548, -307, - 106, -5, - 27, 330, - -416, 475, - 438, -235, - 104, 137, - 21, -5, - -300, -468, - 521, -347, - 170, -200, - -219, 308, - -122, -133, - 219, -16, - 359, 412, - -89, -111, - 48, 322, - 142, 177, - -286, -127, - -39, -63, - -42, -451, - 160, 308, - -57, 193, - -48, 74, - -346, 59, - -27, 27, - -469, -277, - -344, 282, - 262, 122, - 171, -249, - 27, 258, - 188, -3, - 67, -206, - -284, 291, - -117, -88, - -477, 375, - 50, 106, - 99, -182, - 438, -376, - -401, -49, - 119, -23, - -10, -48, - -116, -200, - -310, 121, - 73, 7, - 237, -226, - 139, -456, - 397, 35, - 3, -108, - 323, -75, - 332, 198, - -99, -21 - }; - - static final SKP_Silk_NLSF_CBS[] SKP_Silk_NLSF_CB1_10_Stage_info = - { - new SKP_Silk_NLSF_CBS(32,SKP_Silk_NLSF_MSVQ_CB1_10_Q15, 0, SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q5, 0 ), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_10_Q15, 10 * 32, SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q5, 32 ), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_10_Q15, 10 * 40, SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q5, 40 ), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_10_Q15, 10 * 48, SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q5, 48 ), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_10_Q15, 10 * 56, SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q5, 56 ), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_10_Q15, 10 * 64, SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q5, 64 ), - }; - - static final SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB1_10 = - new SKP_Silk_NLSF_CB_struct - ( - NLSF_MSVQ_CB1_10_STAGES, - SKP_Silk_NLSF_CB1_10_Stage_info, - SKP_Silk_NLSF_MSVQ_CB1_10_ndelta_min_Q15, - SKP_Silk_NLSF_MSVQ_CB1_10_CDF, - SKP_Silk_NLSF_MSVQ_CB1_10_CDF_start_ptr, - SKP_Silk_NLSF_MSVQ_CB1_10_CDF_middle_idx - ); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB1_10_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB1_10_FLP.java deleted file mode 100644 index e1994094d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB1_10_FLP.java +++ /dev/null @@ -1,476 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * This file has been automatically generated. - * ROM usage: 3.21 kB. - * - * @author Dingxin Xu - */ -public class Silk_tables_NLSF_CB1_10_FLP -{ -// const SKP_float SKP_Silk_NLSF_MSVQ_CB1_10_rates[ NLSF_MSVQ_CB1_10_VECTORS ] = - static final float SKP_Silk_NLSF_MSVQ_CB1_10_rates[] = - { - 1.93750000000000000000f, 3.21875000000000000000f, - 3.75000000000000000000f, 3.96875000000000000000f, - 4.21875000000000000000f, 4.21875000000000000000f, - 4.84375000000000000000f, 5.21875000000000000000f, - 5.25000000000000000000f, 5.37500000000000000000f, - 5.40625000000000000000f, 5.50000000000000000000f, - 5.59375000000000000000f, 5.65625000000000000000f, - 5.65625000000000000000f, 5.78125000000000000000f, - 5.81250000000000000000f, 6.18750000000000000000f, - 6.21875000000000000000f, 6.34375000000000000000f, - 6.40625000000000000000f, 6.93750000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 1.68750000000000000000f, 2.37500000000000000000f, - 3.15625000000000000000f, 3.37500000000000000000f, - 3.71875000000000000000f, 3.75000000000000000000f, - 3.84375000000000000000f, 3.90625000000000000000f, - 2.12500000000000000000f, 2.65625000000000000000f, - 2.71875000000000000000f, 3.21875000000000000000f, - 3.34375000000000000000f, 3.50000000000000000000f, - 3.59375000000000000000f, 3.62500000000000000000f, - 2.43750000000000000000f, 2.65625000000000000000f, - 2.65625000000000000000f, 3.15625000000000000000f, - 3.28125000000000000000f, 3.28125000000000000000f, - 3.43750000000000000000f, 3.46875000000000000000f, - 2.59375000000000000000f, 2.84375000000000000000f, - 3.03125000000000000000f, 3.03125000000000000000f, - 3.03125000000000000000f, 3.12500000000000000000f, - 3.15625000000000000000f, 3.28125000000000000000f, - 2.87500000000000000000f, 2.90625000000000000000f, - 2.90625000000000000000f, 2.96875000000000000000f, - 3.00000000000000000000f, 3.06250000000000000000f, - 3.09375000000000000000f, 3.21875000000000000000f - }; - -// const SKP_float SKP_Silk_NLSF_MSVQ_CB1_10_ndelta_min[ 10 + 1 ] = - static final float SKP_Silk_NLSF_MSVQ_CB1_10_ndelta_min[] = - { - 0.01409912109375000000f, - 0.00009155273437500000f, - 0.00195312500000000000f, - 0.00225830078125000000f, - 0.00299072265625000000f, - 0.00152587890625000000f, - 0.00296020507812500000f, - 0.00207519531250000000f, - 0.00366210937499999960f, - 0.00161743164062500000f, - 0.01950073242187500000f - }; - -// const SKP_float SKP_Silk_NLSF_MSVQ_CB1_10[ 10 * NLSF_MSVQ_CB1_10_VECTORS ] = - static final float SKP_Silk_NLSF_MSVQ_CB1_10[] = - { - 0.05728149414062500000f, 0.14178466796875000000f, - 0.23535156250000003000f, 0.32791137695312500000f, - 0.42614746093750000000f, 0.51965332031250000000f, - 0.61764526367187500000f, 0.70745849609375000000f, - 0.80783081054687511000f, 0.89376831054687500000f, - 0.04919433593750000000f, 0.10003662109375001000f, - 0.21624755859374997000f, 0.30441284179687500000f, - 0.40368652343750000000f, 0.49633789062499994000f, - 0.59802246093750000000f, 0.69244384765625011000f, - 0.79458618164062500000f, 0.88394165039062500000f, - 0.06619262695312500000f, 0.11688232421875000000f, - 0.19714355468750000000f, 0.27337646484375000000f, - 0.36499023437500000000f, 0.45013427734375000000f, - 0.56176757812500000000f, 0.66098022460937500000f, - 0.76348876953125000000f, 0.85580444335937489000f, - 0.11230468750000001000f, 0.18383789062500000000f, - 0.27423095703125000000f, 0.37402343749999994000f, - 0.46389770507812494000f, 0.55505371093750000000f, - 0.66348266601562500000f, 0.74645996093750000000f, - 0.83874511718749989000f, 0.91732788085937500000f, - 0.07885742187500000000f, 0.15829467773437500000f, - 0.23800659179687500000f, 0.33270263671874994000f, - 0.40219116210937500000f, 0.48110961914062500000f, - 0.58035278320312500000f, 0.68453979492187500000f, - 0.79013061523437500000f, 0.87579345703125000000f, - 0.11386108398437500000f, 0.17550659179687500000f, - 0.26397705078125000000f, 0.35833740234375000000f, - 0.46051025390625000000f, 0.53121948242187500000f, - 0.62228393554687500000f, 0.71475219726562500000f, - 0.80041503906250000000f, 0.89254760742187511000f, - 0.06430053710937500000f, 0.19296264648437500000f, - 0.27206420898437500000f, 0.37310791015625000000f, - 0.45089721679687500000f, 0.54293823242187500000f, - 0.63061523437500000000f, 0.72262573242187500000f, - 0.81875610351562500000f, 0.89578247070312500000f, - 0.05117797851562500000f, 0.08758544921875000000f, - 0.16436767578125000000f, 0.24649047851562500000f, - 0.36062622070312500000f, 0.46313476562500000000f, - 0.56936645507812500000f, 0.67156982421875011000f, - 0.77859497070312500000f, 0.87551879882812500000f, - 0.06442260742187500000f, 0.11062622070312501000f, - 0.21444702148437500000f, 0.32312011718750000000f, - 0.42904663085937500000f, 0.52468872070312500000f, - 0.64505004882812489000f, 0.74035644531250000000f, - 0.84158325195312500000f, 0.91662597656250011000f, - 0.07409667968750000000f, 0.12237548828125000000f, - 0.17593383789062500000f, 0.28613281250000000000f, - 0.42129516601562500000f, 0.48281860351562500000f, - 0.59338378906250000000f, 0.68325805664062511000f, - 0.77194213867187500000f, 0.89447021484375000000f, - 0.06884765625000000000f, 0.14123535156250000000f, - 0.25564575195312500000f, 0.37966918945312500000f, - 0.46640014648437500000f, 0.59393310546875000000f, - 0.67922973632812500000f, 0.77975463867187489000f, - 0.86767578124999989000f, 0.92480468750000000000f, - 0.07177734375000000000f, 0.11215209960937499000f, - 0.18704223632812500000f, 0.36218261718750000000f, - 0.44406127929687494000f, 0.50827026367187500000f, - 0.59887695312500000000f, 0.66781616210937500000f, - 0.80950927734375000000f, 0.88040161132812500000f, - 0.16000366210937500000f, 0.22119140625000000000f, - 0.32220458984375000000f, 0.40493774414062500000f, - 0.47763061523437506000f, 0.54684448242187500000f, - 0.64517211914062500000f, 0.72714233398437500000f, - 0.82708740234375000000f, 0.90084838867187489000f, - 0.13494873046875000000f, 0.20523071289062500000f, - 0.31887817382812500000f, 0.40505981445312500000f, - 0.49206542968750000000f, 0.60794067382812500000f, - 0.69659423828124989000f, 0.79531860351562500000f, - 0.87777709960937500000f, 0.93331909179687500000f, - 0.13757324218750000000f, 0.19198608398437500000f, - 0.29003906250000000000f, 0.36038208007812506000f, - 0.42196655273437500000f, 0.48675537109375000000f, - 0.58218383789062500000f, 0.67395019531250000000f, - 0.78552246093750000000f, 0.87457275390625000000f, - 0.07751464843750000000f, 0.13113403320312500000f, - 0.26181030273437500000f, 0.41436767578125000000f, - 0.50762939453125000000f, 0.58291625976562500000f, - 0.65756225585937500000f, 0.72897338867187500000f, - 0.81716918945312489000f, 0.88946533203125000000f, - 0.10305786132812501000f, 0.19403076171875003000f, - 0.31201171875000000000f, 0.44305419921875000000f, - 0.54641723632812500000f, 0.64257812500000000000f, - 0.72134399414062500000f, 0.78686523437500011000f, - 0.85940551757812500000f, 0.91885375976562500000f, - 0.12747192382812500000f, 0.18133544921875000000f, - 0.24899291992187497000f, 0.30847167968750000000f, - 0.37017822265625000000f, 0.47210693359375000000f, - 0.61618041992187500000f, 0.71185302734375000000f, - 0.81732177734375000000f, 0.89596557617187500000f, - 0.07604980468750000000f, 0.11599731445312501000f, - 0.18750000000000000000f, 0.29983520507812500000f, - 0.48828124999999994000f, 0.56979370117187500000f, - 0.63760375976562489000f, 0.72213745117187500000f, - 0.79037475585937500000f, 0.88421630859374989000f, - 0.09188842773437500000f, 0.14425659179687500000f, - 0.20855712890625000000f, 0.32058715820312500000f, - 0.38040161132812500000f, 0.44238281250000000000f, - 0.52078247070312500000f, 0.61193847656250000000f, - 0.77102661132812500000f, 0.85623168945312500000f, - 0.12661743164062500000f, 0.21963500976562500000f, - 0.37652587890625000000f, 0.46008300781249994000f, - 0.54937744140625000000f, 0.61614990234375000000f, - 0.67709350585937500000f, 0.75448608398437500000f, - 0.82650756835937500000f, 0.88882446289062511000f, - 0.09078979492187500000f, 0.13970947265625000000f, - 0.19677734375000000000f, 0.25567626953125000000f, - 0.29513549804687500000f, 0.40359497070312500000f, - 0.59515380859375000000f, 0.67984008789062500000f, - 0.79522705078125000000f, 0.88043212890625000000f, - 0.12518310546875000000f, 0.17578125000000000000f, - 0.23632812500000000000f, 0.28942871093750000000f, - 0.32788085937500000000f, 0.37561035156250000000f, - 0.44790649414062500000f, 0.59835815429687500000f, - 0.75808715820312500000f, 0.86611938476562489000f, - 0.15048217773437500000f, 0.28341674804687500000f, - 0.38076782226562500000f, 0.40878295898437500000f, - 0.41845703125000000000f, 0.43795776367187506000f, - 0.48974609375000000000f, 0.60629272460937500000f, - 0.73815917968750000000f, 0.88482666015624989000f, - 0.12637329101562500000f, 0.24008178710937500000f, - 0.40100097656250000000f, 0.54077148437500000000f, - 0.61230468750000000000f, 0.64416503906250000000f, - 0.66198730468750000000f, 0.69342041015625000000f, - 0.72436523437500000000f, 0.83767700195312500000f, - 0.12240600585937499000f, 0.26611328125000000000f, - 0.40386962890625006000f, 0.49456787109375006000f, - 0.53713989257812500000f, 0.55813598632812500000f, - 0.56530761718750000000f, 0.60086059570312500000f, - 0.70904541015625000000f, 0.85089111328125000000f, - 0.10437011718750000000f, 0.18295288085937500000f, - 0.34271240234375006000f, 0.46133422851562500000f, - 0.48544311523437500000f, 0.51217651367187500000f, - 0.54205322265625000000f, 0.71249389648437500000f, - 0.82086181640625000000f, 0.91387939453125000000f, - 0.09399414062500001400f, 0.20709228515625000000f, - 0.31936645507812506000f, 0.41735839843750000000f, - 0.55111694335937500000f, 0.72067260742187489000f, - 0.82574462890624989000f, 0.88751220703124989000f, - 0.90219116210937500000f, 0.91262817382812500000f, - 0.09271240234375000000f, 0.17150878906250003000f, - 0.28277587890625000000f, 0.39276123046875000000f, - 0.57382202148437500000f, 0.59844970703125000000f, - 0.61065673828125000000f, 0.63482666015625000000f, - 0.72882080078125011000f, 0.89434814453125000000f, - 0.10113525390625000000f, 0.19592285156250000000f, - 0.27606201171875000000f, 0.40472412109375000000f, - 0.48428344726562500000f, 0.70547485351562500000f, - 0.72225952148437500000f, 0.73898315429687500000f, - 0.74728393554687500000f, 0.79086303710937500000f, - 0.10586547851562500000f, 0.21249389648437500000f, - 0.30831909179687500000f, 0.46636962890625006000f, - 0.62655639648437500000f, 0.70922851562500000000f, - 0.76367187500000000000f, 0.79409790039062500000f, - 0.81591796875000000000f, 0.83175659179687500000f, - 0.09280395507812500000f, 0.19711303710937500000f, - 0.29837036132812500000f, 0.39355468750000000000f, - 0.49789428710937500000f, 0.59234619140625000000f, - 0.73455810546875000000f, 0.89578247070312500000f, - 0.97030639648437500000f, 0.97885131835937500000f, - -0.00610351562500000000f, -0.00408935546875000000f, - -0.00344848632812500000f, -0.00622558593750000000f, - -0.01058959960937500000f, -0.01342773437500000000f, - -0.01074218749999999800f, -0.00643920898437500000f, - -0.01275634765625000200f, -0.00524902343750000000f, - -0.00955200195312500000f, 0.00180053710937500000f, - 0.01510620117187500000f, 0.02355957031250000000f, - 0.02200317382812500000f, 0.01873779296875000000f, - 0.01019287109375000000f, 0.01354980468750000000f, - 0.00686645507812500000f, 0.00738525390625000000f, - 0.00491333007812500000f, 0.00048828125000000000f, - 0.00836181640625000000f, 0.01721191406250000000f, - -0.00222778320312500000f, -0.00573730468750000000f, - -0.01205444335937500000f, -0.00521850585937500000f, - 0.02371215820312499700f, 0.01550292968750000000f, - 0.04089355468750000000f, 0.03494262695312500000f, - 0.02133178710937500000f, 0.00598144531250000000f, - 0.00680541992187500000f, 0.00527954101562500000f, - 0.00274658203125000000f, 0.00076293945312500000f, - -0.00079345703125000011f, 0.00054931640625000000f, - 0.00405883789062500000f, -0.00320434570312500000f, - -0.01098632812500000000f, -0.00845336914062500000f, - 0.02621459960937500000f, 0.01934814453125000000f, - 0.00125122070312500000f, -0.01699829101562500000f, - -0.02343750000000000000f, -0.02825927734375000000f, - -0.01834106445312500000f, -0.03115844726562500000f, - -0.03628540039062500000f, -0.01113891601562500000f, - 0.00686645507812500000f, 0.00326538085937500000f, - 0.01141357421875000200f, -0.00152587890625000000f, - 0.01321411132812500000f, 0.01272583007812500000f, - 0.00476074218750000000f, 0.00119018554687500000f, - -0.01821899414062500000f, -0.04263305664062499300f, - -0.04864501953125000000f, -0.01806640625000000000f, - -0.01480102539062500000f, -0.00891113281250000000f, - 0.00772094726562500000f, 0.00265502929687500000f, - -0.00000000000000000000f, -0.00018310546875000000f, - -0.00076293945312500000f, -0.01052856445312500000f, - -0.00732421874999999910f, 0.00366210937499999960f, - 0.03848266601562500000f, 0.02886962890625000000f, - 0.00506591796875000090f, -0.00845336914062500000f, - 0.00735473632812500090f, 0.00509643554687500000f, - 0.00518798828125000000f, 0.01309204101562500000f, - 0.01580810546875000000f, 0.02178955078125000000f, - 0.01837158203125000000f, 0.00775146484375000000f, - 0.00408935546875000000f, 0.00280761718750000000f, - -0.00463867187500000000f, -0.00988769531250000000f, - -0.01202392578124999800f, 0.00149536132812500000f, - -0.00460815429687500000f, -0.00927734375000000000f, - -0.02209472656250000000f, -0.02005004882812500000f, - -0.00494384765625000000f, -0.01126098632812500000f, - -0.00106811523437500000f, 0.00009155273437500000f, - -0.00006103515625000000f, -0.00952148437500000000f, - -0.00610351562500000000f, -0.00280761718750000000f, - -0.00692749023437500000f, 0.00738525390625000000f, - 0.01916503906250000000f, 0.01724243164062500000f, - -0.00378417968750000000f, 0.03222656250000000000f, - 0.02349853515625000300f, 0.00308227539062500000f, - -0.00256347656250000000f, -0.00100708007812500000f, - 0.00012207031250000000f, -0.00585937500000000000f, - -0.00830078125000000000f, 0.00015258789062500000f, - -0.01913452148437500000f, -0.02981567382812500000f, - 0.01278686523437500000f, 0.01440429687500000000f, - 0.00161743164062500000f, -0.00314331054687500000f, - 0.00442504882812500000f, 0.00982666015625000000f, - -0.00289916992187500000f, -0.00094604492187500000f, - -0.00305175781250000000f, -0.00924682617187500000f, - -0.01708984375000000000f, -0.03256225585937500000f, - -0.01260375976562500000f, 0.02178955078125000000f, - 0.00863647460937500000f, 0.00006103515625000000f, - -0.00680541992187500000f, -0.01119995117187500000f, - 0.01596069335937500000f, 0.01098632812500000000f, - -0.00115966796875000000f, -0.00350952148437500040f, - 0.01153564453125000000f, -0.01803588867187500000f, - -0.02191162109375000000f, 0.01367187500000000000f, - -0.01467895507812500000f, -0.00836181640625000000f, - 0.00549316406250000000f, -0.00268554687499999960f, - -0.01773071289062500000f, -0.00479125976562500000f, - -0.02124023437500000000f, -0.03860473632812500000f, - 0.01202392578124999800f, -0.01461791992187500000f, - -0.00070190429687500000f, 0.00378417968750000000f, - -0.00131225585937500000f, 0.00057983398437500000f, - -0.00344848632812500000f, -0.00720214843750000000f, - -0.01257324218750000000f, -0.02011108398437500000f, - -0.00610351562500000000f, 0.00006103515625000000f, - -0.00210571289062500000f, -0.01043701171875000000f, - 0.00607299804687500000f, 0.00167846679687500000f, - 0.00177001953125000000f, -0.00109863281250000000f, - -0.00155639648437500000f, -0.00189208984375000000f, - 0.01547241210937500000f, 0.01547241210937500000f, - 0.01303100585937500200f, 0.01348876953125000000f, - 0.00109863281250000000f, 0.01834106445312500000f, - -0.00430297851562500000f, 0.00207519531250000000f, - 0.00836181640625000000f, 0.00836181640625000000f, - 0.00207519531250000000f, -0.00036621093750000000f, - -0.00012207031250000000f, 0.00216674804687500000f, - -0.00588989257812500000f, -0.01416015625000000000f, - -0.01296997070312499800f, -0.01168823242187499800f, - 0.01245117187500000000f, 0.00619506835937500000f, - -0.01028442382812500000f, 0.00720214843750000000f, - 0.01251220703125000000f, -0.00180053710937500000f, - -0.00076293945312500000f, -0.01040649414062499800f, - -0.01370239257812500200f, 0.00085449218750000000f, - -0.00027465820312500000f, 0.00274658203125000000f, - 0.01013183593750000200f, -0.00042724609375000000f, - -0.02761840820312499700f, 0.00292968750000000000f, - -0.01647949218750000000f, -0.00738525390625000000f, - 0.02072143554687500000f, -0.00180053710937500000f, - 0.00585937500000000000f, -0.00073242187500000000f, - 0.00183105468749999980f, -0.00662231445312500000f, - 0.00015258789062500000f, -0.00112915039062500000f, - 0.00546264648437500000f, -0.00061035156250000000f, - 0.00949096679687500000f, 0.01583862304687500000f, - 0.00836181640625000000f, 0.00219726562500000000f, - -0.00994873046875000000f, -0.03143310546875000000f, - -0.00799560546875000000f, 0.00650024414062500000f, - 0.01159667968750000000f, 0.00250244140625000000f, - 0.01000976562500000000f, 0.01254272460937500000f, - -0.01647949218750000000f, 0.01751708984375000000f, - -0.00863647460937500000f, 0.00460815429687500000f, - 0.00552368164062500000f, -0.01226806640625000000f, - -0.00848388671875000000f, -0.00732421874999999910f, - -0.00335693359375000000f, -0.00692749023437500000f, - -0.00805664062500000000f, -0.00271606445312500000f, - -0.00762939453124999910f, -0.00790405273437500000f, - -0.00082397460937500000f, 0.00323486328125000000f, - -0.00729370117187499910f, -0.00299072265625000000f, - -0.01190185546875000000f, 0.00360107421875000000f, - 0.00186157226562500000f, 0.00317382812500000040f, - 0.00897216796875000000f, 0.01623535156250000000f, - 0.00280761718750000000f, -0.00039672851562500005f, - 0.00183105468749999980f, -0.00711059570312500000f, - 0.01022338867187500000f, 0.01651000976562500000f, - 0.00936889648437500000f, -0.00079345703125000011f, - -0.00335693359375000000f, -0.00277709960937500000f, - -0.00704956054687500000f, -0.01403808593750000200f, - 0.00518798828125000000f, 0.00613403320312500000f, - 0.00292968750000000000f, -0.01135253906249999800f, - 0.00402832031250000000f, 0.01327514648437500000f, - -0.00921630859375000000f, 0.00659179687500000000f, - -0.00851440429687500000f, -0.00125122070312500000f, - 0.00225830078125000000f, 0.00579833984375000000f, - 0.01123046875000000000f, 0.00833129882812500000f, - -0.00567626953124999910f, -0.01855468750000000000f, - -0.00479125976562500000f, 0.00485229492187500000f, - 0.00036621093750000000f, 0.00848388671875000000f, - 0.00747680664062500000f, 0.00936889648437500000f, - 0.00076293945312500000f, -0.00570678710937500090f, - -0.00048828125000000000f, 0.00167846679687500000f, - 0.00091552734374999989f, -0.00497436523437500000f, - 0.01672363281250000000f, -0.00936889648437500000f, - 0.00323486328125000000f, -0.00015258789062500000f, - 0.00082397460937500000f, 0.01007080078124999800f, - -0.01269531250000000200f, 0.01449584960937500000f, - 0.01336669921875000200f, -0.00717163085937500000f, - 0.00317382812500000040f, 0.00418090820312500000f, - 0.00064086914062500000f, -0.00015258789062500000f, - -0.00915527343750000000f, -0.01428222656250000000f, - 0.01589965820312500000f, -0.01058959960937500000f, - 0.00518798828125000000f, -0.00610351562500000000f, - -0.00668334960937500090f, 0.00939941406250000000f, - -0.00372314453125000000f, -0.00405883789062500000f, - 0.00668334960937500090f, -0.00048828125000000000f, - 0.01095581054687500000f, 0.01257324218750000000f, - -0.00271606445312500000f, -0.00338745117187500000f, - 0.00146484375000000000f, 0.00982666015625000000f, - 0.00433349609375000000f, 0.00540161132812500090f, - -0.00872802734375000000f, -0.00387573242187500000f, - -0.00119018554687500000f, -0.00192260742187500000f, - -0.00128173828125000000f, -0.01376342773437500000f, - 0.00488281250000000000f, 0.00939941406250000000f, - -0.00173950195312500000f, 0.00588989257812500000f, - -0.00146484375000000000f, 0.00225830078125000000f, - -0.01055908203125000000f, 0.00180053710937500000f, - -0.00082397460937500000f, 0.00082397460937500000f, - -0.01431274414062499800f, -0.00845336914062500000f, - -0.01049804687500000000f, 0.00860595703125000000f, - 0.00799560546875000000f, 0.00372314453125000000f, - 0.00521850585937500000f, -0.00759887695312500000f, - 0.00082397460937500000f, 0.00787353515625000000f, - 0.00573730468750000000f, -0.00009155273437500000f, - 0.00204467773437500000f, -0.00628662109375000000f, - -0.00866699218750000000f, 0.00888061523437500000f, - -0.00357055664062500000f, -0.00268554687499999960f, - -0.01455688476562500000f, 0.01144409179687500000f, - 0.00152587890625000000f, 0.00323486328125000000f, - 0.00302124023437500040f, -0.00555419921875000000f, - 0.01336669921875000200f, -0.01147460937500000000f, - -0.01223754882812500000f, -0.00149536132812500000f, - 0.00363159179687500000f, -0.00070190429687500000f, - -0.00030517578125000000f, -0.00146484375000000000f, - -0.00354003906250000000f, -0.00610351562500000000f, - -0.00946044921875000000f, 0.00369262695312500000f, - 0.00222778320312500000f, 0.00021362304687500000f, - 0.00723266601562500000f, -0.00689697265625000000f, - 0.00424194335937500000f, -0.01391601562500000000f, - 0.01211547851562500000f, 0.00106811523437500000f, - 0.00009155273437500000f, -0.00329589843750000000f, - 0.00985717773437500000f, -0.00228881835937500000f, - 0.01013183593750000200f, 0.00604248046875000090f, - -0.00302124023437500040f, -0.00064086914062500000f - }; - -// const SKP_Silk_NLSF_CBS_FLP SKP_Silk_NLSF_CB1_10_Stage_info_FLP[ NLSF_MSVQ_CB1_10_STAGES ] = -// { -// { 32, &SKP_Silk_NLSF_MSVQ_CB1_10[ 10 * 0 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates[ 0 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_10[ 10 * 32 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates[ 32 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_10[ 10 * 40 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates[ 40 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_10[ 10 * 48 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates[ 48 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_10[ 10 * 56 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates[ 56 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_10[ 10 * 64 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates[ 64 ] } -// }; - static final SKP_Silk_NLSF_CBS_FLP SKP_Silk_NLSF_CB1_10_Stage_info_FLP[] = - { - new SKP_Silk_NLSF_CBS_FLP(32, SKP_Silk_NLSF_MSVQ_CB1_10, 10*0, SKP_Silk_NLSF_MSVQ_CB1_10_rates, 0), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_10, 10*32, SKP_Silk_NLSF_MSVQ_CB1_10_rates, 32), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_10, 10*40, SKP_Silk_NLSF_MSVQ_CB1_10_rates, 40), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_10, 10*48, SKP_Silk_NLSF_MSVQ_CB1_10_rates, 48), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_10, 10*56, SKP_Silk_NLSF_MSVQ_CB1_10_rates, 56), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_10, 10*64, SKP_Silk_NLSF_MSVQ_CB1_10_rates, 64), - }; - -// const SKP_Silk_NLSF_CB_FLP SKP_Silk_NLSF_CB1_10_FLP = -// { -// NLSF_MSVQ_CB1_10_STAGES, -// SKP_Silk_NLSF_CB1_10_Stage_info_FLP, -// SKP_Silk_NLSF_MSVQ_CB1_10_ndelta_min, -// SKP_Silk_NLSF_MSVQ_CB1_10_CDF, -// SKP_Silk_NLSF_MSVQ_CB1_10_CDF_start_ptr, -// SKP_Silk_NLSF_MSVQ_CB1_10_CDF_middle_idx -// }; - static final SKP_Silk_NLSF_CB_FLP SKP_Silk_NLSF_CB1_10_FLP = - new SKP_Silk_NLSF_CB_FLP( - Silk_tables_NLSF_CB1_10.NLSF_MSVQ_CB1_10_STAGES, - SKP_Silk_NLSF_CB1_10_Stage_info_FLP, - SKP_Silk_NLSF_MSVQ_CB1_10_ndelta_min, - Silk_tables_NLSF_CB1_10.SKP_Silk_NLSF_MSVQ_CB1_10_CDF, - Silk_tables_NLSF_CB1_10.SKP_Silk_NLSF_MSVQ_CB1_10_CDF_start_ptr, - Silk_tables_NLSF_CB1_10.SKP_Silk_NLSF_MSVQ_CB1_10_CDF_middle_idx - ); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB1_16.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB1_16.java deleted file mode 100644 index 12fedaf43..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB1_16.java +++ /dev/null @@ -1,708 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * This file has been automatically generated - * ROM usage: 0.29 + 3.57 kB. - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_tables_NLSF_CB1_16 -{ - static final int NLSF_MSVQ_CB1_16_STAGES = 10; - static final int NLSF_MSVQ_CB1_16_VECTORS = 104; - - static final int[] SKP_Silk_NLSF_MSVQ_CB1_16_CDF = - { - 0, - 19099, - 26957, - 30639, - 34242, - 37546, - 40447, - 43287, - 46005, - 48445, - 49865, - 51284, - 52673, - 53975, - 55221, - 56441, - 57267, - 58025, - 58648, - 59232, - 59768, - 60248, - 60729, - 61210, - 61690, - 62171, - 62651, - 63132, - 63613, - 64093, - 64574, - 65054, - 65535, - 0, - 28808, - 38775, - 46801, - 51785, - 55886, - 59410, - 62572, - 65535, - 0, - 27376, - 38639, - 45052, - 51465, - 55448, - 59021, - 62594, - 65535, - 0, - 33403, - 39569, - 45102, - 49961, - 54047, - 57959, - 61788, - 65535, - 0, - 25851, - 43356, - 47828, - 52204, - 55964, - 59413, - 62507, - 65535, - 0, - 34277, - 40337, - 45432, - 50311, - 54326, - 58171, - 61853, - 65535, - 0, - 33538, - 39865, - 45302, - 50076, - 54549, - 58478, - 62159, - 65535, - 0, - 27445, - 35258, - 40665, - 46072, - 51362, - 56540, - 61086, - 65535, - 0, - 22080, - 30779, - 37065, - 43085, - 48849, - 54613, - 60133, - 65535, - 0, - 13417, - 21748, - 30078, - 38231, - 46383, - 53091, - 59515, - 65535 - }; - static private int [] SKP_Silk_NLSF_MSVQ_CB1_16_CDF_0 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_16_CDF, 0, SKP_Silk_NLSF_MSVQ_CB1_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_16_CDF_33 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_16_CDF, 33, SKP_Silk_NLSF_MSVQ_CB1_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_16_CDF_42 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_16_CDF, 42, SKP_Silk_NLSF_MSVQ_CB1_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_16_CDF_51 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_16_CDF, 51, SKP_Silk_NLSF_MSVQ_CB1_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_16_CDF_60 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_16_CDF, 60, SKP_Silk_NLSF_MSVQ_CB1_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_16_CDF_69 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_16_CDF, 69, SKP_Silk_NLSF_MSVQ_CB1_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_16_CDF_78 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_16_CDF, 78, SKP_Silk_NLSF_MSVQ_CB1_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_16_CDF_87 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_16_CDF, 87, SKP_Silk_NLSF_MSVQ_CB1_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_16_CDF_96 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_16_CDF, 96, SKP_Silk_NLSF_MSVQ_CB1_16_CDF.length); - static private int [] SKP_Silk_NLSF_MSVQ_CB1_16_CDF_105 - = Silk_tables.copyOfRange(SKP_Silk_NLSF_MSVQ_CB1_16_CDF, 105, SKP_Silk_NLSF_MSVQ_CB1_16_CDF.length); - - static final int[][] SKP_Silk_NLSF_MSVQ_CB1_16_CDF_start_ptr = - { - SKP_Silk_NLSF_MSVQ_CB1_16_CDF_0 , - SKP_Silk_NLSF_MSVQ_CB1_16_CDF_33 , - SKP_Silk_NLSF_MSVQ_CB1_16_CDF_42 , - SKP_Silk_NLSF_MSVQ_CB1_16_CDF_51 , - SKP_Silk_NLSF_MSVQ_CB1_16_CDF_60 , - SKP_Silk_NLSF_MSVQ_CB1_16_CDF_69 , - SKP_Silk_NLSF_MSVQ_CB1_16_CDF_78 , - SKP_Silk_NLSF_MSVQ_CB1_16_CDF_87 , - SKP_Silk_NLSF_MSVQ_CB1_16_CDF_96 , - SKP_Silk_NLSF_MSVQ_CB1_16_CDF_105 - }; - - static final int[] SKP_Silk_NLSF_MSVQ_CB1_16_CDF_middle_idx = - { - 5, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 3, - 4 - }; - - static final short[] SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q5 = - { - 57, 98, - 133, 134, - 138, 144, - 145, 147, - 152, 177, - 177, 178, - 181, 183, - 184, 202, - 206, 215, - 218, 222, - 227, 227, - 227, 227, - 227, 227, - 227, 227, - 227, 227, - 227, 227, - 38, 87, - 97, 119, - 128, 135, - 140, 143, - 40, 81, - 107, 107, - 129, 134, - 134, 143, - 31, 109, - 114, 120, - 128, 130, - 131, 132, - 43, 61, - 124, 125, - 132, 136, - 141, 142, - 30, 110, - 118, 120, - 129, 131, - 133, 133, - 31, 108, - 115, 121, - 124, 130, - 133, 137, - 40, 98, - 115, 115, - 116, 117, - 123, 124, - 50, 93, - 108, 110, - 112, 112, - 114, 115, - 73, 95, - 95, 96, - 96, 105, - 107, 110 - }; - - static final int[] SKP_Silk_NLSF_MSVQ_CB1_16_ndelta_min_Q15 = - { - 148, - 3, - 60, - 68, - 117, - 86, - 121, - 124, - 152, - 153, - 207, - 151, - 225, - 239, - 126, - 183, - 792 - }; - - static final short[] SKP_Silk_NLSF_MSVQ_CB1_16_Q15 = - { - 1309, 3060, 5071, 6996, - 9028, 10938, 12934, 14891, - 16933, 18854, 20792, 22764, - 24753, 26659, 28626, 30501, - 1264, 2745, 4610, 6408, - 8286, 10043, 12084, 14108, - 16118, 18163, 20095, 22164, - 24264, 26316, 28329, 30251, - 1044, 2080, 3672, 5179, - 7140, 9100, 11070, 13065, - 15423, 17790, 19931, 22101, - 24290, 26361, 28499, 30418, - 1131, 2476, 4478, 6149, - 7902, 9875, 11938, 13809, - 15869, 17730, 19948, 21707, - 23761, 25535, 27426, 28917, - 1040, 2004, 4026, 6100, - 8432, 10494, 12610, 14694, - 16797, 18775, 20799, 22782, - 24772, 26682, 28631, 30516, - 2310, 3812, 5913, 7933, - 10033, 11881, 13885, 15798, - 17751, 19576, 21482, 23276, - 25157, 27010, 28833, 30623, - 1254, 2847, 5013, 6781, - 8626, 10370, 12726, 14633, - 16281, 17852, 19870, 21472, - 23002, 24629, 26710, 27960, - 1468, 3059, 4987, 7026, - 8741, 10412, 12281, 14020, - 15970, 17723, 19640, 21522, - 23472, 25661, 27986, 30225, - 2171, 3566, 5605, 7384, - 9404, 11220, 13030, 14758, - 16687, 18417, 20346, 22091, - 24055, 26212, 28356, 30397, - 2409, 4676, 7543, 9786, - 11419, 12935, 14368, 15653, - 17366, 18943, 20762, 22477, - 24440, 26327, 28284, 30242, - 2354, 4222, 6820, 9107, - 11596, 13934, 15973, 17682, - 19158, 20517, 21991, 23420, - 25178, 26936, 28794, 30527, - 1323, 2414, 4184, 6039, - 7534, 9398, 11099, 13097, - 14799, 16451, 18434, 20887, - 23490, 25838, 28046, 30225, - 1361, 3243, 6048, 8511, - 11001, 13145, 15073, 16608, - 18126, 19381, 20912, 22607, - 24660, 26668, 28663, 30566, - 1216, 2648, 5901, 8422, - 10037, 11425, 12973, 14603, - 16686, 18600, 20555, 22415, - 24450, 26280, 28206, 30077, - 2417, 4048, 6316, 8433, - 10510, 12757, 15072, 17295, - 19573, 21503, 23329, 24782, - 26235, 27689, 29214, 30819, - 1012, 2345, 4991, 7377, - 9465, 11916, 14296, 16566, - 18672, 20544, 22292, 23838, - 25415, 27050, 28848, 30551, - 1937, 3693, 6267, 8019, - 10372, 12194, 14287, 15657, - 17431, 18864, 20769, 22206, - 24037, 25463, 27383, 28602, - 1969, 3305, 5017, 6726, - 8375, 9993, 11634, 13280, - 15078, 16751, 18464, 20119, - 21959, 23858, 26224, 29298, - 1198, 2647, 5428, 7423, - 9775, 12155, 14665, 16344, - 18121, 19790, 21557, 22847, - 24484, 25742, 27639, 28711, - 1636, 3353, 5447, 7597, - 9837, 11647, 13964, 16019, - 17862, 20116, 22319, 24037, - 25966, 28086, 29914, 31294, - 2676, 4105, 6378, 8223, - 10058, 11549, 13072, 14453, - 15956, 17355, 18931, 20402, - 22183, 23884, 25717, 27723, - 1373, 2593, 4449, 5633, - 7300, 8425, 9474, 10818, - 12769, 15722, 19002, 21429, - 23682, 25924, 28135, 30333, - 1596, 3183, 5378, 7164, - 8670, 10105, 11470, 12834, - 13991, 15042, 16642, 17903, - 20759, 25283, 27770, 30240, - 2037, 3987, 6237, 8117, - 9954, 12245, 14217, 15892, - 17775, 20114, 22314, 25942, - 26305, 26483, 26796, 28561, - 2181, 3858, 5760, 7924, - 10041, 11577, 13769, 15700, - 17429, 19879, 23583, 24538, - 25212, 25693, 28688, 30507, - 1992, 3882, 6474, 7883, - 9381, 12672, 14340, 15701, - 16658, 17832, 20850, 22885, - 24677, 26457, 28491, 30460, - 2391, 3988, 5448, 7432, - 11014, 12579, 13140, 14146, - 15898, 18592, 21104, 22993, - 24673, 27186, 28142, 29612, - 1713, 5102, 6989, 7798, - 8670, 10110, 12746, 14881, - 16709, 18407, 20126, 22107, - 24181, 26198, 28237, 30137, - 1612, 3617, 6148, 8359, - 9576, 11528, 14936, 17809, - 18287, 18729, 19001, 21111, - 24631, 26596, 28740, 30643, - 2266, 4168, 7862, 9546, - 9618, 9703, 10134, 13897, - 16265, 18432, 20587, 22605, - 24754, 26994, 29125, 30840, - 1840, 3917, 6272, 7809, - 9714, 11438, 13767, 15799, - 19244, 21972, 22980, 23180, - 23723, 25650, 29117, 31085, - 1458, 3612, 6008, 7488, - 9827, 11893, 14086, 15734, - 17440, 19535, 22424, 24767, - 29246, 29928, 30516, 30947, - -102, -121, -31, -6, - 5, -2, 8, -18, - -4, 6, 14, -2, - -12, -16, -12, -60, - -126, -353, -574, -677, - -657, -617, -498, -393, - -348, -277, -225, -164, - -102, -70, -31, 33, - 4, 379, 387, 551, - 605, 620, 532, 482, - 442, 454, 385, 347, - 322, 299, 266, 200, - 1168, 951, 672, 246, - 60, -161, -259, -234, - -253, -282, -203, -187, - -155, -176, -198, -178, - 10, 170, 393, 609, - 555, 208, -330, -571, - -769, -633, -319, -43, - 95, 105, 106, 116, - -152, -140, -125, 5, - 173, 274, 264, 331, - -37, -293, -609, -786, - -959, -814, -645, -238, - -91, 36, -11, -101, - -279, -227, -40, 90, - 530, 677, 890, 1104, - 999, 835, 564, 295, - -280, -364, -340, -331, - -284, 288, 761, 880, - 988, 627, 146, -226, - -203, -181, -142, 39, - 24, -26, -107, -92, - -161, -135, -131, -88, - -160, -156, -75, -43, - -36, -6, -33, 33, - -324, -415, -108, 124, - 157, 191, 203, 197, - 144, 109, 152, 176, - 190, 122, 101, 159, - 663, 668, 480, 400, - 379, 444, 446, 458, - 343, 351, 310, 228, - 133, 44, 75, 63, - -84, 39, -29, 35, - -94, -233, -261, -354, - 77, 262, -24, -145, - -333, -409, -404, -597, - -488, -300, 910, 592, - 412, 120, 130, -51, - -37, -77, -172, -181, - -159, -148, -72, -62, - 510, 516, 113, -585, - -1075, -957, -417, -195, - 9, 7, -88, -173, - -91, 54, 98, 95, - -28, 197, -527, -621, - 157, 122, -168, 147, - 309, 300, 336, 315, - 396, 408, 376, 106, - -162, -170, -315, 98, - 821, 908, 570, -33, - -312, -568, -572, -378, - -107, 23, 156, 93, - -129, -87, 20, -72, - -37, 40, 21, 27, - 48, 75, 77, 65, - 46, 71, 66, 47, - 136, 344, 236, 322, - 170, 283, 269, 291, - 162, -43, -204, -259, - -240, -305, -350, -312, - 447, 348, 345, 257, - 71, -131, -77, -190, - -202, -40, 35, 133, - 261, 365, 438, 303, - -8, 22, 140, 137, - -300, -641, -764, -268, - -23, -25, 73, -162, - -150, -212, -72, 6, - 39, 78, 104, -93, - -308, -136, 117, -71, - -513, -820, -700, -450, - -161, -23, 29, 78, - 337, 106, -406, -782, - -112, 233, 383, 62, - -126, 6, -77, -29, - -146, -123, -51, -27, - -27, -381, -641, 402, - 539, 8, -207, -366, - -36, -27, -204, -227, - -237, -189, -64, 51, - -92, -137, -281, 62, - 233, 92, 148, 294, - 363, 416, 564, 625, - 370, -36, -469, -462, - 102, 168, 32, 117, - -21, 97, 139, 89, - 104, 35, 4, 82, - 66, 58, 73, 93, - -76, -320, -236, -189, - -203, -142, -27, -73, - 9, -9, -25, 12, - -15, 4, 4, -50, - 314, 180, 162, -49, - 199, -108, -227, -66, - -447, -67, -264, -394, - 5, 55, -133, -176, - -116, -241, 272, 109, - 282, 262, 192, -64, - -392, -514, 156, 203, - 154, 72, -34, -160, - -73, 3, -33, -431, - 321, 18, -567, -590, - -108, 88, 66, 51, - -31, -193, -46, 65, - -29, -23, 215, -31, - 101, -113, 32, 304, - 88, 320, 448, 5, - -439, -562, -508, -135, - -13, -171, -8, 182, - -99, -181, -149, 376, - 476, 64, -396, -652, - -150, 176, 222, 65, - -590, 719, 271, 399, - 245, 72, -156, -152, - -176, 59, 94, 125, - -9, -7, 9, 1, - -61, -116, -82, 1, - 79, 22, -44, -15, - -48, -65, -62, -101, - -102, -54, -70, -78, - -80, -25, 398, 71, - 139, 38, 90, 194, - 222, 249, 165, 94, - 221, 262, 163, 91, - -206, 573, 200, -287, - -147, 5, -18, -85, - -74, -125, -87, 85, - 141, 4, -4, 28, - 234, 48, -150, -111, - -506, 237, -209, 345, - 94, -124, 77, 121, - 143, 12, -80, -48, - 191, 144, -93, -65, - -151, -643, 435, 106, - 87, 7, 65, 102, - 94, 68, 5, 99, - 222, 93, 94, 355, - -13, -89, -228, -503, - 287, 109, 108, 449, - 253, -29, -109, -116, - 15, -73, -20, 131, - -147, 72, 59, -150, - -594, 273, 316, 132, - 199, 106, 198, 212, - 220, 82, 45, -13, - 223, 137, 270, 38, - 252, 135, -177, -207, - -360, -102, 403, 406, - -14, 83, 64, 51, - -7, -99, -97, -88, - -124, -65, 42, 32, - 28, 29, 12, 20, - 119, -26, -212, -201, - 373, 251, 141, 103, - 36, -52, 66, 18, - -6, -95, -196, 5, - 98, -85, -108, 218, - -164, 20, 356, 172, - 37, 266, 23, 112, - -24, -99, -92, -178, - 29, -278, 388, -60, - -220, 300, -13, 154, - 191, 15, -37, -110, - -153, -150, -114, -7, - -94, -31, -62, -177, - 4, -70, 35, 453, - 147, -247, -328, 101, - 20, -114, 147, 108, - -119, -109, -102, -238, - 55, -102, 173, -89, - 129, 138, -330, -160, - 485, 154, -59, -170, - -20, -34, -261, -40, - -129, 77, -84, 69, - 83, 160, 169, 63, - -516, 30, 336, 52, - -0, -52, -124, 158, - 19, 197, -10, -375, - 405, 285, 114, -395, - -47, 196, 62, 87, - -106, -65, -75, -69, - -13, 34, 99, 59, - 83, 98, 44, 0, - 24, 18, 17, 70, - -22, 194, 208, 144, - -79, -15, 32, -104, - -28, -105, -186, -212, - -228, -79, -76, 51, - -71, 72, 118, -34, - -3, -171, 5, 2, - -108, -125, 62, -58, - 58, -121, 73, -466, - 92, 63, -94, -78, - -76, 212, 36, -225, - -71, -354, 152, 143, - -79, -246, -51, -31, - -6, -270, 240, 210, - 30, -157, -231, 74, - -146, 88, -273, 156, - 92, 56, 71, 2, - 318, 164, 32, -110, - -35, -41, -95, -106, - 11, 132, -68, 55, - 123, -83, -149, 212, - 132, 0, -194, 55, - 206, -108, -353, 289, - -195, 1, 233, -22, - -60, 20, 26, 68, - 166, 27, -58, 130, - 112, 107, 27, -165, - 115, -93, -37, 38, - 83, 483, 65, -229, - -13, 157, 85, 50, - 136, 10, 32, 83, - 82, 55, 5, -9, - -52, -78, -81, -51, - 40, 18, -127, -224, - -41, 53, -210, -113, - 24, -17, -187, -89, - 8, 121, 83, 77, - 91, -74, -35, -112, - -161, -173, 102, 132, - -125, -61, 103, -260, - 52, 166, -32, -156, - -87, -56, 60, -70, - -124, 242, 114, -251, - -166, 201, 127, 28, - -11, 23, -80, -115, - -20, -51, -348, 340, - -34, 133, 13, 92, - -124, -136, -120, -26, - -6, 17, 28, 21, - 120, -168, 160, -35, - 115, 28, 9, 7, - -56, 39, 156, 256, - -18, 1, 277, 82, - -70, -144, -88, -13, - -59, -157, 8, -134, - 21, -40, 58, -21, - 194, -276, 97, 279, - -56, -140, 125, 57, - -184, -204, -70, -2, - 128, -202, -78, 230, - -23, 161, -102, 1, - 1, 180, -31, -86, - -167, -57, -60, 27, - -13, 99, 108, 111, - 76, 69, 34, -21, - 53, 38, 34, 78, - 73, 219, 51, 15, - -72, -103, -207, 30, - 213, -14, 31, -94, - -40, -144, 67, 4, - 105, 59, -240, 25, - 244, 69, 58, 23, - -24, -5, -15, -133, - -71, -67, 181, 29, - -45, 121, 96, 51, - -72, -53, 56, -153, - -27, 85, 183, 211, - 105, -34, -46, 43, - -72, -93, 36, -128, - 29, 111, -95, -156, - -179, -235, 21, -39, - -71, -33, -61, -252, - 230, -131, 157, -21, - -85, -28, -123, 80, - -160, 63, 47, -6, - -49, -96, -19, 17, - -58, 17, -0, -13, - -170, 25, -35, 59, - 10, -31, -413, 81, - 62, 18, -164, 245, - 92, -165, 42, 26, - 126, -248, 193, -55, - 16, 39, 14, 50 - }; - - static final SKP_Silk_NLSF_CBS[] SKP_Silk_NLSF_CB1_16_Stage_info = - { - new SKP_Silk_NLSF_CBS(32, SKP_Silk_NLSF_MSVQ_CB1_16_Q15, 16 * 0, SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q5, 0), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_16_Q15, 16 * 32, SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q5, 32), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_16_Q15, 16 * 40, SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q5, 40), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_16_Q15, 16 * 48, SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q5, 48), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_16_Q15, 16 * 56, SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q5, 56), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_16_Q15, 16 * 64, SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q5, 64), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_16_Q15, 16 * 72, SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q5, 72), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_16_Q15, 16 * 80, SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q5, 80), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_16_Q15, 16 * 88, SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q5, 88), - new SKP_Silk_NLSF_CBS(8, SKP_Silk_NLSF_MSVQ_CB1_16_Q15, 16 * 96, SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q5, 96), - }; - - static final SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB1_16 = - new SKP_Silk_NLSF_CB_struct - ( - NLSF_MSVQ_CB1_16_STAGES, - SKP_Silk_NLSF_CB1_16_Stage_info, - SKP_Silk_NLSF_MSVQ_CB1_16_ndelta_min_Q15, - SKP_Silk_NLSF_MSVQ_CB1_16_CDF, - SKP_Silk_NLSF_MSVQ_CB1_16_CDF_start_ptr, - SKP_Silk_NLSF_MSVQ_CB1_16_CDF_middle_idx - ); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB1_16_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB1_16_FLP.java deleted file mode 100644 index 089d98bc7..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_NLSF_CB1_16_FLP.java +++ /dev/null @@ -1,979 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * This file has been automatically generated. - * ROM usage: 7.14 kB - * - * @author Dingxin Xu - */ -public class Silk_tables_NLSF_CB1_16_FLP -{ -// const SKP_float SKP_Silk_NLSF_MSVQ_CB1_16_rates[ NLSF_MSVQ_CB1_16_VECTORS ] = - static final float SKP_Silk_NLSF_MSVQ_CB1_16_rates[] = - { - 1.78125000000000000000f, 3.06250000000000000000f, - 4.15625000000000000000f, 4.18750000000000000000f, - 4.31250000000000000000f, 4.50000000000000000000f, - 4.53125000000000000000f, 4.59375000000000000000f, - 4.75000000000000000000f, 5.53125000000000000000f, - 5.53125000000000000000f, 5.56250000000000000000f, - 5.65625000000000000000f, 5.71875000000000000000f, - 5.75000000000000000000f, 6.31250000000000000000f, - 6.43750000000000000000f, 6.71875000000000000000f, - 6.81250000000000000000f, 6.93750000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 7.09375000000000000000f, 7.09375000000000000000f, - 1.18750000000000000000f, 2.71875000000000000000f, - 3.03125000000000000000f, 3.71875000000000000000f, - 4.00000000000000000000f, 4.21875000000000000000f, - 4.37500000000000000000f, 4.46875000000000000000f, - 1.25000000000000000000f, 2.53125000000000000000f, - 3.34375000000000000000f, 3.34375000000000000000f, - 4.03125000000000000000f, 4.18750000000000000000f, - 4.18750000000000000000f, 4.46875000000000000000f, - 0.96875000000000000000f, 3.40625000000000000000f, - 3.56250000000000000000f, 3.75000000000000000000f, - 4.00000000000000000000f, 4.06250000000000000000f, - 4.09375000000000000000f, 4.12500000000000000000f, - 1.34375000000000000000f, 1.90625000000000000000f, - 3.87500000000000000000f, 3.90625000000000000000f, - 4.12500000000000000000f, 4.25000000000000000000f, - 4.40625000000000000000f, 4.43750000000000000000f, - 0.93750000000000000000f, 3.43750000000000000000f, - 3.68750000000000000000f, 3.75000000000000000000f, - 4.03125000000000000000f, 4.09375000000000000000f, - 4.15625000000000000000f, 4.15625000000000000000f, - 0.96875000000000000000f, 3.37500000000000000000f, - 3.59375000000000000000f, 3.78125000000000000000f, - 3.87500000000000000000f, 4.06250000000000000000f, - 4.15625000000000000000f, 4.28125000000000000000f, - 1.25000000000000000000f, 3.06250000000000000000f, - 3.59375000000000000000f, 3.59375000000000000000f, - 3.62500000000000000000f, 3.65625000000000000000f, - 3.84375000000000000000f, 3.87500000000000000000f, - 1.56250000000000000000f, 2.90625000000000000000f, - 3.37500000000000000000f, 3.43750000000000000000f, - 3.50000000000000000000f, 3.50000000000000000000f, - 3.56250000000000000000f, 3.59375000000000000000f, - 2.28125000000000000000f, 2.96875000000000000000f, - 2.96875000000000000000f, 3.00000000000000000000f, - 3.00000000000000000000f, 3.28125000000000000000f, - 3.34375000000000000000f, 3.43750000000000000000f - }; - -// const SKP_float SKP_Silk_NLSF_MSVQ_CB1_16_ndelta_min[ 16 + 1 ] = - static final float SKP_Silk_NLSF_MSVQ_CB1_16_ndelta_min[] = - { - 0.00451660156250000000f, - 0.00009155273437500000f, - 0.00183105468749999980f, - 0.00207519531250000000f, - 0.00357055664062500000f, - 0.00262451171875000000f, - 0.00369262695312500000f, - 0.00378417968750000000f, - 0.00463867187500000000f, - 0.00466918945312500000f, - 0.00631713867187499910f, - 0.00460815429687500000f, - 0.00686645507812500000f, - 0.00729370117187499910f, - 0.00384521484375000000f, - 0.00558471679687500000f, - 0.02416992187500000300f - }; - -// const SKP_float SKP_Silk_NLSF_MSVQ_CB1_16[ 16 * NLSF_MSVQ_CB1_16_VECTORS ] = - static final float SKP_Silk_NLSF_MSVQ_CB1_16[] = - { - 0.03994750976562499300f, 0.09338378906250000000f, - 0.15475463867187500000f, 0.21350097656250000000f, - 0.27551269531250000000f, 0.33380126953125000000f, - 0.39471435546875000000f, 0.45443725585937500000f, - 0.51675415039062500000f, 0.57537841796875000000f, - 0.63452148437500000000f, 0.69470214843750000000f, - 0.75540161132812500000f, 0.81356811523437500000f, - 0.87359619140625000000f, 0.93081665039062500000f, - 0.03857421875000000000f, 0.08377075195312498600f, - 0.14068603515625000000f, 0.19555664062500000000f, - 0.25286865234375000000f, 0.30648803710937500000f, - 0.36877441406250000000f, 0.43054199218750000000f, - 0.49188232421875006000f, 0.55429077148437500000f, - 0.61325073242187500000f, 0.67639160156250000000f, - 0.74047851562500000000f, 0.80310058593750000000f, - 0.86453247070312500000f, 0.92318725585937500000f, - 0.03186035156250000000f, 0.06347656250000000000f, - 0.11206054687500000000f, 0.15805053710937500000f, - 0.21789550781250003000f, 0.27770996093750000000f, - 0.33782958984375000000f, 0.39871215820312494000f, - 0.47067260742187500000f, 0.54290771484375000000f, - 0.60824584960937500000f, 0.67446899414062500000f, - 0.74127197265625000000f, 0.80447387695312500000f, - 0.86972045898437500000f, 0.92828369140625000000f, - 0.03451538085937500000f, 0.07556152343750000000f, - 0.13665771484375000000f, 0.18765258789062500000f, - 0.24114990234375000000f, 0.30136108398437500000f, - 0.36431884765624994000f, 0.42141723632812500000f, - 0.48428344726562500000f, 0.54107666015625000000f, - 0.60876464843750000000f, 0.66244506835937500000f, - 0.72512817382812500000f, 0.77926635742187500000f, - 0.83697509765625000000f, 0.88247680664062500000f, - 0.03173828125000000000f, 0.06115722656250000000f, - 0.12286376953125000000f, 0.18615722656250000000f, - 0.25732421875000000000f, 0.32025146484375000000f, - 0.38482666015625000000f, 0.44842529296875000000f, - 0.51260375976562500000f, 0.57296752929687500000f, - 0.63473510742187500000f, 0.69525146484375000000f, - 0.75598144531250000000f, 0.81427001953125000000f, - 0.87374877929687511000f, 0.93127441406250000000f, - 0.07049560546875000000f, 0.11633300781250001000f, - 0.18045043945312497000f, 0.24209594726562500000f, - 0.30618286132812500000f, 0.36257934570312500000f, - 0.42373657226562500000f, 0.48211669921875000000f, - 0.54171752929687500000f, 0.59741210937500000000f, - 0.65557861328125000000f, 0.71032714843750000000f, - 0.76773071289062500000f, 0.82427978515624989000f, - 0.87991333007812500000f, 0.93453979492187500000f, - 0.03826904296875000000f, 0.08688354492187500000f, - 0.15298461914062500000f, 0.20693969726562500000f, - 0.26324462890625000000f, 0.31646728515625000000f, - 0.38836669921875000000f, 0.44656372070312500000f, - 0.49685668945312494000f, 0.54479980468750000000f, - 0.60638427734375000000f, 0.65527343749999989000f, - 0.70196533203124989000f, 0.75161743164062500000f, - 0.81512451171875000000f, 0.85327148437500000000f, - 0.04479980468750000000f, 0.09335327148437500000f, - 0.15219116210937500000f, 0.21441650390625000000f, - 0.26675415039062500000f, 0.31774902343750000000f, - 0.37478637695312500000f, 0.42785644531250000000f, - 0.48736572265625000000f, 0.54086303710937500000f, - 0.59936523437500000000f, 0.65679931640625000000f, - 0.71630859375000000000f, 0.78311157226562500000f, - 0.85406494140625000000f, 0.92239379882812500000f, - 0.06625366210937500000f, 0.10882568359375000000f, - 0.17105102539062497000f, 0.22534179687500000000f, - 0.28698730468750000000f, 0.34240722656249994000f, - 0.39764404296875000000f, 0.45037841796875000000f, - 0.50924682617187500000f, 0.56204223632812500000f, - 0.62091064453125000000f, 0.67416381835937511000f, - 0.73410034179687489000f, 0.79992675781250000000f, - 0.86535644531250000000f, 0.92764282226562500000f, - 0.07351684570312500000f, 0.14270019531250000000f, - 0.23019409179687497000f, 0.29864501953125000000f, - 0.34848022460937500000f, 0.39474487304687500000f, - 0.43847656250000006000f, 0.47769165039062500000f, - 0.52996826171875000000f, 0.57809448242187500000f, - 0.63360595703125000000f, 0.68594360351562511000f, - 0.74584960937500000000f, 0.80343627929687500000f, - 0.86315917968750000000f, 0.92291259765625000000f, - 0.07183837890625000000f, 0.12884521484375000000f, - 0.20812988281250003000f, 0.27792358398437500000f, - 0.35388183593749994000f, 0.42523193359375000000f, - 0.48745727539062494000f, 0.53961181640625000000f, - 0.58465576171875000000f, 0.62612915039062500000f, - 0.67111206054687500000f, 0.71472167968750000000f, - 0.76837158203125000000f, 0.82202148437499989000f, - 0.87872314453125000000f, 0.93161010742187511000f, - 0.04037475585937500000f, 0.07366943359375000000f, - 0.12768554687500000000f, 0.18429565429687500000f, - 0.22991943359375000000f, 0.28680419921875000000f, - 0.33871459960937500000f, 0.39968872070312500000f, - 0.45162963867187500000f, 0.50204467773437500000f, - 0.56256103515625000000f, 0.63742065429687500000f, - 0.71685791015624989000f, 0.78851318359375011000f, - 0.85589599609374989000f, 0.92239379882812500000f, - 0.04153442382812500700f, 0.09896850585937500000f, - 0.18457031250000000000f, 0.25973510742187500000f, - 0.33572387695312500000f, 0.40115356445312500000f, - 0.45999145507812500000f, 0.50683593750000000000f, - 0.55316162109375000000f, 0.59146118164062500000f, - 0.63818359375000000000f, 0.68991088867187500000f, - 0.75256347656250011000f, 0.81384277343750000000f, - 0.87472534179687500000f, 0.93280029296875000000f, - 0.03710937500000000000f, 0.08081054687500000000f, - 0.18008422851562503000f, 0.25701904296875000000f, - 0.30630493164062500000f, 0.34866333007812500000f, - 0.39590454101562500000f, 0.44564819335937500000f, - 0.50921630859375000000f, 0.56762695312500000000f, - 0.62728881835937500000f, 0.68405151367187500000f, - 0.74615478515625000000f, 0.80200195312500000000f, - 0.86077880859375000000f, 0.91787719726562500000f, - 0.07376098632812500000f, 0.12353515625000000000f, - 0.19274902343750000000f, 0.25735473632812500000f, - 0.32073974609375000000f, 0.38931274414062494000f, - 0.45996093750000006000f, 0.52780151367187500000f, - 0.59732055664062500000f, 0.65621948242187489000f, - 0.71194458007812500000f, 0.75628662109375011000f, - 0.80062866210937489000f, 0.84500122070312500000f, - 0.89154052734375000000f, 0.94052124023437500000f, - 0.03088378906250000000f, 0.07156372070312500000f, - 0.15231323242187500000f, 0.22512817382812503000f, - 0.28884887695312500000f, 0.36364746093750000000f, - 0.43627929687500000000f, 0.50555419921875000000f, - 0.56982421875000000000f, 0.62695312500000000000f, - 0.68029785156250000000f, 0.72747802734375000000f, - 0.77560424804687511000f, 0.82550048828125011000f, - 0.88037109375000000000f, 0.93234252929687500000f, - 0.05911254882812500000f, 0.11270141601562500000f, - 0.19125366210937500000f, 0.24472045898437500000f, - 0.31652832031250000000f, 0.37213134765625000000f, - 0.43600463867187494000f, 0.47781372070312500000f, - 0.53195190429687500000f, 0.57568359375000000000f, - 0.63381958007812500000f, 0.67767333984375000000f, - 0.73355102539062500000f, 0.77706909179687489000f, - 0.83566284179687500000f, 0.87286376953125000000f, - 0.06008911132812500000f, 0.10086059570312500000f, - 0.15310668945312500000f, 0.20526123046875000000f, - 0.25558471679687500000f, 0.30496215820312500000f, - 0.35504150390625000000f, 0.40527343750000000000f, - 0.46014404296875000000f, 0.51119995117187500000f, - 0.56347656250000000000f, 0.61398315429687500000f, - 0.67013549804687500000f, 0.72808837890625000000f, - 0.80029296875000011000f, 0.89410400390625011000f, - 0.03656005859375000000f, 0.08078002929687500000f, - 0.16564941406250000000f, 0.22653198242187500000f, - 0.29830932617187500000f, 0.37094116210937500000f, - 0.44754028320312500000f, 0.49877929687500000000f, - 0.55300903320312500000f, 0.60394287109375000000f, - 0.65786743164062489000f, 0.69723510742187500000f, - 0.74719238281250011000f, 0.78558349609375000000f, - 0.84347534179687500000f, 0.87619018554687500000f, - 0.04992675781250000000f, 0.10232543945312500000f, - 0.16622924804687500000f, 0.23184204101562503000f, - 0.30020141601562500000f, 0.35543823242187500000f, - 0.42614746093750000000f, 0.48886108398437500000f, - 0.54510498046875000000f, 0.61389160156250000000f, - 0.68112182617187500000f, 0.73355102539062500000f, - 0.79241943359375000000f, 0.85711669921875011000f, - 0.91290283203125011000f, 0.95501708984375000000f, - 0.08166503906250000000f, 0.12527465820312500000f, - 0.19464111328125000000f, 0.25094604492187500000f, - 0.30694580078125000000f, 0.35244750976562500000f, - 0.39892578124999994000f, 0.44107055664062494000f, - 0.48693847656249994000f, 0.52963256835937500000f, - 0.57772827148437500000f, 0.62261962890625000000f, - 0.67697143554687500000f, 0.72888183593750000000f, - 0.78482055664062500000f, 0.84603881835937500000f, - 0.04190063476562500000f, 0.07913208007812500000f, - 0.13577270507812500000f, 0.17190551757812500000f, - 0.22277832031250000000f, 0.25711059570312500000f, - 0.28912353515625000000f, 0.33013916015625000000f, - 0.38967895507812500000f, 0.47979736328125006000f, - 0.57989501953125000000f, 0.65396118164062500000f, - 0.72271728515625000000f, 0.79113769531250000000f, - 0.85861206054687500000f, 0.92568969726562500000f, - 0.04870605468750000000f, 0.09713745117187500000f, - 0.16412353515625003000f, 0.21862792968750000000f, - 0.26458740234375000000f, 0.30838012695312500000f, - 0.35003662109375000000f, 0.39166259765625000000f, - 0.42697143554687500000f, 0.45904541015624994000f, - 0.50787353515625000000f, 0.54635620117187500000f, - 0.63351440429687500000f, 0.77157592773437500000f, - 0.84747314453125000000f, 0.92285156249999989000f, - 0.06216430664062500000f, 0.12167358398437500000f, - 0.19033813476562500000f, 0.24771118164062500000f, - 0.30377197265625000000f, 0.37368774414062500000f, - 0.43386840820312500000f, 0.48498535156250000000f, - 0.54244995117187500000f, 0.61383056640625000000f, - 0.68096923828125000000f, 0.79168701171875000000f, - 0.80276489257812500000f, 0.80819702148437500000f, - 0.81774902343750000000f, 0.87161254882812500000f, - 0.06655883789062500000f, 0.11773681640625000000f, - 0.17578125000000000000f, 0.24182128906250000000f, - 0.30642700195312500000f, 0.35330200195312500000f, - 0.42019653320312494000f, 0.47912597656250000000f, - 0.53189086914062500000f, 0.60665893554687500000f, - 0.71969604492187500000f, 0.74884033203125000000f, - 0.76940917968750000000f, 0.78408813476562511000f, - 0.87548828125000000000f, 0.93099975585937489000f, - 0.06079101562500000000f, 0.11846923828125000000f, - 0.19757080078125000000f, 0.24057006835937503000f, - 0.28628540039062500000f, 0.38671875000000006000f, - 0.43762207031250000000f, 0.47915649414062500000f, - 0.50836181640625000000f, 0.54418945312500000000f, - 0.63629150390625000000f, 0.69839477539062500000f, - 0.75308227539062511000f, 0.80740356445312500000f, - 0.86947631835937500000f, 0.92956542968750000000f, - 0.07296752929687500000f, 0.12170410156250000000f, - 0.16625976562500000000f, 0.22680664062500000000f, - 0.33612060546875000000f, 0.38388061523437500000f, - 0.40100097656250000000f, 0.43170166015625000000f, - 0.48516845703125006000f, 0.56738281250000000000f, - 0.64404296875000000000f, 0.70169067382812500000f, - 0.75296020507812500000f, 0.82965087890624989000f, - 0.85882568359375000000f, 0.90368652343750000000f, - 0.05227661132812500000f, 0.15570068359375000000f, - 0.21328735351562500000f, 0.23797607421875000000f, - 0.26458740234375000000f, 0.30853271484375000000f, - 0.38897705078125000000f, 0.45413208007812500000f, - 0.50991821289062500000f, 0.56173706054687500000f, - 0.61419677734375000000f, 0.67465209960937500000f, - 0.73794555664062500000f, 0.79949951171874989000f, - 0.86172485351562500000f, 0.91970825195312500000f, - 0.04919433593750000000f, 0.11038208007812500000f, - 0.18762207031250000000f, 0.25509643554687500000f, - 0.29223632812500000000f, 0.35180664062500006000f, - 0.45581054687500000000f, 0.54348754882812500000f, - 0.55807495117187500000f, 0.57156372070312500000f, - 0.57986450195312500000f, 0.64425659179687500000f, - 0.75167846679687500000f, 0.81164550781250000000f, - 0.87707519531250000000f, 0.93515014648437500000f, - 0.06915283203125000000f, 0.12719726562500000000f, - 0.23992919921875000000f, 0.29132080078125000000f, - 0.29351806640625000000f, 0.29611206054687500000f, - 0.30926513671875000000f, 0.42410278320312500000f, - 0.49636840820312500000f, 0.56250000000000000000f, - 0.62826538085937500000f, 0.68984985351562500000f, - 0.75543212890625000000f, 0.82379150390625000000f, - 0.88882446289062511000f, 0.94116210937500000000f, - 0.05615234375000000700f, 0.11953735351562501000f, - 0.19140625000000000000f, 0.23831176757812500000f, - 0.29644775390625000000f, 0.34906005859375000000f, - 0.42013549804687500000f, 0.48214721679687500000f, - 0.58728027343750000000f, 0.67053222656250000000f, - 0.70129394531250000000f, 0.70739746093750000000f, - 0.72396850585937489000f, 0.78277587890625000000f, - 0.88858032226562500000f, 0.94863891601562500000f, - 0.04449462890625000000f, 0.11022949218750000000f, - 0.18334960937500000000f, 0.22851562500000000000f, - 0.29989624023437500000f, 0.36294555664062500000f, - 0.42987060546875000000f, 0.48016357421875000000f, - 0.53222656250000000000f, 0.59616088867187500000f, - 0.68432617187500000000f, 0.75582885742187500000f, - 0.89251708984375000000f, 0.91333007812499989000f, - 0.93127441406250000000f, 0.94442749023437489000f, - -0.00311279296875000000f, -0.00369262695312500000f, - -0.00094604492187500000f, -0.00018310546875000000f, - 0.00015258789062500000f, -0.00006103515625000000f, - 0.00024414062500000000f, -0.00054931640625000000f, - -0.00012207031250000000f, 0.00018310546875000000f, - 0.00042724609375000000f, -0.00006103515625000000f, - -0.00036621093750000000f, -0.00048828125000000000f, - -0.00036621093750000000f, -0.00183105468749999980f, - -0.00384521484375000000f, -0.01077270507812500000f, - -0.01751708984375000000f, -0.02066040039062500000f, - -0.02005004882812500000f, -0.01882934570312500000f, - -0.01519775390625000000f, -0.01199340820312500000f, - -0.01062011718750000000f, -0.00845336914062500000f, - -0.00686645507812500000f, -0.00500488281250000000f, - -0.00311279296875000000f, -0.00213623046875000000f, - -0.00094604492187500000f, 0.00100708007812500000f, - 0.00012207031250000000f, 0.01156616210937500000f, - 0.01181030273437500000f, 0.01681518554687500000f, - 0.01846313476562500000f, 0.01892089843750000000f, - 0.01623535156250000000f, 0.01470947265625000200f, - 0.01348876953125000000f, 0.01385498046875000000f, - 0.01174926757812500200f, 0.01058959960937500000f, - 0.00982666015625000000f, 0.00912475585937500000f, - 0.00811767578125000000f, 0.00610351562500000000f, - 0.03564453125000000000f, 0.02902221679687500000f, - 0.02050781250000000000f, 0.00750732421875000000f, - 0.00183105468749999980f, -0.00491333007812500000f, - -0.00790405273437500000f, -0.00714111328125000000f, - -0.00772094726562500000f, -0.00860595703125000000f, - -0.00619506835937500000f, -0.00570678710937500090f, - -0.00473022460937500000f, -0.00537109374999999910f, - -0.00604248046875000090f, -0.00543212890625000000f, - 0.00030517578125000000f, 0.00518798828125000000f, - 0.01199340820312500000f, 0.01858520507812500000f, - 0.01693725585937500000f, 0.00634765625000000090f, - -0.01007080078124999800f, -0.01742553710937500000f, - -0.02346801757812500000f, -0.01931762695312500000f, - -0.00973510742187500000f, -0.00131225585937500000f, - 0.00289916992187500000f, 0.00320434570312500000f, - 0.00323486328125000000f, 0.00354003906250000000f, - -0.00463867187500000000f, -0.00427246093750000000f, - -0.00381469726562499960f, 0.00015258789062500000f, - 0.00527954101562500000f, 0.00836181640625000000f, - 0.00805664062500000000f, 0.01010131835937500000f, - -0.00112915039062500000f, -0.00894165039062500000f, - -0.01858520507812500000f, -0.02398681640625000000f, - -0.02926635742187500000f, -0.02484130859375000300f, - -0.01968383789062500000f, -0.00726318359375000000f, - -0.00277709960937500000f, 0.00109863281250000000f, - -0.00033569335937499995f, -0.00308227539062500000f, - -0.00851440429687500000f, -0.00692749023437500000f, - -0.00122070312500000000f, 0.00274658203125000000f, - 0.01617431640625000000f, 0.02066040039062500000f, - 0.02716064453125000000f, 0.03369140625000000000f, - 0.03048706054687500000f, 0.02548217773437500000f, - 0.01721191406250000000f, 0.00900268554687500000f, - -0.00854492187500000000f, -0.01110839843750000000f, - -0.01037597656250000000f, -0.01010131835937500000f, - -0.00866699218750000000f, 0.00878906250000000000f, - 0.02322387695312500000f, 0.02685546875000000000f, - 0.03015136718750000000f, 0.01913452148437500000f, - 0.00445556640625000000f, -0.00689697265625000000f, - -0.00619506835937500000f, -0.00552368164062500000f, - -0.00433349609375000000f, 0.00119018554687500000f, - 0.00073242187500000000f, -0.00079345703125000011f, - -0.00326538085937500000f, -0.00280761718750000000f, - -0.00491333007812500000f, -0.00411987304687500000f, - -0.00399780273437500000f, -0.00268554687499999960f, - -0.00488281250000000000f, -0.00476074218750000000f, - -0.00228881835937500000f, -0.00131225585937500000f, - -0.00109863281250000000f, -0.00018310546875000000f, - -0.00100708007812500000f, 0.00100708007812500000f, - -0.00988769531250000000f, -0.01266479492187500000f, - -0.00329589843750000000f, 0.00378417968750000000f, - 0.00479125976562500000f, 0.00582885742187500000f, - 0.00619506835937500000f, 0.00601196289062499910f, - 0.00439453125000000000f, 0.00332641601562499960f, - 0.00463867187500000000f, 0.00537109374999999910f, - 0.00579833984375000000f, 0.00372314453125000000f, - 0.00308227539062500000f, 0.00485229492187500000f, - 0.02023315429687500000f, 0.02038574218750000000f, - 0.01464843749999999800f, 0.01220703125000000000f, - 0.01156616210937500000f, 0.01354980468750000000f, - 0.01361083984375000000f, 0.01397705078124999800f, - 0.01046752929687500200f, 0.01071166992187500000f, - 0.00946044921875000000f, 0.00695800781250000000f, - 0.00405883789062500000f, 0.00134277343749999980f, - 0.00228881835937500000f, 0.00192260742187500000f, - -0.00256347656250000000f, 0.00119018554687500000f, - -0.00088500976562500000f, 0.00106811523437500000f, - -0.00286865234375000000f, -0.00711059570312500000f, - -0.00796508789062500000f, -0.01080322265625000200f, - 0.00234985351562500000f, 0.00799560546875000000f, - -0.00073242187500000000f, -0.00442504882812500000f, - -0.01016235351562500000f, -0.01248168945312500000f, - -0.01232910156250000000f, -0.01821899414062500000f, - -0.01489257812500000000f, -0.00915527343750000000f, - 0.02777099609375000000f, 0.01806640625000000000f, - 0.01257324218750000000f, 0.00366210937499999960f, - 0.00396728515625000000f, -0.00155639648437500000f, - -0.00112915039062500000f, -0.00234985351562500000f, - -0.00524902343750000000f, -0.00552368164062500000f, - -0.00485229492187500000f, -0.00451660156250000000f, - -0.00219726562500000000f, -0.00189208984375000000f, - 0.01556396484375000000f, 0.01574707031250000000f, - 0.00344848632812500000f, -0.01785278320312500000f, - -0.03280639648437500000f, -0.02920532226562500000f, - -0.01272583007812500000f, -0.00595092773437500000f, - 0.00027465820312500000f, 0.00021362304687500000f, - -0.00268554687499999960f, -0.00527954101562500000f, - -0.00277709960937500000f, 0.00164794921875000000f, - 0.00299072265625000000f, 0.00289916992187500000f, - -0.00085449218750000000f, 0.00601196289062499910f, - -0.01608276367187500000f, -0.01895141601562500000f, - 0.00479125976562500000f, 0.00372314453125000000f, - -0.00512695312500000000f, 0.00448608398437500000f, - 0.00942993164062500000f, 0.00915527343750000000f, - 0.01025390625000000000f, 0.00961303710937500000f, - 0.01208496093750000200f, 0.01245117187500000000f, - 0.01147460937500000000f, 0.00323486328125000000f, - -0.00494384765625000000f, -0.00518798828125000000f, - -0.00961303710937500000f, 0.00299072265625000000f, - 0.02505493164062499700f, 0.02770996093750000000f, - 0.01739501953125000000f, -0.00100708007812500000f, - -0.00952148437500000000f, -0.01733398437500000000f, - -0.01745605468750000000f, -0.01153564453125000000f, - -0.00326538085937500000f, 0.00070190429687500000f, - 0.00476074218750000000f, 0.00283813476562499960f, - -0.00393676757812500000f, -0.00265502929687500000f, - 0.00061035156250000000f, -0.00219726562500000000f, - -0.00112915039062500000f, 0.00122070312500000000f, - 0.00064086914062500000f, 0.00082397460937500000f, - 0.00146484375000000000f, 0.00228881835937500000f, - 0.00234985351562500000f, 0.00198364257812500000f, - 0.00140380859375000000f, 0.00216674804687500000f, - 0.00201416015625000000f, 0.00143432617187500000f, - 0.00415039062500000000f, 0.01049804687500000000f, - 0.00720214843750000000f, 0.00982666015625000000f, - 0.00518798828125000000f, 0.00863647460937500000f, - 0.00820922851562500000f, 0.00888061523437500000f, - 0.00494384765625000000f, -0.00131225585937500000f, - -0.00622558593750000000f, -0.00790405273437500000f, - -0.00732421874999999910f, -0.00930786132812500000f, - -0.01068115234374999800f, -0.00952148437500000000f, - 0.01364135742187499800f, 0.01062011718750000000f, - 0.01052856445312500000f, 0.00784301757812500000f, - 0.00216674804687500000f, -0.00399780273437500000f, - -0.00234985351562500000f, -0.00579833984375000000f, - -0.00616455078125000000f, -0.00122070312500000000f, - 0.00106811523437500000f, 0.00405883789062500000f, - 0.00796508789062500000f, 0.01113891601562500000f, - 0.01336669921875000200f, 0.00924682617187500000f, - -0.00024414062500000000f, 0.00067138671874999989f, - 0.00427246093750000000f, 0.00418090820312500000f, - -0.00915527343750000000f, -0.01956176757812500000f, - -0.02331542968750000000f, -0.00817871093750000000f, - -0.00070190429687500000f, -0.00076293945312500000f, - 0.00222778320312500000f, -0.00494384765625000000f, - -0.00457763671875000000f, -0.00646972656250000000f, - -0.00219726562500000000f, 0.00018310546875000000f, - 0.00119018554687500000f, 0.00238037109375000000f, - 0.00317382812500000040f, -0.00283813476562499960f, - -0.00939941406250000000f, -0.00415039062500000000f, - 0.00357055664062500000f, -0.00216674804687500000f, - -0.01565551757812500000f, -0.02502441406250000000f, - -0.02136230468749999700f, -0.01373291015625000000f, - -0.00491333007812500000f, -0.00070190429687500000f, - 0.00088500976562500000f, 0.00238037109375000000f, - 0.01028442382812500000f, 0.00323486328125000000f, - -0.01239013671875000000f, -0.02386474609375000000f, - -0.00341796875000000000f, 0.00711059570312500000f, - 0.01168823242187499800f, 0.00189208984375000000f, - -0.00384521484375000000f, 0.00018310546875000000f, - -0.00234985351562500000f, -0.00088500976562500000f, - -0.00445556640625000000f, -0.00375366210937500000f, - -0.00155639648437500000f, -0.00082397460937500000f, - -0.00082397460937500000f, -0.01162719726562500000f, - -0.01956176757812500000f, 0.01226806640625000000f, - 0.01644897460937500000f, 0.00024414062500000000f, - -0.00631713867187499910f, -0.01116943359375000000f, - -0.00109863281250000000f, -0.00082397460937500000f, - -0.00622558593750000000f, -0.00692749023437500000f, - -0.00723266601562500000f, -0.00576782226562500000f, - -0.00195312500000000000f, 0.00155639648437500000f, - -0.00280761718750000000f, -0.00418090820312500000f, - -0.00857543945312500000f, 0.00189208984375000000f, - 0.00711059570312500000f, 0.00280761718750000000f, - 0.00451660156250000000f, 0.00897216796875000000f, - 0.01107788085937500200f, 0.01269531250000000200f, - 0.01721191406250000000f, 0.01907348632812500000f, - 0.01129150390625000000f, -0.00109863281250000000f, - -0.01431274414062499800f, -0.01409912109375000000f, - 0.00311279296875000000f, 0.00512695312500000000f, - 0.00097656250000000000f, 0.00357055664062500000f, - -0.00064086914062500000f, 0.00296020507812500000f, - 0.00424194335937500000f, 0.00271606445312500000f, - 0.00317382812500000040f, 0.00106811523437500000f, - 0.00012207031250000000f, 0.00250244140625000000f, - 0.00201416015625000000f, 0.00177001953125000000f, - 0.00222778320312500000f, 0.00283813476562499960f, - -0.00231933593750000000f, -0.00976562500000000000f, - -0.00720214843750000000f, -0.00576782226562500000f, - -0.00619506835937500000f, -0.00433349609375000000f, - -0.00082397460937500000f, -0.00222778320312500000f, - 0.00027465820312500000f, -0.00027465820312500000f, - -0.00076293945312500000f, 0.00036621093750000000f, - -0.00045776367187499995f, 0.00012207031250000000f, - 0.00012207031250000000f, -0.00152587890625000000f, - 0.00958251953125000000f, 0.00549316406250000000f, - 0.00494384765625000000f, -0.00149536132812500000f, - 0.00607299804687500000f, -0.00329589843750000000f, - -0.00692749023437500000f, -0.00201416015625000000f, - -0.01364135742187499800f, -0.00204467773437500000f, - -0.00805664062500000000f, -0.01202392578124999800f, - 0.00015258789062500000f, 0.00167846679687500000f, - -0.00405883789062500000f, -0.00537109374999999910f, - -0.00354003906250000000f, -0.00735473632812500090f, - 0.00830078125000000000f, 0.00332641601562499960f, - 0.00860595703125000000f, 0.00799560546875000000f, - 0.00585937500000000000f, -0.00195312500000000000f, - -0.01196289062500000000f, -0.01568603515625000000f, - 0.00476074218750000000f, 0.00619506835937500000f, - 0.00469970703125000000f, 0.00219726562500000000f, - -0.00103759765625000000f, -0.00488281250000000000f, - -0.00222778320312500000f, 0.00009155273437500000f, - -0.00100708007812500000f, -0.01315307617187500000f, - 0.00979614257812500000f, 0.00054931640625000000f, - -0.01730346679687500000f, -0.01800537109375000000f, - -0.00329589843750000000f, 0.00268554687499999960f, - 0.00201416015625000000f, 0.00155639648437500000f, - -0.00094604492187500000f, -0.00588989257812500000f, - -0.00140380859375000000f, 0.00198364257812500000f, - -0.00088500976562500000f, -0.00070190429687500000f, - 0.00656127929687500000f, -0.00094604492187500000f, - 0.00308227539062500000f, -0.00344848632812500000f, - 0.00097656250000000000f, 0.00927734375000000000f, - 0.00268554687499999960f, 0.00976562500000000000f, - 0.01367187500000000000f, 0.00015258789062500000f, - -0.01339721679687500000f, -0.01715087890625000000f, - -0.01550292968750000000f, -0.00411987304687500000f, - -0.00039672851562500005f, -0.00521850585937500000f, - -0.00024414062500000000f, 0.00555419921875000000f, - -0.00302124023437500040f, -0.00552368164062500000f, - -0.00454711914062500000f, 0.01147460937500000000f, - 0.01452636718750000000f, 0.00195312500000000000f, - -0.01208496093750000200f, -0.01989746093750000000f, - -0.00457763671875000000f, 0.00537109374999999910f, - 0.00677490234375000000f, 0.00198364257812500000f, - -0.01800537109375000000f, 0.02194213867187500300f, - 0.00827026367187500000f, 0.01217651367187500000f, - 0.00747680664062500000f, 0.00219726562500000000f, - -0.00476074218750000000f, -0.00463867187500000000f, - -0.00537109374999999910f, 0.00180053710937500000f, - 0.00286865234375000000f, 0.00381469726562499960f, - -0.00027465820312500000f, -0.00021362304687500000f, - 0.00027465820312500000f, 0.00003051757812500000f, - -0.00186157226562500000f, -0.00354003906250000000f, - -0.00250244140625000000f, 0.00003051757812500000f, - 0.00241088867187500000f, 0.00067138671874999989f, - -0.00134277343749999980f, -0.00045776367187499995f, - -0.00146484375000000000f, -0.00198364257812500000f, - -0.00189208984375000000f, -0.00308227539062500000f, - -0.00311279296875000000f, -0.00164794921875000000f, - -0.00213623046875000000f, -0.00238037109375000000f, - -0.00244140625000000000f, -0.00076293945312500000f, - 0.01214599609375000000f, 0.00216674804687500000f, - 0.00424194335937500000f, 0.00115966796875000000f, - 0.00274658203125000000f, 0.00592041015625000000f, - 0.00677490234375000000f, 0.00759887695312500000f, - 0.00503540039062499910f, 0.00286865234375000000f, - 0.00674438476562500000f, 0.00799560546875000000f, - 0.00497436523437500000f, 0.00277709960937500000f, - -0.00628662109375000000f, 0.01748657226562500000f, - 0.00610351562500000000f, -0.00875854492187500000f, - -0.00448608398437500000f, 0.00015258789062500000f, - -0.00054931640625000000f, -0.00259399414062500000f, - -0.00225830078125000000f, -0.00381469726562499960f, - -0.00265502929687500000f, 0.00259399414062500000f, - 0.00430297851562500000f, 0.00012207031250000000f, - -0.00012207031250000000f, 0.00085449218750000000f, - 0.00714111328125000000f, 0.00146484375000000000f, - -0.00457763671875000000f, -0.00338745117187500000f, - -0.01544189453125000000f, 0.00723266601562500000f, - -0.00637817382812500090f, 0.01052856445312500000f, - 0.00286865234375000000f, -0.00378417968750000000f, - 0.00234985351562500000f, 0.00369262695312500000f, - 0.00436401367187500000f, 0.00036621093750000000f, - -0.00244140625000000000f, -0.00146484375000000000f, - 0.00582885742187500000f, 0.00439453125000000000f, - -0.00283813476562499960f, -0.00198364257812500000f, - -0.00460815429687500000f, -0.01962280273437500000f, - 0.01327514648437500000f, 0.00323486328125000000f, - 0.00265502929687500000f, 0.00021362304687500000f, - 0.00198364257812500000f, 0.00311279296875000000f, - 0.00286865234375000000f, 0.00207519531250000000f, - 0.00015258789062500000f, 0.00302124023437500040f, - 0.00677490234375000000f, 0.00283813476562499960f, - 0.00286865234375000000f, 0.01083374023437500000f, - -0.00039672851562500005f, -0.00271606445312500000f, - -0.00695800781250000000f, -0.01535034179687500000f, - 0.00875854492187500000f, 0.00332641601562499960f, - 0.00329589843750000000f, 0.01370239257812500200f, - 0.00772094726562500000f, -0.00088500976562500000f, - -0.00332641601562499960f, -0.00354003906250000000f, - 0.00045776367187499995f, -0.00222778320312500000f, - -0.00061035156250000000f, 0.00399780273437500000f, - -0.00448608398437500000f, 0.00219726562500000000f, - 0.00180053710937500000f, -0.00457763671875000000f, - -0.01812744140625000000f, 0.00833129882812500000f, - 0.00964355468750000000f, 0.00402832031250000000f, - 0.00607299804687500000f, 0.00323486328125000000f, - 0.00604248046875000090f, 0.00646972656250000000f, - 0.00671386718750000000f, 0.00250244140625000000f, - 0.00137329101562500000f, -0.00039672851562500005f, - 0.00680541992187500000f, 0.00418090820312500000f, - 0.00823974609375000000f, 0.00115966796875000000f, - 0.00769042968750000000f, 0.00411987304687500000f, - -0.00540161132812500090f, -0.00631713867187499910f, - -0.01098632812500000000f, -0.00311279296875000000f, - 0.01229858398437500000f, 0.01239013671875000000f, - -0.00042724609375000000f, 0.00253295898437500040f, - 0.00195312500000000000f, 0.00155639648437500000f, - -0.00021362304687500000f, -0.00302124023437500040f, - -0.00296020507812500000f, -0.00268554687499999960f, - -0.00378417968750000000f, -0.00198364257812500000f, - 0.00128173828125000000f, 0.00097656250000000000f, - 0.00085449218750000000f, 0.00088500976562500000f, - 0.00036621093750000000f, 0.00061035156250000000f, - 0.00363159179687500000f, -0.00079345703125000011f, - -0.00646972656250000000f, -0.00613403320312500000f, - 0.01138305664062500000f, 0.00765991210937500090f, - 0.00430297851562500000f, 0.00314331054687500000f, - 0.00109863281250000000f, -0.00158691406250000020f, - 0.00201416015625000000f, 0.00054931640625000000f, - -0.00018310546875000000f, -0.00289916992187500000f, - -0.00598144531250000000f, 0.00015258789062500000f, - 0.00299072265625000000f, -0.00259399414062500000f, - -0.00329589843750000000f, 0.00665283203124999910f, - -0.00500488281250000000f, 0.00061035156250000000f, - 0.01086425781250000000f, 0.00524902343750000000f, - 0.00112915039062500000f, 0.00811767578125000000f, - 0.00070190429687500000f, 0.00341796875000000000f, - -0.00073242187500000000f, -0.00302124023437500040f, - -0.00280761718750000000f, -0.00543212890625000000f, - 0.00088500976562500000f, -0.00848388671875000000f, - 0.01184082031250000000f, -0.00183105468749999980f, - -0.00671386718750000000f, 0.00915527343750000000f, - -0.00039672851562500005f, 0.00469970703125000000f, - 0.00582885742187500000f, 0.00045776367187499995f, - -0.00112915039062500000f, -0.00335693359375000000f, - -0.00466918945312500000f, -0.00457763671875000000f, - -0.00347900390625000000f, -0.00021362304687500000f, - -0.00286865234375000000f, -0.00094604492187500000f, - -0.00189208984375000000f, -0.00540161132812500090f, - 0.00012207031250000000f, -0.00213623046875000000f, - 0.00106811523437500000f, 0.01382446289062500000f, - 0.00448608398437500000f, -0.00753784179687500000f, - -0.01000976562500000000f, 0.00308227539062500000f, - 0.00061035156250000000f, -0.00347900390625000000f, - 0.00448608398437500000f, 0.00329589843750000000f, - -0.00363159179687500000f, -0.00332641601562499960f, - -0.00311279296875000000f, -0.00726318359375000000f, - 0.00167846679687500000f, -0.00311279296875000000f, - 0.00527954101562500000f, -0.00271606445312500000f, - 0.00393676757812500000f, 0.00421142578125000000f, - -0.01007080078124999800f, -0.00488281250000000000f, - 0.01480102539062500000f, 0.00469970703125000000f, - -0.00180053710937500000f, -0.00518798828125000000f, - -0.00061035156250000000f, -0.00103759765625000000f, - -0.00796508789062500000f, -0.00122070312500000000f, - -0.00393676757812500000f, 0.00234985351562500000f, - -0.00256347656250000000f, 0.00210571289062500000f, - 0.00253295898437500040f, 0.00488281250000000000f, - 0.00515747070312500000f, 0.00192260742187500000f, - -0.01574707031250000000f, 0.00091552734374999989f, - 0.01025390625000000000f, 0.00158691406250000020f, - -0.00000000000000000000f, -0.00158691406250000020f, - -0.00378417968750000000f, 0.00482177734375000000f, - 0.00057983398437500000f, 0.00601196289062499910f, - -0.00030517578125000000f, -0.01144409179687500000f, - 0.01235961914062499800f, 0.00869750976562500000f, - 0.00347900390625000000f, -0.01205444335937500000f, - -0.00143432617187500000f, 0.00598144531250000000f, - 0.00189208984375000000f, 0.00265502929687500000f, - -0.00323486328125000000f, -0.00198364257812500000f, - -0.00228881835937500000f, -0.00210571289062500000f, - -0.00039672851562500005f, 0.00103759765625000000f, - 0.00302124023437500040f, 0.00180053710937500000f, - 0.00253295898437500040f, 0.00299072265625000000f, - 0.00134277343749999980f, 0.00000000000000000000f, - 0.00073242187500000000f, 0.00054931640625000000f, - 0.00051879882812500000f, 0.00213623046875000000f, - -0.00067138671874999989f, 0.00592041015625000000f, - 0.00634765625000000090f, 0.00439453125000000000f, - -0.00241088867187500000f, -0.00045776367187499995f, - 0.00097656250000000000f, -0.00317382812500000040f, - -0.00085449218750000000f, -0.00320434570312500000f, - -0.00567626953124999910f, -0.00646972656250000000f, - -0.00695800781250000000f, -0.00241088867187500000f, - -0.00231933593750000000f, 0.00155639648437500000f, - -0.00216674804687500000f, 0.00219726562500000000f, - 0.00360107421875000000f, -0.00103759765625000000f, - -0.00009155273437500000f, -0.00521850585937500000f, - 0.00015258789062500000f, 0.00006103515625000000f, - -0.00329589843750000000f, -0.00381469726562499960f, - 0.00189208984375000000f, -0.00177001953125000000f, - 0.00177001953125000000f, -0.00369262695312500000f, - 0.00222778320312500000f, -0.01422119140625000000f, - 0.00280761718750000000f, 0.00192260742187500000f, - -0.00286865234375000000f, -0.00238037109375000000f, - -0.00231933593750000000f, 0.00646972656250000000f, - 0.00109863281250000000f, -0.00686645507812500000f, - -0.00216674804687500000f, -0.01080322265625000200f, - 0.00463867187500000000f, 0.00436401367187500000f, - -0.00241088867187500000f, -0.00750732421875000000f, - -0.00155639648437500000f, -0.00094604492187500000f, - -0.00018310546875000000f, -0.00823974609375000000f, - 0.00732421874999999910f, 0.00640869140625000000f, - 0.00091552734374999989f, -0.00479125976562500000f, - -0.00704956054687500000f, 0.00225830078125000000f, - -0.00445556640625000000f, 0.00268554687499999960f, - -0.00833129882812500000f, 0.00476074218750000000f, - 0.00280761718750000000f, 0.00170898437500000000f, - 0.00216674804687500000f, 0.00006103515625000000f, - 0.00970458984375000000f, 0.00500488281250000000f, - 0.00097656250000000000f, -0.00335693359375000000f, - -0.00106811523437500000f, -0.00125122070312500000f, - -0.00289916992187500000f, -0.00323486328125000000f, - 0.00033569335937499995f, 0.00402832031250000000f, - -0.00207519531250000000f, 0.00167846679687500000f, - 0.00375366210937500000f, -0.00253295898437500040f, - -0.00454711914062500000f, 0.00646972656250000000f, - 0.00402832031250000000f, 0.00000000000000000000f, - -0.00592041015625000000f, 0.00167846679687500000f, - 0.00628662109375000000f, -0.00329589843750000000f, - -0.01077270507812500000f, 0.00881958007812500000f, - -0.00595092773437500000f, 0.00003051757812500000f, - 0.00711059570312500000f, -0.00067138671874999989f, - -0.00183105468749999980f, 0.00061035156250000000f, - 0.00079345703125000011f, 0.00207519531250000000f, - 0.00506591796875000090f, 0.00082397460937500000f, - -0.00177001953125000000f, 0.00396728515625000000f, - 0.00341796875000000000f, 0.00326538085937500000f, - 0.00082397460937500000f, -0.00503540039062499910f, - 0.00350952148437500040f, -0.00283813476562499960f, - -0.00112915039062500000f, 0.00115966796875000000f, - 0.00253295898437500040f, 0.01473999023437500000f, - 0.00198364257812500000f, -0.00698852539062499910f, - -0.00039672851562500005f, 0.00479125976562500000f, - 0.00259399414062500000f, 0.00152587890625000000f, - 0.00415039062500000000f, 0.00030517578125000000f, - 0.00097656250000000000f, 0.00253295898437500040f, - 0.00250244140625000000f, 0.00167846679687500000f, - 0.00015258789062500000f, -0.00027465820312500000f, - -0.00158691406250000020f, -0.00238037109375000000f, - -0.00247192382812500000f, -0.00155639648437500000f, - 0.00122070312500000000f, 0.00054931640625000000f, - -0.00387573242187500000f, -0.00683593750000000000f, - -0.00125122070312500000f, 0.00161743164062500000f, - -0.00640869140625000000f, -0.00344848632812500000f, - 0.00073242187500000000f, -0.00051879882812500000f, - -0.00570678710937500090f, -0.00271606445312500000f, - 0.00024414062500000000f, 0.00369262695312500000f, - 0.00253295898437500040f, 0.00234985351562500000f, - 0.00277709960937500000f, -0.00225830078125000000f, - -0.00106811523437500000f, -0.00341796875000000000f, - -0.00491333007812500000f, -0.00527954101562500000f, - 0.00311279296875000000f, 0.00402832031250000000f, - -0.00381469726562499960f, -0.00186157226562500000f, - 0.00314331054687500000f, -0.00793457031250000000f, - 0.00158691406250000020f, 0.00506591796875000090f, - -0.00097656250000000000f, -0.00476074218750000000f, - -0.00265502929687500000f, -0.00170898437500000000f, - 0.00183105468749999980f, -0.00213623046875000000f, - -0.00378417968750000000f, 0.00738525390625000000f, - 0.00347900390625000000f, -0.00765991210937500090f, - -0.00506591796875000090f, 0.00613403320312500000f, - 0.00387573242187500000f, 0.00085449218750000000f, - -0.00033569335937499995f, 0.00070190429687500000f, - -0.00244140625000000000f, -0.00350952148437500040f, - -0.00061035156250000000f, -0.00155639648437500000f, - -0.01062011718750000000f, 0.01037597656250000000f, - -0.00103759765625000000f, 0.00405883789062500000f, - 0.00039672851562500005f, 0.00280761718750000000f, - -0.00378417968750000000f, -0.00415039062500000000f, - -0.00366210937499999960f, -0.00079345703125000011f, - -0.00018310546875000000f, 0.00051879882812500000f, - 0.00085449218750000000f, 0.00064086914062500000f, - 0.00366210937499999960f, -0.00512695312500000000f, - 0.00488281250000000000f, -0.00106811523437500000f, - 0.00350952148437500040f, 0.00085449218750000000f, - 0.00027465820312500000f, 0.00021362304687500000f, - -0.00170898437500000000f, 0.00119018554687500000f, - 0.00476074218750000000f, 0.00781250000000000000f, - -0.00054931640625000000f, 0.00003051757812500000f, - 0.00845336914062500000f, 0.00250244140625000000f, - -0.00213623046875000000f, -0.00439453125000000000f, - -0.00268554687499999960f, -0.00039672851562500005f, - -0.00180053710937500000f, -0.00479125976562500000f, - 0.00024414062500000000f, -0.00408935546875000000f, - 0.00064086914062500000f, -0.00122070312500000000f, - 0.00177001953125000000f, -0.00064086914062500000f, - 0.00592041015625000000f, -0.00842285156250000000f, - 0.00296020507812500000f, 0.00851440429687500000f, - -0.00170898437500000000f, -0.00427246093750000000f, - 0.00381469726562499960f, 0.00173950195312500000f, - -0.00561523437500000000f, -0.00622558593750000000f, - -0.00213623046875000000f, -0.00006103515625000000f, - 0.00390625000000000000f, -0.00616455078125000000f, - -0.00238037109375000000f, 0.00701904296875000090f, - -0.00070190429687500000f, 0.00491333007812500000f, - -0.00311279296875000000f, 0.00003051757812500000f, - 0.00003051757812500000f, 0.00549316406250000000f, - -0.00094604492187500000f, -0.00262451171875000000f, - -0.00509643554687500000f, -0.00173950195312500000f, - -0.00183105468749999980f, 0.00082397460937500000f, - -0.00039672851562500005f, 0.00302124023437500040f, - 0.00329589843750000000f, 0.00338745117187500000f, - 0.00231933593750000000f, 0.00210571289062500000f, - 0.00103759765625000000f, -0.00064086914062500000f, - 0.00161743164062500000f, 0.00115966796875000000f, - 0.00103759765625000000f, 0.00238037109375000000f, - 0.00222778320312500000f, 0.00668334960937500090f, - 0.00155639648437500000f, 0.00045776367187499995f, - -0.00219726562500000000f, -0.00314331054687500000f, - -0.00631713867187499910f, 0.00091552734374999989f, - 0.00650024414062500000f, -0.00042724609375000000f, - 0.00094604492187500000f, -0.00286865234375000000f, - -0.00122070312500000000f, -0.00439453125000000000f, - 0.00204467773437500000f, 0.00012207031250000000f, - 0.00320434570312500000f, 0.00180053710937500000f, - -0.00732421874999999910f, 0.00076293945312500000f, - 0.00744628906250000000f, 0.00210571289062500000f, - 0.00177001953125000000f, 0.00070190429687500000f, - -0.00073242187500000000f, -0.00015258789062500000f, - -0.00045776367187499995f, -0.00405883789062500000f, - -0.00216674804687500000f, -0.00204467773437500000f, - 0.00552368164062500000f, 0.00088500976562500000f, - -0.00137329101562500000f, 0.00369262695312500000f, - 0.00292968750000000000f, 0.00155639648437500000f, - -0.00219726562500000000f, -0.00161743164062500000f, - 0.00170898437500000000f, -0.00466918945312500000f, - -0.00082397460937500000f, 0.00259399414062500000f, - 0.00558471679687500000f, 0.00643920898437500000f, - 0.00320434570312500000f, -0.00103759765625000000f, - -0.00140380859375000000f, 0.00131225585937500000f, - -0.00219726562500000000f, -0.00283813476562499960f, - 0.00109863281250000000f, -0.00390625000000000000f, - 0.00088500976562500000f, 0.00338745117187500000f, - -0.00289916992187500000f, -0.00476074218750000000f, - -0.00546264648437500000f, -0.00717163085937500000f, - 0.00064086914062500000f, -0.00119018554687500000f, - -0.00216674804687500000f, -0.00100708007812500000f, - -0.00186157226562500000f, -0.00769042968750000000f, - 0.00701904296875000090f, -0.00399780273437500000f, - 0.00479125976562500000f, -0.00064086914062500000f, - -0.00259399414062500000f, -0.00085449218750000000f, - -0.00375366210937500000f, 0.00244140625000000000f, - -0.00488281250000000000f, 0.00192260742187500000f, - 0.00143432617187500000f, -0.00018310546875000000f, - -0.00149536132812500000f, -0.00292968750000000000f, - -0.00057983398437500000f, 0.00051879882812500000f, - -0.00177001953125000000f, 0.00051879882812500000f, - -0.00000000000000000000f, -0.00039672851562500005f, - -0.00518798828125000000f, 0.00076293945312500000f, - -0.00106811523437500000f, 0.00180053710937500000f, - 0.00030517578125000000f, -0.00094604492187500000f, - -0.01260375976562500000f, 0.00247192382812500000f, - 0.00189208984375000000f, 0.00054931640625000000f, - -0.00500488281250000000f, 0.00747680664062500000f, - 0.00280761718750000000f, -0.00503540039062499910f, - 0.00128173828125000000f, 0.00079345703125000011f, - 0.00384521484375000000f, -0.00756835937500000000f, - 0.00588989257812500000f, -0.00167846679687500000f, - 0.00048828125000000000f, 0.00119018554687500000f, - 0.00042724609375000000f, 0.00152587890625000000f - }; - -// const SKP_Silk_NLSF_CBS_FLP SKP_Silk_NLSF_CB1_16_Stage_info_FLP[ NLSF_MSVQ_CB1_16_STAGES ] = -// { -// { 32, &SKP_Silk_NLSF_MSVQ_CB1_16[ 16 * 0 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates[ 0 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_16[ 16 * 32 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates[ 32 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_16[ 16 * 40 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates[ 40 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_16[ 16 * 48 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates[ 48 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_16[ 16 * 56 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates[ 56 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_16[ 16 * 64 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates[ 64 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_16[ 16 * 72 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates[ 72 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_16[ 16 * 80 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates[ 80 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_16[ 16 * 88 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates[ 88 ] }, -// { 8, &SKP_Silk_NLSF_MSVQ_CB1_16[ 16 * 96 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates[ 96 ] } -// }; - - static final SKP_Silk_NLSF_CBS_FLP SKP_Silk_NLSF_CB1_16_Stage_info_FLP[] = - { - new SKP_Silk_NLSF_CBS_FLP(32, SKP_Silk_NLSF_MSVQ_CB1_16, 16*0, SKP_Silk_NLSF_MSVQ_CB1_16_rates, 0), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_16, 16*32, SKP_Silk_NLSF_MSVQ_CB1_16_rates, 32), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_16, 16*40, SKP_Silk_NLSF_MSVQ_CB1_16_rates, 40), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_16, 16*48, SKP_Silk_NLSF_MSVQ_CB1_16_rates, 48), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_16, 16*56, SKP_Silk_NLSF_MSVQ_CB1_16_rates, 56), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_16, 16*64, SKP_Silk_NLSF_MSVQ_CB1_16_rates, 64), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_16, 16*72, SKP_Silk_NLSF_MSVQ_CB1_16_rates, 72), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_16, 16*80, SKP_Silk_NLSF_MSVQ_CB1_16_rates, 80), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_16, 16*88, SKP_Silk_NLSF_MSVQ_CB1_16_rates, 88), - new SKP_Silk_NLSF_CBS_FLP(8, SKP_Silk_NLSF_MSVQ_CB1_16, 16*96, SKP_Silk_NLSF_MSVQ_CB1_16_rates, 96), - }; - -// const SKP_Silk_NLSF_CB_FLP SKP_Silk_NLSF_CB1_16_FLP = -// { -// NLSF_MSVQ_CB1_16_STAGES, -// SKP_Silk_NLSF_CB1_16_Stage_info_FLP, -// SKP_Silk_NLSF_MSVQ_CB1_16_ndelta_min, -// SKP_Silk_NLSF_MSVQ_CB1_16_CDF, -// SKP_Silk_NLSF_MSVQ_CB1_16_CDF_start_ptr, -// SKP_Silk_NLSF_MSVQ_CB1_16_CDF_middle_idx -// }; - static final SKP_Silk_NLSF_CB_FLP SKP_Silk_NLSF_CB1_16_FLP = - new SKP_Silk_NLSF_CB_FLP ( - Silk_tables_NLSF_CB1_16.NLSF_MSVQ_CB1_16_STAGES, - SKP_Silk_NLSF_CB1_16_Stage_info_FLP, - SKP_Silk_NLSF_MSVQ_CB1_16_ndelta_min, - Silk_tables_NLSF_CB1_16.SKP_Silk_NLSF_MSVQ_CB1_16_CDF, - Silk_tables_NLSF_CB1_16.SKP_Silk_NLSF_MSVQ_CB1_16_CDF_start_ptr, - Silk_tables_NLSF_CB1_16.SKP_Silk_NLSF_MSVQ_CB1_16_CDF_middle_idx - ); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_gain.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_gain.java deleted file mode 100644 index 3359be1a6..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_gain.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_tables_gain -{ - static int[][] SKP_Silk_gain_CDF = { - { 0, 18, 45, 94, 181, 320, 519, 777, 1093, 1468, 1909, 2417, 2997, - 3657, 4404, 5245, 6185, 7228, 8384, 9664, 11069, 12596, - 14244, 16022, 17937, 19979, 22121, 24345, 26646, 29021, - 31454, 33927, 36438, 38982, 41538, 44068, 46532, 48904, - 51160, 53265, 55184, 56904, 58422, 59739, 60858, 61793, - 62568, 63210, 63738, 64165, 64504, 64769, 64976, 65133, - 65249, 65330, 65386, 65424, 65451, 65471, 65487, 65501, - 65513, 65524, 65535 }, - { 0, 214, 581, 1261, 2376, 3920, 5742, 7632, 9449, 11157, 12780, - 14352, 15897, 17427, 18949, 20462, 21957, 23430, 24889, - 26342, 27780, 29191, 30575, 31952, 33345, 34763, 36200, - 37642, 39083, 40519, 41930, 43291, 44602, 45885, 47154, - 48402, 49619, 50805, 51959, 53069, 54127, 55140, 56128, - 57101, 58056, 58979, 59859, 60692, 61468, 62177, 62812, - 63368, 63845, 64242, 64563, 64818, 65023, 65184, 65306, - 65391, 65447, 65482, 65505, 65521, 65535 } }; - - static final int SKP_Silk_gain_CDF_offset = 32; - - static int[] SKP_Silk_delta_gain_CDF = { - 0, 2358, 3856, 7023, 15376, 53058, 59135, 61555, - 62784, 63498, 63949, 64265, 64478, 64647, 64783, 64894, - 64986, 65052, 65113, 65169, 65213, 65252, 65284, 65314, - 65338, 65359, 65377, 65392, 65403, 65415, 65424, 65432, - 65440, 65448, 65455, 65462, 65470, 65477, 65484, 65491, - 65499, 65506, 65513, 65521, 65528, 65535 - }; - - static final int SKP_Silk_delta_gain_CDF_offset = 5; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_other.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_other.java deleted file mode 100644 index 197d2f98e..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_other.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_tables_other -{ - /* Piece-wise linear mapping from bitrate in kbps to coding quality in dB SNR */ - static final int[] TargetRate_table_NB = - { - 0, 8000, 9000, 11000, 13000, 16000, 22000, 100000 - }; - - static final int[] TargetRate_table_MB = { - 0, 10000, 12000, 14000, 17000, 21000, 28000, 100000 - }; - - static final int[] TargetRate_table_WB = { - 0, 11000, 14000, 17000, 21000, 26000, 36000, 100000 - }; - - static final int[] TargetRate_table_SWB = { - 0, 13000, 16000, 19000, 25000, 32000, 46000, 100000 - }; - - static final int[] SNR_table_Q1 = { - 19, 31, 35, 39, 43, 47, 54, 59 - }; - - static final int[] SNR_table_one_bit_per_sample_Q7 = { - 1984, 2240, 2408, 2708 - }; - - /* Filter coeficicnts for HP filter: 4. Order filter implementad as two biquad filters */ - static final short[][] SKP_Silk_SWB_detect_B_HP_Q13 = { - {575, -948, 575}, {575, -221, 575}, {575, 104, 575} - }; - static final short[][] SKP_Silk_SWB_detect_A_HP_Q13 = { - {14613, 6868}, {12883, 7337}, {11586, 7911} - }; - - /* Decoder high-pass filter coefficients for 24 kHz sampling, -6 dB @ 44 Hz */ - static final short[] SKP_Silk_Dec_A_HP_24 = {-16220, 8030}; // second order AR coefs, Q13 - static final short[] SKP_Silk_Dec_B_HP_24 = {8000, -16000, 8000}; // second order MA coefs, Q13 - - /* Decoder high-pass filter coefficients for 16 kHz sampling, - 6 dB @ 46 Hz */ - static final short[] SKP_Silk_Dec_A_HP_16 = {-16127, 7940}; // second order AR coefs, Q13 - static final short[] SKP_Silk_Dec_B_HP_16 = {8000, -16000, 8000}; // second order MA coefs, Q13 - - - /* Decoder high-pass filter coefficients for 12 kHz sampling, -6 dB @ 44 Hz */ - static final short[] SKP_Silk_Dec_A_HP_12 = {-16043, 7859}; // second order AR coefs, Q13 - static final short[] SKP_Silk_Dec_B_HP_12 = {8000, -16000, 8000}; // second order MA coefs, Q13 - - - /* Decoder high-pass filter coefficients for 8 kHz sampling, -6 dB @ 43 Hz */ - static final short[] SKP_Silk_Dec_A_HP_8 = {-15885, 7710}; // second order AR coefs, Q13 - static final short[] SKP_Silk_Dec_B_HP_8 = {8000, -16000, 8000}; // second order MA coefs, Q13 - - /* table for LSB coding */ - static final int[] SKP_Silk_lsb_CDF = {0, 40000, 65535}; - - /* tables for LTPScale */ - static final int[] SKP_Silk_LTPscale_CDF = {0, 32000, 48000, 65535}; - static final int SKP_Silk_LTPscale_offset = 2; - - /* tables for VAD flag */ - static final int[] SKP_Silk_vadflag_CDF = {0, 22000, 65535}; // 66% for speech, 33% for no speech - static final int SKP_Silk_vadflag_offset =1; - - /* tables for sampling rate */ - static final int[] SKP_Silk_SamplingRates_table = {8, 12, 16, 24}; - static final int[] SKP_Silk_SamplingRates_CDF = {0, 16000, 32000, 48000, 65535}; - static final int SKP_Silk_SamplingRates_offset = 2; - - /* tables for NLSF interpolation factor */ - static final int[] SKP_Silk_NLSF_interpolation_factor_CDF = {0, 3706, 8703, 19226, 30926, 65535}; - static final int SKP_Silk_NLSF_interpolation_factor_offset = 4; - - /* Table for frame termination indication */ - static final int[] SKP_Silk_FrameTermination_CDF = {0, 20000, 45000, 56000, 65535}; - static final int SKP_Silk_FrameTermination_offset = 2; - - /* Table for random seed */ - static final int[] SKP_Silk_Seed_CDF = {0, 16384, 32768, 49152, 65535}; - static final int SKP_Silk_Seed_offset = 2; - - /* Quantization offsets */ - static final short[][] SKP_Silk_Quantization_Offsets_Q10 = { - { Silk_define.OFFSET_VL_Q10, Silk_define.OFFSET_VH_Q10 }, { Silk_define.OFFSET_UVL_Q10, Silk_define.OFFSET_UVH_Q10 } - }; - - /* Table for LTPScale */ - static final short[] SKP_Silk_LTPScales_table_Q14 = { 15565, 11469, 8192 }; - - - /* Elliptic/Cauer filters designed with 0.1 dB passband ripple, - 80 dB minimum stopband attenuation, and - [0.95 : 0.15 : 0.35] normalized cut off frequencies. */ - - /* Interpolation points for filter coefficients used in the bandwidth transition smoother */ - static final int[][] SKP_Silk_Transition_LP_B_Q28= - { - { 250767114, 501534038, 250767114 }, - { 209867381, 419732057, 209867381 }, - { 170987846, 341967853, 170987846 }, - { 131531482, 263046905, 131531482 }, - { 89306658, 178584282, 89306658 } - }; - - /* Interpolation points for filter coefficients used in the bandwidth transition smoother */ - static final int[][] SKP_Silk_Transition_LP_A_Q28 = - { - { 506393414, 239854379 }, - { 411067935, 169683996 }, - { 306733530, 116694253 }, - { 185807084, 77959395 }, - { 35497197, 57401098 } - }; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_other_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_other_FLP.java deleted file mode 100644 index 42ebd8beb..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_other_FLP.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - * - */ -public class Silk_tables_other_FLP -{ - static float[] SKP_Silk_HarmShapeFIR_FLP = { 16384.0f / 65536.0f, 32767.0f / 65536.0f, 16384.0f / 65536.0f }; - - float[][] SKP_Silk_Quantization_Offsets = - { - { Silk_define.OFFSET_VL_Q10 / 1024.0f, Silk_define.OFFSET_VH_Q10 / 1024.0f }, - { Silk_define.OFFSET_UVL_Q10 / 1024.0f, Silk_define.OFFSET_UVH_Q10 / 1024.0f } - }; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_pitch_lag.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_pitch_lag.java deleted file mode 100644 index ef0a030bf..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_pitch_lag.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_tables_pitch_lag -{ - static int[] SKP_Silk_pitch_lag_NB_CDF = { - 0, 194, 395, 608, 841, 1099, 1391, 1724, - 2105, 2544, 3047, 3624, 4282, 5027, 5865, 6799, - 7833, 8965, 10193, 11510, 12910, 14379, 15905, 17473, - 19065, 20664, 22252, 23814, 25335, 26802, 28206, 29541, - 30803, 31992, 33110, 34163, 35156, 36098, 36997, 37861, - 38698, 39515, 40319, 41115, 41906, 42696, 43485, 44273, - 45061, 45847, 46630, 47406, 48175, 48933, 49679, 50411, - 51126, 51824, 52502, 53161, 53799, 54416, 55011, 55584, - 56136, 56666, 57174, 57661, 58126, 58570, 58993, 59394, - 59775, 60134, 60472, 60790, 61087, 61363, 61620, 61856, - 62075, 62275, 62458, 62625, 62778, 62918, 63045, 63162, - 63269, 63368, 63459, 63544, 63623, 63698, 63769, 63836, - 63901, 63963, 64023, 64081, 64138, 64194, 64248, 64301, - 64354, 64406, 64457, 64508, 64558, 64608, 64657, 64706, - 64754, 64803, 64851, 64899, 64946, 64994, 65041, 65088, - 65135, 65181, 65227, 65272, 65317, 65361, 65405, 65449, - 65492, 65535 - }; - - static final int SKP_Silk_pitch_lag_NB_CDF_offset = 43; - - static int[] SKP_Silk_pitch_contour_NB_CDF = { - 0, 14445, 18587, 25628, 30013, 34859, 40597, 48426, - 54460, 59033, 62990, 65535 - }; - - static final int SKP_Silk_pitch_contour_NB_CDF_offset = 5; - - static int[] SKP_Silk_pitch_lag_MB_CDF = { - 0, 132, 266, 402, 542, 686, 838, 997, - 1167, 1349, 1546, 1760, 1993, 2248, 2528, 2835, - 3173, 3544, 3951, 4397, 4882, 5411, 5984, 6604, - 7270, 7984, 8745, 9552, 10405, 11300, 12235, 13206, - 14209, 15239, 16289, 17355, 18430, 19507, 20579, 21642, - 22688, 23712, 24710, 25677, 26610, 27507, 28366, 29188, - 29971, 30717, 31427, 32104, 32751, 33370, 33964, 34537, - 35091, 35630, 36157, 36675, 37186, 37692, 38195, 38697, - 39199, 39701, 40206, 40713, 41222, 41733, 42247, 42761, - 43277, 43793, 44309, 44824, 45336, 45845, 46351, 46851, - 47347, 47836, 48319, 48795, 49264, 49724, 50177, 50621, - 51057, 51484, 51902, 52312, 52714, 53106, 53490, 53866, - 54233, 54592, 54942, 55284, 55618, 55944, 56261, 56571, - 56873, 57167, 57453, 57731, 58001, 58263, 58516, 58762, - 58998, 59226, 59446, 59656, 59857, 60050, 60233, 60408, - 60574, 60732, 60882, 61024, 61159, 61288, 61410, 61526, - 61636, 61742, 61843, 61940, 62033, 62123, 62210, 62293, - 62374, 62452, 62528, 62602, 62674, 62744, 62812, 62879, - 62945, 63009, 63072, 63135, 63196, 63256, 63316, 63375, - 63434, 63491, 63549, 63605, 63661, 63717, 63772, 63827, - 63881, 63935, 63988, 64041, 64094, 64147, 64199, 64252, - 64304, 64356, 64409, 64461, 64513, 64565, 64617, 64669, - 64721, 64773, 64824, 64875, 64925, 64975, 65024, 65072, - 65121, 65168, 65215, 65262, 65308, 65354, 65399, 65445, - 65490, 65535 - }; - - static final int SKP_Silk_pitch_lag_MB_CDF_offset = 64; - - static final int[] SKP_Silk_pitch_lag_WB_CDF = { - 0, 106, 213, 321, 429, 539, 651, 766, - 884, 1005, 1132, 1264, 1403, 1549, 1705, 1870, - 2047, 2236, 2439, 2658, 2893, 3147, 3420, 3714, - 4030, 4370, 4736, 5127, 5546, 5993, 6470, 6978, - 7516, 8086, 8687, 9320, 9985, 10680, 11405, 12158, - 12938, 13744, 14572, 15420, 16286, 17166, 18057, 18955, - 19857, 20759, 21657, 22547, 23427, 24293, 25141, 25969, - 26774, 27555, 28310, 29037, 29736, 30406, 31048, 31662, - 32248, 32808, 33343, 33855, 34345, 34815, 35268, 35704, - 36127, 36537, 36938, 37330, 37715, 38095, 38471, 38844, - 39216, 39588, 39959, 40332, 40707, 41084, 41463, 41844, - 42229, 42615, 43005, 43397, 43791, 44186, 44583, 44982, - 45381, 45780, 46179, 46578, 46975, 47371, 47765, 48156, - 48545, 48930, 49312, 49690, 50064, 50433, 50798, 51158, - 51513, 51862, 52206, 52544, 52877, 53204, 53526, 53842, - 54152, 54457, 54756, 55050, 55338, 55621, 55898, 56170, - 56436, 56697, 56953, 57204, 57449, 57689, 57924, 58154, - 58378, 58598, 58812, 59022, 59226, 59426, 59620, 59810, - 59994, 60173, 60348, 60517, 60681, 60840, 60993, 61141, - 61284, 61421, 61553, 61679, 61800, 61916, 62026, 62131, - 62231, 62326, 62417, 62503, 62585, 62663, 62737, 62807, - 62874, 62938, 62999, 63057, 63113, 63166, 63217, 63266, - 63314, 63359, 63404, 63446, 63488, 63528, 63567, 63605, - 63642, 63678, 63713, 63748, 63781, 63815, 63847, 63879, - 63911, 63942, 63973, 64003, 64033, 64063, 64092, 64121, - 64150, 64179, 64207, 64235, 64263, 64291, 64319, 64347, - 64374, 64401, 64428, 64455, 64481, 64508, 64534, 64560, - 64585, 64610, 64635, 64660, 64685, 64710, 64734, 64758, - 64782, 64807, 64831, 64855, 64878, 64902, 64926, 64950, - 64974, 64998, 65022, 65045, 65069, 65093, 65116, 65139, - 65163, 65186, 65209, 65231, 65254, 65276, 65299, 65321, - 65343, 65364, 65386, 65408, 65429, 65450, 65471, 65493, - 65514, 65535 - }; - - static final int SKP_Silk_pitch_lag_WB_CDF_offset = 86; - - static int[] SKP_Silk_pitch_lag_SWB_CDF = { - 0, 253, 505, 757, 1008, 1258, 1507, 1755, - 2003, 2249, 2494, 2738, 2982, 3225, 3469, 3713, - 3957, 4202, 4449, 4698, 4949, 5203, 5460, 5720, - 5983, 6251, 6522, 6798, 7077, 7361, 7650, 7942, - 8238, 8539, 8843, 9150, 9461, 9775, 10092, 10411, - 10733, 11057, 11383, 11710, 12039, 12370, 12701, 13034, - 13368, 13703, 14040, 14377, 14716, 15056, 15398, 15742, - 16087, 16435, 16785, 17137, 17492, 17850, 18212, 18577, - 18946, 19318, 19695, 20075, 20460, 20849, 21243, 21640, - 22041, 22447, 22856, 23269, 23684, 24103, 24524, 24947, - 25372, 25798, 26225, 26652, 27079, 27504, 27929, 28352, - 28773, 29191, 29606, 30018, 30427, 30831, 31231, 31627, - 32018, 32404, 32786, 33163, 33535, 33902, 34264, 34621, - 34973, 35320, 35663, 36000, 36333, 36662, 36985, 37304, - 37619, 37929, 38234, 38535, 38831, 39122, 39409, 39692, - 39970, 40244, 40513, 40778, 41039, 41295, 41548, 41796, - 42041, 42282, 42520, 42754, 42985, 43213, 43438, 43660, - 43880, 44097, 44312, 44525, 44736, 44945, 45153, 45359, - 45565, 45769, 45972, 46175, 46377, 46578, 46780, 46981, - 47182, 47383, 47585, 47787, 47989, 48192, 48395, 48599, - 48804, 49009, 49215, 49422, 49630, 49839, 50049, 50259, - 50470, 50682, 50894, 51107, 51320, 51533, 51747, 51961, - 52175, 52388, 52601, 52813, 53025, 53236, 53446, 53655, - 53863, 54069, 54274, 54477, 54679, 54879, 55078, 55274, - 55469, 55662, 55853, 56042, 56230, 56415, 56598, 56779, - 56959, 57136, 57311, 57484, 57654, 57823, 57989, 58152, - 58314, 58473, 58629, 58783, 58935, 59084, 59230, 59373, - 59514, 59652, 59787, 59919, 60048, 60174, 60297, 60417, - 60533, 60647, 60757, 60865, 60969, 61070, 61167, 61262, - 61353, 61442, 61527, 61609, 61689, 61765, 61839, 61910, - 61979, 62045, 62109, 62170, 62230, 62287, 62343, 62396, - 62448, 62498, 62547, 62594, 62640, 62685, 62728, 62770, - 62811, 62852, 62891, 62929, 62967, 63004, 63040, 63075, - 63110, 63145, 63178, 63212, 63244, 63277, 63308, 63340, - 63371, 63402, 63432, 63462, 63491, 63521, 63550, 63578, - 63607, 63635, 63663, 63690, 63718, 63744, 63771, 63798, - 63824, 63850, 63875, 63900, 63925, 63950, 63975, 63999, - 64023, 64046, 64069, 64092, 64115, 64138, 64160, 64182, - 64204, 64225, 64247, 64268, 64289, 64310, 64330, 64351, - 64371, 64391, 64411, 64431, 64450, 64470, 64489, 64508, - 64527, 64545, 64564, 64582, 64600, 64617, 64635, 64652, - 64669, 64686, 64702, 64719, 64735, 64750, 64766, 64782, - 64797, 64812, 64827, 64842, 64857, 64872, 64886, 64901, - 64915, 64930, 64944, 64959, 64974, 64988, 65003, 65018, - 65033, 65048, 65063, 65078, 65094, 65109, 65125, 65141, - 65157, 65172, 65188, 65204, 65220, 65236, 65252, 65268, - 65283, 65299, 65314, 65330, 65345, 65360, 65375, 65390, - 65405, 65419, 65434, 65449, 65463, 65477, 65492, 65506, - 65521, 65535 - }; - - static final int SKP_Silk_pitch_lag_SWB_CDF_offset = 128; - - static int[] SKP_Silk_pitch_contour_CDF = { - 0, 372, 843, 1315, 1836, 2644, 3576, 4719, - 6088, 7621, 9396, 11509, 14245, 17618, 20777, 24294, - 27992, 33116, 40100, 44329, 47558, 50679, 53130, 55557, - 57510, 59022, 60285, 61345, 62316, 63140, 63762, 64321, - 64729, 65099, 65535 - }; - - static final int SKP_Silk_pitch_contour_CDF_offset = 17; - - static int[] SKP_Silk_pitch_delta_CDF = { - 0, 343, 740, 1249, 1889, 2733, 3861, 5396, - 7552, 10890, 16053, 24152, 30220, 34680, 37973, 40405, - 42243, 43708, 44823, 45773, 46462, 47055, 65535 - }; - - static final int SKP_Silk_pitch_delta_CDF_offset = 11; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_pulses_per_block.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_pulses_per_block.java deleted file mode 100644 index 68d1cbc28..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_pulses_per_block.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_tables_pulses_per_block -{ - static int[] SKP_Silk_max_pulses_table = { - 6, 8, 12, 18 - }; - - static int[][] SKP_Silk_pulses_per_block_CDF = - { - { - 0, 47113, 61501, 64590, 65125, 65277, 65352, 65407, - 65450, 65474, 65488, 65501, 65508, 65514, 65516, 65520, - 65521, 65523, 65524, 65526, 65535 - }, - { - 0, 26368, 47760, 58803, 63085, 64567, 65113, 65333, - 65424, 65474, 65498, 65511, 65517, 65520, 65523, 65525, - 65526, 65528, 65529, 65530, 65535 - }, - { - 0, 9601, 28014, 45877, 57210, 62560, 64611, 65260, - 65447, 65500, 65511, 65519, 65521, 65525, 65526, 65529, - 65530, 65531, 65532, 65534, 65535 - }, - { - 0, 3351, 12462, 25972, 39782, 50686, 57644, 61525, - 63521, 64506, 65009, 65255, 65375, 65441, 65471, 65488, - 65497, 65505, 65509, 65512, 65535 - }, - { - 0, 488, 2944, 9295, 19712, 32160, 43976, 53121, - 59144, 62518, 64213, 65016, 65346, 65470, 65511, 65515, - 65525, 65529, 65531, 65534, 65535 - }, - { - 0, 17013, 30405, 40812, 48142, 53466, 57166, 59845, - 61650, 62873, 63684, 64223, 64575, 64811, 64959, 65051, - 65111, 65143, 65165, 65183, 65535 - }, - { - 0, 2994, 8323, 15845, 24196, 32300, 39340, 45140, - 49813, 53474, 56349, 58518, 60167, 61397, 62313, 62969, - 63410, 63715, 63906, 64056, 65535 - }, - { - 0, 88, 721, 2795, 7542, 14888, 24420, 34593, - 43912, 51484, 56962, 60558, 62760, 64037, 64716, 65069, - 65262, 65358, 65398, 65420, 65535 - }, - { - 0, 287, 789, 2064, 4398, 8174, 13534, 20151, - 27347, 34533, 41295, 47242, 52070, 55772, 58458, 60381, - 61679, 62533, 63109, 63519, 65535 - }, - { - 0, 1, 3, 91, 4521, 14708, 28329, 41955, - 52116, 58375, 61729, 63534, 64459, 64924, 65092, 65164, - 65182, 65198, 65203, 65211, 65535 - } - }; - - static final int SKP_Silk_pulses_per_block_CDF_offset = 6; - - static short[][] SKP_Silk_pulses_per_block_BITS_Q6 = - { - { - 30, 140, 282, 444, 560, 625, 654, 677, - 731, 780, 787, 844, 859, 960, 896, 1024, - 960, 1024, 960, 821 - }, - { - 84, 103, 164, 252, 350, 442, 526, 607, - 663, 731, 787, 859, 923, 923, 960, 1024, - 960, 1024, 1024, 875 - }, - { - 177, 117, 120, 162, 231, 320, 426, 541, - 657, 803, 832, 960, 896, 1024, 923, 1024, - 1024, 1024, 960, 1024 - }, - { - 275, 182, 146, 144, 166, 207, 261, 322, - 388, 450, 516, 582, 637, 710, 762, 821, - 832, 896, 923, 734 - }, - { - 452, 303, 216, 170, 153, 158, 182, 220, - 274, 337, 406, 489, 579, 681, 896, 811, - 896, 960, 923, 1024 - }, - { - 125, 147, 170, 202, 232, 265, 295, 332, - 368, 406, 443, 483, 520, 563, 606, 646, - 704, 739, 757, 483 - }, - { - 285, 232, 200, 190, 193, 206, 224, 244, - 266, 289, 315, 340, 367, 394, 425, 462, - 496, 539, 561, 350 - }, - { - 611, 428, 319, 242, 202, 178, 172, 180, - 199, 229, 268, 313, 364, 422, 482, 538, - 603, 683, 739, 586 - }, - { - 501, 450, 364, 308, 264, 231, 212, 204, - 204, 210, 222, 241, 265, 295, 326, 362, - 401, 437, 469, 321 - } - }; - - static int[][] SKP_Silk_rate_levels_CDF = - { - { - 0, 2005, 12717, 20281, 31328, 36234, 45816, 57753, - 63104, 65535 - }, - { - 0, 8553, 23489, 36031, 46295, 53519, 56519, 59151, - 64185, 65535 - } - }; - - static final int SKP_Silk_rate_levels_CDF_offset = 4; - - static short[][] SKP_Silk_rate_levels_BITS_Q6 = - { - { - 322, 167, 199, 164, 239, 178, 157, 231, - 304 - }, - { - 188, 137, 153, 171, 204, 285, 297, 237, - 358 - } - }; - - static int[] SKP_Silk_shell_code_table0 = { - 0, 32748, 65535, 0, 9505, 56230, 65535, 0, - 4093, 32204, 61720, 65535, 0, 2285, 16207, 48750, - 63424, 65535, 0, 1709, 9446, 32026, 55752, 63876, - 65535, 0, 1623, 6986, 21845, 45381, 59147, 64186, - 65535 - }; - - static int[] SKP_Silk_shell_code_table1 = { - 0, 32691, 65535, 0, 12782, 52752, 65535, 0, - 4847, 32665, 60899, 65535, 0, 2500, 17305, 47989, - 63369, 65535, 0, 1843, 10329, 32419, 55433, 64277, - 65535, 0, 1485, 7062, 21465, 43414, 59079, 64623, - 65535, 0, 0, 4841, 14797, 31799, 49667, 61309, - 65535, 65535, 0, 0, 0, 8032, 21695, 41078, - 56317, 65535, 65535, 65535 - }; - - static int[] SKP_Silk_shell_code_table2 = { - 0, 32615, 65535, 0, 14447, 50912, 65535, 0, - 6301, 32587, 59361, 65535, 0, 3038, 18640, 46809, - 62852, 65535, 0, 1746, 10524, 32509, 55273, 64278, - 65535, 0, 1234, 6360, 21259, 43712, 59651, 64805, - 65535, 0, 1020, 4461, 14030, 32286, 51249, 61904, - 65100, 65535, 0, 851, 3435, 10006, 23241, 40797, - 55444, 63009, 65252, 65535, 0, 0, 2075, 7137, - 17119, 31499, 46982, 58723, 63976, 65535, 65535, 0, - 0, 0, 3820, 11572, 23038, 37789, 51969, 61243, - 65535, 65535, 65535, 0, 0, 0, 0, 6882, - 16828, 30444, 44844, 57365, 65535, 65535, 65535, 65535, - 0, 0, 0, 0, 0, 10093, 22963, 38779, - 54426, 65535, 65535, 65535, 65535, 65535 - }; - - static int[] SKP_Silk_shell_code_table3 = { - 0, 32324, 65535, 0, 15328, 49505, 65535, 0, - 7474, 32344, 57955, 65535, 0, 3944, 19450, 45364, - 61873, 65535, 0, 2338, 11698, 32435, 53915, 63734, - 65535, 0, 1506, 7074, 21778, 42972, 58861, 64590, - 65535, 0, 1027, 4490, 14383, 32264, 50980, 61712, - 65043, 65535, 0, 760, 3022, 9696, 23264, 41465, - 56181, 63253, 65251, 65535, 0, 579, 2256, 6873, - 16661, 31951, 48250, 59403, 64198, 65360, 65535, 0, - 464, 1783, 5181, 12269, 24247, 39877, 53490, 61502, - 64591, 65410, 65535, 0, 366, 1332, 3880, 9273, - 18585, 32014, 45928, 56659, 62616, 64899, 65483, 65535, - 0, 286, 1065, 3089, 6969, 14148, 24859, 38274, - 50715, 59078, 63448, 65091, 65481, 65535, 0, 0, - 482, 2010, 5302, 10408, 18988, 30698, 43634, 54233, - 60828, 64119, 65288, 65535, 65535, 0, 0, 0, - 1006, 3531, 7857, 14832, 24543, 36272, 47547, 56883, - 62327, 64746, 65535, 65535, 65535, 0, 0, 0, - 0, 1863, 4950, 10730, 19284, 29397, 41382, 52335, - 59755, 63834, 65535, 65535, 65535, 65535, 0, 0, - 0, 0, 0, 2513, 7290, 14487, 24275, 35312, - 46240, 55841, 62007, 65535, 65535, 65535, 65535, 65535, - 0, 0, 0, 0, 0, 0, 3606, 9573, - 18764, 28667, 40220, 51290, 59924, 65535, 65535, 65535, - 65535, 65535, 65535, 0, 0, 0, 0, 0, - 0, 0, 4879, 13091, 23376, 36061, 49395, 59315, - 65535, 65535, 65535, 65535, 65535, 65535, 65535 - }; - - static int[] SKP_Silk_shell_code_table_offsets = { - 0, 0, 3, 7, 12, 18, 25, 33, - 42, 52, 63, 75, 88, 102, 117, 133, - 150, 168, 187 - }; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_sign.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_sign.java deleted file mode 100644 index 90e7173a4..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_sign.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_tables_sign -{ - static int[] SKP_Silk_sign_CDF = - { - 37840, 36944, 36251, 35304, - 34715, 35503, 34529, 34296, - 34016, 47659, 44945, 42503, - 40235, 38569, 40254, 37851, - 37243, 36595, 43410, 44121, - 43127, 40978, 38845, 40433, - 38252, 37795, 36637, 59159, - 55630, 51806, 48073, 45036, - 48416, 43857, 42678, 41146, - }; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_type_offset.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_type_offset.java deleted file mode 100644 index 91295d09d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_tables_type_offset.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_tables_type_offset -{ - static final int[] SKP_Silk_type_offset_CDF = { - 0, 37522, 41030, 44212, 65535 - }; - - static final int SKP_Silk_type_offset_CDF_offset = 2; - - static final int[][] SKP_Silk_type_offset_joint_CDF = - { - { - 0, 57686, 61230, 62358, 65535 - }, - { - 0, 18346, 40067, 43659, 65535 - }, - { - 0, 22694, 24279, 35507, 65535 - }, - { - 0, 6067, 7215, 13010, 65535 - } - }; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_typedef.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_typedef.java deleted file mode 100644 index 9b4f386a1..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_typedef.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_typedef -{ - static int SKP_STR_CASEINSENSITIVE_COMPARE(String x, String y) - { - return x.compareTo(y); - } - - static final long SKP_int64_MAX = 0x7FFFFFFFFFFFFFFFL; // 2^63 - 1 - static final long SKP_int64_MIN = 0x8000000000000000L; // -2^63 - static final int SKP_int32_MAX = 0x7FFFFFFF; // 2^31 - 1 = 2147483647 - static final int SKP_int32_MIN = 0x80000000; // -2^31 = -2147483648 - static final short SKP_int16_MAX = 0x7FFF; // 2^15 - 1 = 32767 - static final short SKP_int16_MIN = (short)0x8000; // -2^15 = -32768 - static final byte SKP_int8_MAX = 0x7F; // 2^7 - 1 = 127 - static final byte SKP_int8_MIN = (byte)0x80; // -2^7 = -128 - - static final long SKP_uint32_MAX = 0xFFFFFFFFL; // 2^32 - 1 = 4294967295 - static final long SKP_uint32_MIN = 0x00000000L; - static final int SKP_uint16_MAX = 0xFFFF; // 2^16 - 1 = 65535 - static final int SKP_uint16_MIN = 0x0000; - static final short SKP_uint8_MAX = 0xFF; // 2^8 - 1 = 255 - static final short SKP_uint8_MIN = 0x00; - - static final boolean SKP_TRUE = true; - static final boolean SKP_FALSE = false; - - /* assertions */ - static void SKP_assert(boolean COND) - { - assert(COND); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_wrappers_FLP.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_wrappers_FLP.java deleted file mode 100644 index 01f139ac2..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/silk/Silk_wrappers_FLP.java +++ /dev/null @@ -1,536 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.silk; - -/** - * - * @author Jing Dai - * @author Dingxin Xu - */ -public class Silk_wrappers_FLP -{ - /* Wrappers. Calls flp / fix code */ - static long ar2_q13_file_offset = 0; - static long x_16_file_offset = 0; - static int frame_cnt = 0; - - /* Convert AR filter coefficients to NLSF parameters */ - static void SKP_Silk_A2NLSF_FLP( - float[] pNLSF, /* O NLSF vector [ LPC_order ] */ - float[] pAR, /* I LPC coefficients [ LPC_order ] */ - final int LPC_order /* I LPC order */ - ) - { - int i; - int[] NLSF_fix = new int[ Silk_define.MAX_LPC_ORDER ]; - int[] a_fix_Q16 = new int[ Silk_define.MAX_LPC_ORDER ]; - - for( i = 0; i < LPC_order; i++ ) - { - a_fix_Q16[ i ] = Silk_SigProc_FLP.SKP_float2int( pAR[ i ] * 65536.0f ); - } - Silk_A2NLSF.SKP_Silk_A2NLSF( NLSF_fix, a_fix_Q16, LPC_order ); - - for( i = 0; i < LPC_order; i++ ) - { - pNLSF[ i ] = NLSF_fix[ i ] * ( 1.0f / 32768.0f ); - } - } - - /* Convert LSF parameters to AR prediction filter coefficients */ - static void SKP_Silk_NLSF2A_stable_FLP( - float [] pAR, /* O LPC coefficients [ LPC_order ] */ - float[] pNLSF, /* I NLSF vector [ LPC_order ] */ - final int LPC_order /* I LPC order */ - ) - { - int i; - int[] NLSF_fix = new int[ Silk_define.MAX_LPC_ORDER ]; - short[] a_fix_Q12 = new short[ Silk_define.MAX_LPC_ORDER ]; - - for( i = 0; i < LPC_order; i++ ) - { - NLSF_fix[ i ] = Silk_SigProc_FLP.SKP_float2int( pNLSF[ i ] * 32768.0f ); - } - - Silk_NLSF2A_stable.SKP_Silk_NLSF2A_stable( a_fix_Q12, NLSF_fix, LPC_order ); - - for( i = 0; i < LPC_order; i++ ) - { - pAR[ i ] = a_fix_Q12[ i ] / 4096.0f; - } - } - - - /* LSF stabilizer, for a single input data vector */ - static void SKP_Silk_NLSF_stabilize_FLP( - float[] pNLSF, /* I/O (Un)stable NLSF vector [ LPC_order ] */ - float[] pNDelta_min, /* I Normalized delta min vector[LPC_order+1]*/ - final int LPC_order /* I LPC order */ - ) - { - int i; - int[] NLSF_Q15 = new int[ Silk_define.MAX_LPC_ORDER ], ndelta_min_Q15 = new int[ Silk_define.MAX_LPC_ORDER + 1 ]; - - for( i = 0; i < LPC_order; i++ ) - { - NLSF_Q15[ i ] = Silk_SigProc_FLP.SKP_float2int( pNLSF[ i ] * 32768.0f ); - ndelta_min_Q15[ i ] = Silk_SigProc_FLP.SKP_float2int( pNDelta_min[ i ] * 32768.0f ); - } - ndelta_min_Q15[ LPC_order ] = Silk_SigProc_FLP.SKP_float2int( pNDelta_min[ LPC_order ] * 32768.0f ); - - /* NLSF stabilizer, for a single input data vector */ - Silk_NLSF_stabilize.SKP_Silk_NLSF_stabilize( NLSF_Q15,0, ndelta_min_Q15, LPC_order ); - - for( i = 0; i < LPC_order; i++ ) - { - pNLSF[ i ] = NLSF_Q15[ i ] * ( 1.0f / 32768.0f ); - } - } - - /* Interpolation function with fixed point rounding */ - static void SKP_Silk_interpolate_wrapper_FLP( - float xi[], /* O Interpolated vector */ - float x0[], /* I First vector */ - float x1[], /* I Second vector */ - final float ifact, /* I Interp. factor, weight on second vector */ - final int d /* I Number of parameters */ - ) - { - int[] x0_int = new int[ Silk_define.MAX_LPC_ORDER ], x1_int = new int[ Silk_define.MAX_LPC_ORDER ], xi_int = new int[ Silk_define.MAX_LPC_ORDER ]; - int ifact_Q2 = ( int )( ifact * 4.0f ); - int i; - - /* Convert input from flp to fix */ - for( i = 0; i < d; i++ ) { - x0_int[ i ] = Silk_SigProc_FLP.SKP_float2int( x0[ i ] * 32768.0f ); - x1_int[ i ] = Silk_SigProc_FLP.SKP_float2int( x1[ i ] * 32768.0f ); - } - - /* Interpolate two vectors */ - Silk_interpolate.SKP_Silk_interpolate( xi_int, x0_int, x1_int, ifact_Q2, d ); - - /* Convert output from fix to flp */ - for( i = 0; i < d; i++ ) - { - xi[ i ] = xi_int[ i ] * ( 1.0f / 32768.0f ); - } - } - - /****************************************/ - /* Floating-point Silk VAD wrapper */ - /****************************************/ - static int SKP_Silk_VAD_FLP( - SKP_Silk_encoder_state_FLP psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP psEncCtrl, /* I/O Encoder control FLP */ - short[] pIn, /* I Input signal */ - int pIn_offset - ) - { - int i, ret; - int[] SA_Q8 = new int[1], SNR_dB_Q7 = new int[1], Tilt_Q15 = new int[1]; - int[] Quality_Bands_Q15 = new int[ Silk_define.VAD_N_BANDS ]; - - ret = Silk_VAD.SKP_Silk_VAD_GetSA_Q8( psEnc.sCmn.sVAD, SA_Q8, SNR_dB_Q7, Quality_Bands_Q15, Tilt_Q15, - pIn,pIn_offset, psEnc.sCmn.frame_length ); - - psEnc.speech_activity = SA_Q8[0] / 256.0f; - for( i = 0; i < Silk_define.VAD_N_BANDS; i++ ) - { - psEncCtrl.input_quality_bands[ i ] = Quality_Bands_Q15[ i ] / 32768.0f; - } - psEncCtrl.input_tilt = Tilt_Q15[0] / 32768.0f; - - return ret; - } - - /****************************************/ - /* Floating-point Silk NSQ wrapper */ - /****************************************/ - static void SKP_Silk_NSQ_wrapper_FLP( - SKP_Silk_encoder_state_FLP psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP psEncCtrl, /* I/O Encoder control FLP */ - float x[], /* I Prefiltered input signal */ - int x_offset, - byte q[], /* O Quantized pulse signal */ - int q_offset, - final int useLBRR /* I LBRR flag */ - ) - { - int i, j; - float tmp_float; - short[] x_16 = new short[ Silk_define.MAX_FRAME_LENGTH ]; - /* Prediction and coding parameters */ - int[] Gains_Q16 = new int[ Silk_define.NB_SUBFR ]; - short[][] PredCoef_Q12 = new short[ 2 ][ Silk_define.MAX_LPC_ORDER ]; - short[] LTPCoef_Q14 = new short[ Silk_define.LTP_ORDER * Silk_define.NB_SUBFR ]; - int LTP_scale_Q14; - - /* Noise shaping parameters */ - /* Testing */ - short[] AR2_Q13 = new short[ Silk_define.NB_SUBFR * Silk_define.SHAPE_LPC_ORDER_MAX ]; - int[] LF_shp_Q14 = new int[ Silk_define.NB_SUBFR ]; /* Packs two int16 coefficients per int32 value */ - int Lambda_Q10; - int[] Tilt_Q14 = new int[ Silk_define.NB_SUBFR ]; - int[] HarmShapeGain_Q14 = new int[ Silk_define.NB_SUBFR ]; - - /* Convert control struct to fix control struct */ - /* Noise shape parameters */ - for( i = 0; i < Silk_define.NB_SUBFR * Silk_define.SHAPE_LPC_ORDER_MAX; i++ ) - { - AR2_Q13[ i ] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FLP.SKP_float2int( psEncCtrl.AR2[ i ] * 8192.0f ) ); - } - - /*TEST************************************************************************/ - /* - * test of the AR2_Q13 - * - */ - short[] ar2_q13 = new short[ Silk_define.NB_SUBFR * Silk_define.SHAPE_LPC_ORDER_MAX ]; - String ar2_q13_filename = "D:/gsoc/ar2_q13"; - -// /* -// * Option 1: -// */ -// DataInputStream ar2_q13_datain = null; -// try -// { -// ar2_q13_datain = new DataInputStream( -// new FileInputStream( -// new File(ar2_q13_filename))); -// -// for( i = 0; i < Silk_define.NB_SUBFR * Silk_define.SHAPE_LPC_ORDER_MAX; i++ ) -// { -// // AR2_Q13[ i ] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FLP.SKP_float2int( psEncCtrl.AR2[ i ] * 8192.0f ) ); -// try -// { -// ar2_q13[i] = ar2_q13_datain.readShort(); -// AR2_Q13[i] = (short) (((ar2_q13[i] << 8) & 0xFF00) | ((ar2_q13[i] >>> 8) & 0x00FF)); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// try -// { -// ar2_q13_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } - /* - * Option 2; - */ -// RandomAccessFile ar2_q13_datain_rand = null; -// try -// { -// ar2_q13_datain_rand = new RandomAccessFile(new File(ar2_q13_filename), "r"); -// try -// { -// ar2_q13_datain_rand.seek(ar2_q13_file_offset); -// for( i = 0; i < Silk_define.NB_SUBFR * Silk_define.SHAPE_LPC_ORDER_MAX; i++ ) -// { -// // AR2_Q13[ i ] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FLP.SKP_float2int( psEncCtrl.AR2[ i ] * 8192.0f ) ); -// try -// { -// ar2_q13[i] = ar2_q13_datain_rand.readShort(); -// AR2_Q13[i] = (short) (((ar2_q13[i] << 8) & 0xFF00) | ((ar2_q13[i] >>> 8) & 0x00FF)); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// ar2_q13_file_offset += i; -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// -// try -// { -// ar2_q13_datain_rand.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// catch (FileNotFoundException e1) -// { -// // TODO Auto-generated catch block -// e1.printStackTrace(); -// } - - /** - * Option 3: - */ -// ar2_q13_filename += frame_cnt; -// DataInputStream ar2_q13_datain = null; -// try -// { -// ar2_q13_datain = new DataInputStream( -// new FileInputStream( -// new File(ar2_q13_filename))); -// -// for( i = 0; i < Silk_define.NB_SUBFR * Silk_define.SHAPE_LPC_ORDER_MAX; i++ ) -// { -// // AR2_Q13[ i ] = (short)Silk_SigProc_FIX.SKP_SAT16( Silk_SigProc_FLP.SKP_float2int( psEncCtrl.AR2[ i ] * 8192.0f ) ); -// try -// { -// ar2_q13[i] = ar2_q13_datain.readShort(); -// AR2_Q13[i] = (short) (((ar2_q13[i] << 8) & 0xFF00) | ((ar2_q13[i] >>> 8) & 0x00FF)); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// try -// { -// ar2_q13_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } - /*TEST End***********************************************************************/ - - for( i = 0; i < Silk_define.NB_SUBFR; i++ ) - { - LF_shp_Q14[ i ] = ( Silk_SigProc_FLP.SKP_float2int( psEncCtrl.LF_AR_shp[ i ] * 16384.0f ) << 16 ) | - ( 0x0000FFFF & Silk_SigProc_FLP.SKP_float2int( psEncCtrl.LF_MA_shp[ i ] * 16384.0f ) ); - Tilt_Q14[ i ] = Silk_SigProc_FLP.SKP_float2int( psEncCtrl.Tilt[ i ] * 16384.0f ); - HarmShapeGain_Q14[ i ] = Silk_SigProc_FLP.SKP_float2int( psEncCtrl.HarmShapeGain[ i ] * 16384.0f ); - } - Lambda_Q10 = Silk_SigProc_FLP.SKP_float2int( psEncCtrl.Lambda * 1024.0f ); - - /* prediction and coding parameters */ - for( i = 0; i < Silk_define.NB_SUBFR * Silk_define.LTP_ORDER; i++ ) - { - LTPCoef_Q14[ i ] = ( short )Silk_SigProc_FLP.SKP_float2int( psEncCtrl.LTPCoef[ i ] * 16384.0f ); - } - - for( j = 0; j < Silk_define.NB_SUBFR >> 1; j++ ) - { - for( i = 0; i < Silk_define.MAX_LPC_ORDER; i++ ) - { - PredCoef_Q12[ j ][ i ] = ( short )Silk_SigProc_FLP.SKP_float2int( psEncCtrl.PredCoef[ j ][ i ] * 4096.0f ); - } - } - - for( i = 0; i < Silk_define.NB_SUBFR; i++ ) - { - tmp_float = Silk_SigProc_FIX.SKP_LIMIT( ( psEncCtrl.Gains[ i ] * 65536.0f ), 2147483000.0f, -2147483000.0f ); - Gains_Q16[ i ] = Silk_SigProc_FLP.SKP_float2int( tmp_float ); - if( psEncCtrl.Gains[ i ] > 0.0f ) - { - assert( tmp_float >= 0.0f ); - assert( Gains_Q16[ i ] >= 0 ); - } - } - - if( psEncCtrl.sCmn.sigtype == Silk_define.SIG_TYPE_VOICED ) { - - LTP_scale_Q14 = Silk_tables_other.SKP_Silk_LTPScales_table_Q14[ psEncCtrl.sCmn.LTP_scaleIndex ]; - } - else - { - LTP_scale_Q14 = 0; - } - - /* Convert input to fix */ - Silk_SigProc_FLP.SKP_float2short_array( x_16,0, x,x_offset, psEnc.sCmn.frame_length ); - - /*TEST************************************************************************/ - /** - * test of x_16 - */ - short x_16_test[] = new short[ Silk_define.MAX_FRAME_LENGTH ]; - String x_16_filename = "D:/gsoc/x_16"; -// /* -// * Option 1: -// */ -// DataInputStream x_16_datain = null; -// try -// { -// x_16_datain = new DataInputStream( -// new FileInputStream( -// new File(x_16_filename))); -// for(int k = 0; k < psEnc.sCmn.frame_length; k++) -// { -// try -// { -// x_16_test[k] = x_16_datain.readShort(); -// x_16[k] = (short) (((x_16_test[k]<<8)&0xFF00)|((x_16_test[k]>>>8)&0x00FF)); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// try -// { -// x_16_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } - - /* - * Option 2: - */ -// RandomAccessFile x_16_datain_rand = null; -// int k; -// try -// { -// x_16_datain_rand = new RandomAccessFile(new File(x_16_filename), "r"); -// try -// { -// x_16_datain_rand.seek(x_16_file_offset); -// for(k = 0; k < psEnc.sCmn.frame_length; k++) -// { -// try -// { -// x_16_test[k] = x_16_datain_rand.readShort(); -// x_16[k] = (short) (((x_16_test[k]<<8)&0xFF00)|((x_16_test[k]>>>8)&0x00FF)); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// x_16_file_offset += k; -// } -// catch (IOException e1) -// { -// // TODO Auto-generated catch block -// e1.printStackTrace(); -// } -// try -// { -// x_16_datain_rand.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } - - /** - * Optino 3: - */ -// x_16_filename += frame_cnt; -// DataInputStream x_16_datain = null; -// try -// { -// x_16_datain = new DataInputStream( -// new FileInputStream( -// new File(x_16_filename))); -// for(int k = 0; k < psEnc.sCmn.frame_length; k++) -// { -// try -// { -// x_16_test[k] = x_16_datain.readShort(); -// x_16[k] = (short) (((x_16_test[k]<<8)&0xFF00)|((x_16_test[k]>>>8)&0x00FF)); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// try -// { -// x_16_datain.close(); -// } -// catch (IOException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// catch (FileNotFoundException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// frame_cnt++; - /*TEST END************************************************************************/ - - /* Call NSQ */ - short[] PredCoef_Q12_dim1_tmp= new short[PredCoef_Q12.length * PredCoef_Q12[0].length]; - int PredCoef_Q12_offset = 0; - for(int PredCoef_Q12_i = 0; PredCoef_Q12_i < PredCoef_Q12.length; PredCoef_Q12_i++) - { - System.arraycopy(PredCoef_Q12[PredCoef_Q12_i],0, PredCoef_Q12_dim1_tmp, PredCoef_Q12_offset, PredCoef_Q12[PredCoef_Q12_i].length); - PredCoef_Q12_offset += PredCoef_Q12[PredCoef_Q12_i].length; - } - if( useLBRR!=0 ) - { -// psEnc.NoiseShapingQuantizer( psEnc.sCmn, psEncCtrl.sCmn, psEnc.sNSQ_LBRR, -// x_16, q, psEncCtrl.sCmn.NLSFInterpCoef_Q2, PredCoef_Q12[ 0 ], LTPCoef_Q14, AR2_Q13, -// HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, Lambda_Q10, LTP_scale_Q14 );\ - psEnc.NoiseShapingQuantizer( psEnc.sCmn, psEncCtrl.sCmn, psEnc.sNSQ_LBRR, - x_16, q, psEncCtrl.sCmn.NLSFInterpCoef_Q2, PredCoef_Q12_dim1_tmp, LTPCoef_Q14, AR2_Q13, - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, Lambda_Q10, LTP_scale_Q14 ); -// psEnc.NoiseShapingQuantizer( &psEnc->sCmn, &psEncCtrl->sCmn, &psEnc->sNSQ_LBRR, -// x_16, q, psEncCtrl->sCmn.NLSFInterpCoef_Q2, PredCoef_Q12[ 0 ], LTPCoef_Q14, AR2_Q13, -// HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, Lambda_Q10, LTP_scale_Q14 ); - } - else - { -// psEnc.NoiseShapingQuantizer( psEnc.sCmn, psEncCtrl.sCmn, psEnc.sNSQ, -// x_16, q, psEncCtrl.sCmn.NLSFInterpCoef_Q2, PredCoef_Q12[ 0 ], LTPCoef_Q14, AR2_Q13, -// HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, Lambda_Q10, LTP_scale_Q14 ); - psEnc.NoiseShapingQuantizer( psEnc.sCmn, psEncCtrl.sCmn, psEnc.sNSQ, - x_16, q, psEncCtrl.sCmn.NLSFInterpCoef_Q2, PredCoef_Q12_dim1_tmp, LTPCoef_Q14, AR2_Q13, - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, Lambda_Q10, LTP_scale_Q14 ); -// psEnc.NoiseShapingQuantizer( &psEnc->sCmn, &psEncCtrl->sCmn, &psEnc->sNSQ, -// x_16, q, psEncCtrl->sCmn.NLSFInterpCoef_Q2, PredCoef_Q12[ 0 ], LTPCoef_Q14, AR2_Q13, -// HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, Lambda_Q10, LTP_scale_Q14 ); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/JNIDecoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/JNIDecoder.java deleted file mode 100644 index 19b9a3f05..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/JNIDecoder.java +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.speex; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.sf.fmj.media.*; - -/** - * Implements a Speex decoder and RTP depacketizer using the native Speex - * library. - * - * @author Lubomir Marinov - */ -public class JNIDecoder - extends AbstractCodecExt -{ - - /** - * The list of Formats of audio data supported as input by - * JNIDecoder instances. - */ - private static final Format[] SUPPORTED_INPUT_FORMATS; - - /** - * The list of Formats of audio data supported as output by - * JNIDecoder instances. - */ - private static final Format[] SUPPORTED_OUTPUT_FORMATS - = new Format[] - { - new AudioFormat( - AudioFormat.LINEAR, - Format.NOT_SPECIFIED, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - Format.byteArray) - }; - - static - { - Speex.assertSpeexIsFunctional(); - - double[] SUPPORTED_INPUT_SAMPLE_RATES - = JNIEncoder.SUPPORTED_INPUT_SAMPLE_RATES; - int supportedInputCount = SUPPORTED_INPUT_SAMPLE_RATES.length; - - SUPPORTED_INPUT_FORMATS = new Format[supportedInputCount]; - for (int i = 0; i < supportedInputCount; i++) - { - SUPPORTED_INPUT_FORMATS[i] - = new AudioFormat( - Constants.SPEEX_RTP, - SUPPORTED_INPUT_SAMPLE_RATES[i], - Format.NOT_SPECIFIED, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - Format.byteArray); - } - } - - /** - * The pointer to the native SpeexBits from which the native Speex - * decoder (i.e. {@link #state}) reads the encoded audio data. - */ - private long bits = 0; - - /** - * The duration in nanoseconds of an output Buffer produced by this - * Codec. - */ - private long duration = 0; - - /** - * The number of bytes from an input Buffer that this - * Codec processes in one call of its - * {@link #process(Buffer, Buffer)}. - */ - private int frameSize = 0; - - /** - * The sample rate configured into {@link #state}. - */ - private int sampleRate = 0; - - /** - * The native Speex decoder represented by this instance. - */ - private long state = 0; - - /** - * Initializes a new JNIDecoder instance. - */ - public JNIDecoder() - { - super( - "Speex JNI Decoder", - AudioFormat.class, - SUPPORTED_OUTPUT_FORMATS); - - inputFormats = SUPPORTED_INPUT_FORMATS; - } - - /** - * @see AbstractCodecExt#doClose() - */ - protected void doClose() - { - // state - if (state != 0) - { - Speex.speex_decoder_destroy(state); - state = 0; - sampleRate = 0; - frameSize = 0; - duration = 0; - } - // bits - Speex.speex_bits_destroy(bits); - bits = 0; - } - - /** - * Opens this Codec and acquires the resources that it needs to - * operate. A call to {@link PlugIn#open()} on this instance will result in - * a call to doOpen only if {@link AbstractCodec#opened} is - * false. All required input and/or output formats are assumed to - * have been set on this Codec before doOpen is called. - * - * @throws ResourceUnavailableException if any of the resources that this - * Codec needs to operate cannot be acquired - * @see AbstractCodecExt#doOpen() - */ - protected void doOpen() - throws ResourceUnavailableException - { - bits = Speex.speex_bits_init(); - if (bits == 0) - throw new ResourceUnavailableException("speex_bits_init"); - } - - /** - * Decodes Speex media from a specific input Buffer - * - * @param inputBuffer input Buffer - * @param outputBuffer output Buffer - * @return BUFFER_PROCESSED_OK if inBuffer has been - * successfully processed - * @see AbstractCodecExt#doProcess(Buffer, Buffer) - */ - protected int doProcess(Buffer inputBuffer, Buffer outputBuffer) - { - Format inputFormat = inputBuffer.getFormat(); - - if ((inputFormat != null) - && (inputFormat != this.inputFormat) - && !inputFormat.equals(this.inputFormat)) - { - if (null == setInputFormat(inputFormat)) - return BUFFER_PROCESSED_FAILED; - } - inputFormat = this.inputFormat; - - /* - * Make sure that the native Speex decoder which is represented by this - * instance is configured to work with the inputFormat. - */ - AudioFormat inputAudioFormat = (AudioFormat) inputFormat; - int inputSampleRate = (int) inputAudioFormat.getSampleRate(); - - if ((state != 0) && (sampleRate != inputSampleRate)) - { - Speex.speex_decoder_destroy(state); - state = 0; - sampleRate = 0; - frameSize = 0; - } - if (state == 0) - { - long mode - = Speex.speex_lib_get_mode( - (inputSampleRate == 16000) - ? Speex.SPEEX_MODEID_WB - : (inputSampleRate == 32000) - ? Speex.SPEEX_MODEID_UWB - : Speex.SPEEX_MODEID_NB); - - if (mode == 0) - return BUFFER_PROCESSED_FAILED; - state = Speex.speex_decoder_init(mode); - if (state == 0) - return BUFFER_PROCESSED_FAILED; - if (Speex.speex_decoder_ctl( - state, - Speex.SPEEX_SET_ENH, - 1) - != 0) - return BUFFER_PROCESSED_FAILED; - if (Speex.speex_decoder_ctl( - state, - Speex.SPEEX_SET_SAMPLING_RATE, - inputSampleRate) - != 0) - return BUFFER_PROCESSED_FAILED; - - int frameSize - = Speex.speex_decoder_ctl(state, Speex.SPEEX_GET_FRAME_SIZE); - - if (frameSize < 0) - return BUFFER_PROCESSED_FAILED; - - sampleRate = inputSampleRate; - this.frameSize = frameSize * 2 /* (sampleSizeInBits / 8) */; - duration = (long) ((frameSize * 1000 * 1000000) / sampleRate); - } - - /* Read the encoded audio data from inputBuffer into the SpeexBits. */ - int inputLength = inputBuffer.getLength(); - - if (inputLength > 0) - { - byte[] input = (byte[]) inputBuffer.getData(); - int inputOffset = inputBuffer.getOffset(); - - Speex.speex_bits_read_from(bits, input, inputOffset, inputLength); - inputLength = 0; - inputBuffer.setLength(inputLength); - inputBuffer.setOffset(inputOffset + inputLength); - } - - /* At long last, do the actual decoding. */ - int outputLength = this.frameSize; - boolean inputBufferNotConsumed; - - if (outputLength > 0) - { - byte[] output = validateByteArraySize(outputBuffer, outputLength); - - if (0 == Speex.speex_decode_int(state, bits, output, 0)) - { - outputBuffer.setDuration(duration); - outputBuffer.setFormat(getOutputFormat()); - outputBuffer.setLength(outputLength); - outputBuffer.setOffset(0); - inputBufferNotConsumed = (Speex.speex_bits_remaining(bits) > 0); - } - else - { - outputBuffer.setLength(0); - discardOutputBuffer(outputBuffer); - inputBufferNotConsumed = false; - } - } - else - { - outputBuffer.setLength(0); - discardOutputBuffer(outputBuffer); - inputBufferNotConsumed = false; - } - - if ((inputLength < 1) && !inputBufferNotConsumed) - return BUFFER_PROCESSED_OK; - else - return BUFFER_PROCESSED_OK | INPUT_BUFFER_NOT_CONSUMED; - } - - /** - * Get all supported output Formats. - * - * @param inputFormat input Format to determine corresponding output - * Format/tt>s - * @return array of supported Format - * @see AbstractCodecExt#getMatchingOutputFormats(Format) - */ - @Override - protected Format[] getMatchingOutputFormats(Format inputFormat) - { - AudioFormat inputAudioFormat = (AudioFormat) inputFormat; - - return - new Format[] - { - new AudioFormat( - AudioFormat.LINEAR, - inputAudioFormat.getSampleRate(), - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - Format.byteArray) - }; - } - - /** - * Sets the Format of the media data to be input for processing in - * this Codec. - * - * @param format the Format of the media data to be input for - * processing in this Codec - * @return the Format of the media data to be input for processing - * in this Codec if format is compatible with this - * Codec; otherwise, null - * @see AbstractCodecExt#setInputFormat(Format) - */ - @Override - public Format setInputFormat(Format format) - { - Format inputFormat = super.setInputFormat(format); - - if (inputFormat != null) - { - double outputSampleRate; - int outputChannels; - - if (outputFormat == null) - { - outputSampleRate = Format.NOT_SPECIFIED; - outputChannels = Format.NOT_SPECIFIED; - } - else - { - AudioFormat outputAudioFormat = (AudioFormat) outputFormat; - - outputSampleRate = outputAudioFormat.getSampleRate(); - outputChannels = outputAudioFormat.getChannels(); - } - - AudioFormat inputAudioFormat = (AudioFormat) inputFormat; - double inputSampleRate = inputAudioFormat.getSampleRate(); - int inputChannels = inputAudioFormat.getChannels(); - - if ((outputSampleRate != inputSampleRate) - || (outputChannels != inputChannels)) - { - setOutputFormat( - new AudioFormat( - AudioFormat.LINEAR, - inputSampleRate, - 16, - inputChannels, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - Format.byteArray)); - } - } - return inputFormat; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/JNIEncoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/JNIEncoder.java deleted file mode 100644 index 3993ed91a..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/JNIEncoder.java +++ /dev/null @@ -1,492 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.speex; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.sf.fmj.media.*; - -/** - * Implements a Speex encoder and RTP packetizer using the native Speex library. - * - * @author Lubomir Marinov - */ -public class JNIEncoder - extends AbstractCodecExt -{ - - /** - * The list of Formats of audio data supported as input by - * JNIEncoder instances. - */ - private static final Format[] SUPPORTED_INPUT_FORMATS; - - /** - * The list of sample rates of audio data supported as input by - * JNIEncoder instances. - */ - static final double[] SUPPORTED_INPUT_SAMPLE_RATES - = new double[] { 8000, 16000, 32000 }; - - /** - * The list of Formats of audio data supported as output by - * JNIEncoder instances. - */ - private static final Format[] SUPPORTED_OUTPUT_FORMATS - = new Format[] { new AudioFormat(Constants.SPEEX_RTP) }; - - static - { - Speex.assertSpeexIsFunctional(); - - int supportedInputCount = SUPPORTED_INPUT_SAMPLE_RATES.length; - - SUPPORTED_INPUT_FORMATS = new Format[supportedInputCount]; - for (int i = 0; i < supportedInputCount; i++) - { - SUPPORTED_INPUT_FORMATS[i] - = new AudioFormat( - AudioFormat.LINEAR, - SUPPORTED_INPUT_SAMPLE_RATES[i], - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - Format.byteArray); - } - } - - /** - * The pointer to the native SpeexBits into which the native Speex - * encoder (i.e. {@link #state}) writes the encoded audio data. - */ - private long bits = 0; - - /** - * The duration in nanoseconds of an output Buffer produced by this - * Codec. - */ - private long duration = 0; - - /** - * The number of bytes from an input Buffer that this - * Codec processes in one call of its - * {@link #process(Buffer, Buffer)}. - */ - private int frameSize = 0; - - /** - * The bytes from an input Buffer from a previous call to - * {@link #process(Buffer, Buffer)} that this Codec didn't process - * because the total number of bytes was less than {@link #frameSize} and - * need to be prepended to a subsequent input Buffer in order to - * process a total of {@link #frameSize} bytes. - */ - private byte[] previousInput; - - /** - * The length of the audio data in {@link #previousInput}. - */ - private int previousInputLength = 0; - - /** - * The sample rate configured into {@link #state}. - */ - private int sampleRate = 0; - - /** - * The native Speex encoder represented by this instance. - */ - private long state = 0; - - /** - * Initializes a new JNIEncoder instance. - */ - public JNIEncoder() - { - super( - "Speex JNI Encoder", - AudioFormat.class, - SUPPORTED_OUTPUT_FORMATS); - - inputFormats = SUPPORTED_INPUT_FORMATS; - } - - /** - * @see AbstractCodecExt#doClose() - */ - protected void doClose() - { - // state - if (state != 0) - { - Speex.speex_encoder_destroy(state); - state = 0; - sampleRate = 0; - frameSize = 0; - duration = 0; - } - // bits - Speex.speex_bits_destroy(bits); - bits = 0; - // previousInput - previousInput = null; - } - - /** - * Opens this Codec and acquires the resources that it needs to - * operate. A call to {@link PlugIn#open()} on this instance will result in - * a call to doOpen only if {@link AbstractCodec#opened} is - * false. All required input and/or output formats are assumed to - * have been set on this Codec before doOpen is called. - * - * @throws ResourceUnavailableException if any of the resources that this - * Codec needs to operate cannot be acquired - * @see AbstractCodecExt#doOpen() - */ - protected void doOpen() - throws ResourceUnavailableException - { - bits = Speex.speex_bits_init(); - if (bits == 0) - throw new ResourceUnavailableException("speex_bits_init"); - } - - /** - * Processes (encode) a specific input Buffer. - * - * @param inputBuffer input buffer - * @param outputBuffer output buffer - * @return BUFFER_PROCESSED_OK if buffer has been successfully - * processed - * @see AbstractCodecExt#doProcess(Buffer, Buffer) - */ - protected int doProcess(Buffer inputBuffer, Buffer outputBuffer) - { - Format inputFormat = inputBuffer.getFormat(); - - if ((inputFormat != null) - && (inputFormat != this.inputFormat) - && !inputFormat.equals(this.inputFormat)) - { - if (null == setInputFormat(inputFormat)) - return BUFFER_PROCESSED_FAILED; - } - inputFormat = this.inputFormat; - - /* - * Make sure that the native Speex encoder which is represented by this - * instance is configured to work with the inputFormat. - */ - AudioFormat inputAudioFormat = (AudioFormat) inputFormat; - int inputSampleRate = (int) inputAudioFormat.getSampleRate(); - - if ((state != 0) && (sampleRate != inputSampleRate)) - { - Speex.speex_encoder_destroy(state); - state = 0; - sampleRate = 0; - frameSize = 0; - } - if (state == 0) - { - long mode - = Speex.speex_lib_get_mode( - (inputSampleRate == 16000) - ? Speex.SPEEX_MODEID_WB - : (inputSampleRate == 32000) - ? Speex.SPEEX_MODEID_UWB - : Speex.SPEEX_MODEID_NB); - - if (mode == 0) - return BUFFER_PROCESSED_FAILED; - state = Speex.speex_encoder_init(mode); - if (state == 0) - return BUFFER_PROCESSED_FAILED; - if (Speex.speex_encoder_ctl( - state, - Speex.SPEEX_SET_QUALITY, - 4) - != 0) - return BUFFER_PROCESSED_FAILED; - if (Speex.speex_encoder_ctl( - state, - Speex.SPEEX_SET_SAMPLING_RATE, - inputSampleRate) - != 0) - return BUFFER_PROCESSED_FAILED; - - int frameSize - = Speex.speex_encoder_ctl(state, Speex.SPEEX_GET_FRAME_SIZE); - - if (frameSize < 0) - return BUFFER_PROCESSED_FAILED; - - sampleRate = inputSampleRate; - this.frameSize = frameSize * 2 /* (sampleSizeInBits / 8) */; - duration - = (((long) frameSize) * 1000 * 1000000) / ((long) sampleRate); - } - - /* - * The native Speex encoder always processes frameSize bytes from the - * input in one call. If any specified inputBuffer is with a different - * length, then we'll have to wait for more bytes to arrive until we - * have frameSize bytes. Remember whatever is left unprocessed in - * previousInput and prepend it to the next inputBuffer. - */ - byte[] input = (byte[]) inputBuffer.getData(); - int inputLength = inputBuffer.getLength(); - int inputOffset = inputBuffer.getOffset(); - - if ((previousInput != null) && (previousInputLength > 0)) - { - if (previousInputLength < this.frameSize) - { - if (previousInput.length < this.frameSize) - { - byte[] newPreviousInput = new byte[this.frameSize]; - - System.arraycopy( - previousInput, 0, - newPreviousInput, 0, - previousInput.length); - previousInput = newPreviousInput; - } - - int bytesToCopyFromInputToPreviousInput - = Math.min( - this.frameSize - previousInputLength, - inputLength); - - if (bytesToCopyFromInputToPreviousInput > 0) - { - System.arraycopy( - input, inputOffset, - previousInput, previousInputLength, - bytesToCopyFromInputToPreviousInput); - previousInputLength += bytesToCopyFromInputToPreviousInput; - inputLength -= bytesToCopyFromInputToPreviousInput; - inputBuffer.setLength(inputLength); - inputBuffer.setOffset( - inputOffset + bytesToCopyFromInputToPreviousInput); - } - } - - if (previousInputLength == this.frameSize) - { - input = previousInput; - inputOffset = 0; - previousInputLength = 0; - } - else if (previousInputLength > this.frameSize) - { - input = new byte[this.frameSize]; - System.arraycopy(previousInput, 0, input, 0, input.length); - inputOffset = 0; - previousInputLength -= input.length; - System.arraycopy( - previousInput, input.length, - previousInput, 0, - previousInputLength); - } - else - { - outputBuffer.setLength(0); - discardOutputBuffer(outputBuffer); - if (inputLength < 1) - return BUFFER_PROCESSED_OK; - else - return BUFFER_PROCESSED_OK | INPUT_BUFFER_NOT_CONSUMED; - } - } - else if (inputLength < 1) - { - outputBuffer.setLength(0); - discardOutputBuffer(outputBuffer); - return BUFFER_PROCESSED_OK; - } - else if (inputLength < this.frameSize) - { - if ((previousInput == null) || (previousInput.length < inputLength)) - previousInput = new byte[this.frameSize]; - System.arraycopy(input, inputOffset, previousInput, 0, inputLength); - previousInputLength = inputLength; - outputBuffer.setLength(0); - discardOutputBuffer(outputBuffer); - return BUFFER_PROCESSED_OK; - } - else - { - inputLength -= this.frameSize; - inputBuffer.setLength(inputLength); - inputBuffer.setOffset(inputOffset + this.frameSize); - } - - /* At long last, do the actual encoding. */ - Speex.speex_bits_reset(bits); - Speex.speex_encode_int(state, input, inputOffset, bits); - - /* Read the encoded audio data from the SpeexBits into outputBuffer. */ - int outputLength = Speex.speex_bits_nbytes(bits); - - if (outputLength > 0) - { - byte[] output = validateByteArraySize(outputBuffer, outputLength); - - outputLength - = Speex.speex_bits_write(bits, output, 0, output.length); - if (outputLength > 0) - { - outputBuffer.setDuration(duration); - outputBuffer.setFormat(getOutputFormat()); - outputBuffer.setLength(outputLength); - outputBuffer.setOffset(0); - } - else - { - outputBuffer.setLength(0); - discardOutputBuffer(outputBuffer); - } - } - else - { - outputBuffer.setLength(0); - discardOutputBuffer(outputBuffer); - } - - if (inputLength < 1) - return BUFFER_PROCESSED_OK; - else - return BUFFER_PROCESSED_OK | INPUT_BUFFER_NOT_CONSUMED; - } - - /** - * Get the output formats matching a specific input format. - * - * @param inputFormat the input format to get the matching output formats of - * @return the output formats matching the specified input format - * @see AbstractCodecExt#getMatchingOutputFormats(Format) - */ - @Override - protected Format[] getMatchingOutputFormats(Format inputFormat) - { - AudioFormat inputAudioFormat = (AudioFormat) inputFormat; - - return - new Format[] - { - new AudioFormat( - Constants.SPEEX_RTP, - inputAudioFormat.getSampleRate(), - Format.NOT_SPECIFIED, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - Format.byteArray) - }; - } - - /** - * Get the output format. - * - * @return output format - * @see net.sf.fmj.media.AbstractCodec#getOutputFormat() - */ - @Override - public Format getOutputFormat() - { - Format outputFormat = super.getOutputFormat(); - - if ((outputFormat != null) - && (outputFormat.getClass() == AudioFormat.class)) - { - AudioFormat outputAudioFormat = (AudioFormat) outputFormat; - - outputFormat = setOutputFormat( - new AudioFormat( - outputAudioFormat.getEncoding(), - outputAudioFormat.getSampleRate(), - outputAudioFormat.getSampleSizeInBits(), - outputAudioFormat.getChannels(), - outputAudioFormat.getEndian(), - outputAudioFormat.getSigned(), - outputAudioFormat.getFrameSizeInBits(), - outputAudioFormat.getFrameRate(), - outputAudioFormat.getDataType()) - { - private static final long serialVersionUID = 0L; - - @Override - public long computeDuration(long length) - { - return JNIEncoder.this.duration; - } - }); - } - return outputFormat; - } - - /** - * Sets the input format. - * - * @param format format to set - * @return format - * @see AbstractCodecExt#setInputFormat(Format) - */ - @Override - public Format setInputFormat(Format format) - { - Format inputFormat = super.setInputFormat(format); - - if (inputFormat != null) - { - double outputSampleRate; - int outputChannels; - - if (outputFormat == null) - { - outputSampleRate = Format.NOT_SPECIFIED; - outputChannels = Format.NOT_SPECIFIED; - } - else - { - AudioFormat outputAudioFormat = (AudioFormat) outputFormat; - - outputSampleRate = outputAudioFormat.getSampleRate(); - outputChannels = outputAudioFormat.getChannels(); - } - - AudioFormat inputAudioFormat = (AudioFormat) inputFormat; - double inputSampleRate = inputAudioFormat.getSampleRate(); - int inputChannels = inputAudioFormat.getChannels(); - - if ((outputSampleRate != inputSampleRate) - || (outputChannels != inputChannels)) - { - setOutputFormat( - new AudioFormat( - Constants.SPEEX_RTP, - inputSampleRate, - Format.NOT_SPECIFIED, - inputChannels, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - Format.byteArray)); - } - } - return inputFormat; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/JavaDecoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/JavaDecoder.java deleted file mode 100644 index 0406d252b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/JavaDecoder.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.speex; - -import java.io.*; -import javax.media.*; -import javax.media.format.*; - -import org.xiph.speex.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.sf.fmj.media.*; - -/** - * Speex to PCM java decoder - * @author Damian Minkov - **/ -public class JavaDecoder - extends AbstractCodec -{ - /** - * Default output formats. - */ - protected Format[] DEFAULT_OUTPUT_FORMATS = new Format[] { - new AudioFormat(AudioFormat.LINEAR)}; - - /** - * The input format used to initialize the decoder. - * If null decoder must be created. - */ - private Format lastFormat = null; - - /** - * The decoder. - */ - private SpeexDecoder decoder = null; - - /** - * Creates the decoder and inits supported input formats. - */ - public JavaDecoder() - { - this.inputFormats = new AudioFormat[] - { - new AudioFormat(Constants.SPEEX_RTP, - 8000, - 8, - 1, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED), - new AudioFormat(Constants.SPEEX_RTP, - 16000, - 8, - 1, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED), - new AudioFormat(Constants.SPEEX_RTP, - 32000, - 8, - 1, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED) - }; - } - - /** - * Returns the name of this plugin/codec. - * @return the name. - */ - public String getName() - { - return "Speex Java Decoder"; - } - - /** - * Return the list of formats supported at the output. - * - * @param in the input format. - * @return array of formats supported at output - */ - public Format[] getSupportedOutputFormats(Format in) - { - // null input format - if (in == null) - return DEFAULT_OUTPUT_FORMATS; - - // mismatch input format - if (!(in instanceof AudioFormat) - || (null == AbstractCodecExt.matches(in, inputFormats))) - return new Format[0]; - - return getMatchingOutputFormats(in); - } - - /** - * Returns the output format that matches the supplied input format. - * @param in input format - * @return array of format that match input ones - */ - private Format[] getMatchingOutputFormats(Format in) - { - AudioFormat af = (AudioFormat) in; - - return new AudioFormat[] - { - new AudioFormat( - AudioFormat.LINEAR, - af.getSampleRate(), - 16, - af.getChannels(), - AudioFormat.LITTLE_ENDIAN, //isBigEndian(), - AudioFormat.SIGNED //isSigned()); - )}; - } - - /** - * Does nothing. - */ - public void open() - {} - - /** - * Does nothing. - */ - public void close() - {} - - /** - * Initialize the decoder. - * @param inFormat the input format. - */ - private void initConverter(AudioFormat inFormat) - { - lastFormat = inFormat; - - decoder = new SpeexDecoder(); - - int sampleRate = - (int)inFormat.getSampleRate(); - - int band = JavaEncoder.NARROW_BAND; - - if(sampleRate == 16000) - band = JavaEncoder.WIDE_BAND; - else if(sampleRate == 32000) - band = JavaEncoder.ULTRA_WIDE_BAND; - - decoder.init(band, - sampleRate, - inFormat.getChannels(), - false); - } - - /** - * Process the input and decodes it. - * @param inputBuffer the input data. - * @param outputBuffer the result data. - * @return state of the process. - */ - public int process(Buffer inputBuffer, Buffer outputBuffer) - { - if (!checkInputBuffer(inputBuffer)) - { - return BUFFER_PROCESSED_FAILED; - } - - if (isEOM(inputBuffer)) - { - propagateEOM(outputBuffer); - return BUFFER_PROCESSED_OK; - } - - byte[] inData = (byte[]) inputBuffer.getData(); - - int inpLength = inputBuffer.getLength(); - int outLength = 0; - - int inOffset = inputBuffer.getOffset(); - int outOffset = outputBuffer.getOffset(); - - Format newFormat = inputBuffer.getFormat(); - - if (lastFormat != newFormat) - { - initConverter( (AudioFormat) newFormat); - } - - try - { - int fullyProcessed = - decoder.processData(inData, inOffset, inpLength); - - // sometimes we get more than a frame in single speex packet - // we must process it all - while(fullyProcessed != 1) - { - fullyProcessed = decoder.processData(false); - } - - outLength = decoder.getProcessedDataByteSize(); - - /* - * Do not always allocate a new data array for outBuffer, try to reuse - * the existing one if it is suitable. - */ - Object outData = outputBuffer.getData(); - byte[] out; - - if (outData instanceof byte[]) - { - out = (byte[]) outData; - if (out.length < outLength) - out = null; - } - else - out = null; - if (out == null) - out = new byte[outLength]; - - decoder.getProcessedData(out, outOffset); - - outputBuffer.setData(out); - outputBuffer.setLength(out.length); - outputBuffer.setOffset(0); - outputBuffer.setFormat(outputFormat); - } - catch (StreamCorruptedException ex) - { - ex.printStackTrace(); - } - - return BUFFER_PROCESSED_OK; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/JavaEncoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/JavaEncoder.java deleted file mode 100644 index f9b73706e..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/JavaEncoder.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.speex; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.sf.fmj.media.*; - -import org.xiph.speex.*; - -/** - * The Speex Encoder - * - * @author Damian Minkov - * @author Lubomir Marinov - */ -public class JavaEncoder - extends AbstractCodecExt -{ - - /** - * Narrow band used for 8 kHz. - */ - static final int NARROW_BAND= 0; - - /** - * Utra wide band used for 32 kHz. - */ - static final int ULTRA_WIDE_BAND= 2; - - /** - * Wide band used for 16 kHz. - */ - static final int WIDE_BAND= 1; - - /** - * The speex encoder instance. - */ - private SpeexEncoder encoder = null; - - /** - * The frame size used for current encoder configuration. - */ - private int frameSize = -1; - - /** - * The last input format used by this instance of the encoder. - * If null we must create the encoder with the current input format. - */ - private Format lastFormat = null; - - /** - * Our custom output format which computes the rtp data duration correctly. - */ - private AudioFormat outFormat = null; - - /** - * Creates the encoder and init supported formats - */ - public JavaEncoder() - { - super( - "Speex Java Encoder", - AudioFormat.class, - new Format[] { new AudioFormat(Constants.SPEEX_RTP) }); - - inputFormats - = new AudioFormat[] - { - new AudioFormat( - AudioFormat.LINEAR, - 8000, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED), - new AudioFormat( - AudioFormat.LINEAR, - 16000, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED), - new AudioFormat( - AudioFormat.LINEAR, - 32000, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED) - }; - } - - /** - * Does nothing. - * - * @see AbstractCodecExt#doClose() - */ - public void doClose() - { - } - - /** - * Opens this Codec and acquires the resources that it needs to - * operate. A call to {@link PlugIn#open()} on this instance will result in - * a call to doOpen only if {@link AbstractCodec#opened} is - * false. All required input and/or output formats are assumed to - * have been set on this Codec before doOpen is called. - * - * @throws ResourceUnavailableException if any of the resources that this - * Codec needs to operate cannot be acquired - * @see AbstractCodecExt#doOpen() - */ - public void doOpen() - throws ResourceUnavailableException - { - } - - /** - * Process the input and encodes it. - * - * @param inputBuffer the input data. - * @param outputBuffer the result data - * @return state of the process - * @see AbstractCodecExt#doProcess(Buffer, Buffer) - */ - protected int doProcess(Buffer inputBuffer, Buffer outputBuffer) - { - Format newFormat = inputBuffer.getFormat(); - - if (lastFormat != newFormat) - initConverter((AudioFormat) newFormat); - - int inputLength = inputBuffer.getLength(); - - if (inputLength == 0) - return OUTPUT_BUFFER_NOT_FILLED; - - if (inputLength >= frameSize) - { - byte[] inputData = (byte[]) inputBuffer.getData(); - int inputOffset = inputBuffer.getOffset(); - - encoder.processData(inputData, inputOffset, frameSize); - - byte[] buff = new byte[encoder.getProcessedDataByteSize()]; - - encoder.getProcessedData(buff, 0); - - /* - * Do not always allocate a new data array for outBuffer, try to - * reuse the existing one if it is suitable. - */ - Object outputData = outputBuffer.getData(); - byte[] output; - - if (outputData instanceof byte[]) - { - output = (byte[]) outputData; - if (output.length < buff.length) - output = null; - } - else - output = null; - if (output == null) - output = new byte[buff.length]; - - System.arraycopy(buff, 0, output, 0, buff.length); - - outputBuffer.setData(output); - outputBuffer.setFormat(outFormat); - outputBuffer.setLength(output.length); - outputBuffer.setOffset(0); - - if (inputLength > frameSize) - { - inputBuffer.setLength(inputLength - frameSize); - inputBuffer.setOffset(inputOffset + frameSize); - return BUFFER_PROCESSED_OK | INPUT_BUFFER_NOT_CONSUMED; - } - else - return BUFFER_PROCESSED_OK; - } - else - return OUTPUT_BUFFER_NOT_FILLED; - } - - /** - * Returns the output format that matches the supplied input format. - * - * @param in input format - * @return array of formats that match input ones - * @see AbstractCodecExt#getMatchingOutputFormats(Format) - */ - @Override - protected Format[] getMatchingOutputFormats(Format in) - { - AudioFormat af = (AudioFormat) in; - - return - new Format[] - { - new AudioFormat( - Constants.SPEEX_RTP, - af.getSampleRate(), - af.getSampleSizeInBits(), - af.getChannels(), - af.getEndian(), - af.getSigned()) - }; - } - - /** - * Initialize the encoder with the supplied input format. - * @param inFormat the input format. - */ - private void initConverter(AudioFormat inFormat) - { - lastFormat = inFormat; - - AudioFormat oFormat = (AudioFormat)outputFormat; - outFormat = new AudioFormat( - oFormat.getEncoding(), - oFormat.getSampleRate(), - oFormat.getSampleSizeInBits(), - oFormat.getChannels(), - oFormat.getEndian(), - oFormat.getSigned(), - oFormat.getFrameSizeInBits(), - oFormat.getFrameRate(), - oFormat.getDataType()) - { - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * The length in nanoseconds. - */ - @Override - public long computeDuration(long length) - { - // 20ms in nano - return 20 * 1000000; - } - }; - - encoder = new SpeexEncoder(); - - int sampleRate = (int) inFormat.getSampleRate(); - int band = NARROW_BAND; - - if (sampleRate == 16000) - band = WIDE_BAND; - else if (sampleRate == 32000) - band = ULTRA_WIDE_BAND; - - encoder.init(band, 4, sampleRate, 1); - - frameSize = 2 * encoder.getFrameSize(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/Speex.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/Speex.java deleted file mode 100644 index c76f9e882..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/Speex.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.speex; - -/** - * Provides the interface to the native Speex library. - * - * @author Lubomir Marinov - */ -public final class Speex -{ - public static final int SPEEX_GET_FRAME_SIZE = 3; - - public static final int SPEEX_MODEID_NB = 0; - - public static final int SPEEX_MODEID_UWB = 2; - - public static final int SPEEX_MODEID_WB = 1; - - public static final int SPEEX_RESAMPLER_QUALITY_VOIP = 3; - - public static final int SPEEX_SET_ENH = 0; - - public static final int SPEEX_SET_QUALITY = 4; - - public static final int SPEEX_SET_SAMPLING_RATE = 24; - - static - { - System.loadLibrary("jnspeex"); - } - - static void assertSpeexIsFunctional() - { - speex_lib_get_mode(SPEEX_MODEID_NB); - } - - public static native void speex_bits_destroy(long bits); - - public static native long speex_bits_init(); - - public static native int speex_bits_nbytes(long bits); - - public static native void speex_bits_read_from( - long bits, - byte[] bytes, int bytesOffset, - int len); - - public static native int speex_bits_remaining(long bits); - - public static native void speex_bits_reset(long bits); - - public static native int speex_bits_write( - long bits, - byte[] bytes, int bytesOffset, - int max_len); - - public static native int speex_decode_int( - long state, - long bits, - byte[] out, int byteOffset); - - public static native int speex_decoder_ctl(long state, int request); - - public static native int speex_decoder_ctl( - long state, - int request, - int value); - - public static native void speex_decoder_destroy(long state); - - public static native long speex_decoder_init(long mode); - - public static native int speex_encode_int( - long state, - byte[] in, int inOffset, - long bits); - - public static native int speex_encoder_ctl(long state, int request); - - public static native int speex_encoder_ctl( - long state, - int request, - int value); - - public static native void speex_encoder_destroy(long state); - - public static native long speex_encoder_init(long mode); - - public static native long speex_lib_get_mode(int mode); - - public static native void speex_resampler_destroy(long state); - - public static native long speex_resampler_init( - int nb_channels, - int in_rate, - int out_rate, - int quality, - long err); - - public static native int speex_resampler_process_interleaved_int( - long state, - byte[] in, int inOffset, int in_len, - byte[] out, int outOffset, int out_len); - - public static native int speex_resampler_set_rate( - long state, - int in_rate, - int out_rate); - - /** - * Prevents the creation of Speex instances. - */ - private Speex() - { - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/SpeexResampler.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/SpeexResampler.java deleted file mode 100644 index ee85c658b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/speex/SpeexResampler.java +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.speex; - -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.sf.fmj.media.*; - -/** - * Implements an audio resampler using Speex. - * - * @author Lyubomir Marinov - */ -public class SpeexResampler - extends AbstractCodecExt -{ - /** - * The list of Formats of audio data supported as input and output - * by SpeexResampler instances. - */ - private static final Format[] SUPPORTED_FORMATS; - - /** - * The list of sample rates of audio data supported as input and output by - * SpeexResampler instances. - */ - private static final double[] SUPPORTED_SAMPLE_RATES - = new double[] - { - 8000, - 11025, - 12000, - 16000, - 22050, - 24000, - 32000, - 44100, - 48000, - Format.NOT_SPECIFIED - }; - - static - { - Speex.assertSpeexIsFunctional(); - - int supportedCount = SUPPORTED_SAMPLE_RATES.length; - - SUPPORTED_FORMATS = new Format[2 * supportedCount]; - for (int i = 0; i < supportedCount; i++) - { - int j = 2 * i; - - SUPPORTED_FORMATS[j] - = new AudioFormat( - AudioFormat.LINEAR, - SUPPORTED_SAMPLE_RATES[i], - 16 /* sampleSizeInBits */, - 1 /* channels */, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - Format.byteArray); - SUPPORTED_FORMATS[j + 1] - = new AudioFormat( - AudioFormat.LINEAR, - SUPPORTED_SAMPLE_RATES[i], - 16 /* sampleSizeInBits */, - 1 /* channels */, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - Format.shortArray); - } - } - - /** - * The input sample rate configured in {@link #resampler}. - */ - private int inputSampleRate; - - /** - * The output sample rate configured in {@link #resampler}. - */ - private int outputSampleRate; - - /** - * The pointer to the native SpeexResamplerState which is - * represented by this instance. - */ - private long resampler; - - /** - * Initializes a new SpeexResampler instance. - */ - public SpeexResampler() - { - super("Speex Resampler", AudioFormat.class, SUPPORTED_FORMATS); - - inputFormats = SUPPORTED_FORMATS; - } - - /** - * @see AbstractCodecExt#doClose() - */ - protected void doClose() - { - if (resampler != 0) - { - Speex.speex_resampler_destroy(resampler); - resampler = 0; - } - } - - /** - * Opens this Codec and acquires the resources that it needs to - * operate. A call to {@link PlugIn#open()} on this instance will result in - * a call to doOpen only if {@link AbstractCodec#opened} is - * false. All required input and/or output formats are assumed to - * have been set on this Codec before doOpen is called. - * - * @throws ResourceUnavailableException if any of the resources that this - * Codec needs to operate cannot be acquired - * @see AbstractCodecExt#doOpen() - */ - protected void doOpen() - throws ResourceUnavailableException - { - } - - /** - * Resamples audio from a specific input Buffer into a specific - * output Buffer. - * - * @param inputBuffer input Buffer - * @param outputBuffer output Buffer - * @return BUFFER_PROCESSED_OK if inputBuffer has been - * successfully processed - * @see AbstractCodecExt#doProcess(Buffer, Buffer) - */ - protected int doProcess(Buffer inputBuffer, Buffer outputBuffer) - { - Format inputFormat = inputBuffer.getFormat(); - - if ((inputFormat != null) - && (inputFormat != this.inputFormat) - && !inputFormat.equals(this.inputFormat)) - { - if (null == setInputFormat(inputFormat)) - return BUFFER_PROCESSED_FAILED; - } - inputFormat = this.inputFormat; - - AudioFormat inputAudioFormat = (AudioFormat) inputFormat; - int inputSampleRate = (int) inputAudioFormat.getSampleRate(); - AudioFormat outputAudioFormat = (AudioFormat) getOutputFormat(); - int outputSampleRate = (int) outputAudioFormat.getSampleRate(); - - if (inputSampleRate == outputSampleRate) - { - // passthrough - Class inputDataType = inputAudioFormat.getDataType(); - Class outputDataType = outputAudioFormat.getDataType(); - - if (Format.byteArray.equals(inputDataType)) - { - byte[] input = (byte[]) inputBuffer.getData(); - - if (Format.byteArray.equals(outputDataType)) - { - int length = (input == null) ? 0 : input.length; - byte[] output = validateByteArraySize(outputBuffer, length); - - if ((input != null) && (output != null)) - System.arraycopy(input, 0, output, 0, length); - outputBuffer.setFormat(inputBuffer.getFormat()); - outputBuffer.setLength(inputBuffer.getLength()); - outputBuffer.setOffset(inputBuffer.getOffset()); - } - else - { - int inputLength = inputBuffer.getLength(); - int outputOffset = 0; - int outputLength = inputLength / 2; - short[] output - = validateShortArraySize(outputBuffer, outputLength); - - for (int i = inputBuffer.getOffset(), o = outputOffset; - o < outputLength; - o++) - { - output[o] - = (short) - (((input[i++] & 0xFF) - | (input[i++] & 0xFF) << 8)); - } - outputBuffer.setFormat(outputAudioFormat); - outputBuffer.setLength(outputLength); - outputBuffer.setOffset(outputOffset); - } - } - else - { - short[] input = (short[]) inputBuffer.getData(); - - if (Format.byteArray.equals(outputDataType)) - { - int inputLength = inputBuffer.getLength(); - int outputOffset = 0; - int outputLength = inputLength * 2; - byte[] output - = validateByteArraySize(outputBuffer, outputLength); - - for (int i = inputBuffer.getOffset(), o = outputOffset; - o < outputLength; - i++) - { - short s = input[i]; - - output[o++] = (byte) (s & 0x00FF); - output[o++] = (byte) ((s & 0xFF00) >>> 8); - } - outputBuffer.setFormat(outputAudioFormat); - outputBuffer.setLength(outputLength); - outputBuffer.setOffset(outputOffset); - } - else - { - int length = (input == null) ? 0 : input.length; - short[] output - = validateShortArraySize(outputBuffer, length); - - if ((input != null) && (output != null)) - System.arraycopy(input, 0, output, 0, length); - outputBuffer.setFormat(inputBuffer.getFormat()); - outputBuffer.setLength(inputBuffer.getLength()); - outputBuffer.setOffset(inputBuffer.getOffset()); - } - } - } - else - { - if ((this.inputSampleRate != inputSampleRate) - || (this.outputSampleRate != outputSampleRate)) - { - if (resampler == 0) - { - resampler - = Speex.speex_resampler_init( - 1, - inputSampleRate, - outputSampleRate, - Speex.SPEEX_RESAMPLER_QUALITY_VOIP, - 0); - } - else - { - Speex.speex_resampler_set_rate( - resampler, - inputSampleRate, - outputSampleRate); - } - if (resampler != 0) - { - this.inputSampleRate = inputSampleRate; - this.outputSampleRate = outputSampleRate; - } - } - if (resampler == 0) - return BUFFER_PROCESSED_FAILED; - - byte[] input = (byte[]) inputBuffer.getData(); - int inputLength = inputBuffer.getLength(); - int sampleSizeInBytes = inputAudioFormat.getSampleSizeInBits() / 8; - int inputSampleCount = inputLength / sampleSizeInBytes; - int outputLength - = (inputLength * outputSampleRate) / inputSampleRate; - byte[] output = validateByteArraySize(outputBuffer, outputLength); - int outputSampleCount = outputLength / sampleSizeInBytes; - - outputSampleCount - = Speex.speex_resampler_process_interleaved_int( - resampler, - input, inputBuffer.getOffset(), inputSampleCount, - output, 0, outputSampleCount); - outputBuffer.setFormat(outputAudioFormat); - outputBuffer.setLength(outputSampleCount * sampleSizeInBytes); - outputBuffer.setOffset(0); - } - outputBuffer.setDuration(inputBuffer.getDuration()); - outputBuffer.setEOM(inputBuffer.isEOM()); - outputBuffer.setFlags(inputBuffer.getFlags()); - outputBuffer.setHeader(inputBuffer.getHeader()); - outputBuffer.setSequenceNumber(inputBuffer.getSequenceNumber()); - outputBuffer.setTimeStamp(inputBuffer.getTimeStamp()); - return BUFFER_PROCESSED_OK; - } - - /** - * Get the output formats matching a specific input format. - * - * @param inputFormat the input format to get the matching output formats of - * @return the output formats matching the specified input format - * @see AbstractCodecExt#getMatchingOutputFormats(Format) - */ - @Override - protected Format[] getMatchingOutputFormats(Format inputFormat) - { - Class inputFormatDataType = inputFormat.getDataType(); - List matchingOutputFormats = new ArrayList(); - - for (Format supportedFormat : SUPPORTED_FORMATS) - { - if ((Format.byteArray.equals(supportedFormat.getDataType()) - && Format.byteArray.equals(inputFormatDataType)) - || (((AudioFormat) supportedFormat).getSampleRate() - == ((AudioFormat) inputFormat).getSampleRate())) - matchingOutputFormats.add(supportedFormat); - } - return - matchingOutputFormats.toArray( - new Format[matchingOutputFormats.size()]); - } - - /** - * Sets the Format of the media data to be input for processing in - * this Codec. - * - * @param format the Format of the media data to be input for - * processing in this Codec - * @return the Format of the media data to be input for processing - * in this Codec if format is compatible with this - * Codec; otherwise, null - * @see AbstractCodecExt#setInputFormat(Format) - */ - @Override - public Format setInputFormat(Format format) - { - AudioFormat inputFormat = (AudioFormat) super.setInputFormat(format); - - if (inputFormat != null) - { - double outputSampleRate; - Class outputDataType; - - if (outputFormat == null) - { - outputSampleRate = inputFormat.getSampleRate(); - outputDataType = inputFormat.getDataType(); - } - else - { - AudioFormat outputAudioFormat = (AudioFormat) outputFormat; - - outputSampleRate = outputAudioFormat.getSampleRate(); - outputDataType = outputAudioFormat.getDataType(); - /* - * Conversion between data types is only supported when not - * resampling but rather passing through. - */ - if (outputSampleRate != inputFormat.getSampleRate()) - outputDataType = inputFormat.getDataType(); - } - - setOutputFormat( - new AudioFormat( - inputFormat.getEncoding(), - outputSampleRate, - inputFormat.getSampleSizeInBits(), - inputFormat.getChannels(), - inputFormat.getEndian(), - inputFormat.getSigned(), - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - outputDataType)); - } - return inputFormat; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ulaw/JavaDecoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/ulaw/JavaDecoder.java deleted file mode 100644 index 674308723..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ulaw/JavaDecoder.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.ulaw; - -import com.sun.media.controls.*; - -import javax.media.*; -import javax.media.format.*; - -public class JavaDecoder - extends com.ibm.media.codec.audio.AudioCodec -{ - static private final byte[] lutTableH = new byte[256]; - - static private final byte[] lutTableL = new byte[256]; - - public JavaDecoder() - { - supportedInputFormats = new AudioFormat[] - { new AudioFormat(AudioFormat.ULAW) }; - defaultOutputFormats = new AudioFormat[] - { new AudioFormat(AudioFormat.LINEAR) }; - PLUGIN_NAME = "Mu-Law Decoder"; - } - - public Object[] getControls() - { - if (controls == null) - { - controls - = new Object[] - { - new SilenceSuppressionAdapter(this, false, false) - }; - } - return controls; - } - - protected Format[] getMatchingOutputFormats(Format in) - { - AudioFormat af = (AudioFormat) in; - - supportedOutputFormats = - new AudioFormat[] - { new AudioFormat(AudioFormat.LINEAR, af.getSampleRate(), 16, - af.getChannels(), AudioFormat.LITTLE_ENDIAN, // isBigEndian(), - AudioFormat.SIGNED // isSigned()); - ) }; - return supportedOutputFormats; - } - - private void initTables() - { - for (int i = 0; i < 256; i++) - { - int input = ~i; - int mantissa = ((input & 0xf) << 3) + 0x84; - int segment = (input & 0x70) >> 4; - int value = mantissa << segment; - - value -= 0x84; - - if ((input & 0x80) != 0) - value = -value; - - lutTableL[i] = (byte) value; - lutTableH[i] = (byte) (value >> 8); - } - } - - /** Initializes the codec. */ - public void open() - { - initTables(); - } - - /** Decodes the buffer */ - public int process(Buffer inputBuffer, Buffer outputBuffer) - { - if (!checkInputBuffer(inputBuffer)) - return BUFFER_PROCESSED_FAILED; - if (isEOM(inputBuffer)) - { - propagateEOM(outputBuffer); - return BUFFER_PROCESSED_OK; - } - - byte[] inData = (byte[]) inputBuffer.getData(); - byte[] outData = validateByteArraySize(outputBuffer, inData.length * 2); - - int inpLength = inputBuffer.getLength(); - int outLength = 2 * inpLength; - - int inOffset = inputBuffer.getOffset(); - int outOffset = outputBuffer.getOffset(); - for (int i = 0; i < inpLength; i++) - { - int temp = inData[inOffset++] & 0xff; - outData[outOffset++] = lutTableL[temp]; - outData[outOffset++] = lutTableH[temp]; - } - - updateOutput(outputBuffer, outputFormat, outLength, - outputBuffer.getOffset()); - - return BUFFER_PROCESSED_OK; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ulaw/JavaEncoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/ulaw/JavaEncoder.java deleted file mode 100644 index c764119d6..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ulaw/JavaEncoder.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.ulaw; - -import javax.media.*; -import javax.media.format.*; - -public class JavaEncoder - extends com.ibm.media.codec.audio.AudioCodec -{ - private boolean downmix = false; - - private int inputBias; - - private int inputSampleSize; - - private Format lastFormat = null; - - private int lsbOffset; - - private int msbOffset; - - private int numberOfInputChannels; - - private int numberOfOutputChannels = 1; - - private int signMask; - - public JavaEncoder() - { - supportedInputFormats = new AudioFormat[] { - new AudioFormat(AudioFormat.LINEAR, Format.NOT_SPECIFIED, 16, - 1, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED), - new AudioFormat(AudioFormat.LINEAR, Format.NOT_SPECIFIED, 16, - 2, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED), - new AudioFormat(AudioFormat.LINEAR, Format.NOT_SPECIFIED, 8, 1, - Format.NOT_SPECIFIED, Format.NOT_SPECIFIED), - new AudioFormat(AudioFormat.LINEAR, Format.NOT_SPECIFIED, 8, 2, - Format.NOT_SPECIFIED, Format.NOT_SPECIFIED) }; // support - // 1/2 - // channels - // and - // 8/16 - // bit - // samples - - defaultOutputFormats = new AudioFormat[] { new AudioFormat( - AudioFormat.ULAW, 8000, 8, 1, Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED) }; - PLUGIN_NAME = "pcm to mu-law converter"; - } - - private int calculateOutputSize(int inputLength) - { - if (inputSampleSize == 16) - inputLength /= 2; - - if (downmix) - inputLength /= 2; - - return inputLength; - } - - private void convert(byte[] input, int inputOffset, int inputLength, - byte[] outData, int outputOffset) - { - int sample, signBit, inputSample; - int i; - - for (i = inputOffset + msbOffset; i < (inputLength + inputOffset);) - { - - if (8 == inputSampleSize) - { - inputSample = input[i++] << 8; - - if (downmix) - inputSample - = ((inputSample & signMask) - + ((input[i++] << 8) & signMask)) - >> 1; - } else - { - inputSample = (input[i] << 8) + (0xff & input[i + lsbOffset]); - i += 2; - - if (downmix) - { - inputSample - = ((inputSample & signMask) + (((input[i] << 8) - + (0xff & input[i + lsbOffset])) & signMask)) - >> 1; - i += 2; - } - } - - sample = (int) ((short) (inputSample + inputBias)); - - if (sample >= 0) - { - signBit = 0x80; // sign bit - } - else - { - sample = -sample; - signBit = 0x00; - } - - sample = (132 + sample) >> 3; // bias - - outData[outputOffset++] = (byte) ((sample < 0x0020) ? (signBit - | (7 << 4) | (31 - (sample >> 0))) - : (sample < 0x0040) ? (signBit | (6 << 4) | (31 - (sample >> 1))) - : (sample < 0x0080) ? (signBit | (5 << 4) | (31 - (sample >> 2))) - : (sample < 0x0100) ? (signBit | (4 << 4) | (31 - (sample >> 3))) - : (sample < 0x0200) ? (signBit - | (3 << 4) | (31 - (sample >> 4))) - : (sample < 0x0400) ? (signBit - | (2 << 4) | (31 - (sample >> 5))) - : (sample < 0x0800) ? (signBit - | (1 << 4) | (31 - (sample >> 6))) - : (sample < 0x1000) ? (signBit - | (0 << 4) | (31 - (sample >> 7))) - : (signBit - | (0 << 4) | (31 - (0xfff >> 7)))); - } - - } - - @Override - protected Format[] getMatchingOutputFormats(Format in) - { - AudioFormat inFormat = (AudioFormat) in; - int channels = inFormat.getChannels(); - int sampleRate = (int) (inFormat.getSampleRate()); - - if (channels == 2) - { - supportedOutputFormats = new AudioFormat[] { - new AudioFormat(AudioFormat.ULAW, sampleRate, 8, 2, - Format.NOT_SPECIFIED, Format.NOT_SPECIFIED), - new AudioFormat(AudioFormat.ULAW, sampleRate, 8, 1, - Format.NOT_SPECIFIED, Format.NOT_SPECIFIED) }; - - } - else - { - supportedOutputFormats = new AudioFormat[] { new AudioFormat( - AudioFormat.ULAW, sampleRate, 8, 1, Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED) }; - - } - return supportedOutputFormats; - } - - private void initConverter(AudioFormat inFormat) - { - lastFormat = inFormat; - numberOfInputChannels = inFormat.getChannels(); - if (outputFormat != null) - numberOfOutputChannels = outputFormat.getChannels(); - inputSampleSize = inFormat.getSampleSizeInBits(); - - if ((inFormat.getEndian() == AudioFormat.BIG_ENDIAN) - || (8 == inputSampleSize)) - { - lsbOffset = 1; - msbOffset = 0; - } - else - { - lsbOffset = -1; - msbOffset = 1; - } - - if (inFormat.getSigned() == AudioFormat.SIGNED) - { - inputBias = 0; - signMask = 0xffffffff; - } - else - { - inputBias = 32768; - signMask = 0x0000ffff; - } - - downmix - = (numberOfInputChannels == 2) && (numberOfOutputChannels == 1); - } - - public int process(Buffer inputBuffer, Buffer outputBuffer) - { - if (!checkInputBuffer(inputBuffer)) - return BUFFER_PROCESSED_FAILED; - if (isEOM(inputBuffer)) - { - propagateEOM(outputBuffer); - return BUFFER_PROCESSED_OK; - } - - Format newFormat = inputBuffer.getFormat(); - - if (lastFormat != newFormat) - initConverter((AudioFormat) newFormat); - - int inpLength = inputBuffer.getLength(); - int outLength = calculateOutputSize(inputBuffer.getLength()); - - byte[] inpData = (byte[]) inputBuffer.getData(); - byte[] outData = validateByteArraySize(outputBuffer, outLength); - - convert(inpData, inputBuffer.getOffset(), inpLength, outData, 0); - - updateOutput(outputBuffer, outputFormat, outLength, 0); - return BUFFER_PROCESSED_OK; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ulaw/Packetizer.java b/src/net/java/sip/communicator/impl/neomedia/codec/audio/ulaw/Packetizer.java deleted file mode 100644 index 5cb42b02a..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/audio/ulaw/Packetizer.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.audio.ulaw; - -/** - * Overrides the ULaw Packetizer with a different packet size. - * - * @author Thomas Hofer - */ -public class Packetizer - extends com.sun.media.codec.audio.ulaw.Packetizer -{ - /** - * Constructs a new ULaw Packetizer. - */ - public Packetizer() - { - // RFC 3551 4.5 Audio Encodings default ms/packet is 20 - packetSize = 160; - setPacketSize(packetSize); - - PLUGIN_NAME = "ULaw Packetizer"; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/AVFrame.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/AVFrame.java deleted file mode 100644 index d007fc347..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/AVFrame.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video; - -/** - * Represents a pointer to a native FFmpeg AVFrame object. - * - * @author Lubomir Marinov - */ -public class AVFrame -{ - /** - * The pointer to the native FFmpeg AVFrame object represented by - * this instance. - */ - private final long ptr; - - /** - * Initializes a new AVFrame instance which is to represent a - * specific pointer to a native FFmpeg AVFrame object. - * - * @param ptr the pointer to the native FFmpeg AVFrame object to be - * represented by the new instance - */ - public AVFrame(long ptr) - { - if (ptr == 0) - throw new IllegalArgumentException("ptr"); - - this.ptr = ptr; - } - - /** - * Gets the pointer to the native FFmpeg AVFrame object represented - * by this instance. - * - * @return the pointer to the native FFmpeg AVFrame object - * represented by this instance - */ - public long getPtr() - { - return ptr; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/AVFrameFormat.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/AVFrameFormat.java deleted file mode 100644 index dc2bbb4a9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/AVFrameFormat.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video; - -import java.awt.*; - -import javax.media.*; -import javax.media.format.*; - -/** - * Implements a VideoFormat for a Buffer carrying - * AVFrame as its data. While the AVFrameFormat class - * is not strictly necessary and VideoFormat could have be directly - * used, it is conceived as an appropriate way to avoid possible matching with - * other VideoFormats and a very obvious one. - * - * @author Lyubomir Marinov - * @author Sebastien Vincent - */ -public class AVFrameFormat - extends VideoFormat -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * The encoding of the AVFrameFormat instances. - */ - public static final String AVFRAME = "AVFrame"; - - /** - * The native device-specific format represented by this instance. It's - * necessary in the cases of multiple device-specific formats corresponding - * to one and the same native FFmpeg format in which JMF is unable to - * differentiate them, yet the device needs to know its device-specific - * format. - */ - private int devicePixFmt; - - /** - * The native FFmpeg format represented by this instance. - */ - private int pixFmt; - - /** - * Initializes a new AVFrameFormat instance with unspecified size, - * frame rate and FFmpeg colorspace. - */ - public AVFrameFormat() - { - this(NOT_SPECIFIED, NOT_SPECIFIED); - } - - /** - * Initializes a new AVFrameFormat instance with a specific FFmpeg - * colorspace and unspecified size and frame rate. - * - * @param pixFmt the FFmpeg colorspace to be represented by the new instance - */ - public AVFrameFormat(int pixFmt) - { - this(pixFmt, NOT_SPECIFIED); - } - - /** - * Initializes a new AVFrameFormat instance with a specific FFmpeg - * colorspace and unspecified size and frame rate. - * - * @param pixFmt the FFmpeg colorspace to be represented by the new instance - * @param devicePixFmt the capture device colorspace to be represented by - * the new instance - */ - public AVFrameFormat(int pixFmt, int devicePixFmt) - { - this(null, NOT_SPECIFIED, pixFmt, devicePixFmt); - } - - /** - * Initializes a new AVFrameFormat instance with specific size, - * frame rate and FFmpeg colorspace. - * - * @param size the Dimension of the new instance - * @param frameRate the frame rate of the new instance - * @param pixFmt the FFmpeg colorspace to be represented by the new instance - * @param devicePixFmt the capture device colorspace to be represented by - * the new instance - */ - public AVFrameFormat( - Dimension size, - float frameRate, - int pixFmt, int devicePixFmt) - { - super(AVFRAME, size, NOT_SPECIFIED, AVFrame.class, frameRate); - - this.pixFmt = pixFmt; - this.devicePixFmt = devicePixFmt; - } - - /** - * Initializes a new AVFrameFormat instance which has the same - * properties as this instance. - * - * @return a new AVFrameFormat instance which has the same - * properties as this instance - */ - @Override - public Object clone() - { - AVFrameFormat f - = new AVFrameFormat( - getSize(), - getFrameRate(), - pixFmt, devicePixFmt); - - f.copy(this); - return f; - } - - /** - * Copies the properties of the specified Format into this - * instance. - * - * @param f the Format the properties of which are to be copied - * into this instance - */ - @Override - protected void copy(Format f) - { - super.copy(f); - - if (f instanceof AVFrameFormat) - { - AVFrameFormat avFrameFormat = (AVFrameFormat) f; - - pixFmt = avFrameFormat.pixFmt; - devicePixFmt = avFrameFormat.devicePixFmt; - } - } - - /** - * Determines whether a specific Object represents a value that is - * equal to the value represented by this instance. - * - * @param obj the Object to be determined whether it represents a - * value that is equal to the value represented by this instance - * @return true if the specified obj represents a value - * that is equal to the value represented by this instance; otherwise, - * false - */ - @Override - public boolean equals(Object obj) - { - if ((obj instanceof AVFrameFormat) && super.equals(obj)) - { - AVFrameFormat avFrameFormat = (AVFrameFormat) obj; - - return (pixFmt == avFrameFormat.pixFmt); - } - else - return false; - } - - /** - * Gets the native FFmpeg format represented by this instance. - * - * @return the native FFmpeg format represented by this instance - */ - public int getPixFmt() - { - return pixFmt; - } - - /** - * Gets the native capture device format represented by this instance. - * - * @return native capture device format represented by this instance - */ - public int getDevicePixFmt() - { - return devicePixFmt; - } - - @Override - public int hashCode() - { - return super.hashCode() + pixFmt; - } - - /** - * Finds the attributes shared by two matching Formats. If the - * specified Format does not match this one, the result is - * undefined. - * - * @param format the matching Format to intersect with this one - * @return a Format with its attributes set to the attributes - * common to this instance and the specified format - */ - @Override - public Format intersects(Format format) - { - Format intersection = super.intersects(format); - - if (intersection != null) - { - AVFrameFormat avFrameFormatIntersection - = (AVFrameFormat) intersection; - - avFrameFormatIntersection.pixFmt - = ((pixFmt == NOT_SPECIFIED) - && (format instanceof AVFrameFormat)) - ? ((AVFrameFormat) format).pixFmt - : pixFmt; - } - return intersection; - } - - /** - * Determines whether a specific format matches this instance i.e. whether - * their attributes match according to the definition of "match" given by - * {@link Format#matches(Format)}. - * - * @param format the Format to compare to this instance - * @return true if the specified format matches this one; - * otherwise, false - */ - @Override - public boolean matches(Format format) - { - boolean matches; - - if (super.matches(format)) - { - if (format instanceof AVFrameFormat) - { - AVFrameFormat avFrameFormat = (AVFrameFormat) format; - - matches - = ((pixFmt == NOT_SPECIFIED) - || (avFrameFormat.pixFmt == NOT_SPECIFIED) - || (pixFmt == avFrameFormat.pixFmt)); - } - else - matches = true; - } - else - matches = false; - return matches; - } - - @Override - public String toString() - { - return super.toString() + ", pixFmt= " + pixFmt; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/ByteBuffer.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/ByteBuffer.java deleted file mode 100644 index 2bb81d59a..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/ByteBuffer.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video; - -import net.java.sip.communicator.impl.neomedia.codec.*; - -/** - * Represents a buffer of native memory with a specific size/capacity which - * either contains a specific number of bytes of valid data or is free for - * consumption. - * - * @author Lubomir Marinov - */ -public class ByteBuffer -{ - - /** - * The maximum number of bytes which can be written into the native memory - * represented by this instance. - */ - public final int capacity; - - /** - * The indicator which determines whether this instance is free to be - * written bytes into. - */ - private boolean free; - - /** - * The number of bytes of valid data that the native memory represented by - * this instance contains. - */ - private int length; - - /** - * The pointer to the native memory represented by this instance. - */ - public final long ptr; - - /** - * Initializes a new ByteBuffer instance with a specific - * capacity. - * - * @param capacity the maximum number of bytes which can be written into the - * native memory represented by the new instance - */ - public ByteBuffer(int capacity) - { - this.capacity = capacity; - this.ptr = FFmpeg.av_malloc(this.capacity); - - this.free = true; - this.length = 0; - - if (this.ptr == 0) - { - throw - new OutOfMemoryError( - getClass().getSimpleName() - + " with capacity " - + this.capacity); - } - } - - /** - * Gets the number of bytes of valid data that the native memory represented - * by this instance contains. - * - * @return the number of bytes of valid data that the native memory - * represented by this instance contains - */ - public int getLength() - { - return length; - } - - /** - * Determines whether this instance is free to be written bytes into. - * - * @return true if this instance is free to be written bytes into - * or false is the native memory represented by this instance is - * already is use - */ - public boolean isFree() - { - return free; - } - - /** - * Sets the indicator which determines whether this instance is free to be - * written bytes into. - * - * @param free true if this instance is to be made available for - * writing bytes into; otherwise, false - */ - public void setFree(boolean free) - { - this.free = free; - if (this.free) - setLength(0); - } - - /** - * Sets the number of bytes of valid data that the native memory represented - * by this instance contains. - * - * @param length the number of bytes of valid data that the native memory - * represented by this instance contains - */ - public void setLength(int length) - { - this.length = length; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/FinalizableAVFrame.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/FinalizableAVFrame.java deleted file mode 100644 index 6ef4118b4..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/FinalizableAVFrame.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video; - -import java.awt.*; - -import javax.media.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; - -/** - * Represents an AVFrame used to provide captured media data in native - * format without representing the very frame data in the Java heap. Since the - * user may not know when the AVFrame instances are really safe for - * deallocation, FinalizableAVFrame relies on the Java finalization - * mechanism to reclaim the represented native memory. - * - * @author Lubomir Marinov - */ -public class FinalizableAVFrame - extends AVFrame -{ - - /** - * The indicator which determines whether the native memory represented by - * this instance has already been freed/deallocated. - */ - private boolean freed = false; - - /** - * Initializes a new FinalizableAVFrame instance which is to - * allocate a new native FFmpeg AVFrame and represent it. - */ - public FinalizableAVFrame() - { - super(FFmpeg.avcodec_alloc_frame()); - } - - /** - * Deallocates the native memory represented by this instance. - * - * @see Object#finalize() - */ - @Override - protected void finalize() - throws Throwable - { - try - { - if (!freed) - { - long ptr = getPtr(); - long bufferPtr = FFmpeg.avpicture_get_data0(ptr); - - if (bufferPtr != 0) - freeData0(bufferPtr); - FFmpeg.av_free(ptr); - freed = true; - } - } - finally - { - super.finalize(); - } - } - - /** - * Frees the memory pointed to by the data0 member of the native - * AVFrame. - * @param data0 pointer to free - */ - protected void freeData0(long data0) - { - FFmpeg.av_free(data0); - } - - /** - * Read the frame. - * - * @param buffer buffer - * @param format format of the buffer - * @param data the data - * @param byteBufferPool the ByteBuffer pool - */ - public static void read( - Buffer buffer, - Format format, - ByteBuffer data, - final ByteBufferPool byteBufferPool) - { - Object bufferData = buffer.getData(); - AVFrame frame; - long framePtr; - long bufferPtrToReturnFree; - - if (bufferData instanceof AVFrame) - { - frame = (AVFrame) bufferData; - framePtr = frame.getPtr(); - bufferPtrToReturnFree = FFmpeg.avpicture_get_data0(framePtr); - } - else - { - frame - = new FinalizableAVFrame() - { - @Override - protected void freeData0(long data0) - { - byteBufferPool.returnFreeBuffer(data0); - } - }; - buffer.setData(frame); - framePtr = frame.getPtr(); - bufferPtrToReturnFree = 0; - } - - AVFrameFormat frameFormat = (AVFrameFormat) format; - Dimension frameSize = frameFormat.getSize(); - - FFmpeg.avpicture_fill( - framePtr, - data.ptr, - frameFormat.getPixFmt(), - frameSize.width, frameSize.height); - - if (bufferPtrToReturnFree != 0) - byteBufferPool.returnFreeBuffer(bufferPtrToReturnFree); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/HFlip.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/HFlip.java deleted file mode 100644 index 6283e1096..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/HFlip.java +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video; - -import java.awt.*; - -import javax.media.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.util.*; - -/** - * Implements a video Effect which horizontally flips - * AVFrames. - * - * @author Sebastien Vincent - * @author Lyubomir Marinov - */ -public class HFlip - extends AbstractCodecExt - implements Effect -{ - /** - * The Logger used by the HFlip class and its instances - * for logging output. - */ - private static final Logger logger = Logger.getLogger(HFlip.class); - - /** - * The list of Formats supported by HFlip instances as - * input and output. - */ - private static final Format[] SUPPORTED_FORMATS - = new Format[] { new AVFrameFormat() }; - - /** - * The name of the FFmpeg ffsink video source AVFilter used by - * HFlip. - */ - private static final String VSINK_FFSINK_NAME = "nullsink"; - - /** - * The name of the FFmpeg buffer video source AVFilter used by - * HFlip. - */ - private static final String VSRC_BUFFER_NAME = "buffer"; - - /** - * The pointer to the AVFilterContext in {@link #graph} of the - * FFmpeg video source with the name {@link #VSRC_BUFFER_NAME}. - */ - private long buffer; - - /** - * The pointer to the AVFilterContext in {@link #graph} of the - * FFmpeg video sink with the name {@link #VSINK_FFSINK_NAME}. - */ - private long ffsink; - - /** - * The pointer to the AVFilterGraph instance which contains the - * FFmpeg hflip filter represented by this Effect. - */ - private long graph; - - /** - * The height of {@link #graph}. - */ - private int height; - - /** - * The pointer to the AVFilterBufferRef instance represented as an - * AVFrame by {@link #outputFrame}. - */ - private long outputFilterBufferRef; - - /** - * The pointer to the AVFrame instance which is the output (data) - * of this Effect. - */ - private long outputFrame; - - /** - * The FFmpeg pixel format of {@link #graph}. - */ - private int pixFmt = FFmpeg.PIX_FMT_NONE; - - /** - * The width of {@link #graph}. - */ - private int width; - - /** - * Initializes a new HFlip instance. - */ - public HFlip() - { - super("FFmpeg HFlip Filter", AVFrameFormat.class, SUPPORTED_FORMATS); - } - - /** - * Closes this Effect. - * - * @see AbstractCodecExt#doClose() - */ - protected synchronized void doClose() - { - try - { - if (outputFrame != 0) - { - FFmpeg.av_free(outputFrame); - outputFrame = 0; - } - } - finally - { - reset(); - } - } - - /** - * Opens this Effect. - * - * @throws ResourceUnavailableException if any of the required resource - * cannot be allocated - * @see AbstractCodecExt#doOpen() - */ - protected synchronized void doOpen() - throws ResourceUnavailableException - { - outputFrame = FFmpeg.avcodec_alloc_frame(); - if (outputFrame == 0) - { - String reason = "avcodec_alloc_frame: " + outputFrame; - - logger.error(reason); - throw new ResourceUnavailableException(reason); - } - } - - /** - * Performs the media processing defined by this Effect. - * - * @param inputBuffer the Buffer that contains the media data to be - * processed - * @param outputBuffer the Buffer in which to store the processed - * media data - * @return BUFFER_PROCESSED_OK if the processing is successful - * @see AbstractCodecExt#doProcess(Buffer, Buffer) - */ - protected synchronized int doProcess( - Buffer inputBuffer, - Buffer outputBuffer) - { - /* - * A new frame is about to be output so the old frame is no longer - * necessary. - */ - if (outputFilterBufferRef != 0) - { - FFmpeg.avfilter_unref_buffer(outputFilterBufferRef); - outputFilterBufferRef = 0; - } - - /* - * Make sure the graph is configured with the current Format i.e. size - * and pixFmt. - */ - AVFrameFormat format = (AVFrameFormat) inputBuffer.getFormat(); - Dimension size = format.getSize(); - int pixFmt = format.getPixFmt(); - - if ((this.width != size.width) - || (this.height != size.height) - || (this.pixFmt != pixFmt)) - reset(); - if (graph == 0) - { - String errorReason = null; - int error = 0; - long buffer = 0; - long ffsink = 0; - - graph = FFmpeg.avfilter_graph_alloc(); - if (graph == 0) - errorReason = "avfilter_graph_alloc"; - else - { - String filters - = VSRC_BUFFER_NAME + "=" + size.width + ":" + size.height - + ":" + pixFmt + ":1:1000000:1:1,hflip," - + VSINK_FFSINK_NAME; - long log_ctx = 0; - - error - = FFmpeg.avfilter_graph_parse( - graph, - filters, - 0, 0, - log_ctx); - if (error == 0) - { - /* - * Unfortunately, the name of an AVFilterContext created by - * avfilter_graph_parse is not the name of the AVFilter. - */ - String parsedFilterNameFormat = "Parsed filter %1$d %2$s"; - - buffer - = FFmpeg.avfilter_graph_get_filter( - graph, - String.format( - parsedFilterNameFormat, - 0, - VSRC_BUFFER_NAME)); - if (buffer == 0) - { - errorReason - = "avfilter_graph_get_filter: " + VSRC_BUFFER_NAME; - } - else - { - ffsink - = FFmpeg.avfilter_graph_get_filter( - graph, - String.format( - parsedFilterNameFormat, - 2, - VSINK_FFSINK_NAME)); - if (ffsink == 0) - { - errorReason - = "avfilter_graph_get_filter: " - + VSINK_FFSINK_NAME; - } - else - { - error - = FFmpeg.avfilter_graph_config(graph, log_ctx); - if (error != 0) - errorReason = "avfilter_graph_config"; - } - } - } - else - errorReason = "avfilter_graph_parse"; - if ((errorReason != null) || (error != 0)) - { - FFmpeg.avfilter_graph_free(graph); - graph = 0; - } - } - if (graph == 0) - { - if (errorReason != null) - { - if (error == 0) - logger.error(errorReason); - else - logger.error(errorReason + ": " + error); - } - return BUFFER_PROCESSED_FAILED; - } - else - { - this.width = size.width; - this.height = size.height; - this.pixFmt = pixFmt; - this.buffer = buffer; - this.ffsink = ffsink; - } - } - - /* - * The graph is configured for the current Format, apply its filters to - * the inputFrame. - */ - long inputFrame = ((AVFrame) inputBuffer.getData()).getPtr(); - - outputFilterBufferRef - = FFmpeg.get_filtered_video_frame( - inputFrame, this.width, this.height, this.pixFmt, - buffer, - ffsink, - outputFrame); - if(outputFilterBufferRef == 0) - { - /* - * If get_filtered_video_frame fails, it is likely to fail for any - * frame. Consequently, printing that it has failed will result in a - * lot of repeating logging output. Since the failure in question - * will be visible in the UI anyway, just debug it. - */ - if (logger.isDebugEnabled()) - logger.debug("get_filtered_video_frame"); - return BUFFER_PROCESSED_FAILED; - } - - Object out = outputBuffer.getData(); - - if (!(out instanceof AVFrame) - || (((AVFrame) out).getPtr() != outputFrame)) - { - outputBuffer.setData(new AVFrame(outputFrame)); - } - - outputBuffer.setDiscard(inputBuffer.isDiscard()); - outputBuffer.setDuration(inputBuffer.getDuration()); - outputBuffer.setEOM(inputBuffer.isEOM()); - outputBuffer.setFlags(inputBuffer.getFlags()); - outputBuffer.setFormat(format); - outputBuffer.setHeader(inputBuffer.getHeader()); - outputBuffer.setLength(inputBuffer.getLength()); - outputBuffer.setSequenceNumber(inputBuffer.getSequenceNumber()); - outputBuffer.setTimeStamp(inputBuffer.getTimeStamp()); - return BUFFER_PROCESSED_OK; - } - - /** - * Resets the state of this PlugIn. - */ - @Override - public synchronized void reset() - { - if (outputFilterBufferRef != 0) - { - FFmpeg.avfilter_unref_buffer(outputFilterBufferRef); - outputFilterBufferRef = 0; - } - if (graph != 0) - { - FFmpeg.avfilter_graph_free(graph); - graph = 0; - - width = 0; - height = 0; - pixFmt = FFmpeg.PIX_FMT_NONE; - buffer = 0; - ffsink = 0; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/ImageScaler.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/ImageScaler.java deleted file mode 100644 index 4850460b6..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/ImageScaler.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video; - -import java.awt.*; -import java.awt.image.*; - -import javax.media.Buffer; -import javax.media.Codec; -import javax.media.Format; -import javax.media.format.RGBFormat; -import javax.media.format.VideoFormat; - -import net.sf.fmj.media.AbstractCodec; -import net.sf.fmj.media.util.BufferToImage; -import net.sf.fmj.media.util.ImageToBuffer; - -/** - * Codec that scales images from one size to another. - * Interestingly, cross-platform JMF does not appear to have a corresponding codec. - * @author Ken Larson - * - * Original from fmj project, changed only output format sizes. - * The sizes are those supported in h263 and h264. - * @author Damian Minkov - * @author Sebastien Vincent - */ -public class ImageScaler - extends AbstractCodec - implements Codec -{ - // TODO: all formats supported by BufferToImage - private final Format[] supportedInputFormats = new Format[] { - new RGBFormat(null, -1, Format.intArray, -1.0f, 32, -1, -1, -1), - }; - private final Format[] supportedOutputFormats = new Format[] { - //new RGBFormat(new Dimension(1280, 1024), -1, Format.intArray, -1.0f, 32, -1, -1, -1), - //new RGBFormat(new Dimension(1280, 800), -1, Format.intArray, -1.0f, 32, -1, -1, -1), - new RGBFormat(new Dimension(1024, 768), -1, Format.intArray, -1.0f, 32, -1, -1, -1), - new RGBFormat(new Dimension(800, 600), -1, Format.intArray, -1.0f, 32, -1, -1, -1), - new RGBFormat(new Dimension(640, 480), -1, Format.intArray, -1.0f, 32, -1, -1, -1), - new RGBFormat(new Dimension(720, 576), -1, Format.intArray, -1.0f, 32, -1, -1, -1), - //P720 - new RGBFormat(new Dimension(720, 480), -1, Format.intArray, -1.0f, 32, -1, -1, -1), - //CIF4 - new RGBFormat(new Dimension(704, 576), -1, Format.intArray, -1.0f, 32, -1, -1, -1), - //CIF - new RGBFormat(new Dimension(352, 288), -1, Format.intArray, -1.0f, 32, -1, -1, -1), - new RGBFormat(new Dimension(320, 240), -1, Format.intArray, -1.0f, 32, -1, -1, -1), - //QCIF - new RGBFormat(new Dimension(176, 144), -1, Format.intArray, -1.0f, 32, -1, -1, -1), - //SQCIF - new RGBFormat(new Dimension(128, 96), -1, Format.intArray, -1.0f, 32, -1, -1, -1), - }; - - private BufferToImage bufferToImage; - - private boolean passthrough; - - @Override - public Format[] getSupportedInputFormats() - { - return supportedInputFormats; - } - - @Override - public Format[] getSupportedOutputFormats(Format input) - { -// if (input == null) - return supportedOutputFormats; -// VideoFormat inputCast = (VideoFormat) input; -// final Format[] result = new Format[] { -// new RGBFormat(DIMENSION, -1, Format.intArray, -1.0f, 32, -1, -1, -1)}; -// // TODO: we have to specify the RGB, etc. in the output format. -// return result; - } - - @Override - public Format setInputFormat(Format format) - { - final VideoFormat videoFormat = (VideoFormat) format; - if (videoFormat.getSize() == null) - return null; // must set a size. - - // TODO: check VideoFormat and compatibility - bufferToImage = new BufferToImage(videoFormat); - - format = super.setInputFormat(format); - updatePassthrough(); - return format; - } - - @Override - public Format setOutputFormat(Format format) - { - format = super.setOutputFormat(format); - updatePassthrough(); - return format; - } - - private void updatePassthrough() - { - Format outputFormat = getOutputFormat(); - if (outputFormat != null) - { - Dimension outputSize = ((VideoFormat) outputFormat).getSize(); - if (outputSize != null) - { - Format inputFormat = getInputFormat(); - passthrough = - (inputFormat != null) - && outputSize.equals( - ((VideoFormat) inputFormat).getSize()); - return; - } - } - passthrough = false; - } - - @Override - public int process(Buffer input, Buffer output) - { - if (!checkInputBuffer(input)) - { - return BUFFER_PROCESSED_FAILED; - } - - if (isEOM(input)) - { - propagateEOM(output); // TODO: what about data? can there be any? - return BUFFER_PROCESSED_OK; - } - - // sometimes format sizes are the same but some other field is different - // and jmf use the scaler (in my case length field was not sent in - // one of the formats) the check for sizes is made in method - // setInputFormat - if(passthrough) - { - output.setData(input.getData()); - output.setLength(input.getLength()); - output.setOffset(input.getOffset()); - return BUFFER_PROCESSED_OK; - } - - final BufferedImage image = (BufferedImage) bufferToImage.createImage(input); -/* - final Dimension inputSize = ((VideoFormat) inputFormat).getSize(); - final Dimension outputSize = ((VideoFormat) outputFormat).getSize(); - final double scaleX = ((double) outputSize.width) / ((double) inputSize.width); - final double scaleY = ((double) outputSize.height) / ((double) inputSize.height); - - final BufferedImage scaled = scale(image, scaleX, scaleY); // TODO: is the size exact? what about rounding errors? -*/ - - final Dimension outputSize = ((VideoFormat) outputFormat).getSize(); - /* rescale by preserving ratio */ - final BufferedImage scaled = scalePreserveRatio(image, outputSize.width, outputSize.height); // TODO: is the size exact? what about rounding errors? - - final Buffer b = ImageToBuffer.createBuffer(scaled, ((VideoFormat) outputFormat).getFrameRate()); - output.setData(b.getData()); - output.setLength(b.getLength()); - output.setOffset(b.getOffset()); - output.setFormat(b.getFormat()); - // TODO: what about format? - - return BUFFER_PROCESSED_OK; - } - - /** - * Get a scaled BufferedImage that preserves ratio and puts black - * borders if the ratio of the source image is different than the ratio of - * the scaled image. - *

- * Mainly inspired by - * http://java.developpez.com/faq/gui/?page=graphique_general_images - * #GRAPHIQUE_IMAGE_redimensionner - *

- * - * @param src the BufferedImage to scale - * @param width width of the scaled image - * @param height height of scaled image - * @return the BufferedImage which represents src scaled - * to width and height - */ - public static BufferedImage scalePreserveRatio(BufferedImage src, - int width, - int height) - { - BufferedImage buf = new BufferedImage(width, height, src.getType()); - double ratioSrc = (double)src.getWidth() / (double)src.getHeight(); - double ratioDst = width / height; - int startWidth = 0; - int startHeight = 0; - - if(Double.compare(ratioSrc, ratioDst) != 0) - { - /* adjust ratio */ - int newWidth = 0; - int newHeight = ((src.getHeight() * width) / src.getWidth()); - - /* first try to adjust height */ - startHeight = (height - newHeight) / 2; - - if(startHeight < 0) - { - /* rescale width */ - newWidth = ((src.getWidth() * height) / src.getHeight()); - startWidth = (width - newWidth) / 2; - - startHeight = 0; - width = newWidth; - } - else - { - height = newHeight; - } - } - - Graphics2D g2d = buf.createGraphics(); - g2d.setBackground(Color.BLACK); - g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR); - g2d.drawImage(src, startWidth, startHeight, width, height, null); - g2d.dispose(); - return buf; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/SwScaler.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/SwScaler.java deleted file mode 100644 index 3abf18431..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/SwScaler.java +++ /dev/null @@ -1,663 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video; - -import java.awt.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.control.*; -import net.java.sip.communicator.util.*; -import net.sf.fmj.media.*; - -/** - * Implements a Codec which uses libswscale to scale images and convert - * between color spaces (typically, RGB and YUV). - * - * @author Sebastien Vincent - * @author Lyubomir Marinov - */ -public class SwScaler - extends AbstractCodec -{ - - /** - * The Logger used by the SwScaler class and its instances - * for logging output. - */ - private static final Logger logger = Logger.getLogger(SwScaler.class); - - /** - * The minimum height and/or width of the input and/or output to be passed - * to sws_scale in order to prevent its crashing. - */ - private static final int MIN_SWS_SCALE_HEIGHT_OR_WIDTH = 4; - - /** - * The indicator which determines whether this scaler will attempt to keep - * the width and height of YUV 420 output even. - */ - private final boolean fixOddYuv420Size; - - /** - * The FrameProcessingControl of this Codec which allows - * JMF to instruct it to drop frames because it's behind schedule. - */ - private final FrameProcessingControlImpl frameProcessingControl - = new FrameProcessingControlImpl(); - - /** - * Supported output formats. - */ - private Format[] supportedOutputFormats = new Format[] - { - new YUVFormat(null, -1, Format.byteArray, -1.0f, YUVFormat.YUV_420, - -1, -1, 0, -1, -1), - new YUVFormat(null, -1, Format.intArray, -1.0f, YUVFormat.YUV_420, - -1, -1, 0, -1, -1), - new YUVFormat(null, -1, Format.shortArray, -1.0f, YUVFormat.YUV_420, - -1, -1, 0, -1, -1), - new RGBFormat(null, -1, Format.byteArray, -1.0f, 32, -1, -1, -1), - new RGBFormat(null, -1, Format.intArray, -1.0f, 32, -1, -1, -1), - new RGBFormat(null, -1, Format.shortArray, -1.0f, 32, -1, -1, -1), - new RGBFormat(null, -1, Format.byteArray, -1.0f, 24, -1, -1, -1), - new RGBFormat(null, -1, Format.intArray, -1.0f, 24, -1, -1, -1), - new RGBFormat(null, -1, Format.shortArray, -1.0f, 24, -1, -1, -1), - }; - - /** - * Libswscale context pointer. - */ - private long swsContext = 0; - - /** - * Initializes a new SwScaler instance which doesn't have an output - * size and will use a default one when it becomes necessary unless an - * explicit one is specified in the meantime. - */ - public SwScaler() - { - this(false); - } - - /** - * Initializes a new SwScaler instance which can optionally attempt - * to keep the width and height of YUV 420 output even. - * - * @param fixOddYuv420Size true to keep the width and height of YUV - * 420 output even; otherwise, false - */ - protected SwScaler(boolean fixOddYuv420Size) - { - this.fixOddYuv420Size = fixOddYuv420Size; - - inputFormats = new Format[] - { - new AVFrameFormat(), - new RGBFormat(null, -1, Format.byteArray, -1.0f, 32, -1, -1, -1), - new RGBFormat(null, -1, Format.intArray, -1.0f, 32, -1, -1, -1), - new RGBFormat(null, -1, Format.shortArray, -1.0f, 32, -1, -1, -1), - new RGBFormat(null, -1, Format.byteArray, -1.0f, 24, -1, -1, -1), - new RGBFormat(null, -1, Format.intArray, -1.0f, 24, -1, -1, -1), - new RGBFormat(null, -1, Format.shortArray, -1.0f, 24, -1, -1, -1), - new YUVFormat(null, -1, Format.byteArray, -1.0f, YUVFormat.YUV_420, - -1, -1, 0, -1, -1), - new YUVFormat(null, -1, Format.intArray, -1.0f, YUVFormat.YUV_420, - -1, -1, 0, -1, -1), - new YUVFormat(null, -1, Format.shortArray, -1.0f, YUVFormat.YUV_420, - -1, -1, 0, -1, -1), - }; - - addControl(frameProcessingControl); - } - - /** - * Close codec. - */ - @Override - public void close() - { - try - { - if (swsContext != 0) - { - FFmpeg.sws_freeContext(swsContext); - swsContext = 0; - } - } - finally - { - super.close(); - } - } - - /** - * Gets the Format in which this Codec is currently - * configured to accept input media data. - *

- * Makes the protected super implementation public. - *

- * - * @return the Format in which this Codec is currently - * configured to accept input media data - * @see AbstractCodec#getInputFormat() - */ - @Override - public Format getInputFormat() - { - return super.getInputFormat(); - } - - /** - * Gets native (FFmpeg) RGB format. - * - * @param rgb JMF RGBFormat - * @return native RGB format - */ - public static int getNativeRGBFormat(RGBFormat rgb) - { - int fmt; - - if(rgb.getBitsPerPixel() == 32) - switch(rgb.getRedMask()) - { - case 1: - case 0xff: - fmt = FFmpeg.PIX_FMT_BGR32; - break; - case 2: - case (0xff << 8): - fmt = FFmpeg.PIX_FMT_BGR32_1; - break; - case 3: - case (0xff << 16): - fmt = FFmpeg.PIX_FMT_RGB32; - break; - case 4: - case (0xff << 24): - fmt = FFmpeg.PIX_FMT_RGB32_1; - break; - default: - /* assume ARGB ? */ - fmt = FFmpeg.PIX_FMT_RGB32; - break; - } - else - fmt = FFmpeg.PIX_FMT_RGB24; - - return fmt; - } - - /** - * Gets the output size. - * - * @return the output size - */ - public Dimension getOutputSize() - { - Format outputFormat = getOutputFormat(); - - if (outputFormat == null) - { - // They all have one and the same size. - outputFormat = supportedOutputFormats[0]; - } - return ((VideoFormat) outputFormat).getSize(); - } - - /** - * Gets the supported output formats for an input one. - * - * @param input input format to get supported output ones for - * @return array of supported output formats - */ - @Override - public Format[] getSupportedOutputFormats(Format input) - { - if(input == null) - return supportedOutputFormats; - - /* if size is set for element 0 (YUVFormat), it is also set - * for element 1 (RGBFormat) and so on... - */ - Dimension size = ((VideoFormat) supportedOutputFormats[0]).getSize(); - - /* no specified size set so return the same size as input - * in output format supported - */ - VideoFormat videoInput = (VideoFormat) input; - - if(size == null) - size = videoInput.getSize(); - - float frameRate = videoInput.getFrameRate(); - - return - new Format[] - { - new YUVFormat(size, -1, Format.byteArray, frameRate, - YUVFormat.YUV_420, -1, -1, 0, -1, -1), - new YUVFormat(size, -1, Format.intArray, frameRate, - YUVFormat.YUV_420, -1, -1, 0, -1, -1), - new YUVFormat(size, -1, Format.shortArray, frameRate, - YUVFormat.YUV_420, -1, -1, 0, -1, -1), - new RGBFormat(size, -1, Format.byteArray, frameRate, 32, -1, -1, - -1), - new RGBFormat(size, -1, Format.intArray, frameRate, 32, -1, -1, - -1), - new RGBFormat(size, -1, Format.shortArray, frameRate, 32, -1, - -1, -1), - new RGBFormat(size, -1, Format.byteArray, frameRate, 24, -1, -1, - -1), - new RGBFormat(size, -1, Format.intArray, frameRate, 24, -1, -1, - -1), - new RGBFormat(size, -1, Format.shortArray, frameRate, 24, -1, - -1, -1) - }; - } - - /** - * Processes (converts color space and/or scales) a buffer. - * - * @param input input buffer - * @param output output buffer - * @return BUFFER_PROCESSED_OK if buffer has been successfully - * processed - */ - @Override - public int process(Buffer input, Buffer output) - { - if (!checkInputBuffer(input)) - return BUFFER_PROCESSED_FAILED; - if (isEOM(input)) - { - propagateEOM(output); - return BUFFER_PROCESSED_OK; - } - if (input.isDiscard() || frameProcessingControl.isMinimalProcessing()) - { - output.setDiscard(true); - return BUFFER_PROCESSED_OK; - } - - // Determine the input Format. - VideoFormat inputFormat = (VideoFormat) input.getFormat(); - Format thisInputFormat = getInputFormat(); - - if ((inputFormat != thisInputFormat) - && !inputFormat.equals(thisInputFormat)) - setInputFormat(inputFormat); - - // Determine the output Format and size. - VideoFormat outputFormat = (VideoFormat) getOutputFormat(); - - if (outputFormat == null) - { - /* - * The format of the output Buffer is not documented to be used as - * input to the #process method. Anyway, we're trying to use it in - * case this Codec doesn't have an outputFormat set which is - * unlikely to ever happen. - */ - outputFormat = (VideoFormat) output.getFormat(); - if (outputFormat == null) - return BUFFER_PROCESSED_FAILED; - } - - Dimension outputSize = outputFormat.getSize(); - - if (outputSize == null) - { - outputSize = inputFormat.getSize(); - if (outputSize == null) - return BUFFER_PROCESSED_FAILED; - } - - int outputWidth = outputSize.width; - int outputHeight = outputSize.height; - - if ((outputWidth < MIN_SWS_SCALE_HEIGHT_OR_WIDTH) - || (outputHeight <= MIN_SWS_SCALE_HEIGHT_OR_WIDTH)) - return OUTPUT_BUFFER_NOT_FILLED; // sws_scale will crash - - // Apply the outputSize to the outputFormat of the output Buffer. - outputFormat = setSize(outputFormat, outputSize); - if (outputFormat == null) - return BUFFER_PROCESSED_FAILED; - - int dstFmt; - int dstLength; - - if (outputFormat instanceof YUVFormat) - { - dstFmt = FFmpeg.PIX_FMT_YUV420P; - /* YUV420P is 12 bits per pixel i.e. 1.5 bytes. */ - dstLength = (int) (outputWidth * outputHeight * 1.5); - } - else /* RGB format */ - { - dstFmt - = OSUtils.IS_ANDROID - ? getNativeRGBFormat((RGBFormat) outputFormat) - : FFmpeg.PIX_FMT_RGB32; - dstLength = (outputWidth * outputHeight * 4); - } - - Class outputDataType = outputFormat.getDataType(); - Object dst = output.getData(); - - if (Format.byteArray.equals(outputDataType)) - { - if(dst == null || ((byte[])dst).length < dstLength) - dst = new byte[dstLength]; - } - else if (Format.intArray.equals(outputDataType)) - { - /* Java int is always 4 bytes. */ - dstLength = dstLength / 4 + ((dstLength % 4 == 0) ? 0 : 1); - if(dst == null || ((int[])dst).length < dstLength) - dst = new int[dstLength]; - } - else if (Format.shortArray.equals(outputDataType)) - { - /* Java short is always 2 bytes. */ - dstLength = dstLength / 2 + ((dstLength % 2 == 0) ? 0 : 1); - if(dst == null || ((short[])dst).length < dstLength) - dst = new short[dstLength]; - } - else - { - logger.error("Unknown data type " + outputDataType); - return BUFFER_PROCESSED_FAILED; - } - - Dimension inputSize = inputFormat.getSize(); - - if (inputSize == null) - return BUFFER_PROCESSED_FAILED; - - int inputWidth = inputSize.width; - int inputHeight = inputSize.height; - - if ((inputWidth < MIN_SWS_SCALE_HEIGHT_OR_WIDTH) - || (inputHeight < MIN_SWS_SCALE_HEIGHT_OR_WIDTH)) - return OUTPUT_BUFFER_NOT_FILLED; // sws_scale will crash - - Object src = input.getData(); - int srcFmt; - long srcPicture; - - if (src instanceof AVFrame) - { - srcFmt = ((AVFrameFormat) inputFormat).getPixFmt(); - srcPicture = ((AVFrame) src).getPtr(); - } - else - { - srcFmt - = (inputFormat instanceof YUVFormat) - ? FFmpeg.PIX_FMT_YUV420P - : getNativeRGBFormat((RGBFormat) inputFormat); - srcPicture = 0; - } - - swsContext - = FFmpeg.sws_getCachedContext( - swsContext, - inputWidth, inputHeight, srcFmt, - outputWidth, outputHeight, dstFmt, - FFmpeg.SWS_BICUBIC); - - if (srcPicture == 0) - { - FFmpeg.sws_scale( - swsContext, - src, srcFmt, inputWidth, inputHeight, 0, inputHeight, - dst, dstFmt, outputWidth, outputHeight); - } - else - { - FFmpeg.sws_scale( - swsContext, - srcPicture, 0, inputHeight, - dst, dstFmt, outputWidth, outputHeight); - } - - output.setData(dst); - output.setDuration(input.getDuration()); - output.setFlags(input.getFlags()); - output.setFormat(outputFormat); - output.setLength(dstLength); - output.setOffset(0); - output.setSequenceNumber(input.getSequenceNumber()); - output.setTimeStamp(input.getTimeStamp()); - - // flags - int inFlags = input.getFlags(); - int outFlags = output.getFlags(); - - if ((inFlags & Buffer.FLAG_LIVE_DATA) != 0) - outFlags |= Buffer.FLAG_LIVE_DATA; - if ((inFlags & Buffer.FLAG_NO_WAIT) != 0) - outFlags |= Buffer.FLAG_NO_WAIT; - if ((inFlags & Buffer.FLAG_RELATIVE_TIME) != 0) - outFlags |= Buffer.FLAG_RELATIVE_TIME; - if ((inFlags & Buffer.FLAG_RTP_TIME) != 0) - outFlags |= Buffer.FLAG_RTP_TIME; - if ((inFlags & Buffer.FLAG_SYSTEM_TIME) != 0) - outFlags |= Buffer.FLAG_SYSTEM_TIME; - output.setFlags(outFlags); - - return BUFFER_PROCESSED_OK; - } - - /** - * Sets the input format. - * - * @param format format to set - * @return format - */ - @Override - public Format setInputFormat(Format format) - { - Format inputFormat - = (format instanceof VideoFormat) - ? super.setInputFormat(format) - : null /* A size is not required, the input must be video. */; - - if (inputFormat != null) - { - if (logger.isDebugEnabled()) - logger.debug("SwScaler set to input in " + inputFormat); - } - return inputFormat; - } - - /** - * Sets the Format in which this Codec is to output media - * data. - * - * @param format the Format in which this Codec is to - * output media data - * @return the Format in which this Codec is currently - * configured to output media data or null if format was - * found to be incompatible with this Codec - */ - @Override - public Format setOutputFormat(Format format) - { - if (fixOddYuv420Size && (format instanceof YUVFormat)) - { - YUVFormat yuvFormat = (YUVFormat) format; - - if (YUVFormat.YUV_420 == yuvFormat.getYuvType()) - { - Dimension size = yuvFormat.getSize(); - - if ((size != null) && (size.width > 2) && (size.height > 2)) - { - int width = (size.width >> 1) << 1; - int height = (size.height >> 1) << 1; - - if ((width != size.width) || (height != size.height)) - { - format - = new YUVFormat( - new Dimension(width, height), - Format.NOT_SPECIFIED, - yuvFormat.getDataType(), - yuvFormat.getFrameRate(), - yuvFormat.getYuvType(), - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - 0, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED); - } - } - } - } - - Format outputFormat = super.setOutputFormat(format); - - if (logger.isDebugEnabled() && (outputFormat != null)) - logger.debug("SwScaler set to output in " + outputFormat); - return outputFormat; - } - - /** - * Sets the size i.e. width and height of the current outputFormat - * of this SwScaler - * - * @param size the size i.e. width and height to be set on the current - * outputFormat of this SwScaler - */ - private void setOutputFormatSize(Dimension size) - { - VideoFormat outputFormat = (VideoFormat) getOutputFormat(); - - if (outputFormat != null) - { - outputFormat = setSize(outputFormat, size); - if (outputFormat != null) - setOutputFormat(outputFormat); - } - } - - /** - * Sets the output size. - * - * @param size the size to set as the output size - */ - public void setOutputSize(Dimension size) - { - supportedOutputFormats[0] - = new YUVFormat(size, -1, Format.byteArray, -1.0f, - YUVFormat.YUV_420, -1, -1, 0, -1, -1); - supportedOutputFormats[1] - = new YUVFormat(size, -1, Format.intArray, -1.0f, YUVFormat.YUV_420, - -1, -1, 0, -1, -1); - supportedOutputFormats[2] - = new YUVFormat(size, -1, Format.shortArray, -1.0f, - YUVFormat.YUV_420, -1, -1, 0, -1, -1); - supportedOutputFormats[3] - = new RGBFormat(size, -1, Format.byteArray, -1.0f, 32, -1, -1, -1); - supportedOutputFormats[4] - = new RGBFormat(size, -1, Format.intArray, -1.0f, 32, -1, -1, -1); - supportedOutputFormats[5] - = new RGBFormat(size, -1, Format.shortArray, -1.0f, 32, -1, -1, -1); - supportedOutputFormats[6] - = new RGBFormat(size, -1, Format.byteArray, -1.0f, 24, -1, -1, -1); - supportedOutputFormats[7] - = new RGBFormat(size, -1, Format.intArray, -1.0f, 24, -1, -1, -1); - supportedOutputFormats[8] - = new RGBFormat(size, -1, Format.shortArray, -1.0f, 24, -1, -1, -1); - - // Set the size to the outputFormat as well. - setOutputFormatSize(size); - } - - /** - * Gets a VideoFormat with a specific size i.e. width and height - * using a specific VideoFormat as a template. - * - * @param format the VideoFormat which is the template for the - * VideoFormat to be returned - * @param size the size i.e. width and height of the VideoFormat to - * be returned - * @return a VideoFormat with the specified size and based - * on the specified format - */ - private static VideoFormat setSize(VideoFormat format, Dimension size) - { - /* - * Since the size of the Format has changed, its size-related properties - * should change as well. Format#intersects doesn't seem to be cool - * because it preserves them and thus the resulting Format is - * inconsistent. - */ - if (format instanceof RGBFormat) - { - RGBFormat rgbFormat = (RGBFormat) format; - Class dataType = format.getDataType(); - int bitsPerPixel = rgbFormat.getBitsPerPixel(); - int pixelStride = rgbFormat.getPixelStride(); - - if ((pixelStride == Format.NOT_SPECIFIED) - && (dataType != null) - && (bitsPerPixel != Format.NOT_SPECIFIED)) - pixelStride - = dataType.equals(Format.byteArray) - ? (bitsPerPixel / 8) - : 1; - format - = new RGBFormat( - size, - Format.NOT_SPECIFIED, - dataType, - format.getFrameRate(), - bitsPerPixel, - rgbFormat.getRedMask(), - rgbFormat.getGreenMask(), - rgbFormat.getBlueMask(), - pixelStride, - ((pixelStride == Format.NOT_SPECIFIED) - || (size == null)) - ? Format.NOT_SPECIFIED - : (pixelStride * size.width) /* lineStride */, - rgbFormat.getFlipped(), - rgbFormat.getEndian()); - } - else if (format instanceof YUVFormat) - { - YUVFormat yuvFormat = (YUVFormat) format; - - format - = new YUVFormat( - size, - Format.NOT_SPECIFIED, - format.getDataType(), - format.getFrameRate(), - yuvFormat.getYuvType(), - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED, - 0, - Format.NOT_SPECIFIED, - Format.NOT_SPECIFIED); - } - else if (format != null) - { - logger.warn( - "SwScaler outputFormat of type " - + format.getClass().getName() - + " is not supported for optimized scaling."); - } - return format; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/h263p/DePacketizer.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/h263p/DePacketizer.java deleted file mode 100644 index e910bca34..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/h263p/DePacketizer.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video.h263p; - -import java.util.Arrays; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.util.Logger; -import net.sf.fmj.media.*; - -/** - * Depacketizes H.263+ RTP packets in in accord with RFC 4529 "RTP Payload - * Format for ITU-T Rec. H.263 Video". - * - * @author Sebastien Vincent - * @author Lubomir Marinov - */ -public class DePacketizer - extends AbstractCodecExt -{ - /** - * The Logger used by the DePacketizer class and its - * instances for logging output. - */ - private static final Logger logger = Logger.getLogger(DePacketizer.class); - - /** - * The size of the padding at the end of the output data of this - * DePacketizer expected by the H.263+ decoder. - */ - private final int outputPaddingSize = FFmpeg.FF_INPUT_BUFFER_PADDING_SIZE; - - /** - * Keeps track of last (input) sequence number in order to avoid - * inconsistent data. - */ - private long lastSequenceNumber = -1; - - /** - * The indicator which determines whether incomplete buffer packets are - * output from the H.263+ DePacketizer to the decoder. - */ - private static final boolean OUTPUT_INCOMPLETE_BUFFER = true; - - /** - * Initializes a new DePacketizer instance which is to depacketize - * H.263+ RTP packet. - */ - public DePacketizer() - { - super( - "H263+ DePacketizer", - VideoFormat.class, - new VideoFormat[] { new VideoFormat(Constants.H263P) }); - - inputFormats - = new VideoFormat[] { new VideoFormat(Constants.H263P_RTP) }; - } - - /** - * Close the Codec. - */ - protected void doClose() - { - } - - /** - * Opens this Codec and acquires the resources that it needs to - * operate. A call to {@link PlugIn#open()} on this instance will result in - * a call to doOpen only if {@link AbstractCodec#opened} is - * false. All required input and/or output formats are assumed to - * have been set on this Codec before doOpen is called. - * - * @throws ResourceUnavailableException if any of the resources that this - * Codec needs to operate cannot be acquired - * @see AbstractCodecExt#doOpen() - */ - protected void doOpen() - throws ResourceUnavailableException - { - } - - /** - * Processes (depacketizes) a buffer. - * - * @param inBuffer input buffer - * @param outBuffer output buffer - * @return BUFFER_PROCESSED_OK if buffer has been successfully - * processed - */ - protected int doProcess(Buffer inBuffer, Buffer outBuffer) - { - long sequenceNumber = inBuffer.getSequenceNumber(); - - if ((lastSequenceNumber != -1) - && ((sequenceNumber - lastSequenceNumber) != 1)) - { - int ret = 0; - - /* maybe we lost a frame somewhere or the sequence number reach - * its maximum number - */ - if (logger.isTraceEnabled()) - logger.trace( - "Dropped RTP packets upto sequenceNumber " - + lastSequenceNumber - + " and continuing with sequenceNumber " - + sequenceNumber); - - ret = reset(outBuffer); - - if ((ret & OUTPUT_BUFFER_NOT_FILLED) == 0) - { - lastSequenceNumber = -1; - return ret; - } - } - - lastSequenceNumber = sequenceNumber; - - byte[] in = (byte[]) inBuffer.getData(); - int inLength = inBuffer.getLength(); - int inOffset = inBuffer.getOffset(); - int outOffset = outBuffer.getOffset(); - - if(inLength < 3) - { - return BUFFER_PROCESSED_FAILED; - } - - boolean pBit = ((in[inOffset] & 0x04) > 0); - boolean vBit = ((in[inOffset] & 0x02) > 0);; - int plen = ((in[inOffset] & 0x01) << 5) + - ((in[inOffset + 1] & 0xF8) >> 3); - int dataLength = inLength - plen - (vBit ? 1 : 0) - (pBit ? 0 : 2); - - byte out[] = validateByteArraySize(outBuffer, outOffset + dataLength + - outputPaddingSize); - - if(pBit) - { - out[0] = 0x00; - out[1] = 0x00; - } - - if(vBit) - { - /* ignore VRC */ - } - - if(plen > 0) - { - if(logger.isInfoEnabled()) - { - logger.info("Extra picture header present PLEN=" + plen); - } - } - - System.arraycopy(in, inOffset + 2 + (vBit ? 1 : 0) + plen, - out, outOffset + (pBit ? 2 : 0), dataLength - (pBit ? 2 : 0)); - - padOutput(out, outOffset + dataLength); - - outBuffer.setLength(outOffset + dataLength); - outBuffer.setSequenceNumber(sequenceNumber); - - /* - * The RTP marker bit is set for the very last packet of the access unit - * indicated by the RTP time stamp to allow an efficient playout buffer - * handling. Consequently, we have to output it as well. - */ - if ((inBuffer.getFlags() & Buffer.FLAG_RTP_MARKER) != 0) - { - outBuffer.setFlags(outBuffer.getFlags() | Buffer.FLAG_RTP_MARKER); - outBuffer.setOffset(0); - return BUFFER_PROCESSED_OK; - } - else - { - outBuffer.setOffset(outOffset + dataLength); - return OUTPUT_BUFFER_NOT_FILLED; - } - } - - /** - * Appends {@link #outputPaddingSize} number of bytes to out - * beginning at index outOffset. The specified out is - * expected to be large enough to accommodate the mentioned number of bytes. - * - * @param out the buffer in which outputPaddingSize number of bytes - * are to be written - * @param outOffset the index in outOffset at which the writing of - * outputPaddingSize number of bytes is to begin - */ - private void padOutput(byte[] out, int outOffset) - { - Arrays.fill(out, outOffset, outOffset + outputPaddingSize, (byte) 0); - } - - /** - * Resets the states of this DePacketizer and a specific output - * Buffer so that they are ready to have this DePacketizer - * process input RTP payloads. - * - * @param outBuffer the output Buffer to be reset - * @return the flags such as BUFFER_PROCESSED_OK and - * OUTPUT_BUFFER_NOT_FILLED to be returned by - * {@link #process(Buffer, Buffer)} - */ - private int reset(Buffer outBuffer) - { - if (OUTPUT_INCOMPLETE_BUFFER && outBuffer.getLength() > 0) - { - Object outData = outBuffer.getData(); - - if (outData instanceof byte[]) - { - return (BUFFER_PROCESSED_OK | INPUT_BUFFER_NOT_CONSUMED); - } - } - - outBuffer.setLength(0); - return OUTPUT_BUFFER_NOT_FILLED; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/h263p/JNIDecoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/h263p/JNIDecoder.java deleted file mode 100644 index f17e97c7f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/h263p/JNIDecoder.java +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video.h263p; - -import java.awt.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.sf.fmj.media.*; - -/** - * Implements a H.263+ decoder. - * - * @author Sebastien Vincent - * @author Lubomir Marinov - */ -public class JNIDecoder - extends AbstractCodec -{ - /** - * Plugin name. - */ - private static final String PLUGIN_NAME = "H.263+ Decoder"; - - /** - * The default output VideoFormat. - */ - private static final VideoFormat[] DEFAULT_OUTPUT_FORMATS - = new VideoFormat[] { new AVFrameFormat() }; - - /** - * Array of output VideoFormats. - */ - private final VideoFormat[] outputFormats; - - /** - * If decoder has got a picture. - */ - private final boolean[] got_picture = new boolean[1]; - - /** - * The codec context native pointer we will use. - */ - private long avcontext = 0; - - /** - * The decoded data is stored in avpicture in native ffmpeg format (YUV). - */ - private long avframe = 0; - - /** - * The last known width of {@link #avcontext} i.e. the video output by this - * JNIDecoder. Used to detect changes in the output size. - */ - private int width = 0; - - /** - * The last known height of {@link #avcontext} i.e. the video output by this - * JNIDecoder. Used to detect changes in the output size. - */ - private int height = 0; - - /** - * Initializes a new JNIDecoder instance which is to decode H.263+ - * encoded data into frames in YUV format. - */ - public JNIDecoder() - { - inputFormats - = new VideoFormat[] { new VideoFormat(Constants.H263P) }; - outputFormats - = new VideoFormat[] - { - new AVFrameFormat( - new Dimension( - Constants.VIDEO_WIDTH, - Constants.VIDEO_HEIGHT), - ensureFrameRate(Format.NOT_SPECIFIED), - FFmpeg.PIX_FMT_YUV420P, - Format.NOT_SPECIFIED) - }; - - Dimension outputSize = outputFormats[0].getSize(); - - width = outputSize.width; - height = outputSize.height; - } - - /** - * Check Format. - * - * @param format Format to check - * @return true if Format is H263P_RTP - */ - public boolean checkFormat(Format format) - { - return format.getEncoding().equals(Constants.H263P_RTP); - } - - /** - * Close Codec. - */ - @Override - public synchronized void close() - { - if (opened) - { - opened = false; - super.close(); - - FFmpeg.avcodec_close(avcontext); - FFmpeg.av_free(avcontext); - avcontext = 0; - - FFmpeg.av_free(avframe); - avframe = 0; - } - } - - /** - * Ensure frame rate. - * - * @param frameRate frame rate - * @return frame rate - */ - private float ensureFrameRate(float frameRate) - { - return frameRate; - } - - /** - * Get matching outputs for a specified input Format. - * - * @param in input Format - * @return array of matching outputs or null if there are no matching - * outputs. - */ - protected Format[] getMatchingOutputFormats(Format in) - { - VideoFormat ivf = (VideoFormat) in; - Dimension inSize = ivf.getSize(); - Dimension outSize; - - // return the default size/currently decoder and encoder - // set to transmit/receive at this size - if (inSize == null) - { - VideoFormat ovf = outputFormats[0]; - - if (ovf == null) - return null; - else - outSize = ovf.getSize(); - } - else - outSize = inSize; // Output in same size as input. - - return - new Format[] - { - new AVFrameFormat( - outSize, - ensureFrameRate(ivf.getFrameRate()), - FFmpeg.PIX_FMT_YUV420P, - Format.NOT_SPECIFIED) - }; - } - - /** - * Get plugin name. - * - * @return "H.263+ Decoder" - */ - @Override - public String getName() - { - return PLUGIN_NAME; - } - - /** - * Get all supported output Formats. - * - * @param in input Format to determine corresponding output - * Format/tt>s - * @return array of supported Format - */ - public Format[] getSupportedOutputFormats(Format in) - { - if (in == null) - return DEFAULT_OUTPUT_FORMATS; - - // mismatch input format - if (!(in instanceof VideoFormat) - || (AbstractCodecExt.matches(in, inputFormats) == null)) - return new Format[0]; - - // match input format - return getMatchingOutputFormats(in); - } - - /** - * Inits the codec instances. - * - * @throws ResourceUnavailableException if codec initialization failed - */ - @Override - public synchronized void open() - throws ResourceUnavailableException - { - if (opened) - return; - - /* from ffmpeg -formats output: "For example, the h263 decoder - * corresponds to the h263 and h263p encoders". That's why we use - * CODEC_ID_H263 for the decoder side (instead of CODEC_ID_H263P). - */ - long avcodec = FFmpeg.avcodec_find_decoder(FFmpeg.CODEC_ID_H263); - - avcontext = FFmpeg.avcodec_alloc_context(); - FFmpeg.avcodeccontext_set_workaround_bugs(avcontext, - FFmpeg.FF_BUG_AUTODETECT); - - if (FFmpeg.avcodec_open(avcontext, avcodec) < 0) - throw new RuntimeException("Could not open codec CODEC_ID_H263"); - - avframe = FFmpeg.avcodec_alloc_frame(); - - opened = true; - super.open(); - } - - /** - * Decodes H.263+ media data read from a specific input Buffer into - * a specific output Buffer. - * - * @param inBuffer input Buffer - * @param outBuffer output Buffer - * @return BUFFER_PROCESSED_OK if inBuffer has been - * successfully processed - */ - public synchronized int process(Buffer inBuffer, Buffer outBuffer) - { - if (!checkInputBuffer(inBuffer)) - return BUFFER_PROCESSED_FAILED; - - if (isEOM(inBuffer) || !opened) - { - propagateEOM(outBuffer); - return BUFFER_PROCESSED_OK; - } - - if (inBuffer.isDiscard()) - { - outBuffer.setDiscard(true); - return BUFFER_PROCESSED_OK; - } - - // Ask FFmpeg to decode. - got_picture[0] = false; - // TODO Take into account the offset of inputBuffer. - FFmpeg.avcodec_decode_video( - avcontext, - avframe, - got_picture, - (byte[]) inBuffer.getData(), inBuffer.getLength()); - - if (!got_picture[0]) - { - outBuffer.setDiscard(true); - return BUFFER_PROCESSED_OK; - } - - // format - int width = FFmpeg.avcodeccontext_get_width(avcontext); - int height = FFmpeg.avcodeccontext_get_height(avcontext); - - if ((width > 0) - && (height > 0) - && ((this.width != width) || (this.height != height))) - { - this.width = width; - this.height = height; - - // Output in same size and frame rate as input. - Dimension outSize = new Dimension(this.width, this.height); - VideoFormat inFormat = (VideoFormat) inBuffer.getFormat(); - float outFrameRate = ensureFrameRate(inFormat.getFrameRate()); - - outputFormat - = new AVFrameFormat( - outSize, - outFrameRate, - FFmpeg.PIX_FMT_YUV420P, - Format.NOT_SPECIFIED); - } - outBuffer.setFormat(outputFormat); - - // data - Object out = outBuffer.getData(); - - if (!(out instanceof AVFrame) || (((AVFrame) out).getPtr() != avframe)) - outBuffer.setData(new AVFrame(avframe)); - - // timeStamp - long pts = FFmpeg.AV_NOPTS_VALUE; // TODO avframe_get_pts(avframe); - - if (pts == FFmpeg.AV_NOPTS_VALUE) - outBuffer.setTimeStamp(Buffer.TIME_UNKNOWN); - else - { - outBuffer.setTimeStamp(pts); - - int outFlags = outBuffer.getFlags(); - - outFlags |= Buffer.FLAG_RELATIVE_TIME; - outFlags &= ~(Buffer.FLAG_RTP_TIME | Buffer.FLAG_SYSTEM_TIME); - outBuffer.setFlags(outFlags); - } - - return BUFFER_PROCESSED_OK; - } - - /** - * Sets the Format of the media data to be input for processing in - * this Codec. - * - * @param format the Format of the media data to be input for - * processing in this Codec - * @return the Format of the media data to be input for processing - * in this Codec if format is compatible with this - * Codec; otherwise, null - */ - @Override - public Format setInputFormat(Format format) - { - Format setFormat = super.setInputFormat(format); - - if (setFormat != null) - reset(); - return setFormat; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/h263p/JNIEncoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/h263p/JNIEncoder.java deleted file mode 100644 index 13d9d3098..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/h263p/JNIEncoder.java +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video.h263p; - -import java.awt.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.sf.fmj.media.*; - -/** - * Implements a H.263+ encoder. - * - * @author Sebastien Vincent - * @author Lubomir Marinov - */ -public class JNIEncoder - extends AbstractCodec -{ - /** - * The frame rate to be assumed by JNIEncoder instance in the - * absence of any other frame rate indication. - */ - private static final int DEFAULT_FRAME_RATE = 30; - - /** - * Default output formats. - */ - private static final Format[] DEFAULT_OUTPUT_FORMATS - = { new VideoFormat(Constants.H263P) }; - - /** - * Key frame every 300 frames. - */ - private static final int IFRAME_INTERVAL = 300; - - /** - * Name of the code. - */ - private static final String PLUGIN_NAME = "H.263+ Encoder"; - - /** - * The codec we will use. - */ - private long avcontext = 0; - - /** - * The encoded data is stored in avpicture. - */ - private long avframe = 0; - - /** - * We use this buffer to supply data to encoder. - */ - private byte[] encFrameBuffer = null; - - /** - * The supplied data length. - */ - private int encFrameLen = 0; - - /** - * The raw frame buffer. - */ - private long rawFrameBuffer = 0; - - /** - * Next interval for an automatic keyframe. - */ - private int framesSinceLastIFrame = IFRAME_INTERVAL + 1; - - /** - * Initializes a new JNIEncoder instance. - */ - public JNIEncoder() - { - inputFormats - = new Format[] - { - new YUVFormat( - null, - Format.NOT_SPECIFIED, - Format.byteArray, - DEFAULT_FRAME_RATE, - YUVFormat.YUV_420, - Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, - 0, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED) - }; - - inputFormat = null; - outputFormat = null; - } - - /** - * Closes this Codec. - */ - @Override - public synchronized void close() - { - if (opened) - { - opened = false; - super.close(); - - FFmpeg.avcodec_close(avcontext); - FFmpeg.av_free(avcontext); - avcontext = 0; - - FFmpeg.av_free(avframe); - avframe = 0; - FFmpeg.av_free(rawFrameBuffer); - rawFrameBuffer = 0; - - encFrameBuffer = null; - } - } - - /** - * Gets the matching output formats for a specific format. - * - * @param in input format - * @return array for formats matching input format - */ - private Format[] getMatchingOutputFormats(Format in) - { - VideoFormat videoIn = (VideoFormat) in; - - return - new VideoFormat[] - { - new VideoFormat( - Constants.H263P, - videoIn.getSize(), - Format.NOT_SPECIFIED, - Format.byteArray, - videoIn.getFrameRate()) - }; - } - - /** - * Gets the name of this Codec. - * - * @return codec name - */ - @Override - public String getName() - { - return PLUGIN_NAME; - } - - /** - * Returns the list of formats supported at the output. - * - * @param in input Format to determine corresponding output - * Format/tt>s - * @return array of formats supported at output - */ - public Format[] getSupportedOutputFormats(Format in) - { - // null input format - if (in == null) - return DEFAULT_OUTPUT_FORMATS; - - // mismatch input format - if (!(in instanceof VideoFormat) - || (null == AbstractCodecExt.matches(in, inputFormats))) - return new Format[0]; - - return getMatchingOutputFormats(in); - } - - /** - * Opens this Codec. - */ - @Override - public synchronized void open() - throws ResourceUnavailableException - { - if (opened) - return; - - if (inputFormat == null) - throw new ResourceUnavailableException("No input format selected"); - if (outputFormat == null) - throw new ResourceUnavailableException("No output format selected"); - - VideoFormat outputVideoFormat = (VideoFormat) outputFormat; - Dimension size = outputVideoFormat.getSize(); - int width = size.width; - int height = size.height; - - long avcodec = FFmpeg.avcodec_find_encoder(FFmpeg.CODEC_ID_H263P); - - avcontext = FFmpeg.avcodec_alloc_context(); - - FFmpeg.avcodeccontext_set_pix_fmt(avcontext, FFmpeg.PIX_FMT_YUV420P); - FFmpeg.avcodeccontext_set_size(avcontext, width, height); - FFmpeg.avcodeccontext_set_qcompress(avcontext, 0.6f); - - int bitRate = 256000; - int frameRate = (int) outputVideoFormat.getFrameRate(); - - if (frameRate == Format.NOT_SPECIFIED) - frameRate = DEFAULT_FRAME_RATE; - - // average bit rate - FFmpeg.avcodeccontext_set_bit_rate(avcontext, bitRate); - FFmpeg.avcodeccontext_set_bit_rate_tolerance(avcontext, - bitRate / (frameRate - 1)); - //FFmpeg.avcodeccontext_set_rc_max_rate(avcontext, bitRate); - //FFmpeg.avcodeccontext_set_sample_aspect_ratio(avcontext, 0, 0); - - // time_base should be 1 / frame rate - FFmpeg.avcodeccontext_set_time_base(avcontext, 1, frameRate); - //FFmpeg.avcodeccontext_set_quantizer(avcontext, 10, 51, 4); - - FFmpeg.avcodeccontext_set_mb_decision(avcontext, - FFmpeg.FF_MB_DECISION_SIMPLE); - - //FFmpeg.avcodeccontext_set_rc_eq(avcontext, "blurCplx^(1-qComp)"); - - FFmpeg.avcodeccontext_add_flags(avcontext, - FFmpeg.CODEC_FLAG_LOOP_FILTER); - FFmpeg.avcodeccontext_add_flags(avcontext, - FFmpeg.CODEC_FLAG_AC_PRED); - FFmpeg.avcodeccontext_add_flags(avcontext, - FFmpeg.CODEC_FLAG_H263P_UMV); - FFmpeg.avcodeccontext_add_flags(avcontext, - FFmpeg.CODEC_FLAG_H263P_SLICE_STRUCT); - - FFmpeg.avcodeccontext_set_me_method(avcontext, 6); - FFmpeg.avcodeccontext_set_me_subpel_quality(avcontext, 2); - FFmpeg.avcodeccontext_set_me_range(avcontext, 18); - FFmpeg.avcodeccontext_set_me_cmp(avcontext, FFmpeg.FF_CMP_CHROMA); - FFmpeg.avcodeccontext_set_scenechange_threshold(avcontext, 40); - - // Constant quality mode (also known as constant ratefactor) - //FFmpeg.avcodeccontext_set_crf(avcontext, 0); - //FFmpeg.avcodeccontext_set_rc_buffer_size(avcontext, 0); - FFmpeg.avcodeccontext_set_gop_size(avcontext, IFRAME_INTERVAL); - //FFmpeg.avcodeccontext_set_i_quant_factor(avcontext, 1f / 1.4f); - - //FFmpeg.avcodeccontext_set_refs(avcontext, 2); - //FFmpeg.avcodeccontext_set_trellis(avcontext, 2); - - if (FFmpeg.avcodec_open(avcontext, avcodec) < 0) - { - throw - new ResourceUnavailableException( - "Could not open codec. (size= " - + width + "x" + height - + ")"); - } - - encFrameLen = (width * height * 3) / 2; - - rawFrameBuffer = FFmpeg.av_malloc(encFrameLen); - - avframe = FFmpeg.avcodec_alloc_frame(); - - int sizeInBytes = width * height; - - FFmpeg.avframe_set_data( - avframe, - rawFrameBuffer, - sizeInBytes, - sizeInBytes / 4); - FFmpeg.avframe_set_linesize(avframe, width, width / 2, width / 2); - - encFrameBuffer = new byte[encFrameLen]; - - opened = true; - - super.open(); - } - - /** - * Processes/encodes a buffer. - * - * @param inBuffer input buffer - * @param outBuffer output buffer - * @return BUFFER_PROCESSED_OK if buffer has been successfully - * processed - */ - public synchronized int process(Buffer inBuffer, Buffer outBuffer) - { - if (isEOM(inBuffer)) - { - propagateEOM(outBuffer); - reset(); - return BUFFER_PROCESSED_OK; - } - if (inBuffer.isDiscard()) - { - outBuffer.setDiscard(true); - reset(); - return BUFFER_PROCESSED_OK; - } - - Format inFormat = inBuffer.getFormat(); - - if ((inFormat != inputFormat) && !inFormat.matches(inputFormat)) - setInputFormat(inFormat); - - if (inBuffer.getLength() < 3) - { - outBuffer.setDiscard(true); - reset(); - return BUFFER_PROCESSED_OK; - } - - // copy data to avframe - FFmpeg.memcpy( - rawFrameBuffer, - (byte[]) inBuffer.getData(), inBuffer.getOffset(), - encFrameLen); - - if (framesSinceLastIFrame >= IFRAME_INTERVAL) - { - FFmpeg.avframe_set_key_frame(avframe, true); - framesSinceLastIFrame = 0; - } - else - { - framesSinceLastIFrame++; - FFmpeg.avframe_set_key_frame(avframe, false); - } - - // encode data - int encLen - = FFmpeg.avcodec_encode_video( - avcontext, - encFrameBuffer, encFrameLen, - avframe); - - /* - * Do not always allocate a new data array for outBuffer, try to reuse - * the existing one if it is suitable. - */ - Object outData = outBuffer.getData(); - byte[] out; - - if (outData instanceof byte[]) - { - out = (byte[]) outData; - if (out.length < encLen) - out = null; - } - else - out = null; - if (out == null) - out = new byte[encLen]; - - System.arraycopy(encFrameBuffer, 0, out, 0, encLen); - - outBuffer.setData(out); - outBuffer.setLength(encLen); - outBuffer.setOffset(0); - outBuffer.setTimeStamp(inBuffer.getTimeStamp()); - - return BUFFER_PROCESSED_OK; - } - - /** - * Sets the input format. - * - * @param in format to set - * @return format - */ - @Override - public Format setInputFormat(Format in) - { - // mismatch input format - if (!(in instanceof VideoFormat) - || (null == AbstractCodecExt.matches(in, inputFormats))) - return null; - - YUVFormat yuv = (YUVFormat) in; - - if (yuv.getOffsetU() > yuv.getOffsetV()) - return null; - - Dimension size = yuv.getSize(); - - if (size == null) - size = new Dimension(Constants.VIDEO_WIDTH, Constants.VIDEO_HEIGHT); - - int strideY = size.width; - int strideUV = strideY / 2; - int offsetU = strideY * size.height; - int offsetV = offsetU + strideUV * size.height / 2; - - int yuvMaxDataLength = (strideY + strideUV) * size.height; - - inputFormat - = new YUVFormat( - size, - yuvMaxDataLength + FFmpeg.FF_INPUT_BUFFER_PADDING_SIZE, - Format.byteArray, - yuv.getFrameRate(), - YUVFormat.YUV_420, - strideY, strideUV, - 0, offsetU, offsetV); - - // Return the selected inputFormat - return inputFormat; - } - - /** - * Sets the Format in which this Codec is to output media - * data. - * - * @param out the Format in which this Codec is to - * output media data - * @return the Format in which this Codec is currently - * configured to output media data or null if format was - * found to be incompatible with this Codec - */ - @Override - public Format setOutputFormat(Format out) - { - // mismatch output format - if (!(out instanceof VideoFormat) - || (null - == AbstractCodecExt.matches( - out, - getMatchingOutputFormats(inputFormat)))) - return null; - - VideoFormat videoOut = (VideoFormat) out; - Dimension outSize = videoOut.getSize(); - - if (outSize == null) - { - Dimension inSize = ((VideoFormat) inputFormat).getSize(); - - outSize - = (inSize == null) - ? new Dimension( - Constants.VIDEO_WIDTH, - Constants.VIDEO_HEIGHT) - : inSize; - } - - outputFormat - = new VideoFormat( - videoOut.getEncoding(), - outSize, - Format.NOT_SPECIFIED, - Format.byteArray, - videoOut.getFrameRate()); - - // Return the selected outputFormat - return outputFormat; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/h263p/Packetizer.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/h263p/Packetizer.java deleted file mode 100644 index 3267022a8..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/h263p/Packetizer.java +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video.h263p; - -import java.awt.*; -import java.util.*; -import java.util.List; // disambiguation - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.sf.fmj.media.*; - -/** - * Packetizes H.263+ encoded data into RTP packets in accord with RFC 4529 - * "RTP Payload Format for ITU-T Rec. H.263 Video". - * - * @author Sebastien Vincent - * @author Lubomir Marinov - */ -public class Packetizer - extends AbstractPacketizer -{ - /** - * Array of default output formats. - */ - private static final Format[] DEFAULT_OUTPUT_FORMATS - = { new VideoFormat(Constants.H263P_RTP) }; - - /** - * Maximum payload size without the headers. - */ - public static final int MAX_PAYLOAD_SIZE = 1024; - - /** - * Name of the plugin. - */ - private static final String PLUGIN_NAME = "H263+ Packetizer"; - - /** - * The sequence number of the next RTP packet to be output by this - * Packetizer. - */ - private int sequenceNumber = 0; - - /** - * The list of H263+ "Start code" video packets to be sent as payload in RTP - * packets. - */ - private final List videoPkts = new LinkedList(); - - /** - * The timeStamp of the RTP packets in which H263+ packets are to be sent. - */ - private long timeStamp = 0; - - /** - * Initializes a new Packetizer instance which is to packetize - * H.263+ encoded data into RTP packets in accord with - * RFC 4529 "RTP Payload Format for ITU-T Rec. H.263 Video". - */ - public Packetizer() - { - inputFormats = new Format[] { new VideoFormat(Constants.H263P) }; - - inputFormat = null; - outputFormat = null; - } - - /** - * Get the matching output formats for a specific format. - * - * @param in input format - * @return array for formats matching input format - */ - private Format[] getMatchingOutputFormats(Format in) - { - VideoFormat videoIn = (VideoFormat) in; - Dimension inSize = videoIn.getSize(); - - return - new VideoFormat[] - { - new VideoFormat( - Constants.H263P_RTP, - inSize, - Format.NOT_SPECIFIED, - Format.byteArray, - videoIn.getFrameRate()) - }; - } - - /** - * Get codec name. - * - * @return codec name - */ - @Override - public String getName() - { - return PLUGIN_NAME; - } - - /** - * Return the list of formats supported at the output. - * @param in input Format to determine corresponding output - * Format/tt>s - * @return array of formats supported at output - */ - public Format[] getSupportedOutputFormats(Format in) - { - // null input format - if (in == null) - return DEFAULT_OUTPUT_FORMATS; - - // mismatch input format - if (!(in instanceof VideoFormat) - || (null == AbstractCodecExt.matches(in, inputFormats))) - { - return new Format[0]; - } - - return getMatchingOutputFormats(in); - } - - /** - * Open this Packetizer. - * - * @throws ResourceUnavailableException if something goes wrong during - * initialization of the Packetizer. - */ - @Override - public synchronized void open() - throws ResourceUnavailableException - { - if (!opened) - { - videoPkts.clear(); - sequenceNumber = 0; - - super.open(); - opened = true; - } - } - - /** - * Close this Packetizer. - */ - @Override - public synchronized void close() - { - if (opened) - { - videoPkts.clear(); - opened = false; - super.close(); - } - } - - /** - * Sets the input format. - * - * @param in format to set - * @return format - */ - @Override - public Format setInputFormat(Format in) - { - /* - * Return null if the specified input Format is incompatible with this - * Packetizer. - */ - if (!(in instanceof VideoFormat) - || null == AbstractCodecExt.matches(in, inputFormats)) - return null; - - inputFormat = in; - return in; - } - - /** - * Sets the Format in which this Codec is to output media - * data. - * - * @param out the Format in which this Codec is to - * output media data - * @return the Format in which this Codec is currently - * configured to output media data or null if format was - * found to be incompatible with this Codec - */ - @Override - public Format setOutputFormat(Format out) - { - /* - * Return null if the specified output Format is incompatible with this - * Packetizer. - */ - if (!(out instanceof VideoFormat) - || (null - == AbstractCodecExt.matches( - out, - getMatchingOutputFormats(inputFormat)))) - return null; - - VideoFormat videoOut = (VideoFormat) out; - Dimension outSize = videoOut.getSize(); - - if (outSize == null) - { - Dimension inSize = ((VideoFormat) inputFormat).getSize(); - - outSize - = (inSize == null) - ? new Dimension( - Constants.VIDEO_WIDTH, - Constants.VIDEO_HEIGHT) - : inSize; - } - - outputFormat - = new VideoFormat( - videoOut.getEncoding(), - outSize, - outSize.width * outSize.height, - Format.byteArray, - videoOut.getFrameRate()); - - // Return the outputFormat which is actually set. - return outputFormat; - } - - /** - * Processes (packetize) a buffer. - * - * @param inBuffer input buffer - * @param outBuffer output buffer - * @return BUFFER_PROCESSED_OK if buffer has been successfully - * processed - */ - @Override - public int process(Buffer inBuffer, Buffer outBuffer) - { - int inLength = inBuffer.getLength(); - byte inData[] = (byte[])inBuffer.getData(); - int inOffset = inBuffer.getOffset(); - boolean pktAdded = false; - - if (videoPkts.size() > 0) - { - byte[] pktData = videoPkts.remove(0); - - // Send the packet. - outBuffer.setData(pktData); - outBuffer.setLength(pktData.length); - outBuffer.setOffset(0); - outBuffer.setTimeStamp(timeStamp); - outBuffer.setSequenceNumber(sequenceNumber++); - - // If there are other packets, send them as well. - if(videoPkts.size() > 0) - { - return (BUFFER_PROCESSED_OK | INPUT_BUFFER_NOT_CONSUMED); - } - else - { - // It's the last packet of the current frame so mark it. - outBuffer.setFlags( - outBuffer.getFlags() | Buffer.FLAG_RTP_MARKER); - - return BUFFER_PROCESSED_OK; - } - } - - if (isEOM(inBuffer)) - { - propagateEOM(outBuffer); - reset(); - return BUFFER_PROCESSED_OK; - } - - if (inBuffer.isDiscard()) - { - outBuffer.setDiscard(true); - reset(); - return BUFFER_PROCESSED_OK; - } - - Format inFormat = inBuffer.getFormat(); - - if ((inFormat != inputFormat) && !inFormat.matches(inputFormat)) - setInputFormat(inFormat); - - int endIndex = inOffset + inLength; - int beginIndex = findStartcode(inData, inOffset, endIndex); - - if (beginIndex < endIndex) - { - for (int nextBeginIndex; - beginIndex < endIndex; - beginIndex = nextBeginIndex + 3) - { - nextBeginIndex = findStartcode(inData, beginIndex + 3, - endIndex); - int length = nextBeginIndex - beginIndex; - - if (length > 0) - { - pktAdded - = packetize(inData, beginIndex, length) - || pktAdded; - beginIndex += length; - } - } - } - - timeStamp = inBuffer.getTimeStamp(); - - if(pktAdded) - { - return process(inBuffer, outBuffer); - } - else - { - /* first frame is not a synchronization point, discard ?*/ - return BUFFER_PROCESSED_FAILED; - } - } - - /** - * Packetizes H.263+ encoded data so that it becomes ready to be sent as the - * payload of RTP packets. - * - * @param data the bytes which contain the H.263+ encoded data to be - * packetized - * @param offset the offset of H.263+ encoded data to be packetized begins - * @param length the length of the H.263+ encoded data starting at offset - * @return true if at least one RTP packet payload has been - * packetized i.e. prepared for sending; otherwise, false - */ - private boolean packetize(byte[] data, int offset, int length) - { - boolean pktAdded = false; - - while(length > 0) - { - boolean isPsc = false; - int pos = 0; - int maxPayloadLength = MAX_PAYLOAD_SIZE; - byte pkt[] = null; - int payloadLength = 0; - - /* is we are at synchronization point (PSC, GSBC, EOS, EOSBS) */ - if(data.length > 3 && data[offset] == 0x00 && - data[offset + 1] == 0x00) - { - isPsc = true; - pos = 2; - } - else - { - maxPayloadLength -= 2; - } - - if(length > maxPayloadLength) - { - payloadLength = maxPayloadLength; - } - else - { - payloadLength = length; - } - - pkt = new byte[payloadLength + (isPsc ? 0 : 2)]; - - /* add H263+ payload header */ - /* no VRC and no extra picture header */ - pkt[0] = (byte)(isPsc ? 0x04 : 0x00); - pkt[1] = 0x00; - - System.arraycopy(data, offset + pos, pkt, 2, payloadLength - pos); - pktAdded = videoPkts.add(pkt) || pktAdded; - - offset += payloadLength; - length -= payloadLength; - } - - return pktAdded; - } - - /** - * Finds the index in byteStream at which a Picture Start code - * begins. - * - * @param byteStream the H.263+ encoded byte stream - * @param beginIndex the inclusive index in byteStream at which the - * search is to begin - * @param endIndex the exclusive index in byteStream at which the - * search is to end - * @return the index in byteStream at which the Picture Start code - * begins, otherwise, endIndex - */ - private static int findStartcode(byte[] byteStream, int beginIndex, - int endIndex) - { - for (; beginIndex < (endIndex - 3); beginIndex++) - if((byteStream[beginIndex] == 0) - && (byteStream[beginIndex + 1] == 0) - && ((byteStream[beginIndex + 2] & (byte)0x80) == -128)) - { - return beginIndex; - } - return endIndex; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/ConfigurationPanel.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/ConfigurationPanel.java index f8c4db197..fcc710647 100644 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/ConfigurationPanel.java +++ b/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/ConfigurationPanel.java @@ -12,11 +12,13 @@ import javax.swing.*; import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.control.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.impl.neomedia.codec.video.h264.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.neomedia.control.*; +import org.jitsi.service.resources.*; + /** * Implements the H.264 configuration form (panel). * diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/DePacketizer.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/DePacketizer.java deleted file mode 100644 index de200011e..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/DePacketizer.java +++ /dev/null @@ -1,753 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video.h264; - -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.service.neomedia.control.*; -import net.java.sip.communicator.util.*; -import net.sf.fmj.media.*; - -/** - * Implements Codec to represent a depacketizer of H.264 RTP packets - * into NAL units. - * - * @author Lyubomir Marinov - * @author Damian Minkov - */ -public class DePacketizer - extends AbstractCodecExt -{ - - /** - * The Logger used by the DePacketizer class and its - * instances for logging output. - */ - private static final Logger logger = Logger.getLogger(DePacketizer.class); - - /** - * The bytes to prefix any NAL unit to be output by this - * DePacketizer and given to a H.264 decoder. Includes - * start_code_prefix_one_3bytes. According to "B.1 Byte stream NAL unit - * syntax and semantics" of "ITU-T Rec. H.264 Advanced video coding for - * generic audiovisual services", zero_byte "shall be present" when "the - * nal_unit_type within the nal_unit() is equal to 7 (sequence parameter - * set) or 8 (picture parameter set)" or "the byte stream NAL unit syntax - * structure contains the first NAL unit of an access unit in decoding - * order". - */ - private static final byte[] NAL_PREFIX = { 0, 0, 1 }; - - /** - * The indicator which determines whether incomplete NAL units are output - * from the H.264 DePacketizer to the decoder. It is advisable to - * output incomplete NAL units because the FFmpeg H.264 decoder is able to - * decode them. If false, incomplete NAL units will be discarded - * and, consequently, the video quality will be worse (e.g. if the last RTP - * packet of a fragmented NAL unit carrying a keyframe does not arrive from - * the network, the whole keyframe will be discarded and thus all NAL units - * upto the next keyframe will be useless). - */ - private static final boolean OUTPUT_INCOMPLETE_NAL_UNITS = true; - - /** - * The interval of time in milliseconds between two consecutive requests for - * a key frame from the remote peer associated with the - * {@link #keyFrameControl} of DePacketizer. - */ - private static final long TIME_BETWEEN_REQUEST_KEY_FRAME = 500; - - /** - * The interval of time in milliseconds from the time of the last received - * key frame to the time at which a key frame will be requested from the - * remote peer associated with the {@link #keyFrameControl} of - * DePacketizer. The value at the time of this writing is the - * default time between two consecutive key frames generated by - * {@link JNIDecoder} with an addition of a certain fraction of that time in - * the role of a leeway to prevent DePacketizer from requesting key - * frames from JNIEncoder in the scenario of perfect transmission. - */ - private static final long TIME_FROM_KEY_FRAME_TO_REQUEST_KEY_FRAME - = ((JNIEncoder.IFRAME_INTERVAL * 4) - / (JNIEncoder.DEFAULT_FRAME_RATE * 3)) - * 1000; - - /** - * The Unspecified nal_unit_type as defined by the ITU-T - * Recommendation for H.264. - */ - private static final int UNSPECIFIED_NAL_UNIT_TYPE = 0; - - /** - * The indicator which determines whether this DePacketizer has - * successfully processed an RTP packet with payload representing a - * "Fragmentation Unit (FU)" with its Start bit set and has not encountered - * one with its End bit set. - */ - private boolean fuaStartedAndNotEnded = false; - - /** - * The KeyFrameControl used by this DePacketizer to - * control its key frame-related logic. - */ - private KeyFrameControl keyFrameControl; - - /** - * The time stamp of the last received key frame. - */ - private long lastKeyFrameTime = -1; - - /** - * The time of the last request for a key frame from the remote peer - * associated with {@link #keyFrameControl} performed by this - * DePacketizer. - */ - private long lastRequestKeyFrameTime = -1; - - /** - * Keeps track of last (input) sequence number in order to avoid - * inconsistent data. - */ - private long lastSequenceNumber = -1; - - /** - * The nal_unit_type as defined by the ITU-T Recommendation for - * H.264 of the last NAL unit given to this DePacketizer for - * processing. In the case of processing a fragmentation unit, the value is - * equal to the nal_unit_type of the fragmented NAL unit. - */ - private int nal_unit_type; - - /** - * The size of the padding at the end of the output data of this - * DePacketizer expected by the H.264 decoder. - */ - private final int outputPaddingSize - = FFmpeg.FF_INPUT_BUFFER_PADDING_SIZE; - - /** - * The indicator which determines whether this DePacketizer is to - * request a key frame from the remote peer associated with - * {@link #keyFrameControl}. - */ - private boolean requestKeyFrame = false; - - /** - * The Thread which is to asynchronously request key frames from - * the remote peer associated with {@link #keyFrameControl} on behalf of - * this DePacketizer and in accord with {@link #requestKeyFrame}. - */ - private Thread requestKeyFrameThread; - - /** - * Initializes a new DePacketizer instance which is to depacketize - * H.264 RTP packets into NAL units. - */ - public DePacketizer() - { - super( - "H264 DePacketizer", - VideoFormat.class, - new VideoFormat[] { new VideoFormat(Constants.H264) }); - - List inputFormats = new ArrayList(); - - inputFormats.add(new VideoFormat(Constants.H264_RTP)); - /* - * Apart from the generic Constants.H264_RTP VideoFormat, add the - * possible respective ParameterizedVideoFormats because - * ParameterizedVideoFormat will not match every VideoFormat due to the - * fact that a missing packetization-mode format parameter is - * interpreted as it having a value of 0. - */ - Collections.addAll(inputFormats, Packetizer.SUPPORTED_OUTPUT_FORMATS); - this.inputFormats = inputFormats.toArray(new Format[inputFormats.size()]); - } - - /** - * Extracts a fragment of a NAL unit from a specific FU-A RTP packet - * payload. - * - * @param in the payload of the RTP packet from which a FU-A fragment of a - * NAL unit is to be extracted - * @param inOffset the offset in in at which the payload begins - * @param inLength the length of the payload in in beginning at - * inOffset - * @param outBuffer the Buffer which is to receive the extracted - * FU-A fragment of a NAL unit - * @return the flags such as BUFFER_PROCESSED_OK and - * OUTPUT_BUFFER_NOT_FILLED to be returned by - * {@link #process(Buffer, Buffer)} - */ - private int dePacketizeFUA( - byte[] in, int inOffset, int inLength, - Buffer outBuffer) - { - byte fu_indicator = in[inOffset]; - - inOffset++; - inLength--; - - byte fu_header = in[inOffset]; - - inOffset++; - inLength--; - - int nal_unit_type = fu_header & 0x1F; - - this.nal_unit_type = nal_unit_type; - - boolean start_bit = (fu_header & 0x80) != 0; - boolean end_bit = (fu_header & 0x40) != 0; - int outOffset = outBuffer.getOffset(); - int newOutLength = inLength; - int octet; - - if (start_bit) - { - /* - * The Start bit and End bit MUST NOT both be set in the same FU - * header. - */ - if (end_bit) - { - outBuffer.setDiscard(true); - return BUFFER_PROCESSED_OK; - } - - fuaStartedAndNotEnded = true; - - newOutLength += NAL_PREFIX.length + 1 /* octet */; - octet - = (fu_indicator & 0xE0) /* forbidden_zero_bit & NRI */ - | nal_unit_type; - } - else if (!fuaStartedAndNotEnded) - { - outBuffer.setDiscard(true); - return BUFFER_PROCESSED_OK; - } - else - { - int outLength = outBuffer.getLength(); - - outOffset += outLength; - newOutLength += outLength; - octet = 0; // Ignored later on. - } - - byte[] out - = validateByteArraySize( - outBuffer, - outBuffer.getOffset() + newOutLength + outputPaddingSize); - - if (start_bit) - { - // Copy in the NAL start sequence and the (reconstructed) octet. - System.arraycopy(NAL_PREFIX, 0, out, outOffset, NAL_PREFIX.length); - outOffset += NAL_PREFIX.length; - - out[outOffset] = (byte) (octet & 0xFF); - outOffset++; - } - System.arraycopy(in, inOffset, out, outOffset, inLength); - outOffset += inLength; - - padOutput(out, outOffset); - - outBuffer.setLength(newOutLength); - - if (end_bit) - { - fuaStartedAndNotEnded = false; - return BUFFER_PROCESSED_OK; - } - else - return OUTPUT_BUFFER_NOT_FILLED; - } - - /** - * Extract a single (complete) NAL unit from RTP payload. - * - * @param nal_unit_type unit type of NAL - * @param in the payload of the RTP packet - * @param inOffset the offset in in at which the payload begins - * @param inLength the length of the payload in in beginning at - * inOffset - * @param outBuffer the Buffer which is to receive the extracted - * NAL unit - * @return the flags such as BUFFER_PROCESSED_OK and - * OUTPUT_BUFFER_NOT_FILLED to be returned by - * {@link #process(Buffer, Buffer)} - */ - private int dePacketizeSingleNALUnitPacket( - int nal_unit_type, - byte[] in, int inOffset, int inLength, - Buffer outBuffer) - { - this.nal_unit_type = nal_unit_type; - - int outOffset = outBuffer.getOffset(); - int newOutLength = NAL_PREFIX.length + inLength; - byte[] out - = validateByteArraySize( - outBuffer, - outOffset + newOutLength + outputPaddingSize); - - System.arraycopy(NAL_PREFIX, 0, out, outOffset, NAL_PREFIX.length); - outOffset += NAL_PREFIX.length; - - System.arraycopy(in, inOffset, out, outOffset, inLength); - outOffset += inLength; - - padOutput(out, outOffset); - - outBuffer.setLength(newOutLength); - - return BUFFER_PROCESSED_OK; - } - - /** - * Close the Codec. - */ - protected synchronized void doClose() - { - // If requestKeyFrameThread is running, tell it to perish. - requestKeyFrameThread = null; - notifyAll(); - } - - /** - * Opens this Codec and acquires the resources that it needs to - * operate. A call to {@link PlugIn#open()} on this instance will result in - * a call to doOpen only if {@link AbstractCodec#opened} is - * false. All required input and/or output formats are assumed to - * have been set on this Codec before doOpen is called. - * - * @throws ResourceUnavailableException if any of the resources that this - * Codec needs to operate cannot be acquired - * @see AbstractCodecExt#doOpen() - */ - protected synchronized void doOpen() - throws ResourceUnavailableException - { - fuaStartedAndNotEnded = false; - lastKeyFrameTime = -1; - lastRequestKeyFrameTime = -1; - lastSequenceNumber = -1; - nal_unit_type = UNSPECIFIED_NAL_UNIT_TYPE; - requestKeyFrame = false; - requestKeyFrameThread = null; - } - - /** - * Processes (depacketizes) a buffer. - * - * @param inBuffer input buffer - * @param outBuffer output buffer - * @return BUFFER_PROCESSED_OK if buffer has been successfully - * processed - */ - @SuppressWarnings("fallthrough") - protected int doProcess(Buffer inBuffer, Buffer outBuffer) - { - /* - * We'll only be depacketizing, we'll not act as an H.264 parser. - * Consequently, we'll only care about the rules of - * packetizing/depacketizing. For example, we'll have to make sure that - * no packets are lost and no other packets are received when - * depacketizing FU-A Fragmentation Units (FUs). - */ - long sequenceNumber = inBuffer.getSequenceNumber(); - int ret; - boolean requestKeyFrame = (lastKeyFrameTime == -1); - - if ((lastSequenceNumber != -1) - && ((sequenceNumber - lastSequenceNumber) != 1)) - { - /* - * Even if (the new) sequenceNumber is less than lastSequenceNumber, - * we have to use it because the received sequence numbers may have - * reached their maximum value and wrapped around starting from - * their minimum value again. - */ - if (logger.isTraceEnabled()) - logger.trace( - "Dropped RTP packets upto sequenceNumber " - + lastSequenceNumber - + " and continuing with sequenceNumber " - + sequenceNumber); - - /* - * If a frame has been lost, then we may be in a need of a key - * frame. - */ - requestKeyFrame = true; - - ret = reset(outBuffer); - - if ((ret & OUTPUT_BUFFER_NOT_FILLED) == 0) - { - /* - * TODO Do we have to reset the nal_unit_type field of this - * DePacketizer to UNSPECIFIED_NAL_UNIT_TYPE here? If ret - * contains INPUT_BUFFER_NOT_CONSUMED, it seems safe to not - * reset it because the input Buffer will be returned for - * processing during the next call. - */ - - setRequestKeyFrame(requestKeyFrame); - - return ret; - } - } - - /* - * Ignore the RTP time stamp reported by JMF because it is not the - * actual RTP packet time stamp send by the remote peer but some locally - * calculated JMF value. - */ - - lastSequenceNumber = sequenceNumber; - - byte[] in = (byte[]) inBuffer.getData(); - int inOffset = inBuffer.getOffset(); - byte octet = in[inOffset]; - - /* - * NRI equal to the binary value 00 indicates that the content of the - * NAL unit is not used to reconstruct reference pictures for inter - * picture prediction. Such NAL units can be discarded without risking - * the integrity of the reference pictures. However, it is not the place - * of the DePacketizer to take the decision to discard them but of the - * H.264 decoder. - */ - - /* - * The nal_unit_type of the NAL unit given to this DePacketizer for - * processing. In the case of processing a fragmentation unit, the value - * is equal to the nal_unit_type of the fragmentation unit, not the - * fragmented NAL unit and is thus in contrast with the value of the - * nal_unit_type field of this DePacketizer. - */ - int nal_unit_type = octet & 0x1F; - - // Single NAL Unit Packet - if ((nal_unit_type >= 1) && (nal_unit_type <= 23)) - { - fuaStartedAndNotEnded = false; - ret - = dePacketizeSingleNALUnitPacket( - nal_unit_type, - in, inOffset, inBuffer.getLength(), - outBuffer); - } - else if (nal_unit_type == 28) // FU-A Fragmentation unit (FU) - { - ret = dePacketizeFUA(in, inOffset, inBuffer.getLength(), outBuffer); - if (outBuffer.isDiscard()) - fuaStartedAndNotEnded = false; - } - else - { - logger.warn( - "Dropping NAL unit of unsupported type " + nal_unit_type); - this.nal_unit_type = nal_unit_type; - - fuaStartedAndNotEnded = false; - outBuffer.setDiscard(true); - ret = BUFFER_PROCESSED_OK; - } - - outBuffer.setSequenceNumber(sequenceNumber); - - /* - * The RTP marker bit is set for the very last packet of the access unit - * indicated by the RTP time stamp to allow an efficient playout buffer - * handling. Consequently, we have to output it as well. - */ - if ((inBuffer.getFlags() & Buffer.FLAG_RTP_MARKER) != 0) - outBuffer.setFlags(outBuffer.getFlags() | Buffer.FLAG_RTP_MARKER); - - // Should we request a key frame. - switch (this.nal_unit_type) - { - case 5 /* Coded slice of an IDR picture */: - lastKeyFrameTime = System.currentTimeMillis(); - // Do fall through to prevent the request of a key frame. - - /* - * While it seems natural to not request a key frame in the presence of - * 5, 7 and 8 often seem to be followed by 5 so do not request a key - * frame if either 7 or 8 is present. - */ - case 7 /* Sequence parameter set */: - case 8 /* Picture parameter set */: - requestKeyFrame = false; - break; - default: - break; - } - setRequestKeyFrame(requestKeyFrame); - - return ret; - } - - /** - * Appends {@link #outputPaddingSize} number of bytes to out - * beginning at index outOffset. The specified out is - * expected to be large enough to accommodate the mentioned number of bytes. - * - * @param out the buffer in which outputPaddingSize number of bytes - * are to be written - * @param outOffset the index in outOffset at which the writing of - * outputPaddingSize number of bytes is to begin - */ - private void padOutput(byte[] out, int outOffset) - { - Arrays.fill(out, outOffset, outOffset + outputPaddingSize, (byte) 0); - } - - /** - * Requests a key frame from the remote peer associated with this - * DePacketizer using the logic of DePacketizer. - * - * @param urgent true if the caller has determined that the need - * for a key frame is urgent and should not obey all constraints with - * respect to time between two subsequent requests for key frames - * @return true if a key frame was indeed requested in response to - * the call; otherwise, false - */ - public synchronized boolean requestKeyFrame(boolean urgent) - { - lastKeyFrameTime = -1; - setRequestKeyFrame(true); - return true; - } - - /** - * Resets the states of this DePacketizer and a specific output - * Buffer so that they are ready to have this DePacketizer - * process input RTP payloads. If the specified output Buffer - * contains an incomplete NAL unit, its forbidden_zero_bit will be turned on - * and the NAL unit in question will be output by this - * DePacketizer. - * - * @param outBuffer the output Buffer to be reset - * @return the flags such as BUFFER_PROCESSED_OK and - * OUTPUT_BUFFER_NOT_FILLED to be returned by - * {@link #process(Buffer, Buffer)} - */ - private int reset(Buffer outBuffer) - { - /* - * We need the octet at the very least. Additionally, it does not make - * sense to output a NAL unit with zero payload because such NAL units - * are only given meaning for the purposes of the network and not the - * H.264 decoder. - */ - if (OUTPUT_INCOMPLETE_NAL_UNITS - && fuaStartedAndNotEnded - && (outBuffer.getLength() >= (NAL_PREFIX.length + 1 + 1))) - { - Object outData = outBuffer.getData(); - - if (outData instanceof byte[]) - { - byte[] out = (byte[]) outData; - int octetIndex = outBuffer.getOffset() + NAL_PREFIX.length; - - out[octetIndex] |= 0x80; // Turn on the forbidden_zero_bit. - fuaStartedAndNotEnded = false; - return (BUFFER_PROCESSED_OK | INPUT_BUFFER_NOT_CONSUMED); - } - } - - fuaStartedAndNotEnded = false; - outBuffer.setLength(0); - return OUTPUT_BUFFER_NOT_FILLED; - } - - /** - * Requests key frames from the remote peer associated with - * {@link #keyFrameControl} in {@link #requestKeyFrameThread}. - */ - private void runInRequestKeyFrameThread() - { - while (true) - { - synchronized (this) - { - if (requestKeyFrameThread != Thread.currentThread()) - break; - - long now = System.currentTimeMillis(); - long timeout; - - if (requestKeyFrame) - { - /* - * If we have received at least one key frame, we may - * receive a new one later. So allow a certain amount of - * time for the new key frame to arrive without DePacketizer - * requesting it. - */ - long nextKeyFrameTime - = lastKeyFrameTime - + TIME_FROM_KEY_FRAME_TO_REQUEST_KEY_FRAME; - - if (now >= nextKeyFrameTime) - { - /* - * In order to not have the requests for key frames - * overwhelm the remote peer, make sure two consecutive - * requests are separated by a certain amount of time. - */ - long nextRequestKeyFrameTime - = lastRequestKeyFrameTime - + TIME_BETWEEN_REQUEST_KEY_FRAME; - - if (now >= nextRequestKeyFrameTime) - { - // Request a key frame from the remote peer now. - timeout = -1; - } - else - { - /* - * Too little time has passed from our last attempt - * to request a key frame from the remote peer. If - * we do not wait, we risk intruding. - */ - timeout = nextRequestKeyFrameTime - now; - } - } - else - { - /* - * Too little time has passed from the last receipt of a - * key frame to make us think that the remote peer will - * not send a key frame without us requesting it. - */ - timeout = nextKeyFrameTime - now; - } - } - else - { - /* - * This DePacketizer has not expressed its desire to request - * a key frame from the remote peer so we will have to wait - * until it expresses the desire in question. - */ - timeout = 0; - } - - if (timeout >= 0) - { - try - { - wait(timeout); - } - catch (InterruptedException ie) - { - } - continue; - } - } - - KeyFrameControl keyFrameControl = this.keyFrameControl; - - if (keyFrameControl != null) - { - List keyFrameRequesters - = keyFrameControl.getKeyFrameRequesters(); - - if (keyFrameRequesters != null) - { - for (KeyFrameControl.KeyFrameRequester keyFrameRequester - : keyFrameRequesters) - { - try - { - if (keyFrameRequester.requestKeyFrame()) - break; - } - catch (Exception e) - { - /* - * A KeyFrameRequester has malfunctioned, do not let - * it interfere with the others. - */ - } - } - } - } - lastRequestKeyFrameTime = System.currentTimeMillis(); - } - } - - /** - * Sets the KeyFrameControl to be used by this - * DePacketizer as a means of control over its key frame-related - * logic. - * - * @param keyFrameControl the KeyFrameControl to be used by this - * DePacketizer as a means of control over its key frame-related - * logic - */ - public void setKeyFrameControl(KeyFrameControl keyFrameControl) - { - this.keyFrameControl = keyFrameControl; - } - - /** - * Sets the indicator which determines whether this DePacketizer is - * to request a key frame from the remote peer associated with - * {@link #keyFrameControl}. - * - * @param requestKeyFrame true if this DePacketizer is to - * request a key frame from the remote peer associated with - * {@link #keyFrameControl} - */ - private synchronized void setRequestKeyFrame(boolean requestKeyFrame) - { - if (this.requestKeyFrame != requestKeyFrame) - { - this.requestKeyFrame = requestKeyFrame; - - if ((this.requestKeyFrame) && (requestKeyFrameThread == null)) - { - requestKeyFrameThread - = new Thread() - { - public void run() - { - try - { - runInRequestKeyFrameThread(); - } - finally - { - synchronized (DePacketizer.this) - { - if (requestKeyFrameThread - == Thread.currentThread()) - requestKeyFrameThread = null; - } - } - } - }; - requestKeyFrameThread.start(); - } - notifyAll(); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/JNIDecoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/JNIDecoder.java deleted file mode 100644 index 24fb471f2..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/JNIDecoder.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video.h264; - -import java.awt.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.service.neomedia.control.*; -import net.sf.fmj.media.*; - -/** - * Decodes H.264 NAL units and returns the resulting frames as FFmpeg - * AVFrames (i.e. in YUV format). - * - * @author Damian Minkov - * @author Lyubomir Marinov - * @author Sebastien Vincent - */ -public class JNIDecoder - extends AbstractCodec -{ - /** - * Plugin name. - */ - private static final String PLUGIN_NAME = "H.264 Decoder"; - - /** - * The default output VideoFormat. - */ - private static final VideoFormat[] DEFAULT_OUTPUT_FORMATS - = new VideoFormat[] { new AVFrameFormat() }; - - /** - * The codec context native pointer we will use. - */ - private long avctx; - - /** - * The decoded data is stored in avpicture in native ffmpeg format (YUV). - */ - private long avframe; - - /** - * If decoder has got a picture. - */ - private final boolean[] got_picture = new boolean[1]; - - private boolean gotPictureAtLeastOnce; - - /** - * The last known height of {@link #avctx} i.e. the video output by this - * JNIDecoder. Used to detect changes in the output size. - */ - private int height; - - /** - * The KeyFrameControl used by this JNIDecoder to - * control its key frame-related logic. - */ - private KeyFrameControl keyFrameControl; - - /** - * Array of output VideoFormats. - */ - private final VideoFormat[] outputFormats; - - /** - * The last known width of {@link #avctx} i.e. the video output by this - * JNIDecoder. Used to detect changes in the output size. - */ - private int width; - - /** - * Initializes a new JNIDecoder instance which is to decode H.264 - * NAL units into frames in YUV format. - */ - public JNIDecoder() - { - inputFormats - = new VideoFormat[] { new VideoFormat(Constants.H264) }; - outputFormats - = new VideoFormat[] - { - new AVFrameFormat( - new Dimension( - Constants.VIDEO_WIDTH, - Constants.VIDEO_HEIGHT), - ensureFrameRate(Format.NOT_SPECIFIED), - FFmpeg.PIX_FMT_YUV420P, - Format.NOT_SPECIFIED) - }; - - Dimension outputSize = outputFormats[0].getSize(); - - width = outputSize.width; - height = outputSize.height; - } - - /** - * Check Format. - * - * @param format Format to check - * @return true if Format is H264_RTP - */ - public boolean checkFormat(Format format) - { - return format.getEncoding().equals(Constants.H264_RTP); - } - - /** - * Close Codec. - */ - @Override - public synchronized void close() - { - if (opened) - { - opened = false; - super.close(); - - FFmpeg.avcodec_close(avctx); - FFmpeg.av_free(avctx); - avctx = 0; - - FFmpeg.av_free(avframe); - avframe = 0; - - gotPictureAtLeastOnce = false; - } - } - - /** - * Ensure frame rate. - * - * @param frameRate frame rate - * @return frame rate - */ - private float ensureFrameRate(float frameRate) - { - return frameRate; - } - - /** - * Get matching outputs for a specified input Format. - * - * @param in input Format - * @return array of matching outputs or null if there are no matching - * outputs. - */ - protected Format[] getMatchingOutputFormats(Format in) - { - VideoFormat ivf = (VideoFormat) in; - Dimension inSize = ivf.getSize(); - Dimension outSize; - - // return the default size/currently decoder and encoder - // set to transmit/receive at this size - if (inSize == null) - { - VideoFormat ovf = outputFormats[0]; - - if (ovf == null) - return null; - else - outSize = ovf.getSize(); - } - else - outSize = inSize; // Output in same size as input. - - return - new Format[] - { - new AVFrameFormat( - outSize, - ensureFrameRate(ivf.getFrameRate()), - FFmpeg.PIX_FMT_YUV420P, - Format.NOT_SPECIFIED) - }; - } - - /** - * Get plugin name. - * - * @return "H.264 Decoder" - */ - @Override - public String getName() - { - return PLUGIN_NAME; - } - - /** - * Get all supported output Formats. - * - * @param inputFormat input Format to determine corresponding - * output Format/tt>s - * @return an array of supported output Formats - */ - public Format[] getSupportedOutputFormats(Format inputFormat) - { - Format[] supportedOutputFormats; - - if (inputFormat == null) - supportedOutputFormats = DEFAULT_OUTPUT_FORMATS; - else - { - // mismatch input format - if (!(inputFormat instanceof VideoFormat) - || (AbstractCodecExt.matches(inputFormat, inputFormats) - == null)) - supportedOutputFormats = new Format[0]; - else - { - // match input format - supportedOutputFormats = getMatchingOutputFormats(inputFormat); - } - } - return supportedOutputFormats; - } - - /** - * Inits the codec instances. - * - * @throws ResourceUnavailableException if codec initialization failed - */ - @Override - public synchronized void open() - throws ResourceUnavailableException - { - if (opened) - return; - - long avcodec = FFmpeg.avcodec_find_decoder(FFmpeg.CODEC_ID_H264); - - avctx = FFmpeg.avcodec_alloc_context(); - FFmpeg.avcodeccontext_set_workaround_bugs(avctx, - FFmpeg.FF_BUG_AUTODETECT); - - /* allow to pass incomplete frame to decoder */ - FFmpeg.avcodeccontext_add_flags2(avctx, - FFmpeg.CODEC_FLAG2_CHUNKS); - - if (FFmpeg.avcodec_open(avctx, avcodec) < 0) - throw new RuntimeException("Could not open codec CODEC_ID_H264"); - - avframe = FFmpeg.avcodec_alloc_frame(); - - gotPictureAtLeastOnce = false; - - opened = true; - super.open(); - } - - /** - * Decodes H.264 media data read from a specific input Buffer into - * a specific output Buffer. - * - * @param inBuffer input Buffer - * @param outBuffer output Buffer - * @return BUFFER_PROCESSED_OK if inBuffer has been - * successfully processed - */ - public synchronized int process(Buffer inBuffer, Buffer outBuffer) - { - if (!checkInputBuffer(inBuffer)) - return BUFFER_PROCESSED_FAILED; - if (isEOM(inBuffer) || !opened) - { - propagateEOM(outBuffer); - return BUFFER_PROCESSED_OK; - } - if (inBuffer.isDiscard()) - { - outBuffer.setDiscard(true); - return BUFFER_PROCESSED_OK; - } - - // Ask FFmpeg to decode. - got_picture[0] = false; - // TODO Take into account the offset of inputBuffer. - FFmpeg.avcodec_decode_video( - avctx, - avframe, - got_picture, - (byte[]) inBuffer.getData(), inBuffer.getLength()); - - if (!got_picture[0]) - { - if ((inBuffer.getFlags() & Buffer.FLAG_RTP_MARKER) != 0) - { - if (keyFrameControl != null) - keyFrameControl.requestKeyFrame(!gotPictureAtLeastOnce); - } - - outBuffer.setDiscard(true); - return BUFFER_PROCESSED_OK; - } - gotPictureAtLeastOnce = true; - - // format - int width = FFmpeg.avcodeccontext_get_width(avctx); - int height = FFmpeg.avcodeccontext_get_height(avctx); - - if ((width > 0) - && (height > 0) - && ((this.width != width) || (this.height != height))) - { - this.width = width; - this.height = height; - - // Output in same size and frame rate as input. - Dimension outSize = new Dimension(this.width, this.height); - VideoFormat inFormat = (VideoFormat) inBuffer.getFormat(); - float outFrameRate = ensureFrameRate(inFormat.getFrameRate()); - - outputFormat - = new AVFrameFormat( - outSize, - outFrameRate, - FFmpeg.PIX_FMT_YUV420P, - Format.NOT_SPECIFIED); - } - outBuffer.setFormat(outputFormat); - - // data - Object out = outBuffer.getData(); - - if (!(out instanceof AVFrame) || (((AVFrame) out).getPtr() != avframe)) - outBuffer.setData(new AVFrame(avframe)); - - // timeStamp - long pts = FFmpeg.AV_NOPTS_VALUE; // TODO avframe_get_pts(avframe); - - if (pts == FFmpeg.AV_NOPTS_VALUE) - outBuffer.setTimeStamp(Buffer.TIME_UNKNOWN); - else - { - outBuffer.setTimeStamp(pts); - - int outFlags = outBuffer.getFlags(); - - outFlags |= Buffer.FLAG_RELATIVE_TIME; - outFlags &= ~(Buffer.FLAG_RTP_TIME | Buffer.FLAG_SYSTEM_TIME); - outBuffer.setFlags(outFlags); - } - - return BUFFER_PROCESSED_OK; - } - - /** - * Sets the Format of the media data to be input for processing in - * this Codec. - * - * @param format the Format of the media data to be input for - * processing in this Codec - * @return the Format of the media data to be input for processing - * in this Codec if format is compatible with this - * Codec; otherwise, null - */ - @Override - public Format setInputFormat(Format format) - { - Format setFormat = super.setInputFormat(format); - - if (setFormat != null) - reset(); - return setFormat; - } - - /** - * Sets the KeyFrameControl to be used by this - * DePacketizer as a means of control over its key frame-related - * logic. - * - * @param keyFrameControl the KeyFrameControl to be used by this - * DePacketizer as a means of control over its key frame-related - * logic - */ - public void setKeyFrameControl(KeyFrameControl keyFrameControl) - { - this.keyFrameControl = keyFrameControl; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/JNIEncoder.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/JNIEncoder.java deleted file mode 100644 index 4599207c6..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/JNIEncoder.java +++ /dev/null @@ -1,794 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video.h264; - -import java.awt.*; -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.format.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.control.*; -import net.java.sip.communicator.service.neomedia.event.*; -import net.java.sip.communicator.util.*; -import net.sf.fmj.media.*; - -/** - * Implements a H.264 encoder. - * - * @author Damian Minkov - * @author Lyubomir Marinov - * @author Sebastien Vincent - */ -public class JNIEncoder - extends AbstractCodec - implements RTCPFeedbackListener -{ - /** - * The logger used by the JNIEncoder class and its instances for - * logging output. - */ - private static final Logger logger = Logger.getLogger(JNIEncoder.class); - - /** - * The name of the baseline H.264 (encoding) profile. - */ - public static final String BASELINE_PROFILE = "baseline"; - - /** - * The frame rate to be assumed by JNIEncoder instance in the - * absence of any other frame rate indication. - */ - static final int DEFAULT_FRAME_RATE = 15; - - /** - * The name of the ConfigurationService property which specifies - * the H.264 (encoding) profile to be used in the absence of negotiation. - * Though it seems that RFC 3984 "RTP Payload Format for H.264 Video" - * specifies the baseline profile as the default, we have till the time of - * this writing defaulted to the main profile and we do not currently want - * to change from the main to the base profile unless we really have to. - */ - public static final String DEFAULT_PROFILE_PNAME - = "net.java.sip.communicator.impl.neomedia.codec.video.h264." - + "defaultProfile"; - - /** - * Key frame every 150 frames. - */ - static final int IFRAME_INTERVAL = 150; - - /** - * The name of the main H.264 (encoding) profile. - */ - public static final String MAIN_PROFILE = "main"; - - /** - * The default value of the {@link #DEFAULT_PROFILE_PNAME} - * ConfigurationService property. - */ - public static final String DEFAULT_DEFAULT_PROFILE = MAIN_PROFILE; - - /** - * The name of the format parameter which specifies the packetization mode - * of H.264 RTP payload. - */ - public static final String PACKETIZATION_MODE_FMTP = "packetization-mode"; - - /** - * Minimum interval between two PLI request processing (in milliseconds). - */ - private static final long PLI_INTERVAL = 3000; - - /** - * Name of the code. - */ - private static final String PLUGIN_NAME = "H.264 Encoder"; - - /** - * The list of Formats supported by JNIEncoder instances - * as output. - */ - static final Format[] SUPPORTED_OUTPUT_FORMATS - = { - new ParameterizedVideoFormat( - Constants.H264, - PACKETIZATION_MODE_FMTP, "0"), - new ParameterizedVideoFormat( - Constants.H264, - PACKETIZATION_MODE_FMTP, "1") - }; - - /** - * The codec we will use. - */ - private long avctx; - - /** - * The encoded data is stored in avpicture. - */ - private long avframe; - - /** - * We use this buffer to supply data to encoder. - */ - private byte[] encFrameBuffer; - - /** - * The supplied data length. - */ - private int encFrameLen; - - /** - * Force encoder to send a key frame. - * First frame have to be a keyframe. - */ - private boolean forceKeyFrame = true; - - /** - * Next interval for an automatic keyframe. - */ - private int framesSinceLastIFrame = IFRAME_INTERVAL + 1; - - /** - * The KeyFrameControl used by this JNIEncoder to - * control its key frame-related logic. - */ - private KeyFrameControl keyFrameControl; - - private KeyFrameControl.KeyFrameRequestee keyFrameRequestee; - - /** - * The time in milliseconds of the last request for a key frame from the - * remote peer to this local peer. - */ - private long lastKeyFrameRequestTime = System.currentTimeMillis(); - - /** - * The packetization mode to be used for the H.264 RTP payload output by - * this JNIEncoder and the associated packetizer. RFC 3984 "RTP - * Payload Format for H.264 Video" says that "[w]hen the value of - * packetization-mode is equal to 0 or packetization-mode is not present, - * the single NAL mode, as defined in section 6.2 of RFC 3984, MUST be - * used." - */ - private String packetizationMode; - - /** - * The raw frame buffer. - */ - private long rawFrameBuffer; - - /** - * Peer that receive stream from latest ffmpeg/x264 aware peer does not - * manage to decode the first keyframe and must wait for the next periodic - * intra refresh to display the video to the user. - * - * Temporary solution for this problem: send the two first frames as - * keyframes to display video stream. - */ - private boolean secondKeyFrame = true; - - /** - * Additional codec settings. - */ - private Map additionalSettings = null; - - /** - * Initializes a new JNIEncoder instance. - */ - public JNIEncoder() - { - inputFormats - = new Format[] - { - new YUVFormat( - null, - Format.NOT_SPECIFIED, - Format.byteArray, - DEFAULT_FRAME_RATE, - YUVFormat.YUV_420, - Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, - 0, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED) - }; - - inputFormat = null; - outputFormat = null; - } - - /** - * Closes this Codec. - */ - @Override - public synchronized void close() - { - if (opened) - { - opened = false; - super.close(); - - FFmpeg.avcodec_close(avctx); - FFmpeg.av_free(avctx); - avctx = 0; - - FFmpeg.av_free(avframe); - avframe = 0; - FFmpeg.av_free(rawFrameBuffer); - rawFrameBuffer = 0; - - encFrameBuffer = null; - - if (keyFrameRequestee != null) - { - if (keyFrameControl != null) - keyFrameControl.removeKeyFrameRequestee(keyFrameRequestee); - keyFrameRequestee = null; - } - } - } - - /** - * Event fired when RTCP feedback message is received. - * - * @param event RTCPFeedbackEvent - */ - public void feedbackReceived(RTCPFeedbackEvent event) - { - /* - * If RTCP message is a Picture Loss Indication (PLI) or a - * Full Intra-frame Request (FIR) the encoder will force the next frame - * to be a keyframe. - */ - if (event.getPayloadType() == RTCPFeedbackEvent.PT_PS) - { - switch (event.getFeedbackMessageType()) - { - case RTCPFeedbackEvent.FMT_PLI: - case RTCPFeedbackEvent.FMT_FIR: - keyFrameRequest(); - break; - default: - break; - } - } - } - - /** - * Gets the matching output formats for a specific format. - * - * @param in input format - * @return array for formats matching input format - */ - private Format[] getMatchingOutputFormats(Format in) - { - VideoFormat videoIn = (VideoFormat) in; - - String[] packetizationModes - = (this.packetizationMode == null) - ? new String[] { "0", "1" } - : new String[] { this.packetizationMode }; - Format[] matchingOutputFormats = new Format[packetizationModes.length]; - Dimension size = videoIn.getSize(); - float frameRate = videoIn.getFrameRate(); - - for (int index = packetizationModes.length - 1; index >= 0; index--) - { - matchingOutputFormats[index] - = new ParameterizedVideoFormat( - Constants.H264, - size, - Format.NOT_SPECIFIED, - Format.byteArray, - frameRate, - ParameterizedVideoFormat.toMap( - PACKETIZATION_MODE_FMTP, - packetizationModes[index])); - } - return matchingOutputFormats; - } - - /** - * Gets the name of this Codec. - * - * @return codec name - */ - @Override - public String getName() - { - return PLUGIN_NAME; - } - - /** - * Returns the list of formats supported at the output. - * - * @param in input Format to determine corresponding output - * Formats - * @return array of formats supported at output - */ - public Format[] getSupportedOutputFormats(Format in) - { - Format[] supportedOutputFormats; - - // null input format - if (in == null) - supportedOutputFormats = SUPPORTED_OUTPUT_FORMATS; - // mismatch input format - else if (!(in instanceof VideoFormat) - || (null == AbstractCodecExt.matches(in, inputFormats))) - supportedOutputFormats = new Format[0]; - else - supportedOutputFormats = getMatchingOutputFormats(in); - return supportedOutputFormats; - } - - /** - * Notifies this JNIEncoder that the remote peer has requested a - * key frame from this local peer. - * - * @return true if this JNIEncoder has honored the request - * for a key frame; otherwise, false - */ - private boolean keyFrameRequest() - { - if (System.currentTimeMillis() - > (lastKeyFrameRequestTime + PLI_INTERVAL)) - { - lastKeyFrameRequestTime = System.currentTimeMillis(); - forceKeyFrame = true; - } - return true; - } - - /** - * Opens this Codec. - */ - @Override - public synchronized void open() - throws ResourceUnavailableException - { - if (opened) - return; - - if (inputFormat == null) - throw new ResourceUnavailableException("No input format selected"); - if (outputFormat == null) - throw new ResourceUnavailableException("No output format selected"); - - VideoFormat outputVideoFormat = (VideoFormat) outputFormat; - Dimension size = outputVideoFormat.getSize(); - int width = size.width; - int height = size.height; - boolean useIntraRefresh = true; - boolean useCustomProfile = false; - String customProfile = null; - - if(additionalSettings != null) - { - for(Map.Entry entry : additionalSettings.entrySet()) - { - String key = entry.getKey(); - String value = entry.getValue(); - - if(key.equals("h264.intrarefresh") && value.equals("false")) - { - useIntraRefresh = false; - } - else if(key.equals("h264.profile")) - { - if(value.equals(MAIN_PROFILE) || - value.equals(BASELINE_PROFILE)) - { - useCustomProfile = true; - customProfile = value; - } - } - } - } - - long avcodec = FFmpeg.avcodec_find_encoder(FFmpeg.CODEC_ID_H264); - - avctx = FFmpeg.avcodec_alloc_context(); - - FFmpeg.avcodeccontext_set_pix_fmt(avctx, FFmpeg.PIX_FMT_YUV420P); - FFmpeg.avcodeccontext_set_size(avctx, width, height); - - FFmpeg.avcodeccontext_set_qcompress(avctx, 0.6f); - - int bitRate = 128000; - int frameRate = (int) outputVideoFormat.getFrameRate(); - - if (frameRate == Format.NOT_SPECIFIED) - frameRate = DEFAULT_FRAME_RATE; - - // average bit rate - FFmpeg.avcodeccontext_set_bit_rate(avctx, bitRate); - // so to be 1 in x264 - FFmpeg.avcodeccontext_set_bit_rate_tolerance(avctx, (bitRate / - frameRate)); - FFmpeg.avcodeccontext_set_rc_max_rate(avctx, bitRate); - FFmpeg.avcodeccontext_set_sample_aspect_ratio(avctx, 0, 0); - FFmpeg.avcodeccontext_set_thread_count(avctx, 1); - - // time_base should be 1 / frame rate - FFmpeg.avcodeccontext_set_time_base(avctx, 1, frameRate); - FFmpeg.avcodeccontext_set_ticks_per_frame(avctx, 2); - FFmpeg.avcodeccontext_set_quantizer(avctx, 30, 31, 4); - - // avctx.chromaoffset = -2; - - FFmpeg.avcodeccontext_add_partitions(avctx, 0x111); - // X264_PART_I4X4 0x001 - // X264_PART_P8X8 0x010 - // X264_PART_B8X8 0x100 - - FFmpeg.avcodeccontext_set_mb_decision(avctx, - FFmpeg.FF_MB_DECISION_SIMPLE); - - FFmpeg.avcodeccontext_set_rc_eq(avctx, "blurCplx^(1-qComp)"); - - FFmpeg.avcodeccontext_add_flags(avctx, - FFmpeg.CODEC_FLAG_LOOP_FILTER); - if(useIntraRefresh) - FFmpeg.avcodeccontext_add_flags2(avctx, - FFmpeg.CODEC_FLAG2_INTRA_REFRESH); - FFmpeg.avcodeccontext_set_me_method(avctx, 7); - FFmpeg.avcodeccontext_set_me_subpel_quality(avctx, 2); - FFmpeg.avcodeccontext_set_me_range(avctx, 16); - FFmpeg.avcodeccontext_set_me_cmp(avctx, FFmpeg.FF_CMP_CHROMA); - FFmpeg.avcodeccontext_set_scenechange_threshold(avctx, 40); - // Constant quality mode (also known as constant ratefactor) - FFmpeg.avcodeccontext_set_crf(avctx, 0); - FFmpeg.avcodeccontext_set_rc_buffer_size(avctx, 10); - FFmpeg.avcodeccontext_set_gop_size(avctx, IFRAME_INTERVAL); - FFmpeg.avcodeccontext_set_i_quant_factor(avctx, 1f / 1.4f); - - FFmpeg.avcodeccontext_set_refs(avctx, 1); - //FFmpeg.avcodeccontext_set_trellis(avctx, 2); - - FFmpeg.avcodeccontext_set_keyint_min(avctx, 0); - - if ((null == packetizationMode) || "0".equals(packetizationMode)) - { - FFmpeg.avcodeccontext_set_rtp_payload_size(avctx, - Packetizer.MAX_PAYLOAD_SIZE); - } - - /* - * XXX We do not currently negotiate the profile so, regardless of the - * many AVCodecContext properties we have set above, force the default - * profile configuration. - */ - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - String profile - = (cfg == null) - ? null - : cfg.getString(DEFAULT_PROFILE_PNAME, DEFAULT_DEFAULT_PROFILE); - - if(useCustomProfile) - { - profile = customProfile; - } - - try - { - FFmpeg.avcodeccontext_set_profile(avctx, - BASELINE_PROFILE.equalsIgnoreCase(profile) - ? FFmpeg.FF_PROFILE_H264_BASELINE - : FFmpeg.FF_PROFILE_H264_MAIN); - } - catch (UnsatisfiedLinkError ule) - { - logger.warn("The FFmpeg JNI library is out-of-date."); - } - - if (FFmpeg.avcodec_open(avctx, avcodec) < 0) - { - throw - new ResourceUnavailableException( - "Could not open codec. (size= " - + width + "x" + height - + ")"); - } - - encFrameLen = (width * height * 3) / 2; - - rawFrameBuffer = FFmpeg.av_malloc(encFrameLen); - avframe = FFmpeg.avcodec_alloc_frame(); - - int sizeInBytes = width * height; - - FFmpeg.avframe_set_data( - avframe, - rawFrameBuffer, - sizeInBytes, - sizeInBytes / 4); - FFmpeg.avframe_set_linesize(avframe, width, width / 2, width / 2); - - encFrameBuffer = new byte[encFrameLen]; - - /* - * Implement the ability to have the remote peer request key frames from - * this local peer. - */ - if (keyFrameRequestee == null) - { - keyFrameRequestee = new KeyFrameControl.KeyFrameRequestee() - { - public boolean keyFrameRequest() - { - return JNIEncoder.this.keyFrameRequest(); - } - }; - } - if (keyFrameControl != null) - keyFrameControl.addKeyFrameRequestee(-1, keyFrameRequestee); - - opened = true; - super.open(); - } - - /** - * Processes/encodes a buffer. - * - * @param inBuffer input buffer - * @param outBuffer output buffer - * @return BUFFER_PROCESSED_OK if buffer has been successfully - * processed - */ - public synchronized int process(Buffer inBuffer, Buffer outBuffer) - { - if (isEOM(inBuffer)) - { - propagateEOM(outBuffer); - reset(); - return BUFFER_PROCESSED_OK; - } - if (inBuffer.isDiscard()) - { - outBuffer.setDiscard(true); - reset(); - return BUFFER_PROCESSED_OK; - } - - Format inFormat = inBuffer.getFormat(); - - if ((inFormat != inputFormat) && !inFormat.matches(inputFormat)) - setInputFormat(inFormat); - - if (inBuffer.getLength() < 10) - { - outBuffer.setDiscard(true); - reset(); - return BUFFER_PROCESSED_OK; - } - - // copy data to avframe - FFmpeg.memcpy( - rawFrameBuffer, - (byte[]) inBuffer.getData(), inBuffer.getOffset(), - encFrameLen); - - if (/* framesSinceLastIFrame >= IFRAME_INTERVAL || */ forceKeyFrame) - { - FFmpeg.avframe_set_key_frame(avframe, true); - framesSinceLastIFrame = 0; - - /* send keyframe for the first two frames */ - if(secondKeyFrame) - { - secondKeyFrame = false; - forceKeyFrame = true; - } - else - { - forceKeyFrame = false; - } - } - else - { - framesSinceLastIFrame++; - FFmpeg.avframe_set_key_frame(avframe, false); - } - - // encode data - int encLen - = FFmpeg.avcodec_encode_video( - avctx, - encFrameBuffer, encFrameLen, - avframe); - - /* - * Do not always allocate a new data array for outBuffer, try to reuse - * the existing one if it is suitable. - */ - Object outData = outBuffer.getData(); - byte[] out; - - if (outData instanceof byte[]) - { - out = (byte[]) outData; - if (out.length < encLen) - out = null; - } - else - out = null; - if (out == null) - out = new byte[encLen]; - - System.arraycopy(encFrameBuffer, 0, out, 0, encLen); - - outBuffer.setData(out); - outBuffer.setLength(encLen); - outBuffer.setOffset(0); - outBuffer.setTimeStamp(inBuffer.getTimeStamp()); - return BUFFER_PROCESSED_OK; - } - - /** - * Sets the input format. - * - * @param in format to set - * @return format - */ - @Override - public Format setInputFormat(Format in) - { - // mismatch input format - if (!(in instanceof VideoFormat) - || (null == AbstractCodecExt.matches(in, inputFormats))) - return null; - - YUVFormat yuv = (YUVFormat) in; - - if (yuv.getOffsetU() > yuv.getOffsetV()) - return null; - - Dimension size = yuv.getSize(); - - if (size == null) - size = new Dimension(Constants.VIDEO_WIDTH, Constants.VIDEO_HEIGHT); - - int strideY = size.width; - int strideUV = strideY / 2; - int offsetU = strideY * size.height; - int offsetV = offsetU + strideUV * size.height / 2; - - int yuvMaxDataLength = (strideY + strideUV) * size.height; - - inputFormat - = new YUVFormat( - size, - yuvMaxDataLength + FFmpeg.FF_INPUT_BUFFER_PADDING_SIZE, - Format.byteArray, - yuv.getFrameRate(), - YUVFormat.YUV_420, - strideY, strideUV, - 0, offsetU, offsetV); - - // Return the selected inputFormat - return inputFormat; - } - - /** - * Sets the KeyFrameControl to be used by this - * JNIEncoder as a means of control over its key frame-related - * logic. - * - * @param keyFrameControl the KeyFrameControl to be used by this - * JNIEncoder as a means of control over its key frame-related - * logic - */ - public void setKeyFrameControl(KeyFrameControl keyFrameControl) - { - if (this.keyFrameControl != keyFrameControl) - { - if ((this.keyFrameControl != null) && (keyFrameRequestee != null)) - this.keyFrameControl.removeKeyFrameRequestee(keyFrameRequestee); - - this.keyFrameControl = keyFrameControl; - - if ((this.keyFrameControl != null) && (keyFrameRequestee != null)) - this.keyFrameControl.addKeyFrameRequestee(-1, keyFrameRequestee); - } - } - - /** - * Sets the Format in which this Codec is to output media - * data. - * - * @param out the Format in which this Codec is to - * output media data - * @return the Format in which this Codec is currently - * configured to output media data or null if format was - * found to be incompatible with this Codec - */ - @Override - public Format setOutputFormat(Format out) - { - // mismatch output format - if (!(out instanceof VideoFormat) - || (null - == AbstractCodecExt.matches( - out, - getMatchingOutputFormats(inputFormat)))) - return null; - - VideoFormat videoOut = (VideoFormat) out; - Dimension outSize = videoOut.getSize(); - - if (outSize == null) - { - Dimension inSize = ((VideoFormat) inputFormat).getSize(); - - outSize - = (inSize == null) - ? new Dimension( - Constants.VIDEO_WIDTH, - Constants.VIDEO_HEIGHT) - : inSize; - } - - Map fmtps = null; - - if (out instanceof ParameterizedVideoFormat) - fmtps = ((ParameterizedVideoFormat) out).getFormatParameters(); - if (fmtps == null) - fmtps = new HashMap(); - if (packetizationMode != null) - fmtps.put(PACKETIZATION_MODE_FMTP, packetizationMode); - - outputFormat - = new ParameterizedVideoFormat( - videoOut.getEncoding(), - outSize, - Format.NOT_SPECIFIED, - Format.byteArray, - videoOut.getFrameRate(), - fmtps); - - // Return the selected outputFormat - return outputFormat; - } - - /** - * Sets the packetization mode to be used for the H.264 RTP payload output - * by this JNIEncoder and the associated packetizer. - * - * @param packetizationMode the packetization mode to be used for the H.264 - * RTP payload output by this JNIEncoder and the associated - * packetizer - */ - public void setPacketizationMode(String packetizationMode) - { - /* - * RFC 3984 "RTP Payload Format for H.264 Video" says that "[w]hen the - * value of packetization-mode is equal to 0 or packetization-mode is - * not present, the single NAL mode, as defined in section 6.2 of RFC - * 3984, MUST be used." - */ - if ((packetizationMode == null) || "0".equals(packetizationMode)) - this.packetizationMode = "0"; - else if ("1".equals(packetizationMode)) - this.packetizationMode = "1"; - else - throw new IllegalArgumentException("packetizationMode"); - } - - /** - * Sets additional settings for the codec. - * - * @param settings additional settings - */ - public void setAdditionalCodecSettings(Map settings) - { - additionalSettings = settings; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/Packetizer.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/Packetizer.java deleted file mode 100644 index 00cf91b04..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/Packetizer.java +++ /dev/null @@ -1,550 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.codec.video.h264; - -import java.awt.Dimension; // disambiguation -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.format.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.sf.fmj.media.*; - -/** - * Packetizes H.264 encoded data/NAL units into RTP packets in accord with RFC - * 3984 "RTP Payload Format for H.264 Video". - * - * @author Damian Minkov - * @author Lyubomir Marinov - */ -public class Packetizer - extends AbstractPacketizer -{ - /** - * Maximum payload size without the headers. - */ - public static final int MAX_PAYLOAD_SIZE = 1024; - - /** - * Name of the plugin. - */ - private static final String PLUGIN_NAME = "H264 Packetizer"; - - /** - * The Formats supported by Packetizer instances as - * output. - */ - static final Format[] SUPPORTED_OUTPUT_FORMATS - = { - new ParameterizedVideoFormat( - Constants.H264_RTP, - JNIEncoder.PACKETIZATION_MODE_FMTP, "0"), - new ParameterizedVideoFormat( - Constants.H264_RTP, - JNIEncoder.PACKETIZATION_MODE_FMTP, "1") - }; - - /** - * The list of NAL units to be sent as payload in RTP packets. - */ - private final List nals = new LinkedList(); - - /** - * The timeStamp of the RTP packets in which nals are to be sent. - */ - private long nalsTimeStamp; - - /** - * The sequence number of the next RTP packet to be output by this - * Packetizer. - */ - private int sequenceNumber; - - /** - * Initializes a new Packetizer instance which is to packetize - * H.264 encoded data/NAL units into RTP packets in accord with RFC 3984 - * "RTP Payload Format for H.264 Video". - */ - public Packetizer() - { - inputFormats = JNIEncoder.SUPPORTED_OUTPUT_FORMATS; - - inputFormat = null; - outputFormat = null; - } - - /** - * Close this Packetizer. - */ - @Override - public synchronized void close() - { - if (opened) - { - opened = false; - super.close(); - } - } - - /** - * Finds the index in byteStream at which the - * start_code_prefix_one_3bytes of a NAL unit begins. - * - * @param byteStream the H.264 encoded byte stream composed of NAL units in - * which the index of the beginning of the start_code_prefix_one_3bytes of a - * NAL unit is to be found - * @param beginIndex the inclusive index in byteStream at which the - * search is to begin - * @param endIndex the exclusive index in byteStream at which the - * search is to end - * @return the index in byteStream at which the - * start_code_prefix_one_3bytes of a NAL unit begins if it is found; - * otherwise, endIndex - */ - private static int ff_avc_find_startcode( - byte[] byteStream, - int beginIndex, - int endIndex) - { - for (; beginIndex < (endIndex - 3); beginIndex++) - if((byteStream[beginIndex] == 0) - && (byteStream[beginIndex + 1] == 0) - && (byteStream[beginIndex + 2] == 1)) - return beginIndex; - return endIndex; - } - - /** - * Gets the output formats matching a specific input format. - * - * @param input the input format to get the matching output formats for - * @return an array of output formats matching the specified input format - */ - private Format[] getMatchingOutputFormats(Format input) - { - VideoFormat videoInput = (VideoFormat) input; - Dimension size = videoInput.getSize(); - float frameRate = videoInput.getFrameRate(); - String packetizationMode = getPacketizationMode(input); - - return - new Format[] - { - new ParameterizedVideoFormat( - Constants.H264_RTP, - size, - Format.NOT_SPECIFIED, - Format.byteArray, - frameRate, - ParameterizedVideoFormat.toMap( - JNIEncoder.PACKETIZATION_MODE_FMTP, - packetizationMode)) - }; - } - - /** - * Gets the name of this PlugIn. - * - * @return the name of this PlugIn - */ - @Override - public String getName() - { - return PLUGIN_NAME; - } - - /** - * Gets the value of the packetization-mode format parameter - * assigned by a specific Format. - * - * @param format the Format which assigns a value to the - * packetization-mode format parameter - * @return the value of the packetization-mode format parameter - * assigned by the specified format - */ - private String getPacketizationMode(Format format) - { - String packetizationMode = null; - - if (format instanceof ParameterizedVideoFormat) - packetizationMode - = ((ParameterizedVideoFormat) format).getFormatParameter( - JNIEncoder.PACKETIZATION_MODE_FMTP); - if (packetizationMode == null) - packetizationMode = "0"; - - return packetizationMode; - } - - /** - * Return the list of formats supported at the output. - * @param in input Format to determine corresponding output - * Format/tt>s - * @return array of formats supported at output - */ - public Format[] getSupportedOutputFormats(Format in) - { - // null input format - if (in == null) - return SUPPORTED_OUTPUT_FORMATS; - - // mismatch input format - if (!(in instanceof VideoFormat) - || (null == AbstractCodecExt.matches(in, inputFormats))) - return new Format[0]; - - return getMatchingOutputFormats(in); - } - - /** - * Open this Packetizer. - * - * @throws ResourceUnavailableException if something goes wrong during - * initialization of the Packetizer. - */ - @Override - public synchronized void open() - throws ResourceUnavailableException - { - if (!opened) - { - nals.clear(); - sequenceNumber = 0; - - super.open(); - opened = true; - } - } - - /** - * Packetizes a specific NAL unit of H.264 encoded data so that it becomes - * ready to be sent as the payload of RTP packets. If the specified NAL unit - * does not fit into a single RTP packet i.e. will not become a "Single NAL - * Unit Packet", splits it into "Fragmentation Units (FUs)" of type FU-A. - * - * @param nal the bytes which contain the NAL unit of H.264 encoded data to - * be packetized - * @param nalOffset the offset in nal at which the NAL unit of - * H.264 encoded data to be packetized begins - * @param nalLength the length in nal beginning at - * nalOffset of the NAL unit of H.264 encoded data to be packetized - * @return true if at least one RTP packet payload has been - * packetized i.e. prepared for sending; otherwise, false - */ - private boolean packetizeNAL(byte[] nal, int nalOffset, int nalLength) - { - /* - * If the NAL fits into a "Single NAL Unit Packet", it's already - * packetized. - */ - if (nalLength <= MAX_PAYLOAD_SIZE) - { - byte[] singleNALUnitPacket = new byte[nalLength]; - - System.arraycopy(nal, nalOffset, singleNALUnitPacket, 0, nalLength); - return nals.add(singleNALUnitPacket); - } - - // Otherwise, split it into "Fragmentation Units (FUs)". - byte octet = nal[nalOffset]; - int forbidden_zero_bit = octet & 0x80; - int nri = octet & 0x60; - int nal_unit_type = octet & 0x1F; - - byte fuIndicator - = (byte) - (0xFF - & (forbidden_zero_bit - | nri - | 28 /* nal_unit_type FU-A */)); - byte fuHeader - = (byte) - (0xFF - & (0x80 /* Start bit */ - | 0 /* End bit */ - | 0 /* Reserved bit */ - | nal_unit_type)); - - nalOffset++; - nalLength--; - - int maxFUPayloadLength - = MAX_PAYLOAD_SIZE - 2 /* FU indicator & FU header */; - boolean nalsAdded = false; - - while (nalLength > 0) - { - int fuPayloadLength; - - if (nalLength > maxFUPayloadLength) - fuPayloadLength = maxFUPayloadLength; - else - { - fuPayloadLength = nalLength; - fuHeader |= 0x40; // Turn on the End bit. - } - - /* - * Tests with Asterisk suggest that the fragments of a fragmented - * NAL unit must be with one and the same size. There is also a - * similar question on the x264-devel mailing list but, - * unfortunately, it is unanswered. - */ - byte[] fua - = new byte[ - 2 /* FU indicator & FU header */ + maxFUPayloadLength]; - - fua[0] = fuIndicator; - fua[1] = fuHeader; - System.arraycopy(nal, nalOffset, fua, 2, fuPayloadLength); - nalOffset += fuPayloadLength; - nalLength -= fuPayloadLength; - - nalsAdded = nals.add(fua) || nalsAdded; - - fuHeader &= ~0x80; // Turn off the Start bit. - } - return nalsAdded; - } - - /** - * Processes (packetize) a buffer. - * - * @param inBuffer input buffer - * @param outBuffer output buffer - * @return BUFFER_PROCESSED_OK if buffer has been successfully - * processed - */ - @Override - public int process(Buffer inBuffer, Buffer outBuffer) - { - // if there are some nals we check and send them - if (nals.size() > 0) - { - byte[] nal = nals.remove(0); - - // Send the NAL. - outBuffer.setData(nal); - outBuffer.setLength(nal.length); - outBuffer.setOffset(0); - outBuffer.setTimeStamp(nalsTimeStamp); - outBuffer.setSequenceNumber(sequenceNumber++); - - // If there are other NALs, send them as well. - if(nals.size() > 0) - return (BUFFER_PROCESSED_OK | INPUT_BUFFER_NOT_CONSUMED); - else - { - int flags = outBuffer.getFlags() | Buffer.FLAG_RTP_MARKER; - - /* - * It's the last NAL of the current frame so mark it. In order - * to (at least partially) support feeding this Packetizer one - * NAL at a time, do NOT always mark it i.e. the NALs with - * a value for nal_unit_type which signals that they cannot be - * the last NALs in an access unit should probably NOT be - * marked anyway. - */ - if (nal.length > 0) - { - int nal_unit_type = nal[0] & 0x1F; - - if ((nal_unit_type == 28 /* FU-A */) && (nal.length > 1)) - { - byte fuHeader = nal[1]; - - if ((fuHeader & 0x40 /* End bit */) == 0) - { - /* - * A FU-A without the End bit cannot possibly be the - * last NAL unit of an access unit. - */ - flags &= ~Buffer.FLAG_RTP_MARKER; - } - else - nal_unit_type = fuHeader & 0x1F; - } - - switch (nal_unit_type) - { - case 6 /* Supplemental enhancement information (SEI) */: - case 7 /* Sequence parameter set */: - case 8 /* Picture parameter set */: - case 9 /* Access unit delimiter */: - flags &= ~Buffer.FLAG_RTP_MARKER; - break; - } - } - - outBuffer.setFlags(flags); - return BUFFER_PROCESSED_OK; - } - } - - if (isEOM(inBuffer)) - { - propagateEOM(outBuffer); - reset(); - return BUFFER_PROCESSED_OK; - } - if (inBuffer.isDiscard()) - { - outBuffer.setDiscard(true); - reset(); - return BUFFER_PROCESSED_OK; - } - - Format inFormat = inBuffer.getFormat(); - - if ((inFormat != inputFormat) && !inFormat.matches(inputFormat)) - setInputFormat(inFormat); - - int inLength = inBuffer.getLength(); - - /* - * We need 3 bytes for start_code_prefix_one_3bytes and at least 1 byte - * for the NAL unit i.e. its octet serving as the payload header. - */ - if (inLength < 4) - { - outBuffer.setDiscard(true); - reset(); - return BUFFER_PROCESSED_OK; - } - - byte[] inData = (byte[]) inBuffer.getData(); - int inOffset = inBuffer.getOffset(); - boolean nalsAdded = false; - - /* - * Split the H.264 encoded data into NAL units. Each NAL unit begins - * with start_code_prefix_one_3bytes. Refer to "B.1 Byte stream NAL unit - * syntax and semantics" of "ITU-T Rec. H.264 Advanced video coding for - * generic audiovisual services" for further details. - */ - int endIndex = inOffset + inLength; - int beginIndex = ff_avc_find_startcode(inData, inOffset, endIndex); - - if (beginIndex < endIndex) - { - beginIndex += 3; - - for (int nextBeginIndex; - (beginIndex < endIndex) - && ((nextBeginIndex - = ff_avc_find_startcode( - inData, - beginIndex, endIndex)) - <= endIndex); - beginIndex = nextBeginIndex + 3) - { - int nalLength = nextBeginIndex - beginIndex; - - // Discard any trailing_zero_8bits. - while ((nalLength > 0) - && (inData[beginIndex + nalLength - 1] == 0)) - nalLength--; - - if (nalLength > 0) - nalsAdded - = packetizeNAL(inData, beginIndex, nalLength) - || nalsAdded; - } - } - - nalsTimeStamp = inBuffer.getTimeStamp(); - - return - nalsAdded ? process(inBuffer, outBuffer) : OUTPUT_BUFFER_NOT_FILLED; - } - - /** - * Sets the input format. - * - * @param in format to set - * @return format - */ - @Override - public Format setInputFormat(Format in) - { - /* - * Return null if the specified input Format is incompatible with this - * Packetizer. - */ - if (!(in instanceof VideoFormat) - || null == AbstractCodecExt.matches(in, inputFormats)) - return null; - - inputFormat = in; - return in; - } - - /** - * Sets the Format in which this Codec is to output media - * data. - * - * @param output the Format in which this Codec is to - * output media data - * @return the Format in which this Codec is currently - * configured to output media data or null if format was - * found to be incompatible with this Codec - */ - @Override - public Format setOutputFormat(Format output) - { - /* - * Return null if the specified output Format is incompatible with this - * Packetizer. - */ - if (!(output instanceof VideoFormat) - || (null - == AbstractCodecExt.matches( - output, - getMatchingOutputFormats(inputFormat)))) - return null; - - VideoFormat videoOutput = (VideoFormat) output; - Dimension outputSize = videoOutput.getSize(); - - if (outputSize == null) - { - Dimension inputSize = ((VideoFormat) inputFormat).getSize(); - - outputSize - = (inputSize == null) - ? new Dimension( - Constants.VIDEO_WIDTH, - Constants.VIDEO_HEIGHT) - : inputSize; - } - - Map fmtps = null; - - if (output instanceof ParameterizedVideoFormat) - fmtps = ((ParameterizedVideoFormat) output).getFormatParameters(); - if (fmtps == null) - fmtps = new HashMap(); - if (fmtps.get(JNIEncoder.PACKETIZATION_MODE_FMTP) == null) - fmtps.put( - JNIEncoder.PACKETIZATION_MODE_FMTP, - getPacketizationMode(inputFormat)); - - outputFormat - = new ParameterizedVideoFormat( - videoOutput.getEncoding(), - outputSize, - outputSize.width * outputSize.height, - Format.byteArray, - videoOutput.getFrameRate(), - fmtps); - - // Return the outputFormat which is actually set. - return outputFormat; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/conference/AudioMixer.java b/src/net/java/sip/communicator/impl/neomedia/conference/AudioMixer.java deleted file mode 100644 index e3733c23a..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/conference/AudioMixer.java +++ /dev/null @@ -1,1141 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.conference; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; - -import javax.media.*; -import javax.media.Controls; // disambiguation -import javax.media.control.*; -import javax.media.format.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.control.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.protocol.*; -import net.java.sip.communicator.util.*; - -/** - * Represents an audio mixer which manages the mixing of multiple audio streams - * i.e. it is able to output a single audio stream which contains the audio of - * multiple input audio streams. - *

- * The input audio streams are provided to the AudioMixer through - * {@link #addInputDataSource(DataSource)} in the form of input - * DataSources giving access to one or more input - * SourceStreams. - *

- *

- * The output audio stream representing the mix of the multiple input audio - * streams is provided by the AudioMixer in the form of a - * AudioMixingPushBufferDataSource giving access to a - * AudioMixingPushBufferStream. Such an output is obtained through - * {@link #createOutputDataSource()}. The AudioMixer is able to provide - * multiple output audio streams at one and the same time, though, each of them - * containing the mix of a subset of the input audio streams. - *

- * - * @author Lubomir Marinov - */ -public class AudioMixer -{ - - /** - * The Logger used by the AudioMixer class and its - * instances for logging output. - */ - private static final Logger logger = Logger.getLogger(AudioMixer.class); - - /** - * The default output AudioFormat in which AudioMixer, - * AudioMixingPushBufferDataSource and - * AudioMixingPushBufferStream output audio. - */ - private static final AudioFormat DEFAULT_OUTPUT_FORMAT - = new AudioFormat( - AudioFormat.LINEAR, - 8000, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED); - - /** - * The BufferControl of this instance and, respectively, its - * AudioMixingPushBufferDataSources. - */ - private BufferControl bufferControl; - - /** - * The CaptureDevice capabilities provided by the - * AudioMixingPushBufferDataSources created by this - * AudioMixer. JMF's - * Manager.createMergingDataSource(DataSource[]) requires the - * interface implementation for audio if it is implemented for video and it - * is indeed the case for our use case of - * AudioMixingPushBufferDataSource. - */ - protected final CaptureDevice captureDevice; - - /** - * The number of output AudioMixingPushBufferDataSources reading - * from this AudioMixer which are connected. When the value is - * greater than zero, this AudioMixer is connected to the input - * DataSources it manages. - */ - private int connected; - - /** - * The collection of input DataSources this instance reads audio - * data from. - */ - private final List inputDataSources - = new ArrayList(); - - /** - * The AudioMixingPushBufferDataSource which contains the mix of - * inputDataSources excluding captureDevice and is thus - * meant for playback on the local peer in a call. - */ - private final AudioMixingPushBufferDataSource localOutputDataSource; - - /** - * The number of output AudioMixingPushBufferDataSources reading - * from this AudioMixer which are started. When the value is - * greater than zero, this AudioMixer is started and so are the - * input DataSources it manages. - */ - private int started; - - /** - * The output AudioMixerPushBufferStream through which this - * instance pushes audio sample data to - * AudioMixingPushBufferStreams to be mixed. - */ - private AudioMixerPushBufferStream outputStream; - - /** - * Initializes a new AudioMixer instance. Because JMF's - * Manager.createMergingDataSource(DataSource[]) requires the - * implementation of CaptureDevice for audio if it is implemented - * for video and it is indeed the cause for our use case of - * AudioMixingPushBufferDataSource, the new AudioMixer - * instance provides specified CaptureDevice capabilities to the - * AudioMixingPushBufferDataSources it creates. The specified - * CaptureDevice is also added as the first input - * DataSource of the new instance. - * - * @param captureDevice the CaptureDevice capabilities to be - * provided to the AudioMixingPushBufferDataSources created by the - * new instance and its first input DataSource - */ - public AudioMixer(CaptureDevice captureDevice) - { - /* - * AudioMixer provides PushBufferDataSources so it needs a way to push - * them. It does the pushing by using the pushes of its CaptureDevice - * i.e. it has to be a PushBufferDataSource. - */ - if (captureDevice instanceof PullBufferDataSource) - { - captureDevice - = new PushBufferDataSourceAdapter( - (PullBufferDataSource) captureDevice); - } - - // Try to enable tracing on captureDevice. - if (logger.isTraceEnabled()) - { - captureDevice - = MediaDeviceImpl.createTracingCaptureDevice( - captureDevice, - logger); - } - - this.captureDevice = captureDevice; - - this.localOutputDataSource = createOutputDataSource(); - addInputDataSource( - (DataSource) this.captureDevice, - this.localOutputDataSource); - } - - /** - * Adds a new input DataSource to the collection of input - * DataSources from which this instance reads audio. If the - * specified DataSource indeed provides audio, the respective - * contributions to the mix are always included. - * - * @param inputDataSource a new DataSource to input audio to this - * instance - */ - public void addInputDataSource(DataSource inputDataSource) - { - addInputDataSource(inputDataSource, null); - } - - /** - * Adds a new input DataSource to the collection of input - * DataSources from which this instance reads audio. If the - * specified DataSource indeed provides audio, the respective - * contributions to the mix will be excluded from the mix output provided - * through a specific AudioMixingPushBufferDataSource. - * - * @param inputDataSource a new DataSource to input audio to this - * instance - * @param outputDataSource the AudioMixingPushBufferDataSource to - * not include the audio contributions of inputDataSource in the - * mix it outputs - */ - void addInputDataSource( - DataSource inputDataSource, - AudioMixingPushBufferDataSource outputDataSource) - { - if (inputDataSource == null) - throw new NullPointerException("inputDataSource"); - - synchronized (inputDataSources) - { - for (InputDataSourceDesc inputDataSourceDesc : inputDataSources) - if (inputDataSource.equals(inputDataSourceDesc.inputDataSource)) - throw new IllegalArgumentException("inputDataSource"); - - InputDataSourceDesc inputDataSourceDesc - = new InputDataSourceDesc( - inputDataSource, - outputDataSource); - boolean added = inputDataSources.add(inputDataSourceDesc); - - if (added) - { - if (logger.isTraceEnabled()) - { - logger.trace( - "Added input DataSource with hashCode " - + inputDataSource.hashCode()); - } - - /* - * If the other inputDataSources have already been connected, - * connect to the new one as well. - */ - if (connected > 0) - { - try - { - inputDataSourceDesc.connect(this); - } - catch (IOException ioex) - { - throw new UndeclaredThrowableException(ioex); - } - } - - // Update outputStream with any new inputStreams. - if (outputStream != null) - getOutputStream(); - - /* - * If the other inputDataSources have been started, start the - * new one as well. - */ - if (started > 0) - { - try - { - inputDataSourceDesc.start(); - } - catch (IOException ioe) - { - throw new UndeclaredThrowableException(ioe); - } - } - } - } - } - - /** - * Notifies this AudioMixer that an output - * AudioMixingPushBufferDataSource reading from it has been - * connected. The first of the many - * AudioMixingPushBufferDataSources reading from this - * AudioMixer which gets connected causes it to connect to the - * input DataSources it manages. - * - * @throws IOException if input/output error occurred - */ - void connect() - throws IOException - { - synchronized (inputDataSources) - { - if (connected == 0) - { - for (InputDataSourceDesc inputDataSourceDesc : inputDataSources) - try - { - inputDataSourceDesc.connect(this); - } - catch (IOException ioe) - { - logger - .error( - "Failed to connect to inputDataSource " - + MediaStreamImpl - .toString( - inputDataSourceDesc - .inputDataSource), - ioe); - throw ioe; - } - - /* - * Since the media of the input streams is to be mixed, their - * bufferLengths have to be equal. After a DataSource is - * connected, its BufferControl is available and its - * bufferLength may change so make sure that the bufferLengths - * of the input streams are equal. - */ - if (outputStream != null) - outputStream.equalizeInputStreamBufferLength(); - } - - connected++; - } - } - - /** - * Connects to a specific DataSource which this AudioMixer - * will read audio from. The specified DataSource is known to exist - * because of a specific DataSource added as an input to this - * instance i.e. it may be an actual input DataSource added to this - * instance or a DataSource transcoding an input - * DataSource added to this instance. - * - * @param dataSource the DataSource to connect to - * @param inputDataSource the DataSource which is the cause for - * dataSource to exist in this AudioMixer - * @throws IOException if anything wrong happens while connecting to - * dataSource - */ - protected void connect(DataSource dataSource, DataSource inputDataSource) - throws IOException - { - dataSource.connect(); - } - - /** - * Notifies this AudioMixer that a specific input - * DataSource has finished its connecting procedure. Primarily - * meant for input DataSource which have their connecting executed - * in a separate thread as are, for example, input DataSources - * which are being transcoded. - * - * @param inputDataSource the InputDataSourceDesc of the input - * DataSource which has finished its connecting procedure - * @throws IOException if anything wrong happens while including - * inputDataSource into the mix - */ - void connected(InputDataSourceDesc inputDataSource) - throws IOException - { - synchronized (inputDataSources) - { - if (inputDataSources.contains(inputDataSource) - && (connected > 0)) - { - if (started > 0) - inputDataSource.start(); - if (outputStream != null) - getOutputStream(); - } - } - } - - /** - * Creates a new InputStreamDesc instance which is to describe a - * specific input SourceStream originating from a specific input - * DataSource given by its InputDataSourceDesc. - * - * @param inputStream the input SourceStream to be described by the - * new instance - * @param inputDataSourceDesc the input DataSource given by its - * InputDataSourceDesc to be described by the new instance - * @return a new InputStreamDesc instance which describes the - * specified input SourceStream and DataSource - */ - private InputStreamDesc createInputStreamDesc( - SourceStream inputStream, - InputDataSourceDesc inputDataSourceDesc) - { - return new InputStreamDesc(inputStream, inputDataSourceDesc); - } - - /** - * Creates a new AudioMixingPushBufferDataSource which gives - * access to a single audio stream representing the mix of the audio streams - * input into this AudioMixer through its input - * DataSources. The returned - * AudioMixingPushBufferDataSource can also be used to include - * new input DataSources in this AudioMixer but - * have their contributions not included in the mix available through the - * returned AudioMixingPushBufferDataSource. - * - * @return a new AudioMixingPushBufferDataSource which gives access - * to a single audio stream representing the mix of the audio streams input - * into this AudioMixer through its input DataSources - */ - public AudioMixingPushBufferDataSource createOutputDataSource() - { - return new AudioMixingPushBufferDataSource(this); - } - - /** - * Creates a DataSource which attempts to transcode the tracks of a - * specific input DataSource into a specific output - * Format. - * - * @param inputDataSourceDesc the InputDataSourceDesc describing - * the input DataSource to be transcoded into the specified output - * Format and to receive the transcoding DataSource - * @param outputFormat the Format in which the tracks of the input - * DataSource are to be transcoded - * @return true if a new transcoding DataSource has been - * created for the input DataSource described by - * inputDataSourceDesc; otherwise, false - * @throws IOException if an error occurs while creating the transcoding - * DataSource, connecting to it or staring it - */ - private boolean createTranscodingDataSource( - InputDataSourceDesc inputDataSourceDesc, - Format outputFormat) - throws IOException - { - if (inputDataSourceDesc.createTranscodingDataSource(outputFormat)) - { - if (connected > 0) - inputDataSourceDesc.connect(this); - if (started > 0) - inputDataSourceDesc.start(); - return true; - } - else - return false; - } - - /** - * Notifies this AudioMixer that an output - * AudioMixingPushBufferDataSource reading from it has been - * disconnected. The last of the many - * AudioMixingPushBufferDataSources reading from this - * AudioMixer which gets disconnected causes it to disconnect - * from the input DataSources it manages. - */ - void disconnect() - { - synchronized (inputDataSources) - { - if (connected <= 0) - return; - - connected--; - - if (connected == 0) - { - for (InputDataSourceDesc inputDataSourceDesc : inputDataSources) - inputDataSourceDesc.disconnect(); - - /* - * XXX Make the outputStream to release the inputStreams. - * Otherwise, the PushBufferStream ones which have been wrapped - * into CachingPushBufferStream may remaing waiting. - */ - outputStream.setInputStreams(null); - outputStream = null; - } - } - } - - /** - * Gets the BufferControl of this instance and, respectively, its - * AudioMixingPushBufferDataSources. - * - * @return the BufferControl of this instance and, respectively, - * its AudioMixingPushBufferDataSources if such a control is - * available for the CaptureDevice of this instance; otherwise, - * null - */ - BufferControl getBufferControl() - { - if ((bufferControl == null) && (captureDevice instanceof Controls)) - { - BufferControl captureDeviceBufferControl - = (BufferControl) - ((Controls) captureDevice) - .getControl(BufferControl.class.getName()); - - if (captureDeviceBufferControl != null) - bufferControl - = new ReadOnlyBufferControlDelegate( - captureDeviceBufferControl); - } - return bufferControl; - } - - /** - * Gets the CaptureDeviceInfo of the CaptureDevice - * this AudioMixer provides through its output - * AudioMixingPushBufferDataSources. - * - * @return the CaptureDeviceInfo of the CaptureDevice this - * AudioMixer provides through its output - * AudioMixingPushBufferDataSources - */ - CaptureDeviceInfo getCaptureDeviceInfo() - { - return captureDevice.getCaptureDeviceInfo(); - } - - /** - * Gets the content type of the data output by this AudioMixer. - * - * @return the content type of the data output by this AudioMixer - */ - String getContentType() - { - return ContentDescriptor.RAW; - } - - /** - * Gets an InputStreamDesc from a specific existing list of - * InputStreamDescs which describes a specific - * SourceStream. If such an InputStreamDesc does not - * exist, returns null. - * - * @param inputStream the SourceStream to locate an - * InputStreamDesc for in existingInputStreamDescs - * @param existingInputStreamDescs the list of existing - * InputStreamDescs in which an InputStreamDesc for - * inputStream is to be located - * @return an InputStreamDesc from - * existingInputStreamDescs which describes inputStream if - * such an InputStreamDesc exists; otherwise, null - */ - private InputStreamDesc getExistingInputStreamDesc( - SourceStream inputStream, - InputStreamDesc[] existingInputStreamDescs) - { - if (existingInputStreamDescs == null) - return null; - - for (InputStreamDesc existingInputStreamDesc - : existingInputStreamDescs) - { - SourceStream existingInputStream - = existingInputStreamDesc.getInputStream(); - - if (existingInputStream == inputStream) - return existingInputStreamDesc; - if ((existingInputStream instanceof BufferStreamAdapter) - && (((BufferStreamAdapter) existingInputStream) - .getStream() - == inputStream)) - return existingInputStreamDesc; - if ((existingInputStream instanceof CachingPushBufferStream) - && (((CachingPushBufferStream) existingInputStream) - .getStream() - == inputStream)) - return existingInputStreamDesc; - } - return null; - } - - /** - * Gets the duration of each one of the output streams produced by this - * AudioMixer. - * - * @return the duration of each one of the output streams produced by this - * AudioMixer - */ - Time getDuration() - { - return ((DataSource) captureDevice).getDuration(); - } - - /** - * Gets the Format in which a specific DataSource - * provides stream data. - * - * @param dataSource the DataSource for which the Format - * in which it provides stream data is to be determined - * @return the Format in which the specified dataSource - * provides stream data if it was determined; otherwise, null - */ - private static Format getFormat(DataSource dataSource) - { - FormatControl formatControl - = (FormatControl) dataSource.getControl( - FormatControl.class.getName()); - - return (formatControl == null) ? null : formatControl.getFormat(); - } - - /** - * Gets the Format in which a specific - * SourceStream provides data. - * - * @param stream - * the SourceStream for which the - * Format in which it provides data is to be - * determined - * @return the Format in which the specified - * SourceStream provides data if it was determined; - * otherwise, null - */ - private static Format getFormat(SourceStream stream) - { - if (stream instanceof PushBufferStream) - return ((PushBufferStream) stream).getFormat(); - if (stream instanceof PullBufferStream) - return ((PullBufferStream) stream).getFormat(); - return null; - } - - /** - * Gets an array of FormatControls for the - * CaptureDevice this AudioMixer provides through - * its output AudioMixingPushBufferDataSources. - * - * @return an array of FormatControls for the - * CaptureDevice this AudioMixer provides - * through its output AudioMixingPushBufferDataSources - */ - FormatControl[] getFormatControls() - { - /* - * Setting the format of the captureDevice once we've started using it - * is likely to wreak havoc so disable it. - */ - FormatControl[] formatControls = captureDevice.getFormatControls(); - - if (!OSUtils.IS_ANDROID && (formatControls != null)) - for (int i = 0; i < formatControls.length; i++) - formatControls[i] - = new ReadOnlyFormatControlDelegate(formatControls[i]); - return formatControls; - } - - /** - * Gets the SourceStreams (in the form of InputStreamDesc) - * of a specific DataSource (provided in the form of - * InputDataSourceDesc) which produce data in a specific - * AudioFormat (or a matching one). - * - * @param inputDataSourceDesc the DataSource (in the form of - * InputDataSourceDesc) which is to be examined for - * SourceStreams producing data in the specified - * AudioFormat - * @param outputFormat the AudioFormat in which the collected - * SourceStreams are to produce data - * @param existingInputStreams the InputStreamDesc instances which - * already exist and which are used to avoid creating multiple - * InputStreamDescs for input SourceStreams which already - * have ones - * @param inputStreams the List of InputStreamDesc in - * which the discovered SourceStreams are to be returned - * @return true if SourceStreams produced by the specified - * input DataSource and outputting data in the specified - * AudioFormat were discovered and reported in - * inputStreams; otherwise, false - */ - private boolean getInputStreamsFromInputDataSource( - InputDataSourceDesc inputDataSourceDesc, - AudioFormat outputFormat, - InputStreamDesc[] existingInputStreams, - List inputStreams) - { - SourceStream[] inputDataSourceStreams - = inputDataSourceDesc.getStreams(); - - if (inputDataSourceStreams != null) - { - boolean added = false; - - for (SourceStream inputStream : inputDataSourceStreams) - { - Format inputFormat = getFormat(inputStream); - - if ((inputFormat != null) - && matches(inputFormat, outputFormat)) - { - InputStreamDesc inputStreamDesc - = getExistingInputStreamDesc( - inputStream, - existingInputStreams); - - if (inputStreamDesc == null) - inputStreamDesc - = createInputStreamDesc( - inputStream, - inputDataSourceDesc); - if (inputStreams.add(inputStreamDesc)) - added = true; - } - } - return added; - } - - DataSource inputDataSource - = inputDataSourceDesc.getEffectiveInputDataSource(); - - if (inputDataSource == null) - return false; - - Format inputFormat = getFormat(inputDataSource); - - if ((inputFormat != null) && !matches(inputFormat, outputFormat)) - { - if (inputDataSource instanceof PushDataSource) - { - for (PushSourceStream inputStream - : ((PushDataSource) inputDataSource).getStreams()) - { - InputStreamDesc inputStreamDesc - = getExistingInputStreamDesc( - inputStream, - existingInputStreams); - - if (inputStreamDesc == null) - inputStreamDesc - = createInputStreamDesc( - new PushBufferStreamAdapter( - inputStream, - inputFormat), - inputDataSourceDesc); - inputStreams.add(inputStreamDesc); - } - return true; - } - if (inputDataSource instanceof PullDataSource) - { - for (PullSourceStream inputStream - : ((PullDataSource) inputDataSource).getStreams()) - { - InputStreamDesc inputStreamDesc - = getExistingInputStreamDesc( - inputStream, - existingInputStreams); - - if (inputStreamDesc == null) - inputStreamDesc - = createInputStreamDesc( - new PullBufferStreamAdapter( - inputStream, - inputFormat), - inputDataSourceDesc); - inputStreams.add(inputStreamDesc); - } - return true; - } - } - return false; - } - - /** - * Gets the SourceStreams (in the form of InputStreamDesc) - * of the DataSources from which this AudioMixer reads - * data which produce data in a specific AudioFormat. When an input - * DataSource does not have such SourceStreams, an attempt - * is made to transcode its tracks so that such SourceStreams can - * be retrieved from it after transcoding. - * - * @param outputFormat the AudioFormat in which the retrieved - * SourceStreams are to produce data - * @param existingInputStreams the SourceStreams which are already - * known to this AudioMixer - * @return a new collection of SourceStreams (in the form of - * InputStreamDesc) retrieved from the input DataSources - * of this AudioMixer and producing data in the specified - * AudioFormat - * @throws IOException if anything wrong goes while retrieving the input - * SourceStreams from the input DataSources - */ - private Collection getInputStreamsFromInputDataSources( - AudioFormat outputFormat, - InputStreamDesc[] existingInputStreams) - throws IOException - { - List inputStreams = new ArrayList(); - - synchronized (inputDataSources) - { - for (InputDataSourceDesc inputDataSourceDesc : inputDataSources) - { - boolean got - = getInputStreamsFromInputDataSource( - inputDataSourceDesc, - outputFormat, - existingInputStreams, - inputStreams); - - if (!got - && createTranscodingDataSource( - inputDataSourceDesc, - outputFormat)) - getInputStreamsFromInputDataSource( - inputDataSourceDesc, - outputFormat, - existingInputStreams, - inputStreams); - } - } - return inputStreams; - } - - /** - * Gets the AudioMixingPushBufferDataSource containing the mix of - * all input DataSources excluding the CaptureDevice of - * this AudioMixer and is thus meant for playback on the local peer - * in a call. - * - * @return the AudioMixingPushBufferDataSource containing the mix - * of all input DataSources excluding the CaptureDevice of - * this AudioMixer and is thus meant for playback on the local peer - * in a call - */ - public AudioMixingPushBufferDataSource getLocalOutputDataSource() - { - return localOutputDataSource; - } - - /** - * Gets the AudioFormat in which the input - * DataSources of this AudioMixer can produce data - * and which is to be the output Format of this - * AudioMixer. - * - * @return the AudioFormat in which the input - * DataSources of this AudioMixer can - * produce data and which is to be the output Format of - * this AudioMixer - */ - private AudioFormat getOutputFormatFromInputDataSources() - { - String formatControlType = FormatControl.class.getName(); - AudioFormat outputFormat = null; - - synchronized (inputDataSources) - { - for (InputDataSourceDesc inputDataSource : inputDataSources) - { - DataSource effectiveInputDataSource - = inputDataSource.getEffectiveInputDataSource(); - - if (effectiveInputDataSource == null) - continue; - - FormatControl formatControl - = (FormatControl) - effectiveInputDataSource.getControl(formatControlType); - - if (formatControl != null) - { - AudioFormat format - = (AudioFormat) formatControl.getFormat(); - - if (format != null) - { - // SIGNED - int signed = format.getSigned(); - - if ((AudioFormat.SIGNED == signed) - || (Format.NOT_SPECIFIED == signed)) - { - // LITTLE_ENDIAN - int endian = format.getEndian(); - - if ((AudioFormat.LITTLE_ENDIAN == endian) - || (Format.NOT_SPECIFIED == endian)) - { - outputFormat = format; - break; - } - } - } - } - } - } - - if (outputFormat == null) - outputFormat = DEFAULT_OUTPUT_FORMAT; - - if (logger.isTraceEnabled()) - { - logger.trace( - "Determined outputFormat of AudioMixer" - + " from inputDataSources to be " - + outputFormat); - } - return outputFormat; - } - - /** - * Gets the AudioMixerPushBufferStream, first creating it if it - * does not exist already, which reads data from the input - * DataSources of this AudioMixer and pushes it to - * output AudioMixingPushBufferStreams for audio mixing. - * - * @return the AudioMixerPushBufferStream which reads data from - * the input DataSources of this - * AudioMixer and pushes it to output - * AudioMixingPushBufferStreams for audio mixing - */ - AudioMixerPushBufferStream getOutputStream() - { - synchronized (inputDataSources) - { - AudioFormat outputFormat - = (outputStream == null) - ? getOutputFormatFromInputDataSources() - : outputStream.getFormat(); - - setOutputFormatToInputDataSources(outputFormat); - - Collection inputStreams; - - try - { - inputStreams - = getInputStreamsFromInputDataSources( - outputFormat, - (outputStream == null) - ? null - : outputStream.getInputStreams()); - } - catch (IOException ioex) - { - throw new UndeclaredThrowableException(ioex); - } - - if (outputStream == null) - outputStream - = new AudioMixerPushBufferStream(this, outputFormat); - outputStream.setInputStreams(inputStreams); - return outputStream; - } - } - - /** - * Determines whether a specific Format matches a specific - * Format in the sense of JMF Format matching. - * Since this AudioMixer and the audio mixing functionality - * related to it can handle varying characteristics of a certain output - * Format, the only requirement for the specified - * Formats to match is for both of them to have one and the - * same encoding. - * - * @param input - * the Format for which it is required to determine - * whether it matches a specific Format - * @param pattern - * the Format against which the specified - * input is to be matched - * @return true if the specified - * input matches the specified pattern in - * the sense of JMF Format matching; otherwise, - * false - */ - private boolean matches(Format input, AudioFormat pattern) - { - return - ((input instanceof AudioFormat) && input.isSameEncoding(pattern)); - } - - /** - * Reads media from a specific PushBufferStream which belongs to - * a specific DataSource into a specific output Buffer. - * Allows extenders to tap into the reading and monitor and customize it. - * - * @param stream the PushBufferStream to read media from and known - * to belong to the specified DataSOurce - * @param buffer the output Buffer in which the media read from the - * specified stream is to be written so that it gets returned to - * the caller - * @param dataSource the DataSource from which stream - * originated - * @throws IOException if anything wrong happens while reading from the - * specified stream - */ - protected void read( - PushBufferStream stream, - Buffer buffer, - DataSource dataSource) - throws IOException - { - stream.read(buffer); - } - - /** - * Removes DataSources accepted by a specific - * DataSourceFilter from the list of input DataSources of - * this AudioMixer from which it reads audio to be mixed. - * - * @param dataSourceFilter the DataSourceFilter which selects the - * DataSources to be removed from the list of input - * DataSources of this AudioMixer from which it reads - * audio to be mixed - */ - public void removeInputDataSources(DataSourceFilter dataSourceFilter) - { - synchronized (inputDataSources) - { - Iterator inputDataSourceIter - = inputDataSources.iterator(); - boolean removed = false; - - while (inputDataSourceIter.hasNext()) - { - if (dataSourceFilter - .accept(inputDataSourceIter.next().inputDataSource)) - { - inputDataSourceIter.remove(); - removed = true; - } - } - if (removed && (outputStream != null)) - getOutputStream(); - } - } - - /** - * Sets a specific AudioFormat, if possible, as the output - * format of the input DataSources of this - * AudioMixer in an attempt to not have to perform explicit - * transcoding of the input SourceStreams. - * - * @param outputFormat - * the AudioFormat in which the input - * DataSources of this AudioMixer are - * to be instructed to output - */ - private void setOutputFormatToInputDataSources(AudioFormat outputFormat) - { - String formatControlType = FormatControl.class.getName(); - - synchronized (inputDataSources) - { - for (InputDataSourceDesc inputDataSourceDesc : inputDataSources) - { - FormatControl formatControl - = (FormatControl) - inputDataSourceDesc.getControl(formatControlType); - - if (formatControl != null) - { - Format inputFormat = formatControl.getFormat(); - - if ((inputFormat == null) - || !matches(inputFormat, outputFormat)) - { - Format setFormat - = formatControl.setFormat(outputFormat); - - if (setFormat == null) - logger - .error( - "Failed to set format of inputDataSource to " - + outputFormat); - else if (setFormat != outputFormat) - logger - .warn( - "Failed to change format of inputDataSource from " - + setFormat - + " to " - + outputFormat); - else if (logger.isTraceEnabled()) - logger - .trace( - "Set format of inputDataSource to " - + setFormat); - } - } - } - } - } - - /** - * Starts the input DataSources of this AudioMixer. - * - * @param outputStream the AudioMixerPushBufferStream which - * requests this AudioMixer to start. If outputStream is - * the current one and only AudioMixerPushBufferStream of this - * AudioMixer, this AudioMixer starts if it hasn't started - * yet. Otherwise, the request is ignored. - * @throws IOException if any of the input DataSources of this - * AudioMixer throws such an exception while attempting to start it - */ - void start(AudioMixerPushBufferStream outputStream) - throws IOException - { - synchronized (inputDataSources) - { - /* - * AudioMixer has only one outputStream at a time and only its - * current outputStream known when it has to start (and stop). - */ - if (this.outputStream != outputStream) - return; - - if (started == 0) - { - for (InputDataSourceDesc inputDataSourceDesc : inputDataSources) - inputDataSourceDesc.start(); - } - - started++; - } - } - - /** - * Stops the input DataSources of this AudioMixer. - * - * @param outputStream the AudioMixerPushBufferStream which - * requests this AudioMixer to stop. If outputStream is - * the current one and only AudioMixerPushBufferStream of this - * AudioMixer, this AudioMixer stops. Otherwise, the - * request is ignored. - * @throws IOException if any of the input DataSources of this - * AudioMixer throws such an exception while attempting to stop it - */ - void stop(AudioMixerPushBufferStream outputStream) - throws IOException - { - synchronized (inputDataSources) - { - /* - * AudioMixer has only one outputStream at a time and only its - * current outputStream known when it has to stop (and start). - */ - if (this.outputStream != outputStream) - return; - - if (started <= 0) - return; - - started--; - - if (started == 0) - { - for (InputDataSourceDesc inputDataSourceDesc : inputDataSources) - inputDataSourceDesc.stop(); - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/conference/AudioMixerPushBufferStream.java b/src/net/java/sip/communicator/impl/neomedia/conference/AudioMixerPushBufferStream.java deleted file mode 100644 index 0008a267f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/conference/AudioMixerPushBufferStream.java +++ /dev/null @@ -1,1406 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.conference; - -import java.io.*; -import java.lang.ref.*; -import java.lang.reflect.*; -import java.util.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.control.*; -import net.java.sip.communicator.impl.neomedia.protocol.*; -import net.java.sip.communicator.util.*; - -/** - * Represents a PushBufferStream which reads data from the - * SourceStreams of the input DataSources of the associated - * AudioMixer and pushes it to AudioMixingPushBufferStreams - * for audio mixing. - *

- * Pretty much private to AudioMixer but extracted into its own file - * for the sake of clarity. - *

- * - * @author Lyubomir Marinov - */ -class AudioMixerPushBufferStream - extends ControlsAdapter - implements PushBufferStream -{ - /** - * The Logger used by the AudioMixerPushBufferStream class - * and its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(AudioMixerPushBufferStream.class); - - /** - * The factor which scales a short value to an int value. - */ - private static final float INT_TO_SHORT_RATIO - = Integer.MAX_VALUE / (float) Short.MAX_VALUE; - - /** - * The factor which scales an int value to a short value. - */ - private static final float SHORT_TO_INT_RATIO - = Short.MAX_VALUE / (float) Integer.MAX_VALUE; - - /** - * The number of reads from an input stream with no returned samples which - * do not get reported in tracing output. Once the number of such reads from - * an input stream exceeds this limit, it gets reported and the counting is - * restarted. - */ - private static final long TRACE_NON_CONTRIBUTING_READ_COUNT = 0; - - /** - * The AudioMixer which created this - * AudioMixerPushBufferStream. - */ - private final AudioMixer audioMixer; - - /** - * The SourceStreams (in the form of InputStreamDesc so - * that this instance can track back the - * AudioMixingPushBufferDataSource which outputs the mixed audio - * stream and determine whether the associated SourceStream is to - * be included into the mix) from which this instance reads its data. - */ - private InputStreamDesc[] inputStreams; - - /** - * The Object which synchronizes the access to - * {@link #inputStreams}-related members. - */ - private final Object inputStreamsSyncRoot = new Object(); - - /** - * The cache of int arrays managed by this instance for the - * purposes of reducing garbage collection. - */ - private SoftReference> intArrays; - - /** - * The Object which synchronizes the access to {@link #intArrays}. - */ - private final Object intArraysSyncRoot = new Object(); - - /** - * The AudioFormat of the Buffer read during the last read - * from one of the {@link #inputStreams}. Only used for debugging purposes. - */ - private AudioFormat lastReadInputFormat; - - /** - * The AudioFormat of the data this instance outputs. - */ - private final AudioFormat outputFormat; - - /** - * The AudioMixingPushBufferStreams to which this instance pushes - * data for audio mixing. - */ - private final List outputStreams - = new ArrayList(); - - /** - * The BufferTransferHandler through which this instance gets - * notifications from its input SourceStreams that new data is - * available for audio mixing. - */ - private final BufferTransferHandler transferHandler - = new BufferTransferHandler() - { - /** - * The cached Buffer instance to be used during the - * execution of {@link #transferData(PushBufferStream)} in - * order to reduce garbage collection. - */ - private final Buffer buffer = new Buffer(); - - public void transferData(PushBufferStream stream) - { - buffer.setLength(0); - AudioMixerPushBufferStream.this.transferData(buffer); - buffer.setLength(0); - } - }; - - /** - * Initializes a new AudioMixerPushBufferStream instance to output - * data in a specific AudioFormat for a specific - * AudioMixer. - * - * @param audioMixer the AudioMixer which creates this instance and - * for which it is to output data - * @param outputFormat the AudioFormat in which the new instance is - * to output data - */ - public AudioMixerPushBufferStream( - AudioMixer audioMixer, - AudioFormat outputFormat) - { - this.audioMixer = audioMixer; - this.outputFormat = outputFormat; - } - - /** - * Adds a specific AudioMixingPushBufferStream to the collection of - * such streams to which this instance is to push the data for audio mixing - * it reads from its input SourceStreams. - * - * @param outputStream the AudioMixingPushBufferStream to add to - * the collection of such streams to which this instance is to push the data - * for audio mixing it reads from its input SourceStreams - * @throws IOException if outputStream was the first - * AudioMixingPushBufferStream and the AudioMixer failed - * to start - */ - void addOutputStream(AudioMixingPushBufferStream outputStream) - throws IOException - { - if (outputStream == null) - throw new IllegalArgumentException("outputStream"); - - synchronized (outputStreams) - { - if (!outputStreams.contains(outputStream) - && outputStreams.add(outputStream) - && (outputStreams.size() == 1)) - { - boolean started = false; - - try - { - audioMixer.start(this); - started = true; - } - finally - { - if (!started) - outputStreams.remove(outputStream); - } - } - } - } - - public int[] allocateIntArray(int minSize) - { - synchronized (intArraysSyncRoot) - { - List intArrays - = (this.intArrays == null) ? null : this.intArrays.get(); - - if (intArrays != null) - { - Iterator i = intArrays.iterator(); - - while (i.hasNext()) - { - int[] intArray = i.next(); - - if (intArray.length >= minSize) - { - i.remove(); - return intArray; - } - } - } - } - - return new int[minSize]; - } - - public void deallocateIntArray(int[] intArray) - { - if (intArray == null) - return; - - synchronized (intArraysSyncRoot) - { - List intArrays; - - if ((this.intArrays == null) - || ((intArrays = this.intArrays.get()) == null)) - { - intArrays = new LinkedList(); - this.intArrays = new SoftReference>(intArrays); - } - - if (intArrays.size() != 0) - for (int[] element : intArrays) - if (element == intArray) - return; - - intArrays.add(intArray); - } - } - - /** - * Implements {@link SourceStream#endOfStream()}. Delegates to the input - * SourceStreams of this instance. - * - * @return true if all input SourceStreams of this - * instance have reached the end of their content; false, otherwise - */ - public boolean endOfStream() - { - synchronized (inputStreamsSyncRoot) - { - if (inputStreams != null) - for (InputStreamDesc inputStreamDesc : inputStreams) - if (!inputStreamDesc.getInputStream().endOfStream()) - return false; - } - return true; - } - - /** - * Attempts to equalize the length in milliseconds of the buffering - * performed by the inputStreams in order to always read and mix - * one and the same length in milliseconds. - */ - void equalizeInputStreamBufferLength() - { - synchronized (inputStreamsSyncRoot) - { - if ((inputStreams == null) || (inputStreams.length < 1)) - return; - - /* - * The first inputStream is expected to be from the CaptureDevice - * and no custom BufferControl is provided for it so the - * bufferLength is whatever it says. - */ - BufferControl bufferControl = getBufferControl(inputStreams[0]); - long bufferLength - = (bufferControl == null) - ? CachingPushBufferStream.DEFAULT_BUFFER_LENGTH - : bufferControl.getBufferLength(); - - for (int i = 1; i < inputStreams.length; i++) - { - BufferControl inputStreamBufferControl - = getBufferControl(inputStreams[i]); - - if (inputStreamBufferControl != null) - inputStreamBufferControl.setBufferLength(bufferLength); - } - } - } - - /** - * Gets the BufferControl of a specific input stream. The returned - * BufferControl may be available through its input - * DataSource, its transcoding DataSource if any or the - * very input stream. - * - * @param inputStreamDesc an InputStreamDesc which describes the - * input stream and its originating DataSources from which the - * BufferControl is to be retrieved - * @return the BufferControl of the specified input stream found in - * its input DataSource, its transcoding DataSource if any - * or the very input stream if such a control exists; otherwise, - * null - */ - private BufferControl getBufferControl(InputStreamDesc inputStreamDesc) - { - InputDataSourceDesc inputDataSourceDesc - = inputStreamDesc.inputDataSourceDesc; - - // Try the DataSource which directly provides the specified inputStream. - DataSource effectiveInputDataSource - = inputDataSourceDesc.getEffectiveInputDataSource(); - String bufferControlType = BufferControl.class.getName(); - - if (effectiveInputDataSource != null) - { - BufferControl bufferControl - = (BufferControl) - effectiveInputDataSource.getControl(bufferControlType); - - if (bufferControl != null) - return bufferControl; - } - - /* - * If transcoding is taking place and the transcodingDataSource does not - * have a BufferControl, try the inputDataSource which is being - * transcoded. - */ - DataSource inputDataSource = inputDataSourceDesc.inputDataSource; - - if ((inputDataSource != null) - && (inputDataSource != effectiveInputDataSource)) - { - BufferControl bufferControl - = (BufferControl) inputDataSource.getControl(bufferControlType); - - if (bufferControl != null) - return bufferControl; - } - - // If everything else has failed, try the very inputStream. - return - (BufferControl) - inputStreamDesc.getInputStream().getControl(bufferControlType); - } - - /** - * Implements {@link SourceStream#getContentDescriptor()}. Returns a - * ContentDescriptor which describes the content type of this - * instance. - * - * @return a ContentDescriptor which describes the content type of - * this instance - */ - public ContentDescriptor getContentDescriptor() - { - return new ContentDescriptor(audioMixer.getContentType()); - } - - /** - * Implements {@link SourceStream#getContentLength()}. Delegates to the - * input SourceStreams of this instance. - * - * @return the length of the content made available by this instance which - * is the maximum length of the contents made available by its input - * StreamSources - */ - public long getContentLength() - { - long contentLength = 0; - - synchronized (inputStreamsSyncRoot) - { - if (inputStreams != null) - for (InputStreamDesc inputStreamDesc : inputStreams) - { - long inputContentLength - = inputStreamDesc.getInputStream().getContentLength(); - - if (LENGTH_UNKNOWN == inputContentLength) - return LENGTH_UNKNOWN; - if (contentLength < inputContentLength) - contentLength = inputContentLength; - } - } - return contentLength; - } - - /** - * Implements {@link PushBufferStream#getFormat()}. Returns the - * AudioFormat in which this instance was configured to output its - * data. - * - * @return the AudioFormat in which this instance was configured to - * output its data - */ - public AudioFormat getFormat() - { - return outputFormat; - } - - /** - * Gets the SourceStreams (in the form of - * InputStreamDescs) from which this instance reads audio samples. - * - * @return an array of InputStreamDescs which describe the input - * SourceStreams from which this instance reads audio samples - */ - InputStreamDesc[] getInputStreams() - { - synchronized (inputStreamsSyncRoot) - { - return (inputStreams == null) ? null : inputStreams.clone(); - } - } - - /** - * Implements {@link PushBufferStream#read(Buffer)}. Reads audio samples - * from the input SourceStreams of this instance in various - * formats, converts the read audio samples to one and the same format and - * pushes them to the output AudioMixingPushBufferStreams for the - * very audio mixing. - * - * @param buffer the Buffer in which the audio samples read from - * the input SourceStreams are to be returned to the caller - * @throws IOException if any of the input SourceStreams throws - * such an exception while reading from them or anything else goes wrong - */ - public void read(Buffer buffer) - throws IOException - { - InputSampleDesc inputSampleDesc; - int inputStreamCount; - - synchronized (inputStreamsSyncRoot) - { - InputStreamDesc[] thisInputStreams = this.inputStreams; - - if ((thisInputStreams == null) || (thisInputStreams.length == 0)) - return; - else - { - inputSampleDesc = (InputSampleDesc) buffer.getData(); - inputStreamCount = thisInputStreams.length; - if (inputSampleDesc != null) - { - InputStreamDesc[] inputSampleDescInputStreams - = inputSampleDesc.inputStreams; - - if (inputSampleDescInputStreams.length == inputStreamCount) - { - for (int i = 0; i < inputStreamCount; i++) - if (inputSampleDescInputStreams[i] - != thisInputStreams[i]) - { - inputSampleDesc = null; - break; - } - } - else - inputSampleDesc = null; - } - if (inputSampleDesc == null) - { - inputSampleDesc - = new InputSampleDesc( - new int[inputStreamCount][], - thisInputStreams.clone()); - } - } - } - - AudioFormat outputFormat = getFormat(); - int maxInputSampleCount; - - try - { - maxInputSampleCount - = readInputPushBufferStreams(outputFormat, inputSampleDesc); - } - catch (UnsupportedFormatException ufex) - { - IOException ioex = new IOException(); - - ioex.initCause(ufex); - throw ioex; - } - - maxInputSampleCount - = Math.max( - maxInputSampleCount, - readInputPullBufferStreams( - outputFormat, - maxInputSampleCount, - inputSampleDesc)); - - buffer.setData(inputSampleDesc); - buffer.setLength(maxInputSampleCount); - - /* - * Convey the timeStamp so that it can be reported by the Buffers of - * the AudioMixingPushBufferStreams when mixes are read from them. - */ - long timeStamp = inputSampleDesc.getTimeStamp(); - - if (timeStamp != Buffer.TIME_UNKNOWN) - buffer.setTimeStamp(timeStamp); - } - - /** - * Reads audio samples from the input PullBufferStreams of this - * instance and converts them to a specific output AudioFormat. An - * attempt is made to read a specific maximum number of samples from each of - * the PullBufferStreams but the very PullBufferStream may - * not honor the request. - * - * @param outputFormat the AudioFormat in which the audio samples - * read from the PullBufferStreams are to be converted before being - * returned - * @param outputSampleCount the maximum number of audio samples to be read - * from each of the PullBufferStreams but the very - * PullBufferStreams may not honor the request - * @param inputSampleDesc an InputStreamDesc which specifies the - * input streams to be read and the collection of audio samples in which the - * read audio samples are to be returned - * @return the maximum number of audio samples actually read from the input - * PullBufferStreams of this instance - * @throws IOException if anything goes wrong while reading the specified - * input streams - */ - private int readInputPullBufferStreams( - AudioFormat outputFormat, - int outputSampleCount, - InputSampleDesc inputSampleDesc) - throws IOException - { - InputStreamDesc[] inputStreams = inputSampleDesc.inputStreams; - int maxInputSampleCount = 0; - - for (InputStreamDesc inputStream : inputStreams) - if (inputStream.getInputStream() instanceof PullBufferStream) - throw - new UnsupportedOperationException( - AudioMixerPushBufferStream.class.getSimpleName() - + ".readInputPullBufferStreams" - + "(AudioFormat,int,InputSampleDesc)"); - return maxInputSampleCount; - } - - /** - * Reads audio samples from a specific PushBufferStream and - * converts them to a specific output AudioFormat. An attempt is - * made to read a specific maximum number of samples from the specified - * PushBufferStream but the very PushBufferStream may not - * honor the request. - * - * @param inputStreamDesc an InputStreamDesc which specifies the - * input PushBufferStream to read from - * @param outputFormat the AudioFormat to which the samples read - * from inputStream are to be converted before being returned - * @param sampleCount the maximum number of samples which the read operation - * should attempt to read from inputStream but the very - * inputStream may not honor the request - * @param outputBuffer the Buffer into which the array of - * int audio samples read from the specified inputStream - * is to be written - * @throws IOException if anything wrong happens while reading - * inputStream - * @throws UnsupportedFormatException if converting the samples read from - * inputStream to outputFormat fails - */ - private void readInputPushBufferStream( - InputStreamDesc inputStreamDesc, - AudioFormat outputFormat, - int sampleCount, - Buffer outputBuffer) - throws IOException, - UnsupportedFormatException - { - PushBufferStream inputStream - = (PushBufferStream) inputStreamDesc.getInputStream(); - AudioFormat inputStreamFormat - = (AudioFormat) inputStream.getFormat(); - Buffer inputBuffer = inputStreamDesc.getBuffer(true); - - if (sampleCount != 0) - { - Class inputDataType = inputStreamFormat.getDataType(); - - if (Format.byteArray.equals(inputDataType)) - { - Object data = inputBuffer.getData(); - int length - = sampleCount - * (inputStreamFormat.getSampleSizeInBits() / 8); - - if (!(data instanceof byte[]) - || (((byte[]) data).length != length)) - inputBuffer.setData(new byte[length]); - inputBuffer.setLength(0); - inputBuffer.setOffset(0); - } - else - throw new UnsupportedFormatException( - "!Format.getDataType().equals(byte[].class)", - inputStreamFormat); - } - - audioMixer.read( - inputStream, - inputBuffer, - inputStreamDesc.inputDataSourceDesc.inputDataSource); - - /* - * If the media is to be discarded, don't even bother with the - * checks and the conversion. - */ - if (inputBuffer.isDiscard()) - { - outputBuffer.setDiscard(true); - return; - } - - int inputLength = inputBuffer.getLength(); - - if (inputLength <= 0) - { - outputBuffer.setDiscard(true); - return; - } - - AudioFormat inputFormat = (AudioFormat) inputBuffer.getFormat(); - - if (inputFormat == null) - inputFormat = inputStreamFormat; - - if (logger.isTraceEnabled() - && (lastReadInputFormat != null) - && !lastReadInputFormat.matches(inputFormat)) - { - lastReadInputFormat = inputFormat; - logger.trace( - "Read inputSamples in different format " - + lastReadInputFormat); - } - - int inputFormatSigned = inputFormat.getSigned(); - - if ((inputFormatSigned != AudioFormat.SIGNED) - && (inputFormatSigned != Format.NOT_SPECIFIED)) - throw - new UnsupportedFormatException( - "AudioFormat.getSigned()", - inputFormat); - - int inputChannels = inputFormat.getChannels(); - int outputChannels = outputFormat.getChannels(); - - if ((inputChannels != outputChannels) - && (inputChannels != Format.NOT_SPECIFIED) - && (outputChannels != Format.NOT_SPECIFIED)) - { - logger.error( - "Read inputFormat with channels " - + inputChannels - + " while expected outputFormat channels is " - + outputChannels); - throw new UnsupportedFormatException( - "AudioFormat.getChannels()", - inputFormat); - } - - // Warn about different sampleRates. - double inputSampleRate = inputFormat.getSampleRate(); - double outputSampleRate = outputFormat.getSampleRate(); - - if (inputSampleRate != outputSampleRate) - { - logger.warn( - "Read inputFormat with sampleRate " - + inputSampleRate - + " while expected outputFormat sampleRate is " - + outputSampleRate); - } - - Object inputData = inputBuffer.getData(); - - if (inputData == null) - { - outputBuffer.setDiscard(true); - } - else if (inputData instanceof byte[]) - { - int inputSampleSizeInBits = inputFormat.getSampleSizeInBits(); - int outputSampleSizeInBits = outputFormat.getSampleSizeInBits(); - - if (logger.isTraceEnabled() - && (inputSampleSizeInBits != outputSampleSizeInBits)) - { - logger.trace( - "Read inputFormat with sampleSizeInBits " - + inputSampleSizeInBits - + ". Will convert to sampleSizeInBits " - + outputSampleSizeInBits); - } - - byte[] inputSamples = (byte[]) inputData; - int outputLength; - int[] outputSamples; - - switch (inputSampleSizeInBits) - { - case 16: - outputLength = inputLength / 2; - outputSamples - = validateIntArraySize(outputBuffer, outputLength); - for (int i = 0; i < outputLength; i++) - { - int sample = ArrayIOUtils.readInt16(inputSamples, i * 2); - - switch (outputSampleSizeInBits) - { - case 16: - break; - case 32: - sample = Math.round(sample * INT_TO_SHORT_RATIO); - break; - case 8: - case 24: - default: - throw new UnsupportedFormatException( - "AudioFormat.getSampleSizeInBits()", - outputFormat); - } - - outputSamples[i] = sample; - } - break; - case 32: - outputLength = inputSamples.length / 4; - outputSamples - = validateIntArraySize(outputBuffer, outputLength); - for (int i = 0; i < outputLength; i++) - { - int sample = readInt(inputSamples, i * 4); - - switch (outputSampleSizeInBits) - { - case 16: - sample = Math.round(sample * SHORT_TO_INT_RATIO); - break; - case 32: - break; - case 8: - case 24: - default: - throw new UnsupportedFormatException( - "AudioFormat.getSampleSizeInBits()", - outputFormat); - } - - outputSamples[i] = sample; - } - break; - case 8: - case 24: - default: - throw new UnsupportedFormatException( - "AudioFormat.getSampleSizeInBits()", - inputFormat); - } - - outputBuffer.setFlags(inputBuffer.getFlags()); - outputBuffer.setFormat(outputFormat); - outputBuffer.setLength(outputLength); - outputBuffer.setOffset(0); - outputBuffer.setTimeStamp(inputBuffer.getTimeStamp()); - } - else - { - throw new UnsupportedFormatException( - "Format.getDataType().equals(" + inputData.getClass() + ")", - inputFormat); - } - } - - /** - * Reads audio samples from the input PushBufferStreams of this - * instance and converts them to a specific output AudioFormat. - * - * @param outputFormat the AudioFormat in which the audio samples - * read from the PushBufferStreams are to be converted before being - * returned - * @param inputSampleDesc an InputSampleDesc which specifies the - * input streams to be read and the collection of audio samples in which - * the read audio samples are to be returned - * @return the maximum number of audio samples actually read from the input - * PushBufferStreams of this instance - * @throws IOException if anything wrong happens while reading the specified - * input streams - * @throws UnsupportedFormatException if any of the input streams provides - * media in a format different than outputFormat - */ - private int readInputPushBufferStreams( - AudioFormat outputFormat, - InputSampleDesc inputSampleDesc) - throws IOException, - UnsupportedFormatException - { - InputStreamDesc[] inputStreams = inputSampleDesc.inputStreams; - Buffer buffer = inputSampleDesc.getBuffer(true); - int maxInputSampleCount = 0; - int[][] inputSamples = inputSampleDesc.inputSamples; - - for (int i = 0; i < inputStreams.length; i++) - { - InputStreamDesc inputStreamDesc = inputStreams[i]; - SourceStream inputStream = inputStreamDesc.getInputStream(); - - if (inputStream instanceof PushBufferStream) - { - buffer.setDiscard(false); - buffer.setLength(0); - readInputPushBufferStream( - inputStreamDesc, outputFormat, maxInputSampleCount, - buffer); - - int sampleCount; - int[] samples; - - if (buffer.isDiscard()) - { - sampleCount = 0; - samples = null; - } - else - { - sampleCount = buffer.getLength(); - if (sampleCount <= 0) - { - sampleCount = 0; - samples = null; - } - else - { - samples = (int[]) buffer.getData(); - } - } - - if (sampleCount == 0) - { - if ((TRACE_NON_CONTRIBUTING_READ_COUNT > 0) - && logger.isTraceEnabled()) - { - inputStreamDesc.nonContributingReadCount++; - if (inputStreamDesc.nonContributingReadCount - >= TRACE_NON_CONTRIBUTING_READ_COUNT) - { - logger.trace( - "Failed to read actual inputSamples more than " - + inputStreamDesc - .nonContributingReadCount - + " times from inputStream with hash code " - + inputStreamDesc - .getInputStream().hashCode()); - inputStreamDesc.nonContributingReadCount = 0; - } - } - } - else - { - /* - * The int array with the samples will be used via - * inputSamples so the buffer cannot use it anymore. - */ - buffer.setData(null); - - /* - * If the samples array has more elements than sampleCount, - * the elements in question may contain stale samples. - */ - if (samples.length > sampleCount) - Arrays.fill(samples, sampleCount, samples.length, 0); - - inputSamples[i] = samples; - - if (maxInputSampleCount < samples.length) - maxInputSampleCount = samples.length; - - /* - * Convey the timeStamp so that it can be set to the Buffers - * of the AudioMixingPushBufferStreams when mixes are read - * from them. Since the inputStreams will report different - * timeStamps, only use the first meaningful timestamp for - * now. - */ - if (inputSampleDesc.getTimeStamp() == Buffer.TIME_UNKNOWN) - inputSampleDesc.setTimeStamp(buffer.getTimeStamp()); - - continue; - } - } - - inputSamples[i] = null; - } - return maxInputSampleCount; - } - - /** - * Reads an integer from a specific series of bytes starting the reading at - * a specific offset in it. - * - * @param input the series of bytes to read an integer from - * @param inputOffset the offset in input at which the reading of - * the integer is to start - * @return an integer read from the specified series of bytes starting at - * the specified offset in it - */ - private static int readInt(byte[] input, int inputOffset) - { - return - (input[inputOffset + 3] << 24) - | ((input[inputOffset + 2] & 0xFF) << 16) - | ((input[inputOffset + 1] & 0xFF) << 8) - | (input[inputOffset] & 0xFF); - } - - /** - * Removes a specific AudioMixingPushBufferStream from the - * collection of such streams to which this instance pushes the data for - * audio mixing it reads from its input SourceStreams. - * - * @param outputStream the AudioMixingPushBufferStream to remove - * from the collection of such streams to which this instance pushes the - * data for audio mixing it reads from its input SourceStreams - * @throws IOException if outputStream was the last - * AudioMixingPushBufferStream and the AudioMixer failed - * to stop - */ - void removeOutputStream(AudioMixingPushBufferStream outputStream) - throws IOException - { - synchronized (outputStreams) - { - if ((outputStream != null) - && outputStreams.remove(outputStream) - && outputStreams.isEmpty()) - audioMixer.stop(this); - } - } - - /** - * Pushes a copy of a specific set of input audio samples to a specific - * AudioMixingPushBufferStream for audio mixing. Audio samples read - * from input DataSources which the - * AudioMixingPushBufferDataSource owner of the specified - * AudioMixingPushBufferStream has specified to not be included in - * the output mix are not pushed to the - * AudioMixingPushBufferStream. - * - * @param outputStream the AudioMixingPushBufferStream to push the - * specified set of audio samples to - * @param inputSampleDesc the set of audio samples to be pushed to - * outputStream for audio mixing - * @param maxInputSampleCount the maximum number of audio samples available - * in inputSamples - */ - private void setInputSamples( - AudioMixingPushBufferStream outputStream, - InputSampleDesc inputSampleDesc, - int maxInputSampleCount) - { - int[][] inputSamples = inputSampleDesc.inputSamples; - InputStreamDesc[] inputStreams = inputSampleDesc.inputStreams; - - inputSamples = inputSamples.clone(); - - CaptureDevice captureDevice = audioMixer.captureDevice; - AudioMixingPushBufferDataSource outputDataSource - = outputStream.getDataSource(); - boolean outputDataSourceIsSendingDTMF - = (captureDevice instanceof AudioMixingPushBufferDataSource) - ? outputDataSource.isSendingDTMF() - : false; - boolean outputDataSourceIsMute = outputDataSource.isMute(); - - for (int i = 0; i < inputSamples.length; i++) - { - InputStreamDesc inputStreamDesc = inputStreams[i]; - DataSource inputDataSource - = inputStreamDesc.inputDataSourceDesc.inputDataSource; - - if (outputDataSourceIsSendingDTMF - && (inputDataSource == captureDevice)) - { - PushBufferStream inputStream - = (PushBufferStream) inputStreamDesc.getInputStream(); - AudioFormat inputStreamFormat - = (AudioFormat) inputStream.getFormat(); - - double sampleRate = inputStreamFormat.getSampleRate(); - int sampleSizeInBits = inputStreamFormat.getSampleSizeInBits(); - - // Generate the inband DTMF signal. - inputSamples[i] - = outputDataSource.getNextToneSignal( - sampleRate, - sampleSizeInBits); - if (maxInputSampleCount < inputSamples[i].length) - maxInputSampleCount = inputSamples[i].length; - } - else if (outputDataSource.equals( - inputStreamDesc.getOutputDataSource()) - || (outputDataSourceIsMute - && (inputDataSource == captureDevice))) - { - inputSamples[i] = null; - } - } - - outputStream.setInputSamples( - inputSamples, - maxInputSampleCount, - inputSampleDesc.getTimeStamp()); - } - - /** - * Sets the SourceStreams (in the form of InputStreamDesc) - * from which this instance is to read audio samples and push them to the - * AudioMixingPushBufferStreams for audio mixing. - * - * @param inputStreams the SourceStreams (in the form of - * InputStreamDesc) from which this instance is to read audio - * samples and push them to the AudioMixingPushBufferStreams for - * audio mixing - */ - void setInputStreams(Collection inputStreams) - { - InputStreamDesc[] oldValue; - InputStreamDesc[] newValue - = (null == inputStreams) - ? null - : inputStreams.toArray( - new InputStreamDesc[inputStreams.size()]); - - synchronized (inputStreamsSyncRoot) - { - oldValue = this.inputStreams; - - this.inputStreams = newValue; - } - - boolean valueIsChanged = !Arrays.equals(oldValue, newValue); - - if (valueIsChanged) - { - if (oldValue != null) - setTransferHandler(oldValue, null); - - if (newValue == null) - return; - - boolean skippedForTransferHandler = false; - - for (InputStreamDesc inputStreamDesc : newValue) - { - SourceStream inputStream = inputStreamDesc.getInputStream(); - - if (!(inputStream instanceof PushBufferStream)) - continue; - if (!skippedForTransferHandler) - { - skippedForTransferHandler = true; - continue; - } - if (!(inputStream instanceof CachingPushBufferStream)) - { - PushBufferStream cachingInputStream - = new CachingPushBufferStream( - (PushBufferStream) inputStream); - - inputStreamDesc.setInputStream(cachingInputStream); - if (logger.isTraceEnabled()) - logger.trace( - "Created CachingPushBufferStream" - + " with hashCode " - + cachingInputStream.hashCode() - + " for inputStream with hashCode " - + inputStream.hashCode()); - } - } - - setTransferHandler(newValue, transferHandler); - equalizeInputStreamBufferLength(); - - if (logger.isTraceEnabled()) - { - int oldValueLength = (oldValue == null) ? 0 : oldValue.length; - int newValueLength = (newValue == null) ? 0 : newValue.length; - int difference = newValueLength - oldValueLength; - - if (difference > 0) - logger.trace( - "Added " - + difference - + " inputStream(s) and the total is " - + newValueLength); - else if (difference < 0) - logger.trace( - "Removed " - + difference - + " inputStream(s) and the total is " - + newValueLength); - } - } - } - - /** - * Implements - * {@link PushBufferStream#setTransferHandler(BufferTransferHandler)}. - * Because this instance pushes data to multiple output - * AudioMixingPushBufferStreams, a single - * BufferTransferHandler is not sufficient and thus this method is - * unsupported and throws UnsupportedOperationException. - * - * @param transferHandler the BufferTransferHandler to be notified - * by this PushBufferStream when media is available for reading - */ - public void setTransferHandler(BufferTransferHandler transferHandler) - { - throw - new UnsupportedOperationException( - AudioMixerPushBufferStream.class.getSimpleName() - + ".setTransferHandler(BufferTransferHandler)"); - } - - /** - * Sets a specific BufferTransferHandler to a specific collection - * of SourceStreams (in the form of InputStreamDesc) - * abstracting the differences among the various types of - * SourceStreams. - * - * @param inputStreams the input SourceStreams to which the - * specified BufferTransferHandler is to be set - * @param transferHandler the BufferTransferHandler to be set to - * the specified inputStreams - */ - private void setTransferHandler( - InputStreamDesc[] inputStreams, - BufferTransferHandler transferHandler) - { - if ((inputStreams == null) || (inputStreams.length <= 0)) - return; - - boolean transferHandlerIsSet = false; - - for (InputStreamDesc inputStreamDesc : inputStreams) - { - SourceStream inputStream = inputStreamDesc.getInputStream(); - - if (inputStream instanceof PushBufferStream) - { - BufferTransferHandler inputStreamTransferHandler; - PushBufferStream inputPushBufferStream - = (PushBufferStream) inputStream; - - if (transferHandler == null) - inputStreamTransferHandler = null; - else if (transferHandlerIsSet) - inputStreamTransferHandler = new BufferTransferHandler() - { - public void transferData(PushBufferStream stream) - { - /* - * Do nothing because we don't want the associated - * PushBufferStream to cause the transfer of data - * from this AudioMixerPushBufferStream. - */ - } - }; - else - inputStreamTransferHandler - = new StreamSubstituteBufferTransferHandler( - transferHandler, - inputPushBufferStream, - this); - - inputPushBufferStream - .setTransferHandler(inputStreamTransferHandler); - - transferHandlerIsSet = true; - } - } - } - - /** - * Reads audio samples from the input SourceStreams of this - * instance and pushes them to its output - * AudioMixingPushBufferStreams for audio mixing. - * - * @param buffer the cached Buffer instance to be used during the - * execution of the method in order to reduce garbage collection. The - * length of the buffer will be reset to 0 before - * and after the execution of the method. - */ - protected void transferData(Buffer buffer) - { - try - { - read(buffer); - } - catch (IOException ex) - { - throw new UndeclaredThrowableException(ex); - } - - InputSampleDesc inputSampleDesc = (InputSampleDesc) buffer.getData(); - int[][] inputSamples = inputSampleDesc.inputSamples; - int maxInputSampleCount = buffer.getLength(); - - if ((inputSamples == null) - || (inputSamples.length == 0) - || (maxInputSampleCount <= 0)) - return; - - AudioMixingPushBufferStream[] outputStreams; - - synchronized (this.outputStreams) - { - outputStreams - = this.outputStreams.toArray( - new AudioMixingPushBufferStream[ - this.outputStreams.size()]); - } - for (AudioMixingPushBufferStream outputStream : outputStreams) - setInputSamples(outputStream, inputSampleDesc, maxInputSampleCount); - - /* - * The input samples have already been delivered to the output streams - * and are no longer necessary. - */ - for (int i = 0; i < inputSamples.length; i++) - { - deallocateIntArray(inputSamples[i]); - inputSamples[i] = null; - } - } - - private int[] validateIntArraySize(Buffer buffer, int newSize) - { - Object data = buffer.getData(); - int[] intArray; - - if (data instanceof int[]) - { - intArray = (int[]) data; - if (intArray.length < newSize) - { - deallocateIntArray(intArray); - intArray = null; - } - } - else - intArray = null; - if (intArray == null) - { - intArray = allocateIntArray(newSize); - buffer.setData(intArray); - } - return intArray; - } - - /** - * Describes a specific set of audio samples read from a specific set of - * input streams specified by their InputStreamDescs. - */ - private static class InputSampleDesc - { - /** - * The Buffer into which media data is to be read from - * {@link #inputStreams}. - */ - private SoftReference buffer; - - /** - * The set of audio samples read from {@link #inputStreams}. - */ - public final int[][] inputSamples; - - /** - * The set of input streams from which {@link #inputSamples} were read. - */ - public final InputStreamDesc[] inputStreams; - - /** - * The time stamp of inputSamples to be reported in the - * Buffers of the AudioMixingPushBufferStreams when - * mixes are read from them. - */ - private long timeStamp = Buffer.TIME_UNKNOWN; - - /** - * Initializes a new InputSampleDesc instance which is to - * describe a specific set of audio samples read from a specific set of - * input streams specified by their InputStreamDescs. - * - * @param inputSamples the set of audio samples read from - * inputStreams - * @param inputStreams the set of input streams from which - * inputSamples were read - */ - public InputSampleDesc( - int[][] inputSamples, - InputStreamDesc[] inputStreams) - { - this.inputSamples = inputSamples; - this.inputStreams = inputStreams; - } - - /** - * Gets the Buffer into which media data is to be read from the - * input streams associated with this instance. - * - * @param create the indicator which determines whether the - * Buffer is to be created in case it does not exist - * @return the Buffer into which media data is to be read from - * the input streams associated with this instance - */ - public Buffer getBuffer(boolean create) - { - Buffer buffer = (this.buffer == null) ? null : this.buffer.get(); - - if ((buffer == null) && create) - { - buffer = new Buffer(); - setBuffer(buffer); - } - return buffer; - } - - /** - * Gets the time stamp of inputSamples to be reported in the - * Buffers of the AudioMixingPushBufferStreams when - * mixes are read from them. - * - * @return the time stamp of inputSamples to be reported in the - * Buffers of the AudioMixingPushBufferStreams when - * mixes are read from them - */ - public long getTimeStamp() - { - return timeStamp; - } - - /** - * Sets the Buffer into which media data is to be read from the - * input streams associated with this instance. - * - * @param buffer the Buffer into which media data is to be read - * from the input streams associated with this instance - */ - public void setBuffer(Buffer buffer) - { - this.buffer - = (buffer == null) ? null : new SoftReference(buffer); - } - - /** - * Sets the time stamp of inputSamples to be reported in the - * Buffers of the AudioMixingPushBufferStreams when - * mixes are read from them. - * - * @param timeStamp the time stamp of inputSamples to be - * reported in the Buffers of the - * AudioMixingPushBufferStreams when mixes are read from them - */ - public void setTimeStamp(long timeStamp) - { - if (this.timeStamp == Buffer.TIME_UNKNOWN) - this.timeStamp = timeStamp; - else - { - /* - * Setting the timeStamp more than once does not make sense - * because the inputStreams will report different timeStamps so - * only one should be picked up where the very reading from - * inputStreams takes place. - */ - throw new IllegalStateException("timeStamp"); - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/conference/AudioMixingPushBufferDataSource.java b/src/net/java/sip/communicator/impl/neomedia/conference/AudioMixingPushBufferDataSource.java deleted file mode 100644 index b7587c687..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/conference/AudioMixingPushBufferDataSource.java +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.conference; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.control.*; -import net.java.sip.communicator.impl.neomedia.protocol.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.util.*; - -/** - * Represents a PushBufferDataSource which provides a single - * PushBufferStream containing the result of the audio mixing of - * DataSources. - * - * @author Lubomir Marinov - */ -public class AudioMixingPushBufferDataSource - extends PushBufferDataSource - implements CaptureDevice, - MuteDataSource, - InbandDTMFDataSource -{ - - /** - * The Logger used by the AudioMixingPushBufferDataSource - * class and its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(AudioMixingPushBufferDataSource.class); - - /** - * The AudioMixer performing the audio mixing, managing the input - * DataSources and pushing the data of this output - * PushBufferDataSource. - */ - private final AudioMixer audioMixer; - - /** - * The indicator which determines whether this DataSource is - * connected. - */ - private boolean connected; - - /** - * The one and only PushBufferStream this - * PushBufferDataSource provides to its clients and containing the - * result of the audio mixing performed by audioMixer. - */ - private AudioMixingPushBufferStream outputStream; - - /** - * The indicator which determines whether this DataSource is - * started. - */ - private boolean started; - - /** - * The indicator which determines whether this DataSource is set - * to transmit "silence" instead of the actual media. - */ - private boolean mute = false; - - /** - * The tones to send via inband DTMF, if not empty. - */ - private LinkedList tones = new LinkedList(); - - /** - * Initializes a new AudioMixingPushBufferDataSource instance which - * gives access to the result of the audio mixing performed by a specific - * AudioMixer. - * - * @param audioMixer the AudioMixer performing audio mixing, - * managing the input DataSources and pushing the data of the new - * output PushBufferDataSource - */ - public AudioMixingPushBufferDataSource(AudioMixer audioMixer) - { - this.audioMixer = audioMixer; - } - - /** - * Adds a new input DataSource to be mixed by the associated - * AudioMixer of this instance and to not have its audio - * contributions included in the mixing output represented by this - * DataSource. - * - * @param inputDataSource a DataSource to be added for mixing to - * the AudioMixer associate with this instance and to not have its - * audio contributions included in the mixing output represented by this - * DataSource - */ - public void addInputDataSource(DataSource inputDataSource) - { - audioMixer.addInputDataSource(inputDataSource, this); - } - - /** - * Implements {@link DataSource#connect()}. Lets the AudioMixer - * know that one of its output PushBufferDataSources has been - * connected and marks this DataSource as connected. - * - * @throws IOException if the AudioMixer fails to connect - */ - public synchronized void connect() - throws IOException - { - if (!connected) - { - audioMixer.connect(); - connected = true; - } - } - - /** - * Implements {@link DataSource#disconnect()}. Marks this - * DataSource as disconnected and notifies the AudioMixer - * that one of its output PushBufferDataSources has been - * disconnected. - */ - public synchronized void disconnect() - { - try - { - stop(); - } - catch (IOException ioex) - { - throw new UndeclaredThrowableException(ioex); - } - - if (connected) - { - outputStream = null; - connected = false; - - audioMixer.disconnect(); - } - } - - /** - * Gets the BufferControl available for this DataSource. - * Delegates to the AudioMixer because this instance is just a - * facet to it. - * - * @return the BufferControl available for this DataSource - */ - private BufferControl getBufferControl() - { - return audioMixer.getBufferControl(); - } - - /** - * Implements {@link CaptureDevice#getCaptureDeviceInfo()}. Delegates to the - * associated AudioMixer because it knows which - * CaptureDevice is being wrapped. - * - * @return the CaptureDeviceInfo of the CaptureDevice of - * the AudioMixer - */ - public CaptureDeviceInfo getCaptureDeviceInfo() - { - return audioMixer.getCaptureDeviceInfo(); - } - - /** - * Implements {@link DataSource#getContentType()}. Delegates to the - * associated AudioMixer because it manages the inputs and knows - * their characteristics. - * - * @return a String value which represents the type of the content - * being made available by this DataSource i.e. the associated - * AudioMixer - */ - public String getContentType() - { - return audioMixer.getContentType(); - } - - /** - * Implements {@link DataSource#getControl(String)}. - * - * @param controlType a String value which names the type of the - * control of this instance to be retrieved - * @return an Object which represents the control of this instance - * with the specified type if such a control is available; otherwise, - * null - */ - public Object getControl(String controlType) - { - return AbstractControls.getControl(this, controlType); - } - - /** - * Implements {@link DataSource#getControls()}. Gets an array of - * Objects which represent the controls available for this - * DataSource. - * - * @return an array of Objects which represent the controls - * available for this DataSource - */ - public Object[] getControls() - { - BufferControl bufferControl = getBufferControl(); - FormatControl[] formatControls = getFormatControls(); - - if (bufferControl == null) - return formatControls; - else if ((formatControls == null) || (formatControls.length < 1)) - return new Object[] { bufferControl }; - else - { - Object[] controls = new Object[1 + formatControls.length]; - - controls[0] = bufferControl; - System - .arraycopy( - formatControls, - 0, - controls, - 1, - formatControls.length); - return controls; - } - } - - /** - * Implements {@link DataSource#getDuration()}. Delegates to the associated - * AudioMixer because it manages the inputs and knows their - * characteristics. - * - * @return a Time value which represents the duration of the media - * being made available through this DataSource - */ - public Time getDuration() - { - return audioMixer.getDuration(); - } - - /** - * Implements {@link CaptureDevice#getFormatControls()}. Delegates to the - * associated AudioMixer because it knows which - * CaptureDevice is being wrapped. - * - * @return an array of FormatControls of the CaptureDevice - * of the associated AudioMixer - */ - public FormatControl[] getFormatControls() - { - return audioMixer.getFormatControls(); - } - - /** - * Implements {@link PushBufferDataSource#getStreams()}. Gets a - * PushBufferStream which reads data from the associated - * AudioMixer and mixes its inputs. - * - * @return an array with a single PushBufferStream which reads data - * from the associated AudioMixer and mixes its inputs if this - * DataSource is connected; otherwise, an empty array - */ - public synchronized PushBufferStream[] getStreams() - { - if (connected && (outputStream == null)) - { - AudioMixerPushBufferStream audioMixerOutputStream - = audioMixer.getOutputStream(); - - if (audioMixerOutputStream != null) - { - outputStream - = new AudioMixingPushBufferStream( - audioMixerOutputStream, - this); - if (started) - try - { - outputStream.start(); - } - catch (IOException ioex) - { - logger - .error( - "Failed to start " - + outputStream.getClass().getSimpleName() - + " with hashCode " - + outputStream.hashCode(), - ioex); - } - } - } - return - (outputStream == null) - ? new PushBufferStream[0] - : new PushBufferStream[] { outputStream }; - } - - /** - * Implements {@link DataSource#start()}. Starts the output - * PushBufferStream of this DataSource (if it exists) and - * notifies the AudioMixer that one of its output - * PushBufferDataSources has been started. - * - * @throws IOException if anything wrong happens while starting the output - * PushBufferStream of this DataSource - */ - public synchronized void start() - throws IOException - { - if (!started) - { - started = true; - if (outputStream != null) - outputStream.start(); - } - } - - /** - * Implements {@link DataSource#stop()}. Notifies the AudioMixer - * that one of its output PushBufferDataSources has been stopped - * and stops the output PushBufferStream of this - * DataSource (if it exists). - * - * @throws IOException if anything wrong happens while stopping the output - * PushBufferStream of this DataSource - */ - public synchronized void stop() - throws IOException - { - if (started) - { - started = false; - if (outputStream != null) - outputStream.stop(); - } - } - - /** - * Determines whether this DataSource is mute. - * - * @return true if this DataSource is mute; otherwise, - * false - */ - public boolean isMute() - { - return this.mute; - } - - /** - * Sets the mute state of this DataSource. - * - * @param mute true to mute this DataSource; otherwise, - * false - */ - public void setMute(boolean mute) - { - if (this.mute != mute) - { - this.mute = mute; - } - } - - /** - * Adds a new inband DTMF tone to send. - * - * @param tone the DTMF tone to send. - */ - public void addDTMF(DTMFInbandTone tone) - { - this.tones.add(tone); - } - - /** - * Determines whether this DataSource sends a DTMF tone. - * - * @return true if this DataSource is sending a DTMF tone; - * otherwise, false. - */ - public boolean isSendingDTMF() - { - return !this.tones.isEmpty(); - } - - /** - * Gets the next inband DTMF tone signal. - * - * @param samplingFrequency The sampling frequency (codec clock rate) in Hz - * of the stream which will encapsulate this signal. - * @param sampleSizeInBits The size of each sample (8 for a byte, 16 for a - * short and 32 for an int) - * - * @return The data array containing the DTMF signal. - */ - public int[] getNextToneSignal( - double samplingFrequency, - int sampleSizeInBits) - { - DTMFInbandTone tone = tones.poll(); - return tone.getAudioSamples(samplingFrequency, sampleSizeInBits); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/conference/AudioMixingPushBufferStream.java b/src/net/java/sip/communicator/impl/neomedia/conference/AudioMixingPushBufferStream.java deleted file mode 100644 index 4b09161cd..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/conference/AudioMixingPushBufferStream.java +++ /dev/null @@ -1,460 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.conference; - -import java.io.*; - -import javax.media.*; -import javax.media.format.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.control.*; -import net.java.sip.communicator.util.*; - -/** - * Represents a PushBufferStream containing the result of the audio - * mixing of DataSources. - * - * @author Lyubomir Marinov - */ -public class AudioMixingPushBufferStream - extends ControlsAdapter - implements PushBufferStream -{ - - /** - * The Logger used by the AudioMixingPushBufferStream - * class and its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(AudioMixingPushBufferStream.class); - - /** - * The AudioMixerPushBufferStream which reads data from the input - * DataSources and pushes it to this instance to be mixed. - */ - private final AudioMixerPushBufferStream audioMixerStream; - - /** - * The AudioMixingPushBufferDataSource which created and owns this - * instance and defines the input data which is to not be mixed in the - * output of this PushBufferStream. - */ - private final AudioMixingPushBufferDataSource dataSource; - - /** - * The collection of input audio samples still not mixed and read through - * this AudioMixingPushBufferStream. - */ - private int[][] inputSamples; - - /** - * The maximum number of per-stream audio samples available through - * inputSamples. - */ - private int maxInputSampleCount; - - /** - * The Object which synchronizes the access to the data to be read - * from this PushBufferStream i.e. to {@link #inputSamples}, - * {@link #maxInputSampleCount} and {@link #timeStamp}. - */ - private final Object readSyncRoot = new Object(); - - /** - * The time stamp of {@link #inputSamples} to be reported in the specified - * Buffer when data is read from this instance. - */ - private long timeStamp; - - /** - * The BufferTransferHandler through which this - * PushBufferStream notifies its clients that new data is available - * for reading. - */ - private BufferTransferHandler transferHandler; - - /** - * Initializes a new AudioMixingPushBufferStream mixing the - * input data of a specific AudioMixerPushBufferStream and - * excluding from the mix the audio contributions of a specific - * AudioMixingPushBufferDataSource. - * - * @param audioMixerStream the AudioMixerPushBufferStream reading - * data from input DataSources and to push it to the new - * AudioMixingPushBufferStream - * @param dataSource the AudioMixingPushBufferDataSource which has - * requested the initialization of the new instance and which defines the - * input data to not be mixed in the output of the new instance - */ - AudioMixingPushBufferStream( - AudioMixerPushBufferStream audioMixerStream, - AudioMixingPushBufferDataSource dataSource) - { - this.audioMixerStream = audioMixerStream; - this.dataSource = dataSource; - } - - /** - * Implements {@link SourceStream#endOfStream()}. Delegates to the wrapped - * AudioMixerPushBufferStream because this instance is just a facet - * to it. - * - * @return true if this SourceStream has reached the end - * of the media it makes available; otherwise, false - */ - public boolean endOfStream() - { - /* - * TODO If the inputSamples haven't been consumed yet, don't report the - * end of this stream even if the wrapped stream has reached its end. - */ - return audioMixerStream.endOfStream(); - } - - /** - * Implements {@link SourceStream#getContentDescriptor()}. Delegates to the - * wrapped AudioMixerPushBufferStream because this instance is just - * a facet to it. - * - * @return a ContentDescriptor which describes the content being - * made available by this SourceStream - */ - public ContentDescriptor getContentDescriptor() - { - return audioMixerStream.getContentDescriptor(); - } - - /** - * Implements {@link SourceStream#getContentLength()}. Delegates to the - * wrapped AudioMixerPushBufferStream because this instance is just - * a facet to it. - * - * @return the length of the media being made available by this - * SourceStream - */ - public long getContentLength() - { - return audioMixerStream.getContentLength(); - } - - /** - * Gets the AudioMixingPushBufferDataSource which created and owns - * this instance and defines the input data which is to not be mixed in the - * output of this PushBufferStream. - * - * @return the AudioMixingPushBufferDataSource which created and - * owns this instance and defines the input data which is to not be mixed in - * the output of this PushBufferStream - */ - public AudioMixingPushBufferDataSource getDataSource() - { - return dataSource; - } - - /** - * Implements {@link PushBufferStream#getFormat()}. Delegates to the wrapped - * AudioMixerPushBufferStream because this instance is just a facet - * to it. - * - * @return the Format of the audio being made available by this - * PushBufferStream - */ - public AudioFormat getFormat() - { - return audioMixerStream.getFormat(); - } - - /** - * Gets the maximum possible value for an audio sample of a specific - * AudioFormat. - * - * @param outputFormat the AudioFormat of which to get the maximum - * possible value for an audio sample - * @return the maximum possible value for an audio sample of the specified - * AudioFormat - * @throws UnsupportedFormatException if the specified outputFormat - * is not supported by the underlying implementation - */ - private static int getMaxOutputSample(AudioFormat outputFormat) - throws UnsupportedFormatException - { - switch(outputFormat.getSampleSizeInBits()) - { - case 8: - return Byte.MAX_VALUE; - case 16: - return Short.MAX_VALUE; - case 32: - return Integer.MAX_VALUE; - case 24: - default: - throw - new UnsupportedFormatException( - "Format.getSampleSizeInBits()", - outputFormat); - } - } - - /** - * Mixes as in audio mixing a specified collection of audio sample sets and - * returns the resulting mix audio sample set in a specific - * AudioFormat. - * - * @param inputSamples the collection of audio sample sets to be mixed into - * one audio sample set in the sense of audio mixing - * @param outputFormat the AudioFormat in which the resulting mix - * audio sample set is to be produced - * @param outputSampleCount the size of the resulting mix audio sample set - * to be produced - * @return the resulting audio sample set of the audio mixing of the - * specified input audio sample sets - */ - private static int[] mix( - int[][] inputSamples, - AudioFormat outputFormat, - int outputSampleCount) - { - int[] outputSamples = new int[outputSampleCount]; - - /* - * The trivial case of performing audio mixing the audio of a single - * stream. Then there is nothing to mix and the input becomes the - * output. - */ - if (inputSamples.length == 1) - { - int[] inputStreamSamples = inputSamples[0]; - - if (inputStreamSamples != null) - { - System.arraycopy( - inputStreamSamples, 0, - outputSamples, 0, - inputStreamSamples.length); - } - return outputSamples; - } - - int maxOutputSample; - - try - { - maxOutputSample = getMaxOutputSample(outputFormat); - } - catch (UnsupportedFormatException ufex) - { - throw new UnsupportedOperationException(ufex); - } - - for (int[] inputStreamSamples : inputSamples) - { - if (inputStreamSamples == null) - continue; - - int inputStreamSampleCount = inputStreamSamples.length; - - if (inputStreamSampleCount <= 0) - continue; - - for (int i = 0; i < inputStreamSampleCount; i++) - { - int inputStreamSample = inputStreamSamples[i]; - int outputSample = outputSamples[i]; - - outputSamples[i] - = inputStreamSample - + outputSample - - Math.round( - inputStreamSample - * (outputSample - / (float) maxOutputSample)); - } - } - return outputSamples; - } - - /** - * Implements {@link PushBufferStream#read(Buffer)}. If - * inputSamples are available, mixes them and writes the mix to the - * specified Buffer performing the necessary data type conversions. - * - * @param buffer the Buffer to receive the data read from this - * instance - * @throws IOException if anything wrong happens while reading from this - * instance - */ - public void read(Buffer buffer) - throws IOException - { - int[][] inputSamples; - int maxInputSampleCount; - long timeStamp; - - synchronized (readSyncRoot) - { - inputSamples = this.inputSamples; - maxInputSampleCount = this.maxInputSampleCount; - timeStamp = this.timeStamp; - - this.inputSamples = null; - this.maxInputSampleCount = 0; - this.timeStamp = Buffer.TIME_UNKNOWN; - } - - int inputSampleCount = (inputSamples == null) ? 0 : inputSamples.length; - - if ((inputSampleCount == 0) - || (maxInputSampleCount <= 0)) - { - buffer.setLength(0); - return; - } - - AudioFormat outputFormat = getFormat(); - int[] outputSamples - = mix(inputSamples, outputFormat, maxInputSampleCount); - - Class outputDataType = outputFormat.getDataType(); - - if (Format.byteArray.equals(outputDataType)) - { - byte[] outputData; - - switch (outputFormat.getSampleSizeInBits()) - { - case 16: - outputData = new byte[outputSamples.length * 2]; - for (int i = 0; i < outputSamples.length; i++) - ArrayIOUtils.writeInt16(outputSamples[i], outputData, i * 2); - break; - case 32: - outputData = new byte[outputSamples.length * 4]; - for (int i = 0; i < outputSamples.length; i++) - writeInt(outputSamples[i], outputData, i * 4); - break; - case 8: - case 24: - default: - throw - new UnsupportedOperationException( - "AudioMixingPushBufferStream.read(Buffer)"); - } - - buffer.setData(outputData); - buffer.setFormat(outputFormat); - buffer.setLength(outputData.length); - buffer.setOffset(0); - buffer.setTimeStamp(timeStamp); - } - else - throw - new UnsupportedOperationException( - "AudioMixingPushBufferStream.read(Buffer)"); - } - - /** - * Sets the collection of audio sample sets to be mixed in the sense of - * audio mixing by this stream when data is read from it. Triggers a push to - * the clients of this stream. - * - * @param inputSamples the collection of audio sample sets to be mixed by - * this stream when data is read from it - * @param maxInputSampleCount the maximum number of per-stream audio samples - * available through inputSamples - * @param timeStamp the time stamp of inputSamples to be reported - * in the specified Buffer when data is read from this instance - */ - void setInputSamples( - int[][] inputSamples, - int maxInputSampleCount, - long timeStamp) - { - synchronized (readSyncRoot) - { - this.inputSamples = inputSamples; - this.maxInputSampleCount = maxInputSampleCount; - } - - BufferTransferHandler transferHandler = this.transferHandler; - - if (transferHandler != null) - transferHandler.transferData(this); - } - - /** - * Implements - * {@link PushBufferStream#setTransferHandler(BufferTransferHandler)}. Sets - * the BufferTransferHandler which is to be notified by this - * instance when it has media available for reading. - * - * @param transferHandler the BufferTransferHandler to be notified - * by this instance when it has media available for reading - */ - public void setTransferHandler(BufferTransferHandler transferHandler) - { - this.transferHandler = transferHandler; - } - - /** - * Starts the pushing of data out of this stream. - * - * @throws IOException if starting the pushing of data out of this stream - * fails - */ - synchronized void start() - throws IOException - { - audioMixerStream.addOutputStream(this); - if (logger.isTraceEnabled()) - logger - .trace( - "Started " - + getClass().getSimpleName() - + " with hashCode " - + hashCode()); - } - - /** - * Stops the pushing of data out of this stream. - * - * @throws IOException if stopping the pushing of data out of this stream - * fails - */ - synchronized void stop() - throws IOException - { - audioMixerStream.removeOutputStream(this); - if (logger.isTraceEnabled()) - logger - .trace( - "Stopped " - + getClass().getSimpleName() - + " with hashCode " - + hashCode()); - } - - /** - * Converts an integer to a series of bytes and writes the result into a - * specific output array of bytes starting the writing at a specific offset - * in it. - * - * @param input the integer to be written out as a series of bytes - * @param output the output to receive the conversion of the specified - * integer to a series of bytes - * @param outputOffset the offset in output at which the writing of - * the result of the conversion is to be started - */ - private static void writeInt(int input, byte[] output, int outputOffset) - { - output[outputOffset] = (byte) (input & 0xFF); - output[outputOffset + 1] = (byte) ((input >>> 8) & 0xFF); - output[outputOffset + 2] = (byte) ((input >>> 16) & 0xFF); - output[outputOffset + 3] = (byte) (input >> 24); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/conference/DataSourceFilter.java b/src/net/java/sip/communicator/impl/neomedia/conference/DataSourceFilter.java deleted file mode 100644 index 311897aae..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/conference/DataSourceFilter.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.conference; - -import javax.media.protocol.*; - -/** - * Represents a filter which determines whether a specific DataSource - * is to be selected or deselected by the caller of the filter. - * - * @author Lubomir Marinov - */ -public interface DataSourceFilter -{ - - /** - * Determines whether a specific DataSource is accepted by this - * filter i.e. whether the caller of this filter should include it in its - * selection. - * - * @param dataSource the DataSource to be checked whether it is - * accepted by this filter - * @return true if this filter accepts the specified - * DataSource i.e. if the caller of this filter should include it - * in its selection; otherwise, false - */ - public boolean accept(DataSource dataSource); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/conference/InputDataSourceDesc.java b/src/net/java/sip/communicator/impl/neomedia/conference/InputDataSourceDesc.java deleted file mode 100644 index ed7e99640..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/conference/InputDataSourceDesc.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.conference; - -import java.io.*; - -import javax.media.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.protocol.*; -import net.java.sip.communicator.util.*; - -/** - * Describes additional information about a specific input DataSource - * of an AudioMixer so that the AudioMixer can, for example, - * quickly discover the output AudioMixingPushBufferDataSource in the - * mix of which the contribution of the DataSource is to not be - * included. - *

- * Private to AudioMixer and AudioMixerPushBufferStream but - * extracted into its own file for the sake of clarity. - *

- * - * @author Lubomir Marinov - */ -class InputDataSourceDesc -{ - - /** - * The Logger used by the InputDataSourceDesc class and - * its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(InputDataSourceDesc.class); - - /** - * The constant which represents an empty array with SourceStream - * element type. Explicitly defined in order to avoid unnecessary allocations. - */ - private static final SourceStream[] EMPTY_STREAMS = new SourceStream[0]; - - /** - * The indicator which determines whether the effective input - * DataSource described by this instance is currently connected. - */ - private boolean connected; - - /** - * The Thread which currently executes {@link DataSource#connect()} - * on the effective input DataSource described by this instance. - */ - private Thread connectThread; - - /** - * The DataSource for which additional information is described by - * this instance. - */ - public final DataSource inputDataSource; - - /** - * The AudioMixingPushBufferDataSource in which the mix - * contributions of {@link #inputDataSource} are to not be included. - */ - public final AudioMixingPushBufferDataSource outputDataSource; - - /** - * The DataSource, if any, which transcodes the tracks of - * {@link #inputDataSource} in the output Format of the associated - * AudioMixer. - */ - private DataSource transcodingDataSource; - - /** - * Initializes a new InputDataSourceDesc instance which is to - * describe additional information about a specific input - * DataSource of an AudioMixer. Associates the specified - * DataSource with the AudioMixingPushBufferDataSource in - * which the mix contributions of the specified input DataSource - * are to not be included. - * - * @param inputDataSource a DataSourc for which additional - * information is to be described by the new instance - * @param outputDataSource the AudioMixingPushBufferDataSource in - * which the mix contributions of inputDataSource are to not be - * included - */ - public InputDataSourceDesc( - DataSource inputDataSource, - AudioMixingPushBufferDataSource outputDataSource) - { - this.inputDataSource = inputDataSource; - this.outputDataSource = outputDataSource; - } - - /** - * Connects the effective input DataSource described by this - * instance upon request from a specific AudioMixer. If the - * effective input DataSource is to be asynchronously connected, - * the completion of the connect procedure will be reported to the specified - * AudioMixer by calling its - * {@link AudioMixer#connected(InputDataSourceDesc)}. - * - * @param audioMixer the AudioMixer requesting the effective input - * DataSource described by this instance to be connected - * @throws IOException if anything wrong happens while connecting the - * effective input DataSource described by this instance - */ - synchronized void connect(final AudioMixer audioMixer) - throws IOException - { - final DataSource effectiveInputDataSource - = (transcodingDataSource == null) - ? inputDataSource - : transcodingDataSource; - - if (effectiveInputDataSource instanceof TranscodingDataSource) - { - if (connectThread == null) - { - connectThread = new Thread() - { - @Override - public void run() - { - try - { - audioMixer - .connect( - effectiveInputDataSource, - inputDataSource); - synchronized (InputDataSourceDesc.this) - { - connected = true; - } - audioMixer.connected(InputDataSourceDesc.this); - } - catch (IOException ioex) - { - logger - .error( - "Failed to connect to inputDataSource " - + MediaStreamImpl - .toString(inputDataSource), - ioex); - } - finally - { - synchronized (InputDataSourceDesc.this) - { - if (connectThread == Thread.currentThread()) - connectThread = null; - } - } - } - }; - connectThread.setDaemon(true); - connectThread.start(); - } - } - else - { - audioMixer.connect(effectiveInputDataSource, inputDataSource); - connected = true; - } - } - - /** - * Creates a DataSource which attempts to transcode the tracks of - * the input DataSource described by this instance into a specific - * output Format. - * - * @param outputFormat the Format in which the tracks of the input - * DataSource described by this instance are to be transcoded - * @return true if a new transcoding DataSource has been - * created for the input DataSource described by this instance; - * otherwise, false - */ - synchronized boolean createTranscodingDataSource(Format outputFormat) - { - if (transcodingDataSource == null) - { - setTranscodingDataSource( - new TranscodingDataSource(inputDataSource, outputFormat)); - return true; - } - else - return false; - } - - /** - * Disconnects the effective input DataSource described by this - * instance if it is already connected. - */ - synchronized void disconnect() - { - if (connected) - { - getEffectiveInputDataSource().disconnect(); - connected = false; - } - } - - /** - * Gets the control available for the effective input DataSource - * described by this instance with a specific type. - * - * @param controlType a String value which specifies the type of - * the control to be retrieved - * @return an Object which represents the control available for the - * effective input DataSource described by this instance with the - * specified controlType if such a control exists; otherwise, - * null - */ - public synchronized Object getControl(String controlType) - { - DataSource effectiveInputDataSource = getEffectiveInputDataSource(); - - return - (effectiveInputDataSource == null) - ? null - : effectiveInputDataSource.getControl(controlType); - } - - /** - * Gets the actual DataSource from which the associated - * AudioMixer directly reads in order to retrieve the mix - * contribution of the DataSource described by this instance. - * - * @return the actual DataSource from which the associated - * AudioMixer directly reads in order to retrieve the mix - * contribution of the DataSource described by this instance - */ - public synchronized DataSource getEffectiveInputDataSource() - { - return - (transcodingDataSource == null) - ? inputDataSource - : (connected ? transcodingDataSource : null); - } - - /** - * Gets the SourceStreams of the effective input - * DataSource described by this instance. - * - * @return an array of the SourceStreams of the effective input - * DataSource described by this instance - */ - public synchronized SourceStream[] getStreams() - { - if (!connected) - return EMPTY_STREAMS; - - DataSource inputDataSource = getEffectiveInputDataSource(); - - if (inputDataSource instanceof PushBufferDataSource) - return ((PushBufferDataSource) inputDataSource).getStreams(); - else if (inputDataSource instanceof PullBufferDataSource) - return ((PullBufferDataSource) inputDataSource).getStreams(); - else if (inputDataSource instanceof TranscodingDataSource) - return ((TranscodingDataSource) inputDataSource).getStreams(); - else - return null; - } - - /** - * Sets the DataSource, if any, which transcodes the tracks of the - * input DataSource described by this instance in the output - * Format of the associated AudioMixer. - * - * @param transcodingDataSource the DataSource which transcodes - * the tracks of the input DataSource described by this instance in - * the output Format of the associated AudioMixer - */ - private synchronized void setTranscodingDataSource( - DataSource transcodingDataSource) - { - this.transcodingDataSource = transcodingDataSource; - connected = false; - } - - /** - * Starts the effective input DataSource described by this instance - * if it is connected. - * - * @throws IOException if starting the effective input DataSource - * described by this instance fails - */ - synchronized void start() - throws IOException - { - if (connected) - getEffectiveInputDataSource().start(); - } - - /** - * Stops the effective input DataSource described by this instance - * if it is connected. - * - * @throws IOException if stopping the effective input DataSource - * described by this instance fails - */ - synchronized void stop() - throws IOException - { - if (connected) - getEffectiveInputDataSource().stop(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/conference/InputStreamDesc.java b/src/net/java/sip/communicator/impl/neomedia/conference/InputStreamDesc.java deleted file mode 100644 index 4926270e0..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/conference/InputStreamDesc.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.conference; - -import java.lang.ref.*; - -import javax.media.*; -import javax.media.protocol.*; - -/** - * Describes additional information about a specific input audio - * SourceStream of an AudioMixer so that the - * AudioMixer can, for example, quickly discover the output - * AudioMixingPushBufferDataSource in the mix of which the contribution - * of the SourceStream is to not be included. - *

- * Private to AudioMixer and AudioMixerPushBufferStream but - * extracted into its own file for the sake of clarity. - *

- * - * @author Lyubomir Marinov - */ -class InputStreamDesc -{ - /** - * The Buffer into which media data is to be read from - * {@link #inputStream}. - */ - private SoftReference buffer; - - /** - * The DataSource which created the SourceStream described - * by this instance and additional information about it. - */ - public final InputDataSourceDesc inputDataSourceDesc; - - /** - * The SourceStream for which additional information is described - * by this instance. - */ - private SourceStream inputStream; - - /** - * The number of reads of this input stream which did not return any - * samples. - */ - long nonContributingReadCount; - - /** - * Initializes a new InputStreamDesc instance which is to describe - * additional information about a specific input audio SourceStream - * of an AudioMixer. Associates the specified SourceStream - * with the DataSource which created it and additional information - * about it. - * - * @param inputStream a SourceStream for which additional - * information is to be described by the new instance - * @param inputDataSourceDesc the DataSource which created the - * SourceStream to be described by the new instance and additional - * information about it - */ - public InputStreamDesc( - SourceStream inputStream, - InputDataSourceDesc inputDataSourceDesc) - { - this.inputStream = inputStream; - this.inputDataSourceDesc = inputDataSourceDesc; - } - - /** - * Gets the Buffer into which media data is to be read from the - * SourceStream described by this instance. - * - * @param create the indicator which determines whether the Buffer - * is to be created in case it does not exist - * @return the Buffer into which media data is to be read from the - * SourceStream described by this instance - */ - public Buffer getBuffer(boolean create) - { - Buffer buffer = (this.buffer == null) ? null : this.buffer.get(); - - if ((buffer == null) && create) - { - buffer = new Buffer(); - setBuffer(buffer); - } - return buffer; - } - - /** - * Gets the SourceStream described by this instance. - * - * @return the SourceStream described by this instance - */ - public SourceStream getInputStream() - { - return inputStream; - } - - /** - * Gets the AudioMixingPushBufferDataSource in which the mix - * contribution of the SourceStream described by this instance is - * to not be included. - * - * @return the AudioMixingPushBufferDataSource in which the mix - * contribution of the SourceStream described by this instance is - * to not be included - */ - public AudioMixingPushBufferDataSource getOutputDataSource() - { - return inputDataSourceDesc.outputDataSource; - } - - /** - * Sets the Buffer into which media data is to be read from the - * SourceStream described by this instance. - * - * @param buffer the Buffer into which media data is to be read - * from the SourceStream described by this instance - */ - public void setBuffer(Buffer buffer) - { - this.buffer - = (buffer == null) ? null : new SoftReference(buffer); - } - - /** - * Sets the SourceStream to be described by this instance. - * - * @param inputStream the SourceStream to be described by this - * instance - */ - public void setInputStream(SourceStream inputStream) - { - if (this.inputStream != inputStream) - { - this.inputStream = inputStream; - - /* - * Since the inputStream has changed, one may argue that the Buffer - * of the old value is not optimal for the new value. - */ - setBuffer(null); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/control/AbstractControls.java b/src/net/java/sip/communicator/impl/neomedia/control/AbstractControls.java deleted file mode 100644 index 4c3c9e7f5..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/control/AbstractControls.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.control; - -import javax.media.*; - -import net.java.sip.communicator.util.*; - -/** - * Provides an abstract implementation of Controls which facilitates - * implementers by requiring them to only implement - * {@link Controls#getControls()}. - * - * @author Lubomir Marinov - */ -public abstract class AbstractControls - implements Controls -{ - - /** - * The Logger used by the AbstractControls class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(AbstractControls.class); - - /** - * Implements {@link Controls#getControl(String)}. Invokes - * {@link #getControls()} and then looks for a control of the specified type - * in the returned array of controls. - * - * @param controlType a String value naming the type of the control - * of this instance to be retrieved - * @return an Object which represents the control of this instance - * with the specified type - */ - public Object getControl(String controlType) - { - return getControl(this, controlType); - } - - /** - * Gets the control of a specific Controls implementation of a - * specific type if such a control is made available through - * {@link Controls#getControls()}; otherwise, returns null. - * - * @param controlsImpl the implementation of Controls which is to - * be queried for its list of controls so that the control of the specified - * type can be looked for - * @param controlType a String value which names the type of the - * control to be retrieved - * @return an Object which represents the control of - * controlsImpl of the specified controlType if such a - * control is made available through Controls#getControls(); - * otherwise, null - */ - public static Object getControl(Controls controlsImpl, String controlType) - { - Object[] controls = controlsImpl.getControls(); - - if ((controls != null) && (controls.length > 0)) - { - Class controlClass; - - try - { - controlClass = Class.forName(controlType); - } - catch (ClassNotFoundException cnfe) - { - controlClass = null; - logger - .warn( - "Failed to find control class " + controlType, - cnfe); - } - if (controlClass != null) - for (Object control : controls) - if (controlClass.isInstance(control)) - return control; - } - return null; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/control/AbstractFormatControl.java b/src/net/java/sip/communicator/impl/neomedia/control/AbstractFormatControl.java deleted file mode 100644 index 7e105b3da..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/control/AbstractFormatControl.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.control; - -import java.util.*; - -import javax.media.*; -import javax.media.control.*; - -/** - * Provides an abstract implementation of FormatControl which - * facilitates implementers by requiring them to implement just - * {@link FormatControl#getSupportedFormats()} and - * {@link FormatControl#getFormat()}. - * - * @author Lyubomir Marinov - */ -public abstract class AbstractFormatControl - implements FormatControl -{ - - /** - * The indicator which determines whether this track is enabled. - */ - private boolean enabled; - - /** - * Implements {@link Control#getControlComponent()}. Returns null. - * - * @return a Component which represents UI associated with this - * instance if any; otherwise, null - */ - public java.awt.Component getControlComponent() - { - // No Component is exported by this instance. - return null; - } - - /** - * Gets an array of FormatControl instances from the list of - * controls available for a specific Controls implementation. - * - * @param controlsImpl the Controls implementation from which the - * FormatControl instances are to be retrieved - * @return an array of FormatControl instances from the list of - * controls available for the specified Controls implementation - */ - public static FormatControl[] getFormatControls(Controls controlsImpl) - { - List formatControls = new ArrayList(); - - for (Object control : controlsImpl.getControls()) - if (control instanceof FormatControl) - formatControls.add((FormatControl) control); - return formatControls.toArray(new FormatControl[formatControls.size()]); - } - - /** - * Implements {@link FormatControl#isEnabled()}. - * - * @return true if this track is enabled; otherwise, false - */ - public boolean isEnabled() - { - return enabled; - } - - /** - * Implements {@link FormatControl#setEnabled(boolean)}. - * - * @param enabled true if this track is to be enabled; otherwise, - * false - */ - public void setEnabled(boolean enabled) - { - this.enabled = enabled; - } - - /** - * Implements {@link FormatControl#setFormat(Format)}. Not supported and - * just returns the currently set format if the specified Format is - * supported and null if it is not supported. - * - * @param format the Format to be set on this instance - * @return the currently set Format after the attempt to set it on - * this instance if format is supported by this instance and - * regardless of whether it was actually set; null if - * format is not supported by this instance - */ - public Format setFormat(Format format) - { - return setFormat(this, format); - } - - /** - * Implements setting the Format of a specific - * FormatControl as documented for - * {@link FormatControl#setFormat(Format)} in the case of not supporting - * Format setting. - * - * @param formatControl the FormatControl for which the - * functionality is implemented - * @param format the Format specified to be set to - * formatControl and which will be ignored in accord with the - * documentation of FormatControl#setFormat(Format) - * @return the currently set Format of formatControl if - * format is supported by formatControl; null if - * format is not supported by formatControl - */ - public static Format setFormat(FormatControl formatControl, Format format) - { - /* - * Determine whether the specified format is supported by this instance - * because we have to return null if it is not supported. Or at least - * that is what I gather from the respective javadoc. - */ - boolean formatIsSupported = false; - - if (format != null) - for (Format supportedFormat : formatControl.getSupportedFormats()) - if (supportedFormat.matches(format)) - { - formatIsSupported = true; - break; - } - - /* - * We do not actually support setFormat so we have to return the - * currently set format if the specified format is supported. - */ - return formatIsSupported ? formatControl.getFormat() : null; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/control/ControlsAdapter.java b/src/net/java/sip/communicator/impl/neomedia/control/ControlsAdapter.java deleted file mode 100644 index 461c75779..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/control/ControlsAdapter.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.control; - -/** - * Provides a default implementation of Controls which does not expose - * any controls. - * - * @author Lubomir Marinov - */ -public class ControlsAdapter - extends AbstractControls -{ - - /** - * The constant which represents an empty array of controls. Explicitly - * defined in order to avoid unnecessary allocations. - */ - public static final Object[] EMPTY_CONTROLS = new Object[0]; - - /** - * Implements {@link javax.media.Controls#getControls()}. Gets the controls - * available for the owner of this instance. The current implementation - * returns an empty array because it has no available controls. - * - * @return an array of Objects which represent the controls - * available for the owner of this instance - */ - public Object[] getControls() - { - return EMPTY_CONTROLS; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/control/FrameProcessingControlImpl.java b/src/net/java/sip/communicator/impl/neomedia/control/FrameProcessingControlImpl.java deleted file mode 100644 index 6610b2c26..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/control/FrameProcessingControlImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.control; - -import java.awt.*; - -import javax.media.control.*; - -/** - * Provides a base implementation of FrameProcessingControl which keeps - * track of the minimalProcessing property, switches its value to - * true when it's notified that its owner is at least one frame behind - * and doesn't implement the controlComponent and - * framesDropped properties. - * - * @author Lyubomir Marinov - */ -public class FrameProcessingControlImpl - implements FrameProcessingControl -{ - - /** - * The indicator which determines whether the owner of this - * FrameProcessingControl is to perform only the minimum operations - * necessary to keep it working normally but without producing output. - */ - private boolean minimalProcessing = false; - - /** - * Gets the UI Component associated with this Control - * object. - * - * @return the UI Component associated with this Control - * object - */ - public Component getControlComponent() - { - /* - * We totally don't care about providing a UI component which controls - * frame drop from inside the media implementation. - */ - return null; - } - - /** - * Gets the number of output frames that were dropped during processing - * since the last call to this method. - * - * @return the number of output frame that were dropped during processing - * since the last call to this method - */ - public int getFramesDropped() - { - return 0; // Not implemented. - } - - /** - * Determines whether the owner of this FrameProcessingControl is - * to perform only the minimum operations necessary to keep it working - * normally but without producing output. - * - * @return true if the owner of this - * FrameProcessingControl is to perform only the minimum operations - * necessary to keep it working normally but without producing output; - * otherwise, false - */ - public boolean isMinimalProcessing() - { - return minimalProcessing; - } - - /** - * Sets the number of frames the owner of this - * FrameProcessingControl is lagging behind. It is a hint to do - * minimal processing for the next framesBehind frames in order to - * catch up. - * - * @param framesBehind the number of frames the owner of this - * FrameProcessingControl is lagging behind - */ - public void setFramesBehind(float framesBehind) - { - setMinimalProcessing(framesBehind > 0); - } - - /** - * Sets the indicator which determines whether the owner of this - * FrameProcessingControl is to perform only the minimal operations - * necessary to keep it working normally but without producing output. - * - * @param minimalProcessing true if minimal processing mode is to - * be turned on or false if minimal processing mode is to be turned - * off - * @return the actual minimal processing mode in effect after the set - * attempt - */ - public boolean setMinimalProcessing(boolean minimalProcessing) - { - this.minimalProcessing = minimalProcessing; - return this.minimalProcessing; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/control/FrameRateControlAdapter.java b/src/net/java/sip/communicator/impl/neomedia/control/FrameRateControlAdapter.java deleted file mode 100644 index ea2672d91..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/control/FrameRateControlAdapter.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.control; - -import java.awt.*; - -import javax.media.*; -import javax.media.control.*; - -/** - * Provides a default implementation of FrameRateControl. - * - * @author Lyubomir Marinov - */ -public class FrameRateControlAdapter - implements FrameRateControl -{ - /** - * Gets the UI Component associated with this Control - * object. FrameRateControlAdapter always returns null. - * - * @return the UI Component associated with this Control - * object - * @see Control#getControlComponent() - */ - public Component getControlComponent() - { - return null; - } - - /** - * Gets the current output frame rate. FrameRateControlAdapter - * always returns -1. - * - * @return the current output frame rate if it is known; otherwise, - * -1 - * @see FrameRateControl#getFrameRate() - */ - public float getFrameRate() - { - return -1; - } - - /** - * Gets the maximum supported output frame rate. - * FrameRateControlAdapter always returns -1. - * - * @return the maximum supported output frame rate if it is known; - * otherwise, -1 - * @see FrameRateControl#getMaxSupportedFrameRate() - */ - public float getMaxSupportedFrameRate() - { - return -1; - } - - /** - * Gets the default/preferred output frame rate. - * FrameRateControlAdapter always returns -1. - * - * @return the default/preferred output frame rate if it is known; - * otherwise, -1 - * @see FrameRateControl#getPreferredFrameRate() - */ - public float getPreferredFrameRate() - { - return -1; - } - - /** - * Sets the output frame rate. FrameRateControlAdapter always - * returns -1. - * - * @param frameRate the output frame rate to change the current one to - * @return the actual current output frame rate or -1 if it is - * unknown or not controllable - * @see FrameRateControl#setFrameRate(float) - */ - public float setFrameRate(float frameRate) - { - return -1; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/control/ReadOnlyBufferControlDelegate.java b/src/net/java/sip/communicator/impl/neomedia/control/ReadOnlyBufferControlDelegate.java deleted file mode 100644 index 6cd97561b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/control/ReadOnlyBufferControlDelegate.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.control; - -import javax.media.control.*; - -/** - * Represents a wrapper of a specific BufferControl which does not call - * the setters of the wrapped instance and calls only the getters. - * - * @author Lubomir Marinov - */ -public class ReadOnlyBufferControlDelegate - implements BufferControl -{ - - /** - * The BufferControl wrapped by this instance. - */ - private final BufferControl bufferControl; - - /** - * Initializes a new ReadOnlyBufferControlDelegate instance which - * is to wrap a specific BufferControl and call only its getters. - * - * @param bufferControl the BufferControl to be wrapped by the new - * instance - */ - public ReadOnlyBufferControlDelegate(BufferControl bufferControl) - { - this.bufferControl = bufferControl; - } - - /** - * Implements {@link BufferControl#getBufferLength()}. Gets the length in - * milliseconds of the buffering performed by the owner of the wrapped - * BufferControl. - * - * @return the length in milliseconds of the buffering performed by the - * owner of the wrapped BufferControl - */ - public long getBufferLength() - { - return bufferControl.getBufferLength(); - } - - /** - * Implements {@link javax.media.Control#getControlComponent()}. Gets the UI - * Component representing this instance and exported by the owner - * of the wrapped BufferControl. - * - * @return the UI Component representing the wrapped - * BufferControl and exported by its owner if such a - * Component is available; otherwise, null - */ - public java.awt.Component getControlComponent() - { - return bufferControl.getControlComponent(); - } - - /** - * Implements {@link BufferControl#getEnabledThreshold()}. Gets the - * indicator of the wrapped BufferControl which determines whether - * threshold calculations are enabled. - * - * @return true if threshold calculations are enabled in the - * wrapped BufferControl; otherwise, false - */ - public boolean getEnabledThreshold() - { - return bufferControl.getEnabledThreshold(); - } - - /** - * Implements {@link BufferControl#getMinimumThreshold()}. Gets the minimum - * threshold in milliseconds for the buffering performed by the owner of the - * wrapped BufferControl. - * - * @return the minimum threshold in milliseconds for the buffering performed - * by the owner of the wrapped BufferControl - */ - public long getMinimumThreshold() - { - return bufferControl.getMinimumThreshold(); - } - - /** - * Implements {@link BufferControl#setBufferLength(long)}. Ignores the - * request because this instance provides read-only support and returns the - * value actually in effect. - * - * @param bufferLength the length in milliseconds of the buffering to be - * performed by the owner of the wrapped BufferControl - * @return the length in milliseconds of the buffering performed by the - * owner of the wrapped BufferControl that is actually in effect - */ - public long setBufferLength(long bufferLength) - { - return getBufferLength(); - } - - /** - * Implements {@link BufferControl#setEnabledThreshold(boolean)}. Ignores - * the set request because this instance provides read-only support. - * - * @param enabledThreshold true if threshold calculations are - * to be enabled; otherwise, false - */ - public void setEnabledThreshold(boolean enabledThreshold) - { - } - - /** - * Implements {@link BufferControl#setMinimumThreshold(long)}. Ignores the - * set request because this instance provides read-only support and returns - * the value actually in effect. - * - * @param minimumThreshold the minimum threshold in milliseconds for the - * buffering to be performed by the owner of the wrapped - * BufferControl - * @return the minimum threshold in milliseconds for the buffering performed - * by the owner of the wrapped BufferControl that is actually in - * effect - */ - public long setMinimumThreshold(long minimumThreshold) - { - return getMinimumThreshold(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/control/ReadOnlyFormatControlDelegate.java b/src/net/java/sip/communicator/impl/neomedia/control/ReadOnlyFormatControlDelegate.java deleted file mode 100644 index 5c0a9f7f1..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/control/ReadOnlyFormatControlDelegate.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.control; - -import java.awt.*; - -import javax.media.*; -import javax.media.control.*; - -/** - * Represents a wrapper of a specific FormatControl instance which does - * not allow setting its format using {@link FormatControl#setFormat(Format)}. - * - * @author Lubomir Marinov - */ -public class ReadOnlyFormatControlDelegate - implements FormatControl -{ - - /** - * The FormatControl wrapped by this instance. - */ - private final FormatControl formatControl; - - /** - * Initializes a new ReadOnlyFormatControlDelegate instance which - * is to wrap a specific FormatControl in order to prevent calls to - * its {@link FormatControl#setFormat(Format)}. - * - * @param formatControl the FormatControl which is to have calls to - * its FormatControl#setFormat(Format) prevented - */ - public ReadOnlyFormatControlDelegate(FormatControl formatControl) - { - this.formatControl = formatControl; - } - - /** - * Implements {@link Control#getControlComponent()}. - * - * @return a Component which represents UI associated with this - * instance if any; otherwise, null - */ - public Component getControlComponent() - { - return formatControl.getControlComponent(); - } - - /** - * Gets the Format of the owner of this FormatControl. - * Delegates to the wrapped FormatControl. - * - * @return the Format of the owner of this FormatControl - */ - public Format getFormat() - { - return formatControl.getFormat(); - } - - /** - * Gets the Formats supported by the owner of this - * FormatControl. Delegates to the wrapped FormatControl. - * - * @return an array of Formats supported by the owner of this - * FormatControl - */ - public Format[] getSupportedFormats() - { - return formatControl.getSupportedFormats(); - } - - /** - * Implements {@link FormatControl#isEnabled()}. - * - * @return true if this track is enabled; otherwise, false - */ - public boolean isEnabled() - { - return formatControl.isEnabled(); - } - - /** - * Implements {@link FormatControl#setEnabled(boolean)}. - * - * @param enabled true if this track is to be enabled; otherwise, - * false - */ - public void setEnabled(boolean enabled) - { - // Ignore the request because this instance is read-only. - } - - /** - * Implements {@link FormatControl#setFormat(Format)}. Not supported and - * just returns the currently set format if the specified Format is - * supported and null if it is not supported. - * - * @param format the Format to be set on this instance - * @return the currently set Format after the attempt to set it on - * this instance if format is supported by this instance and - * regardless of whether it was actually set; null if - * format is not supported by this instance - */ - public Format setFormat(Format format) - { - return AbstractFormatControl.setFormat(this, format); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/AbstractMediaDevice.java b/src/net/java/sip/communicator/impl/neomedia/device/AbstractMediaDevice.java deleted file mode 100644 index 05f9aca65..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/AbstractMediaDevice.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.io.*; -import java.util.*; - -import javax.media.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; - -/** - * Defines the interface for MediaDevice required by the - * net.java.sip.communicator.impl.neomedia implementation of - * net.java.sip.communicator.service.neomedia. - * - * @author Lyubomir Marinov - */ -public abstract class AbstractMediaDevice - implements MediaDevice -{ - /** - * Connects to a specific CaptureDevice given in the form of a - * DataSource. Explicitly defined in order to allow extenders to - * customize the connect procedure. - * - * @param captureDevice the CaptureDevice to be connected to - * @throws IOException if anything wrong happens while connecting to the - * specified captureDevice - */ - public void connect(DataSource captureDevice) - throws IOException - { - if (captureDevice == null) - throw new NullPointerException("captureDevice"); - try - { - captureDevice.connect(); - } - catch (NullPointerException npe) - { - /* - * The old media says it happens when the operating system does not - * support the operation. - */ - IOException ioe = new IOException(); - - ioe.initCause(npe); - throw ioe; - } - } - - /** - * Creates a DataSource instance for this MediaDevice - * which gives access to the captured media. - * - * @return a DataSource instance which gives access to the media - * captured by this MediaDevice - */ - abstract DataSource createOutputDataSource(); - - /** - * Initializes a new Renderer instance which is to play back media - * on this MediaDevice. - * - * @return a new Renderer instance which is to play back media on - * this MediaDevice or null if a suitable - * Renderer is to be chosen irrespective of this - * MediaDevice - */ - abstract Renderer createRenderer(); - - /** - * Creates a new MediaDeviceSession instance which is to represent - * the use of this MediaDevice by a MediaStream. - * - * @return a new MediaDeviceSession instance which is to represent - * the use of this MediaDevice by a MediaStream - */ - public MediaDeviceSession createSession() - { - switch (getMediaType()) - { - case VIDEO: - return new VideoMediaDeviceSession(this); - default: - return new AudioMediaDeviceSession(this); - } - } - - /** - * Returns a List containing (at the time of writing) a single - * extension descriptor indicating RECVONLY support for - * mixer-to-client audio levels. - * - * @return a List containing the CSRC_AUDIO_LEVEL_URN - * extension descriptor. - */ - public List getSupportedExtensions() - { - return null; - } - - /** - * Gets a list of MediaFormats supported by this - * MediaDevice. - * - * @return the list of MediaFormats supported by this device - * @see MediaDevice#getSupportedFormats() - */ - public List getSupportedFormats() - { - return getSupportedFormats(null, null); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/AudioMediaDeviceImpl.java b/src/net/java/sip/communicator/impl/neomedia/device/AudioMediaDeviceImpl.java deleted file mode 100644 index dceccefd1..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/AudioMediaDeviceImpl.java +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.io.*; -import java.net.*; -import java.util.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.conference.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.util.*; - -/** - * Extends MediaDeviceImpl with audio-specific functionality. - * - * @author Lyubomir Marinov - */ -public class AudioMediaDeviceImpl - extends MediaDeviceImpl -{ - - /** - * The Logger used by the AudioMediaDeviceImpl class and - * its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(AudioMediaDeviceImpl.class); - - /** - * The AudioMixer which enables sharing an exclusive - * CaptureDevice such as JavaSound between multiple - * CaptureDevice users. - */ - private AudioMixer captureDeviceSharing; - - /** - * The List of RTP extensions supported by this device (at the time - * of writing this list is only filled for audio devices and is - * null otherwise). - */ - private List rtpExtensions = null; - - /** - * Initializes a new AudioMediaDeviceImpl instance which represents - * a MediaDevice with MediaType AUDIO and a - * MediaDirection which does not allow sending. - */ - public AudioMediaDeviceImpl() - { - super(MediaType.AUDIO); - } - - /** - * Initializes a new AudioMediaDeviceImpl which is to provide an - * implementation of MediaDevice with MediaType - * AUDIO to a CaptureDevice with a specific - * CaptureDeviceInfo. - * - * @param captureDeviceInfo the CaptureDeviceInfo of the - * CaptureDevice to which the new instance is to provide an - * implementation of MediaDevice - */ - public AudioMediaDeviceImpl(CaptureDeviceInfo captureDeviceInfo) - { - super(captureDeviceInfo, MediaType.AUDIO); - } - - /** - * Connects to a specific CaptureDevice given in the form of a - * DataSource. - * - * @param captureDevice the CaptureDevice to be connected to - * @throws IOException if anything wrong happens while connecting to the - * specified captureDevice - * @see AbstractMediaDevice#connect(DataSource) - */ - @Override - public void connect(DataSource captureDevice) - throws IOException - { - super.connect(captureDevice); - - /* - * 1. Changing buffer size. The default buffer size (for JavaSound) is - * 125 milliseconds - 1/8 sec. On Mac OS X this leads to an exception - * and no audio capture. A value of 30 for the buffer fixes the problem - * and is OK when using some PSTN gateways. - * - * 2. Changing to 60. When it is 30 there are some issues with Asterisk - * and NAT (we don't start to send stream and so Asterisk RTP part - * doesn't notice that we are behind NAT). - * - * 3. Do not set buffer length on Linux as it completely breaks audio - * capture. - */ - if(!OSUtils.IS_LINUX) - { - BufferControl bufferControl - = (BufferControl) - captureDevice.getControl(BufferControl.class.getName()); - - if (bufferControl != null) - bufferControl.setBufferLength(60 /* millis */); - } - } - - /** - * Creates the JMF CaptureDevice this instance represents and - * provides an implementation of MediaDevice for. - * - * @return the JMF CaptureDevice this instance represents and - * provides an implementation of MediaDevice for; null - * if the creation fails - */ - @Override - synchronized CaptureDevice createCaptureDevice() - { - CaptureDevice captureDevice = null; - - if (getDirection().allowsSending()) - { - if (captureDeviceSharing == null) - { - String protocol = getCaptureDeviceInfoLocatorProtocol(); - boolean createCaptureDeviceIfNull = true; - - if (AudioSystem.LOCATOR_PROTOCOL_JAVASOUND.equalsIgnoreCase( - protocol) - || AudioSystem.LOCATOR_PROTOCOL_PORTAUDIO - .equalsIgnoreCase(protocol)) - { - captureDevice = superCreateCaptureDevice(); - createCaptureDeviceIfNull = false; - if (captureDevice != null) - { - captureDeviceSharing - = createCaptureDeviceSharing(captureDevice); - captureDevice - = captureDeviceSharing.createOutputDataSource(); - } - } - if ((captureDevice == null) && createCaptureDeviceIfNull) - captureDevice = superCreateCaptureDevice(); - } - else - captureDevice = captureDeviceSharing.createOutputDataSource(); - } - return captureDevice; - } - - /** - * Creates a new AudioMixer which is to enable the sharing of a - * specific explicit CaptureDevice - * - * @param captureDevice an exclusive CaptureDevice for which - * sharing is to be enabled - * @return a new AudioMixer which enables the sharing of the - * specified exclusive captureDevice - */ - private AudioMixer createCaptureDeviceSharing(CaptureDevice captureDevice) - { - return - new AudioMixer(captureDevice) - { - @Override - protected void connect( - DataSource dataSource, - DataSource inputDataSource) - throws IOException - { - /* - * CaptureDevice needs special connecting as defined by - * AbstractMediaDevice and, especially, MediaDeviceImpl. - */ - if (inputDataSource == captureDevice) - AudioMediaDeviceImpl.this.connect(dataSource); - else - super.connect(dataSource, inputDataSource); - } - }; - } - - /** - * Initializes a new Renderer instance which is to play back media - * on this MediaDevice. - * - * @return a new Renderer instance which is to play back media on - * this MediaDevice or null if a suitable - * Renderer is to be chosen irrespective of this - * MediaDevice - */ - @Override - Renderer createRenderer() - { - Renderer renderer = null; - - try - { - String locatorProtocol = getCaptureDeviceInfoLocatorProtocol(); - - if (locatorProtocol != null) - { - AudioSystem audioSystem - = AudioSystem.getAudioSystem(locatorProtocol); - - if (audioSystem != null) - renderer = audioSystem.createRenderer(true); - } - } - finally - { - if (renderer == null) - renderer = super.createRenderer(); - } - return renderer; - } - - /** - * Gets the protocol of the MediaLocator of the - * CaptureDeviceInfo represented by this instance. - * - * @return the protocol of the MediaLocator of the - * CaptureDeviceInfo represented by this instance - */ - private String getCaptureDeviceInfoLocatorProtocol() - { - CaptureDeviceInfo cdi = getCaptureDeviceInfo(); - - if (cdi != null) - { - MediaLocator locator = cdi.getLocator(); - - if (locator != null) - return locator.getProtocol(); - } - - return null; - } - - /** - * Returns a List containing (at the time of writing) a single - * extension descriptor indicating RECVONLY support for - * mixer-to-client audio levels. - * - * @return a List containing the CSRC_AUDIO_LEVEL_URN - * extension descriptor. - */ - @Override - public List getSupportedExtensions() - { - if (rtpExtensions == null) - { - rtpExtensions = new ArrayList(1); - - URI csrcAudioLevelURN; - - try - { - csrcAudioLevelURN = new URI(RTPExtension.CSRC_AUDIO_LEVEL_URN); - } - catch (URISyntaxException e) - { - // can't happen since CSRC_AUDIO_LEVEL_URN is a valid URI and - // never changes. - if (logger.isInfoEnabled()) - logger.info("Aha! Someone messed with the source!", e); - csrcAudioLevelURN = null; - } - if (csrcAudioLevelURN != null) - rtpExtensions.add( - new RTPExtension( - csrcAudioLevelURN, - MediaDirection.RECVONLY)); - } - - return rtpExtensions; - } - - private boolean isLessThanOrEqualToMaxAudioFormat(Format format) - { - if (format instanceof AudioFormat) - { - AudioFormat audioFormat = (AudioFormat) format; - int channels = audioFormat.getChannels(); - - if ((channels == Format.NOT_SPECIFIED) - || (MediaUtils.MAX_AUDIO_CHANNELS == Format.NOT_SPECIFIED) - || (channels <= MediaUtils.MAX_AUDIO_CHANNELS)) - { - double sampleRate = audioFormat.getSampleRate(); - - if ((sampleRate == Format.NOT_SPECIFIED) - || (MediaUtils.MAX_AUDIO_SAMPLE_RATE - == Format.NOT_SPECIFIED) - || (sampleRate <= MediaUtils.MAX_AUDIO_SAMPLE_RATE)) - { - int sampleSizeInBits - = audioFormat.getSampleSizeInBits(); - - if ((sampleSizeInBits == Format.NOT_SPECIFIED) - || (MediaUtils.MAX_AUDIO_SAMPLE_SIZE_IN_BITS - == Format.NOT_SPECIFIED) - || (sampleSizeInBits - <= MediaUtils - .MAX_AUDIO_SAMPLE_SIZE_IN_BITS)) - { - return true; - } - } - } - } - return false; - } - - /** - * Invokes the super (with respect to the AudioMediaDeviceImpl - * class) implementation of {@link MediaDeviceImpl#createCaptureDevice()}. - * Allows this instance to customize the very CaptureDevice which - * is to be possibly further wrapped by this instance. - * - * @return the CaptureDevice returned by the call to the super - * implementation of MediaDeviceImpl#createCaptureDevice. - */ - protected CaptureDevice superCreateCaptureDevice() - { - CaptureDevice captureDevice = super.createCaptureDevice(); - - if (captureDevice != null) - { - /* - * Try to default the captureDevice to a Format which does not - * exceed the maximum quality known to MediaUtils. - */ - try - { - FormatControl[] formatControls - = captureDevice.getFormatControls(); - - if ((formatControls != null) && (formatControls.length != 0)) - { - for (FormatControl formatControl : formatControls) - { - Format format = formatControl.getFormat(); - - if ((format != null) - && isLessThanOrEqualToMaxAudioFormat(format)) - continue; - - Format[] supportedFormats - = formatControl.getSupportedFormats(); - AudioFormat supportedFormatToSet = null; - - if ((supportedFormats != null) - && (supportedFormats.length != 0)) - { - for (Format supportedFormat : supportedFormats) - { - if (isLessThanOrEqualToMaxAudioFormat( - supportedFormat)) - { - supportedFormatToSet - = (AudioFormat) supportedFormat; - break; - } - } - } - - if (!supportedFormatToSet.matches(format)) - { - int channels = supportedFormatToSet.getChannels(); - double sampleRate - = supportedFormatToSet.getSampleRate(); - int sampleSizeInBits - = supportedFormatToSet.getSampleSizeInBits(); - - if (channels == Format.NOT_SPECIFIED) - channels = MediaUtils.MAX_AUDIO_CHANNELS; - if (sampleRate == Format.NOT_SPECIFIED) - sampleRate = MediaUtils.MAX_AUDIO_SAMPLE_RATE; - if (sampleSizeInBits == Format.NOT_SPECIFIED) - { - sampleSizeInBits - = MediaUtils.MAX_AUDIO_SAMPLE_SIZE_IN_BITS; - /* - * TODO A great deal of the neomedia-contributed - * audio Codecs, CaptureDevices, DataSources and - * Renderers deal with 16-bit samples. - */ - if (sampleSizeInBits == Format.NOT_SPECIFIED) - sampleSizeInBits = 16; - } - - if ((channels != Format.NOT_SPECIFIED) - && (sampleRate != Format.NOT_SPECIFIED) - && (sampleSizeInBits - != Format.NOT_SPECIFIED)) - { - AudioFormat formatToSet - = new AudioFormat( - supportedFormatToSet.getEncoding(), - sampleRate, - sampleSizeInBits, - channels); - - if (supportedFormatToSet.matches(formatToSet)) - formatControl.setFormat( - supportedFormatToSet.intersects( - formatToSet)); - } - } - } - } - } - catch (Throwable t) - { - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - /* - * We tried to default the captureDevice to a Format which does - * not exceed the maximum quality known to MediaUtils and we - * failed but it does not mean that the captureDevice will not - * be successfully used. - */ - } - } - - return captureDevice; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/AudioMediaDeviceSession.java b/src/net/java/sip/communicator/impl/neomedia/device/AudioMediaDeviceSession.java deleted file mode 100644 index fc1cb0372..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/AudioMediaDeviceSession.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.audiolevel.*; -import net.java.sip.communicator.service.neomedia.event.*; -import net.java.sip.communicator.util.*; - -/** - * Extends MediaDeviceSession to add audio-specific functionality. - * - * @author Emil Ivov - * @author Damian Minkov - */ -public class AudioMediaDeviceSession - extends MediaDeviceSession -{ - /** - * The Logger used by the AudioMediaDeviceSession class - * and its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(AudioMediaDeviceSession.class); - - /** - * The Effect that we will register with our DataSource in - * order to measure the audio levels of the local user. - */ - private final AudioLevelEffect localUserAudioLevelEffect - = new AudioLevelEffect(); - - /** - * The effect that we will register with our stream in order to measure - * audio levels of the remote user audio. - */ - private final AudioLevelEffect streamAudioLevelEffect - = new AudioLevelEffect(); - - /** - * Initializes a new MediaDeviceSession instance which is to - * represent the use of a specific MediaDevice by a - * MediaStream. - * - * @param device the MediaDevice the use of which by a - * MediaStream is to be represented by the new instance - */ - protected AudioMediaDeviceSession(AbstractMediaDevice device) - { - super(device); - } - - /** - * Called by {@link MediaDeviceSession#playerControllerUpdate( - * ControllerEvent event)} when the player associated with this session's - * ReceiveStream moves enters the Configured state, so - * we use the occasion to add our audio level effect. - * - * @param player the Player which is the source of a - * ConfigureCompleteEvent - * @see MediaDeviceSession#playerConfigureComplete(Processor) - */ - @Override - protected void playerConfigureComplete(Processor player) - { - super.playerConfigureComplete(player); - - TrackControl tcs[] = player.getTrackControls(); - - if (tcs != null) - { - for (TrackControl tc : tcs) - { - if (tc.getFormat() instanceof AudioFormat) - { - // Assume there is only one audio track. - try - { - registerStreamAudioLevelJMFEffect(tc); - } - catch (UnsupportedPlugInException upie) - { - logger.error( - "Failed to register stream audio level Effect", - upie); - } - break; - } - } - } - } - - /** - * Gets notified about ControllerEvents generated by the - * processor reading our capture data source, calls the corresponding - * method from the parent class so that it would initialize the processor - * and then adds the level effect for the local user audio levels. - * - * @param event the ControllerEvent specifying the - * Controller which is the source of the event and the very type of - * the event - */ - @Override - protected void processorControllerUpdate(ControllerEvent event) - { - super.processorControllerUpdate(event); - - if (event instanceof ConfigureCompleteEvent) - { - Processor processor = (Processor) event.getSourceController(); - - if (processor != null) - registerLocalUserAudioLevelEffect(processor); - } - } - - /** - * Creates an audio level effect and add its to the codec chain of the - * TrackControl assuming that it only contains a single track. - * - * @param processor the processor on which track control we need - * to register a level effect with. - */ - protected void registerLocalUserAudioLevelEffect(Processor processor) - { - //we register the effect regardless of whether or not we have any - //listeners at this point because we won't get a second chance. - //however the effect would do next to nothing unless we register a - //first listener with it. - // - //XXX: i am assuming that a single effect could be reused multiple times - // if that turns out not to be the case we need to create a new instance - // here. - - // here we add sound level indicator for captured media - // from the microphone if there are interested listeners - try - { - TrackControl tcs[] = processor.getTrackControls(); - - if (tcs != null) - for (TrackControl tc : tcs) - if (tc.getFormat() instanceof AudioFormat) - { - //we assume a single track - tc.setCodecChain( - new Codec[] { localUserAudioLevelEffect }); - break; - } - } - catch (UnsupportedPlugInException ex) - { - logger.error( - "Effects are not supported by the datasource.", ex); - } - } - - /** - * Adds an audio level effect to the tracks of the specified - * trackControl and so that we would notify interested listeners - * of audio level changes. - * - * @param trackControl the TrackControl where we need to register - * a level effect that would measure the audio levels of the - * ReceiveStream associated with this class. - * - * @throws UnsupportedPlugInException if we fail to add our sound level - * effect to the track control of mediaStream's processor. - */ - private void registerStreamAudioLevelJMFEffect(TrackControl trackControl) - throws UnsupportedPlugInException - { - //we register the effect regardless of whether or not we have any - //listeners at this point because we won't get a second chance. - //however the effect would do next to nothing unless we register a - //first listener with it. - // Assume there is only one audio track - trackControl.setCodecChain(new Codec[] { streamAudioLevelEffect }); - } - - /** - * Sets the SimpleAudioLevelListener that this session should be - * notifying about changes in local audio level related information. This - * class only supports a single listener for audio changes per source - * (i.e. stream or data source). Audio changes are generally quite time - * intensive (~ 50 per second) so we are doing this in order to reduce the - * number of objects associated with the process (such as event instances - * listener list iterators and sync copies). - * - * @param listener the SimpleAudioLevelListener to add - */ - public void setLocalUserAudioLevelListener( - SimpleAudioLevelListener listener) - { - this.localUserAudioLevelEffect.setAudioLevelListener(listener); - } - - /** - * Sets listener as the SimpleAudioLevelListener that we - * are going to notify every time a change occurs in the audio level of - * the media that this device session is receiving from the remote party. - * This class only supports a single listener for audio changes per source - * (i.e. stream or data source). Audio changes are generally quite time - * intensive (~ 50 per second) so we are doing this in order to reduce the - * number of objects associated with the process (such as event instances - * listener list iterators and sync copies). - * - * @param listener the SimpleAudioLevelListener that we want - * notified for audio level changes in the remote participant's media. - */ - public void setStreamAudioLevelListener(SimpleAudioLevelListener listener) - { - this.streamAudioLevelEffect.setAudioLevelListener(listener); - } - - /** - * Returns the last audio level that was measured by this device session - * for the specified ssrc. - * - * @param ssrc the SSRC ID whose last measured audio level we'd like to - * retrieve. - * - * @return the audio level that was last measured for the specified - * ssrc or -1 if no level has been cached for that ID. - */ - public int getLastMeasuredAudioLevel(long ssrc) - { - return -1; - } - - /** - * Returns the last audio level that was measured by the underlying - * mixer for local user. - * - * @return the audio level that was last measured for the local user. - */ - public int getLastMeasuredLocalUserAudioLevel() - { - return -1; - } - - /** - * Copies the playback part of a specific MediaDeviceSession into - * this instance. - * - * @param deviceSession the MediaDeviceSession to copy the playback - * part of into this instance - */ - @Override - public void copyPlayback(MediaDeviceSession deviceSession) - { - AudioMediaDeviceSession amds = (AudioMediaDeviceSession) deviceSession; - - this.setStreamAudioLevelListener( - amds.streamAudioLevelEffect.getAudioLevelListener()); - this.setLocalUserAudioLevelListener( - amds.localUserAudioLevelEffect.getAudioLevelListener()); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/AudioMixerMediaDevice.java b/src/net/java/sip/communicator/impl/neomedia/device/AudioMixerMediaDevice.java deleted file mode 100644 index 295e59fe9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/AudioMixerMediaDevice.java +++ /dev/null @@ -1,1239 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.io.*; -import java.net.*; -import java.util.*; -import java.beans.*; - -import javax.media.*; -import javax.media.protocol.*; -import javax.media.rtp.*; - -import net.java.sip.communicator.impl.neomedia.audiolevel.*; -import net.java.sip.communicator.impl.neomedia.conference.*; -import net.java.sip.communicator.impl.neomedia.protocol.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.event.*; -import net.java.sip.communicator.service.neomedia.format.*; -import net.java.sip.communicator.util.*; - -/** - * Implements a MediaDevice which performs audio mixing using - * {@link AudioMixer}. - * - * @author Lyubomir Marinov - * @author Emil Ivov - */ -public class AudioMixerMediaDevice - extends AbstractMediaDevice - implements MediaDeviceWrapper -{ - /** - * The Logger used by AudioMixerMediaDevice and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(AudioMixerMediaDevice.class); - - /** - * The AudioMixer which performs audio mixing in this - * MediaDevice (and rather the session that it represents). - */ - private AudioMixer audioMixer; - - /** - * The actual AudioMediaDeviceImpl wrapped by this instance for the - * purposes of audio mixing and used by {@link #audioMixer} as its - * CaptureDevice. - */ - private final AudioMediaDeviceImpl device; - - /** - * The MediaDeviceSession of this AudioMixer with - * {@link #device}. - */ - private AudioMixerMediaDeviceSession deviceSession; - - /** - * The SimpleAudioLevelListener which is registered (or is to be - * registered) with {@link #localUserAudioLevelDispatcher} and which - * delivers each of the audio level changes to - * {@link #localUserAudioLevelListeners}. - */ - private final SimpleAudioLevelListener localUserAudioLevelDelegate - = new SimpleAudioLevelListener() - { - public void audioLevelChanged(int level) - { - lastMeasuredLocalUserAudioLevel = level; - fireLocalUserAudioLevelChanged(level); - } - }; - - /** - * The dispatcher that delivers to listeners calculations of the local - * audio level. - */ - private final AudioLevelEventDispatcher localUserAudioLevelDispatcher - = new AudioLevelEventDispatcher( - "Local User Audio Level Dispatcher (Mixer Edition)"); - - /** - * The List where we store all listeners interested in changes of - * the local audio level and the number of times each one of them has been - * added. We wrap listeners because we may have multiple subscriptions with - * the same listener and we would only store it once. If one of the multiple - * subscriptions of a particular listener is removed, however, we wouldn't - * want to reset the listener to null as there are others still - * interested, and hence the referenceCount in the wrapper. - *

- * Note: localUserAudioLevelListeners is a copy-on-write - * storage and access to it is synchronized by - * {@link #localUserAudioLevelListenersSyncRoot}. - *

- */ - private List - localUserAudioLevelListeners - = new ArrayList(); - - /** - * The Object which synchronizes the access to - * {@link #localUserAudioLevelListeners}. - */ - private final Object localUserAudioLevelListenersSyncRoot = new Object(); - - /** - * The levels map that we use to cache last measured audio levels for all - * streams associated with this mixer. - */ - private final AudioLevelMap audioLevelCache = new AudioLevelMap(); - - /** - * The most recently measured level of the locally captured audio stream. - */ - private int lastMeasuredLocalUserAudioLevel = 0; - - /** - * The List of RTP extensions supported by this device (at the time - * of writing this list is only filled for audio devices and is - * null otherwise). - */ - private List rtpExtensions = null; - - /** - * The Map where we store audio level dispatchers and the - * streams they are interested in. - */ - private final Map - streamAudioLevelListeners - = new HashMap(); - - /** - * Initializes a new AudioMixerMediaDevice instance which is to - * enable audio mixing on a specific AudioMediaDeviceImpl. - * - * @param device the AudioMediaDeviceImpl which the new instance is - * to enable audio mixing on - */ - public AudioMixerMediaDevice(AudioMediaDeviceImpl device) - { - /* - * AudioMixer is initialized with a CaptureDevice so we have to be sure - * that the wrapped device can provide one. - */ - if (!device.getDirection().allowsSending()) - throw - new IllegalArgumentException("device must be able to capture"); - - this.device = device; - } - - /** - * Connects to a specific CaptureDevice given in the form of a - * DataSource. - * - * @param captureDevice the CaptureDevice to be connected to - * @throws IOException if anything wrong happens while connecting to the - * specified captureDevice - * @see AbstractMediaDevice#connect(DataSource) - */ - @Override - public void connect(DataSource captureDevice) - throws IOException - { - DataSource effectiveCaptureDevice = captureDevice; - - /* - * Unwrap wrappers of the captureDevice until - * AudioMixingPushBufferDataSource is found. - */ - if (captureDevice instanceof PushBufferDataSourceDelegate) - captureDevice - = ((PushBufferDataSourceDelegate) captureDevice) - .getDataSource(); - - /* - * AudioMixingPushBufferDataSource is definitely not a CaptureDevice - * and does not need the special connecting defined by - * AbstractMediaDevice and MediaDeviceImpl. - */ - if (captureDevice instanceof AudioMixingPushBufferDataSource) - effectiveCaptureDevice.connect(); - else - device.connect(effectiveCaptureDevice); - } - - /** - * Creates a DataSource instance for this MediaDevice - * which gives access to the captured media. - * - * @return a DataSource instance which gives access to the media - * captured by this MediaDevice - * @see AbstractMediaDevice#createOutputDataSource() - */ - public AudioMixingPushBufferDataSource createOutputDataSource() - { - return getAudioMixer().createOutputDataSource(); - } - - /** - * Initializes a new Renderer instance which is to play back media - * on this MediaDevice. - * - * @return a new Renderer instance which is to play back media on - * this MediaDevice or null if a suitable - * Renderer is to be chosen irrespective of this - * MediaDevice - */ - Renderer createRenderer() - { - return device.createRenderer(); - } - - /** - * Creates a new MediaDeviceSession instance which is to represent - * the use of this MediaDevice by a MediaStream. - * - * @return a new MediaDeviceSession instance which is to represent - * the use of this MediaDevice by a MediaStream - * @see AbstractMediaDevice#createSession() - */ - @Override - public synchronized MediaDeviceSession createSession() - { - if (deviceSession == null) - deviceSession = new AudioMixerMediaDeviceSession(); - return new MediaStreamMediaDeviceSession(deviceSession); - } - - /** - * Notifies the SimpleAudioLevelListeners registered with this - * instance about the new/current audio level of the local media stream. - * - * @param level the new/current audio level of the local media stream. - */ - private void fireLocalUserAudioLevelChanged(int level) - { - List localUserAudioLevelListeners; - - synchronized(localUserAudioLevelListenersSyncRoot) - { - /* - * It is safe to not copy the localUserAudioLevelListeners of this - * instance here because it is a copy-on-write storage. - */ - localUserAudioLevelListeners = this.localUserAudioLevelListeners; - } - - /* - * XXX These events are going to happen veeery often (~50 times per sec) - * and we'd like to avoid creating an iterator every time. - */ - int localUserAudioLevelListenerCount - = localUserAudioLevelListeners.size(); - - for(int i = 0; i < localUserAudioLevelListenerCount; i++) - localUserAudioLevelListeners.get(i).listener.audioLevelChanged( - level); - } - - /** - * Gets the AudioMixer which performs audio mixing in this - * MediaDevice (and rather the session it represents). If it still - * does not exist, it is created. - * - * @return the AudioMixer which performs audio mixing in this - * MediaDevice (and rather the session it represents) - */ - private synchronized AudioMixer getAudioMixer() - { - if (audioMixer == null) - audioMixer = new AudioMixer(device.createCaptureDevice()) - { - @Override - protected void connect( - DataSource dataSource, - DataSource inputDataSource) - throws IOException - { - /* - * CaptureDevice needs special connecting as defined by - * AbstractMediaDevice and, especially, MediaDeviceImpl. - */ - if (inputDataSource == captureDevice) - AudioMixerMediaDevice.this.connect(dataSource); - else - super.connect(dataSource, inputDataSource); - } - - @Override - protected void read( PushBufferStream stream, - Buffer buffer, - DataSource dataSource) - throws IOException - { - super.read(stream, buffer, dataSource); - - /* - * XXX The audio read from the specified stream has not been - * made available to the mixing yet. Slow code here is - * likely to degrade the performance of the whole mixer. - */ - if (dataSource == captureDevice) - { - /* - * The audio of the very CaptureDevice to be contributed - * to the mix. - */ - synchronized(localUserAudioLevelListenersSyncRoot) - { - if (localUserAudioLevelListeners.isEmpty()) - return; - } - - localUserAudioLevelDispatcher.addData(buffer); - - } - else if (dataSource - instanceof ReceiveStreamPushBufferDataSource) - { - /* - * The audio of a ReceiveStream to be contributed to the - * mix. - */ - ReceiveStream receiveStream - = ((ReceiveStreamPushBufferDataSource) dataSource) - .getReceiveStream(); - AudioLevelEventDispatcher streamEventDispatcher; - - synchronized (streamAudioLevelListeners) - { - streamEventDispatcher - = streamAudioLevelListeners.get(receiveStream); - } - - if ((streamEventDispatcher != null) - && !buffer.isDiscard() - && (buffer.getLength() > 0) - && (buffer.getData() != null)) - { - streamEventDispatcher.addData(buffer); - } - } - } - }; - return audioMixer; - } - - /** - * Returns the MediaDirection supported by this device. - * - * @return {@link MediaDirection#SENDONLY} if this is a read-only device, - * {@link MediaDirection#RECVONLY} if this is a write-only device or - * {@link MediaDirection#SENDRECV} if this MediaDevice can both - * capture and render media - * @see MediaDevice#getDirection() - */ - public MediaDirection getDirection() - { - return device.getDirection(); - } - - /** - * Gets the MediaFormat in which this MediaDevice
captures - * media. - * - * @return the MediaFormat in which this MediaDevice - * captures media - * @see MediaDevice#getFormat() - */ - public MediaFormat getFormat() - { - return device.getFormat(); - } - - /** - * Gets the MediaType that this device supports. - * - * @return {@link MediaType#AUDIO} if this is an audio device or - * {@link MediaType#VIDEO} if this is a video device - * @see MediaDevice#getMediaType() - */ - public MediaType getMediaType() - { - return device.getMediaType(); - } - - /** - * Returns a List containing (at the time of writing) a single - * extension descriptor indicating SENDRECV for mixer-to-client - * audio levels. - * - * @return a List containing the CSRC_AUDIO_LEVEL_URN - * extension descriptor. - */ - @Override - public List getSupportedExtensions() - { - if (rtpExtensions == null) - { - rtpExtensions = new ArrayList(1); - - URI csrcAudioLevelURN; - try - { - csrcAudioLevelURN = new URI(RTPExtension.CSRC_AUDIO_LEVEL_URN); - } - catch (URISyntaxException e) - { - // can't happen since CSRC_AUDIO_LEVEL_URN is a valid URI and - // never changes. - if (logger.isInfoEnabled()) - logger.info("Aha! Someone messed with the source!", e); - return null; - } - - rtpExtensions.add(new RTPExtension( - csrcAudioLevelURN, MediaDirection.SENDRECV)); - } - - return rtpExtensions; - } - - /** - * Gets the list of MediaFormats supported by this - * MediaDevice. - * - * @param sendPreset not used - * @param receivePreset not used - * @return the list of MediaFormats supported by this - * MediaDevice - * @see MediaDevice#getSupportedFormats() - */ - public List getSupportedFormats( - QualityPreset sendPreset, - QualityPreset receivePreset) - { - return device.getSupportedFormats(); - } - - /** - * Gets the actual MediaDevice which this MediaDevice is - * effectively built on top of and forwarding to. - * - * @return the actual MediaDevice which this MediaDevice - * is effectively built on top of and forwarding to - * @see MediaDeviceWrapper#getWrappedDevice() - */ - public MediaDevice getWrappedDevice() - { - return device; - } - - /** - * Removes the DataSource accepted by a specific - * DataSourceFilter from the list of input DataSource of - * the AudioMixer of this AudioMixerMediaDevice from - * which it reads audio to be mixed. - * - * @param dataSourceFilter the DataSourceFilter which selects the - * DataSources to be removed - */ - void removeInputDataSources(DataSourceFilter dataSourceFilter) - { - AudioMixer audioMixer = this.audioMixer; - - if (audioMixer != null) - audioMixer.removeInputDataSources(dataSourceFilter); - } - - /** - * Represents the one and only MediaDeviceSession with the - * MediaDevice of this AudioMixer - */ - private class AudioMixerMediaDeviceSession - extends MediaDeviceSession - { - /** - * The list of MediaDeviceSessions of MediaStreams - * which use this AudioMixer. - */ - private final List - mediaStreamMediaDeviceSessions - = new LinkedList(); - - /** - * Initializes a new AudioMixingMediaDeviceSession which is to - * represent the MediaDeviceSession of this AudioMixer - * with its MediaDevice - */ - public AudioMixerMediaDeviceSession() - { - super(AudioMixerMediaDevice.this); - } - - /** - * Adds l to the list of listeners that are being notified of - * new local audio levels as they change. If l is added - * multiple times it would only be registered once. - * - * @param l the listener we'd like to add. - */ - public void addLocalUserAudioLevelListener(SimpleAudioLevelListener l) - { - // If the listener is null, we have nothing more to do here. - if (l == null) - return; - - synchronized(localUserAudioLevelListenersSyncRoot) - { - //if this is the first listener that we are seeing then we also - //need to create the dispatcher. - if (localUserAudioLevelListeners.isEmpty()) - { - localUserAudioLevelDispatcher.setAudioLevelListener( - localUserAudioLevelDelegate); - } - - //check if this listener has already been added. - SimpleAudioLevelListenerWrapper wrapper - = new SimpleAudioLevelListenerWrapper(l); - int index = localUserAudioLevelListeners.indexOf(wrapper); - - if( index != -1) - { - wrapper = localUserAudioLevelListeners.get(index); - wrapper.referenceCount++; - } - else - { - /* - * XXX localUserAudioLevelListeners must be a copy-on-write - * storage so that firing events to its - * SimpleAudioLevelListeners can happen outside a block - * synchronized by localUserAudioLevelListenersSyncRoot and - * thus reduce the chances for a deadlock (which was, - * otherwise, observed in practice). - */ - localUserAudioLevelListeners - = new ArrayList( - localUserAudioLevelListeners); - localUserAudioLevelListeners.add(wrapper); - } - } - } - - /** - * Adds a specific MediaStreamMediaDeviceSession to the mix - * represented by this instance so that it knows when it is in use. - * - * @param mediaStreamMediaDeviceSession the - * MediaStreamMediaDeviceSession to be added to the mix - * represented by this instance - */ - void addMediaStreamMediaDeviceSession( - MediaStreamMediaDeviceSession mediaStreamMediaDeviceSession) - { - if (mediaStreamMediaDeviceSession == null) - throw new NullPointerException("mediaStreamMediaDeviceSession"); - - synchronized (mediaStreamMediaDeviceSessions) - { - if (!mediaStreamMediaDeviceSessions - .contains(mediaStreamMediaDeviceSession)) - mediaStreamMediaDeviceSessions - .add(mediaStreamMediaDeviceSession); - } - } - - /** - * Adds a specific DataSource providing remote audio to the mix - * produced by the associated MediaDevice. - * - * @param playbackDataSource the DataSource providing remote - * audio to be added to the mix produced by the associated - * MediaDevice - */ - @Override - public void addPlaybackDataSource(DataSource playbackDataSource) - { - /* - * We don't play back the contributions of the conference members - * separately, we have a single playback of the mix of all - * contributions but ours. - */ - super.addPlaybackDataSource( - (AudioMixingPushBufferDataSource) getCaptureDevice()); - } - - /** - * Adds a specific ReceiveStream to the list of - * ReceiveStreams known to this instance to be contributing - * audio to the mix produced by its associated AudioMixer. - * - * @param receiveStream the ReceiveStream to be added to the - * list of ReceiveStreams known to this instance to be - * contributing audio to the mix produced by its associated - * AudioMixer - */ - @Override - public void addReceiveStream(ReceiveStream receiveStream) - { - addSSRC(receiveStream.getSSRC()); - } - - /** - * Creates the DataSource that this instance is to read - * captured media from. Since this is the MediaDeviceSession of - * this AudioMixer with its MediaDevice, returns the - * localOutputDataSource of the AudioMixer i.e. the - * DataSource which represents the mix of all - * ReceiveStreams and excludes the captured data from the - * MediaDevice of the AudioMixer. - * - * @return the DataSource that this instance is to read - * captured media from - * @see MediaDeviceSession#createCaptureDevice() - */ - @Override - protected DataSource createCaptureDevice() - { - return getAudioMixer().getLocalOutputDataSource(); - } - - /** - * Sets listener as the list of listeners that will receive - * notifications of audio level event changes in the data arriving from - * stream. - * - * @param stream the stream that l would like to register as - * an audio level listener for. - * @param listener the listener we'd like to register for notifications - * from stream. - */ - public void setStreamAudioLevelListener( - ReceiveStream stream, - SimpleAudioLevelListener listener) - { - synchronized(streamAudioLevelListeners) - { - AudioLevelEventDispatcher dispatcher - = streamAudioLevelListeners.get(stream); - - if (listener == null) - { - if (dispatcher != null) - { - try - { - dispatcher.setAudioLevelListener(null); - dispatcher.setAudioLevelCache(null, -1); - } - finally - { - streamAudioLevelListeners.remove(dispatcher); - } - } - } - else - { - if (dispatcher == null) - { - dispatcher - = new AudioLevelEventDispatcher( - "Stream Audio Level Dispatcher" - + " (Mixer Edition)"); - dispatcher.setAudioLevelCache( - audioLevelCache, - stream.getSSRC()); - streamAudioLevelListeners.put(stream, dispatcher); - } - dispatcher.setAudioLevelListener(listener); - } - } - } - - /** - * Removes l from the list of listeners that are being - * notified of local audio levels.If l is not in the list, - * the method has no effect. - * - * @param l the listener we'd like to remove. - */ - public void removeLocalUserAudioLevelListener( - SimpleAudioLevelListener l) - { - synchronized(localUserAudioLevelListenersSyncRoot) - { - //check if this listener has already been added. - int index - = localUserAudioLevelListeners.indexOf( - new SimpleAudioLevelListenerWrapper(l)); - - if( index != -1) - { - SimpleAudioLevelListenerWrapper wrapper - = localUserAudioLevelListeners.get(index); - - if(wrapper.referenceCount > 1) - wrapper.referenceCount--; - else - { - /* - * XXX localUserAudioLevelListeners must be a - * copy-on-write storage so that firing events to its - * SimpleAudioLevelListeners can happen outside a block - * synchronized by localUserAudioLevelListenersSyncRoot - * and thus reduce the chances for a deadlock (whic - * was, otherwise, observed in practice). - */ - localUserAudioLevelListeners - = new ArrayList( - localUserAudioLevelListeners); - localUserAudioLevelListeners.remove(wrapper); - } - } - - //if this was the last listener then we also need to remove the - //dispatcher - if (localUserAudioLevelListeners.isEmpty()) - localUserAudioLevelDispatcher.setAudioLevelListener(null); - } - } - - /** - * Removes a specific MediaStreamMediaDeviceSession from the - * mix represented by this instance. When the last - * MediaStreamMediaDeviceSession is removed from this instance, - * it is no longer in use and closes itself thus signaling to its - * MediaDevice that it is no longer in use. - * - * @param mediaStreamMediaDeviceSession the - * MediaStreamMediaDeviceSession to be removed from the mix - * represented by this instance - */ - void removeMediaStreamMediaDeviceSession( - MediaStreamMediaDeviceSession mediaStreamMediaDeviceSession) - { - if (mediaStreamMediaDeviceSession != null) - { - synchronized (mediaStreamMediaDeviceSessions) - { - if (mediaStreamMediaDeviceSessions - .remove(mediaStreamMediaDeviceSession) - && mediaStreamMediaDeviceSessions.isEmpty()) - close(); - } - } - } - - /** - * Removes a specific DataSource providing remote audio from - * the mix produced by the associated AudioMixer. - * - * @param playbackDataSource the DataSource providing remote - * audio to be removed from the mix produced by the associated - * AudioMixer - */ - @Override - public void removePlaybackDataSource( - final DataSource playbackDataSource) - { - removeInputDataSources( - new DataSourceFilter() - { - public boolean accept(DataSource dataSource) - { - return dataSource.equals(playbackDataSource); - } - }); - } - - /** - * Removes a specific ReceiveStream from the list of - * ReceiveStreams known to this instance to be contributing - * audio to the mix produced by its associated AudioMixer. - * - * @param receiveStream the ReceiveStream to be removed from - * the list of ReceiveStreams known to this instance to be - * contributing audio to the mix produced by its associated - * AudioMixer - */ - @Override - public void removeReceiveStream(ReceiveStream receiveStream) - { - removeSSRC(receiveStream.getSSRC()); - - //make sure we no longer cache levels for that stream. - audioLevelCache.removeLevel(receiveStream.getSSRC()); - } - } - - /** - * Represents the work of a MediaStream with the - * MediaDevice of an AudioMixer and the contribution of - * that MediaStream to the mix. - */ - private static class MediaStreamMediaDeviceSession - extends AudioMediaDeviceSession - implements PropertyChangeListener - { - /** - * The MediaDeviceSession of the AudioMixer that this - * instance exposes to a MediaStream. While there are multiple - * MediaStreamMediaDeviceSessions each servicing a specific - * MediaStream, they all share and delegate to one and the same - * AudioMixerMediaDeviceSession so that they all contribute to - * the mix. - */ - private final AudioMixerMediaDeviceSession audioMixerMediaDeviceSession; - - /** - * We use this field to keep a reference to the listener that we've - * registered with the audio mixer for local audio level notifications. - * We use this reference so that we could unregister it if someone - * resets it or sets it to null. - */ - private SimpleAudioLevelListener localUserAudioLevelListener = null; - - /** - * We use this field to keep a reference to the listener that we've - * registered with the audio mixer for stream audio level notifications. - * We use this reference so because at the time we get it from the - * MediaStream it might be too early to register it with the - * mixer as it is like that we don't have a receive stream yet. If - * that's the case, we hold on to the listener and register it only - * when we get the ReceiveStream. - */ - private SimpleAudioLevelListener streamAudioLevelListener = null; - - /** - * The Object that we use to lock operations on - * streamAudioLevelListener. - */ - private final Object streamAudioLevelListenerLock = new Object(); - - /** - * Initializes a new MediaStreamMediaDeviceSession which is to - * represent the work of a MediaStream with the - * MediaDevice of this AudioMixer and its contribution - * to the mix. - * - * @param audioMixerMediaDeviceSession the MediaDeviceSession - * of the AudioMixer with its MediaDevice which the - * new instance is to delegate to in order to contribute to the mix - */ - public MediaStreamMediaDeviceSession( - AudioMixerMediaDeviceSession audioMixerMediaDeviceSession) - { - super(audioMixerMediaDeviceSession.getDevice()); - - this.audioMixerMediaDeviceSession = audioMixerMediaDeviceSession; - this.audioMixerMediaDeviceSession - .addMediaStreamMediaDeviceSession(this); - - this.audioMixerMediaDeviceSession.addPropertyChangeListener(this); - } - - /** - * Releases the resources allocated by this instance in the course of - * its execution and prepares it to be garbage collected. - * - * @see MediaDeviceSession#close() - */ - @Override - public void close() - { - try - { - super.close(); - } - finally - { - audioMixerMediaDeviceSession - .removeMediaStreamMediaDeviceSession(this); - } - } - - /** - * Creates a new Player for a specific DataSource so - * that it is played back on the MediaDevice represented by - * this instance. - * - * @param dataSource the DataSource to create a new - * Player for - * @return a new Player for the specified dataSource - * @see MediaDeviceSession#createPlayer(DataSource) - */ - @Override - protected Player createPlayer(DataSource dataSource) - { - /* - * We don't want the contribution of each conference member played - * back separately, we want the one and only mix of all - * contributions but ours to be played back once for all of them. - */ - return null; - } - - /** - * Returns the list of SSRC identifiers that are directly contributing - * to the media flows that we are sending out. Note that since this is - * a pseudo device we would simply be delegating the call to the - * corresponding method of the master mixer device session. - * - * @return a long[] array of SSRC identifiers that are - * currently contributing to the mixer encapsulated by this device - * session. - */ - @Override - public long[] getRemoteSSRCList() - { - return audioMixerMediaDeviceSession.getRemoteSSRCList(); - } - - /** - * Notifies this MediaDeviceSession that a DataSource - * has been added for playback on the represented MediaDevice. - * - * @param playbackDataSource the DataSource which has been - * added for playback on the represented MediaDevice - * @see MediaDeviceSession#playbackDataSourceAdded(DataSource) - */ - @Override - protected void playbackDataSourceAdded(DataSource playbackDataSource) - { - super.playbackDataSourceAdded(playbackDataSource); - - DataSource captureDevice = getCaptureDevice(); - - /* - * Unwrap wrappers of the captureDevice until - * AudioMixingPushBufferDataSource is found. - */ - if (captureDevice instanceof PushBufferDataSourceDelegate) - captureDevice - = ((PushBufferDataSourceDelegate) captureDevice) - .getDataSource(); - if (captureDevice instanceof AudioMixingPushBufferDataSource) - ((AudioMixingPushBufferDataSource) captureDevice) - .addInputDataSource(playbackDataSource); - - audioMixerMediaDeviceSession.addPlaybackDataSource( - playbackDataSource); - } - - /** - * Notifies this MediaDeviceSession that a DataSource - * has been removed from playback on the represented - * MediaDevice. - * - * @param playbackDataSource the DataSource which has been - * removed from playback on the represented MediaDevice - * @see MediaDeviceSession#playbackDataSourceRemoved(DataSource) - */ - @Override - protected void playbackDataSourceRemoved(DataSource playbackDataSource) - { - super.playbackDataSourceRemoved(playbackDataSource); - - audioMixerMediaDeviceSession.removePlaybackDataSource( - playbackDataSource); - } - - /** - * The method relays PropertyChangeEvents indicating a change - * in the SSRC_LIST in the encapsulated mixer device so that the - * MediaStream that uses this device session can update its - * CSRC list. - * - * @param evt that PropertyChangeEvent whose old and new value - * we will be relaying to the stream. - */ - public void propertyChange(PropertyChangeEvent evt) - { - if (MediaDeviceSession.SSRC_LIST.equals(evt.getPropertyName())) - firePropertyChange( - MediaDeviceSession.SSRC_LIST, - evt.getOldValue(), - evt.getNewValue()); - } - - /** - * Notifies this instance that a specific ReceiveStream has - * been added to the list of playbacks of ReceiveStreams and/or - * DataSources performed by respective Players on the - * MediaDevice represented by this instance. - * - * @param receiveStream the ReceiveStream which has been added - * to the list of playbacks of ReceiveStreams and/or - * DataSources performed by respective Players on the - * MediaDevice represented by this instance - */ - @Override - protected void receiveStreamAdded(ReceiveStream receiveStream) - { - super.receiveStreamAdded(receiveStream); - - /* - * If someone registered a stream level listener, we can now add it - * since we have the stream that it's supposed to listen to. - */ - synchronized(streamAudioLevelListenerLock) - { - if(this.streamAudioLevelListener != null) - audioMixerMediaDeviceSession.setStreamAudioLevelListener( - receiveStream, - streamAudioLevelListener); - } - - audioMixerMediaDeviceSession.addReceiveStream(receiveStream); - } - - /** - * Notifies this instance that a specific ReceiveStream has - * been removed from the list of playbacks of ReceiveStreams - * and/or DataSources performed by respective Players - * on the MediaDevice represented by this instance. - * - * @param receiveStream the ReceiveStream which has been - * removed from the list of playbacks of ReceiveStreams and/or - * DataSources performed by respective Players on the - * MediaDevice represented by this instance - */ - @Override - protected void receiveStreamRemoved(ReceiveStream receiveStream) - { - super.receiveStreamRemoved(receiveStream); - - audioMixerMediaDeviceSession.removeReceiveStream(receiveStream); - } - - /** - * Override it here cause we won't register effects to that stream - * cause we already have one. - * - * @param processor the processor. - */ - @Override - protected void registerLocalUserAudioLevelEffect(Processor processor) - { - } - - /** - * Adds a specific SoundLevelListener to the list of listeners - * interested in and notified about changes in local sound level related - * information. - * @param l the SoundLevelListener to add - */ - @Override - public void setLocalUserAudioLevelListener(SimpleAudioLevelListener l) - { - if (localUserAudioLevelListener != null) - { - audioMixerMediaDeviceSession.removeLocalUserAudioLevelListener( - localUserAudioLevelListener); - localUserAudioLevelListener = null; - } - - if (l != null) - { - this.localUserAudioLevelListener = l; - - // add the listener only if we are not muted - // this happens when holding a conversation, stream is muted - // and when recreated listener is again set - if(!isMute()) - audioMixerMediaDeviceSession.addLocalUserAudioLevelListener( - l); - } - } - - /** - * Adds listener to the list of - * SimpleAudioLevelListeners registered with the mixer session - * that this "slave session" encapsulates. This class does not keep a - * reference to listener. - * - * @param listener the SimpleAudioLevelListener that we are to - * pass to the mixer device session or null if we are trying - * to unregister it. - */ - @Override - public void setStreamAudioLevelListener( - SimpleAudioLevelListener listener) - { - synchronized(streamAudioLevelListenerLock) - { - this.streamAudioLevelListener = listener; - - for (ReceiveStream receiveStream : getReceiveStreams()) - { - /* - * If we already have a ReceiveStream, register the listener - * with the mixer; otherwise, wait till we get one. - */ - audioMixerMediaDeviceSession.setStreamAudioLevelListener( - receiveStream, - listener); - } - } - } - - /** - * Returns the last audio level that was measured by the underlying - * mixer for the specified csrc. - * - * @param csrc the CSRC ID whose last measured audio level we'd like to - * retrieve. - * - * @return the audio level that was last measured by the underlying - * mixer for the specified csrc or -1 if the - * csrc does not belong to neither of the conference - * participants. - */ - @Override - public int getLastMeasuredAudioLevel(long csrc) - { - return - ((AudioMixerMediaDevice) getDevice()).audioLevelCache.getLevel( - csrc); - } - - /** - * Returns the last audio level that was measured by the underlying - * mixer for local user. - * - * @return the audio level that was last measured for the local user. - */ - @Override - public int getLastMeasuredLocalUserAudioLevel() - { - return - ((AudioMixerMediaDevice) getDevice()) - .lastMeasuredLocalUserAudioLevel; - } - - /** - * Sets the indicator which determines whether this - * MediaDeviceSession is set to output "silence" instead of the - * actual media fed from its CaptureDevice. - * If we are muted we just remove the local level listener from the - * session. - * - * @param mute true to set this MediaDeviceSession to - * output "silence" instead of the actual media fed from its - * CaptureDevice; otherwise, false - */ - @Override - public void setMute(boolean mute) - { - boolean oldValue = isMute(); - - super.setMute(mute); - - boolean newValue = isMute(); - - if (oldValue != newValue) - { - if (newValue) - { - audioMixerMediaDeviceSession - .removeLocalUserAudioLevelListener( - localUserAudioLevelListener); - } - else - { - audioMixerMediaDeviceSession - .addLocalUserAudioLevelListener( - localUserAudioLevelListener); - } - } - } - } - - /** - * A very lightweight wrapper that allows us to track the number of times - * that a particular listener was added. - */ - private static class SimpleAudioLevelListenerWrapper - { - /** The listener being wrapped by this wrapper. */ - public final SimpleAudioLevelListener listener; - - /** The number of times this listener has been added. */ - int referenceCount; - - /** - * Creates a wrapper of the l listener. - * - * @param l the listener we'd like to wrap; - */ - public SimpleAudioLevelListenerWrapper(SimpleAudioLevelListener l) - { - this.listener = l; - this.referenceCount = 1; - } - - /** - * Returns true if obj is a wrapping the same listener - * as ours. - * - * @param obj the wrapper we'd like to compare to this instance - * - * @return true if obj is a wrapping the same listener - * as ours. - */ - @Override - public boolean equals(Object obj) - { - return (obj instanceof SimpleAudioLevelListenerWrapper) - && ((SimpleAudioLevelListenerWrapper)obj).listener == listener; - } - - /** - * Returns a hash code value for this instance for the benefit of - * hashtables. - * - * @return a hash code value for this instance for the benefit of - * hashtables - */ - @Override - public int hashCode() - { - /* - * Equality is based on the listener field only so its hashCode is - * enough. Besides, it's the only immutable of this instance i.e. - * the only field appropriate for the calculation of the hashCode. - */ - return listener.hashCode(); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/AudioSystem.java b/src/net/java/sip/communicator/impl/neomedia/device/AudioSystem.java deleted file mode 100644 index fcf70e977..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/AudioSystem.java +++ /dev/null @@ -1,505 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.io.*; -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; - -public abstract class AudioSystem - extends DeviceSystem -{ - public static final int FEATURE_DENOISE = 2; - - public static final int FEATURE_ECHO_CANCELLATION = 4; - - public static final int FEATURE_NOTIFY_AND_PLAYBACK_DEVICES = 8; - - private static final int FLAG_CAPTURE_DEVICE_IS_NULL = 1; - - private static final int FLAG_NOTIFY_DEVICE_IS_NULL = 2; - - private static final int FLAG_PLAYBACK_DEVICE_IS_NULL = 4; - - public static final String LOCATOR_PROTOCOL_AUDIORECORD = "audiorecord"; - - public static final String LOCATOR_PROTOCOL_JAVASOUND = "javasound"; - - public static final String LOCATOR_PROTOCOL_OPENSLES = "opensles"; - - public static final String LOCATOR_PROTOCOL_PORTAUDIO = "portaudio"; - - public static final String LOCATOR_PROTOCOL_PULSEAUDIO = "pulseaudio"; - - public static final String PROP_CAPTURE_DEVICE = "captureDevice"; - - public static final String PROP_NOTIFY_DEVICE = "notifyDevice"; - - public static final String PROP_PLAYBACK_DEVICE = "playbackDevice"; - - public static AudioSystem getAudioSystem(String locatorProtocol) - { - AudioSystem[] audioSystems = getAudioSystems(); - AudioSystem audioSystemWithLocatorProtocol = null; - - if (audioSystems != null) - { - for (AudioSystem audioSystem : audioSystems) - { - if (audioSystem.getLocatorProtocol().equalsIgnoreCase( - locatorProtocol)) - { - audioSystemWithLocatorProtocol = audioSystem; - break; - } - } - } - return audioSystemWithLocatorProtocol; - } - - public static AudioSystem[] getAudioSystems() - { - DeviceSystem[] deviceSystems - = DeviceSystem.getDeviceSystems(MediaType.AUDIO); - List audioSystems; - - if (deviceSystems == null) - audioSystems = null; - else - { - audioSystems = new ArrayList(deviceSystems.length); - for (DeviceSystem deviceSystem : deviceSystems) - if (deviceSystem instanceof AudioSystem) - audioSystems.add((AudioSystem) deviceSystem); - } - return - (audioSystems == null) - ? null - : audioSystems.toArray(new AudioSystem[audioSystems.size()]); - } - - private CaptureDeviceInfo captureDevice; - - private int flags; - - private CaptureDeviceInfo notifyDevice; - - private CaptureDeviceInfo playbackDevice; - - private List playbackDevices; - - protected AudioSystem(String locatorProtocol) - throws Exception - { - this(locatorProtocol, 0); - } - - protected AudioSystem(String locatorProtocol, int features) - throws Exception - { - super(MediaType.AUDIO, locatorProtocol, features); - } - - public CaptureDeviceInfo getCaptureDevice() - { - List captureDevices = null; - - if (this.captureDevice != null) - { - if (captureDevices == null) - captureDevices = getCaptureDevices(); - if ((captureDevices == null) - || !captureDevices.contains(this.captureDevice)) - setCaptureDevice(null, false); - } - - CaptureDeviceInfo captureDevice = this.captureDevice; - - if ((captureDevice == null) - && ((flags & FLAG_CAPTURE_DEVICE_IS_NULL) == 0)) - { - if (captureDevices == null) - captureDevices = getCaptureDevices(); - if ((captureDevices != null) && (captureDevices.size() > 0)) - { - captureDevice = loadDevice(PROP_CAPTURE_DEVICE, captureDevices); - if (captureDevice == null) - captureDevice = captureDevices.get(0); - } - } - return captureDevice; - } - - public List getCaptureDevices() - { - MediaServiceImpl mediaServiceImpl - = NeomediaActivator.getMediaServiceImpl(); - DeviceConfiguration deviceConfiguration - = (mediaServiceImpl == null) - ? null - : mediaServiceImpl.getDeviceConfiguration(); - List deviceList; - - if (deviceConfiguration == null) - { - /* - * XXX The initialization of MediaServiceImpl is very complex so it - * is wise to not reference it at the early stage of its - * initialization. The same goes for DeviceConfiguration. If for - * some reason one of the two is not available at this time, just - * fall back go something that makes sense. - */ - @SuppressWarnings("unchecked") - Vector audioCaptureDeviceInfos - = CaptureDeviceManager.getDeviceList( - new AudioFormat(AudioFormat.LINEAR, -1, 16, -1)); - - deviceList = audioCaptureDeviceInfos; - } - else - { - deviceList = deviceConfiguration.getAvailableAudioCaptureDevices(); - } - - return - filterDeviceListByLocatorProtocol(deviceList, getLocatorProtocol()); - } - - public CaptureDeviceInfo getNotifyDevice() - { - List notifyDevices = null; - - if (this.notifyDevice != null) - { - if (notifyDevices == null) - notifyDevices = getNotifyDevices(); - if ((notifyDevices == null) - || !notifyDevices.contains(this.notifyDevice)) - setNotifyDevice(null, false); - } - - CaptureDeviceInfo notifyDevice = this.notifyDevice; - - if ((notifyDevice == null) - && ((flags & FLAG_NOTIFY_DEVICE_IS_NULL) == 0)) - { - if (notifyDevices == null) - notifyDevices = getNotifyDevices(); - if ((notifyDevices != null) && (notifyDevices.size() > 0)) - { - notifyDevice = loadDevice(PROP_NOTIFY_DEVICE, notifyDevices); - if (notifyDevice == null) - notifyDevice = notifyDevices.get(0); - } - } - return notifyDevice; - } - - public List getNotifyDevices() - { - return getPlaybackDevices(); - } - - public CaptureDeviceInfo getPlaybackDevice() - { - List playbackDevices = null; - - if (this.playbackDevice != null) - { - if (playbackDevices == null) - playbackDevices = getPlaybackDevices(); - if ((playbackDevices == null) - || !playbackDevices.contains(this.playbackDevice)) - setPlaybackDevice(null, false); - } - - CaptureDeviceInfo playbackDevice = this.playbackDevice; - - if ((playbackDevice == null) - && ((flags & FLAG_PLAYBACK_DEVICE_IS_NULL) == 0)) - { - if (playbackDevices == null) - playbackDevices = getPlaybackDevices(); - if ((playbackDevices != null) && (playbackDevices.size() > 0)) - { - playbackDevice - = loadDevice(PROP_PLAYBACK_DEVICE, playbackDevices); - if (playbackDevice == null) - playbackDevice = playbackDevices.get(0); - } - } - return playbackDevice; - } - - public List getPlaybackDevices() - { - List playbackDevices = this.playbackDevices; - - return - (playbackDevices == null) - ? null - : new ArrayList(playbackDevices); - } - - /** - * Loads the user's preference with respect to a CaptureDeviceInfo - * among a specific list of CaptureDeviceInfos from the - * ConfigurationService. - * - * @param property the name of the ConfigurationService property - * which specifies the user's preference with respect to a - * CaptureDeviceInfo among the specified list of - * CaptureDeviceInfos - * @param devices the list of CaptureDeviceInfos which are valid - * selections for the user's preference - * @return a CaptureDeviceInfo among the specified devices - * which represents the user's preference stored in the - * ConfigurationService - */ - private CaptureDeviceInfo loadDevice( - String property, - List devices) - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - property - = DeviceConfiguration.PROP_AUDIO_SYSTEM - + "." - + getLocatorProtocol() - + "." - + property; - - String name = cfg.getString(property); - - if ((name != null) - && !NoneAudioSystem.LOCATOR_PROTOCOL.equalsIgnoreCase(name)) - { - for (CaptureDeviceInfo device : devices) - if (name.equals(device.getName())) - return device; - } - } - return null; - } - - @Override - protected void postInitialize() - { - try - { - super.postInitialize(); - } - finally - { - try - { - if (captureDevice != null) - { - List captureDevices = getCaptureDevices(); - - if ((captureDevices == null) - || !captureDevices.contains(captureDevice)) - setCaptureDevice(null, false); - } - } - finally - { - if ((FEATURE_NOTIFY_AND_PLAYBACK_DEVICES & getFeatures()) != 0) - { - try - { - if (notifyDevice != null) - { - List notifyDevices - = getNotifyDevices(); - - if ((notifyDevices == null) - || !notifyDevices.contains(notifyDevice)) - setNotifyDevice(null, false); - } - } - finally - { - if (playbackDevice != null) - { - List playbackDevices - = getPlaybackDevices(); - - if ((playbackDevices == null) - || !playbackDevices.contains( - playbackDevice)) - setPlaybackDevice(null, false); - } - } - } - } - } - } - - /** - * Saves the user's preference with respect to a specific - * CaptureDeviceInfo in the ConfigurationService. - * - * @param property the name of the ConfigurationService property - * into which the user's preference with respect to the specified - * CaptureDeviceInfo is to be saved - * @param device the CaptureDeviceInfo which is the user's - * preference - * @param isNull true if the user's preference with respect to the - * specified device is null; otherwise, false - */ - private void saveDevice( - String property, - CaptureDeviceInfo device, - boolean isNull) - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - property - = DeviceConfiguration.PROP_AUDIO_SYSTEM - + "." - + getLocatorProtocol() - + "." - + property; - if (device == null) - { - if (isNull) - cfg.setProperty(property, NoneAudioSystem.LOCATOR_PROTOCOL); - else - cfg.removeProperty(property); - } - else - cfg.setProperty(property, device.getName()); - } - } - - public void setCaptureDevice(CaptureDeviceInfo captureDevice, boolean save) - { - if ((this.captureDevice != captureDevice) || (captureDevice == null)) - { - CaptureDeviceInfo oldValue = this.captureDevice; - - this.captureDevice = captureDevice; - - if (save) - { - boolean isNull = (this.captureDevice == null); - - if (isNull) - flags |= FLAG_CAPTURE_DEVICE_IS_NULL; - else - flags &= ~FLAG_CAPTURE_DEVICE_IS_NULL; - - saveDevice(PROP_CAPTURE_DEVICE, this.captureDevice, isNull); - } - - CaptureDeviceInfo newValue = getCaptureDevice(); - - if (oldValue != newValue) - firePropertyChange(PROP_CAPTURE_DEVICE, oldValue, newValue); - } - } - - protected void setCaptureDevices(List captureDevices) - { - if (captureDevices != null) - { - boolean commit = false; - - for (CaptureDeviceInfo captureDevice : captureDevices) - { - CaptureDeviceManager.addDevice(captureDevice); - commit = true; - } - if (commit && !MediaServiceImpl.isJmfRegistryDisableLoad()) - { - try - { - CaptureDeviceManager.commit(); - } - catch (IOException ioe) - { - // Whatever. - } - } - } - } - - public void setNotifyDevice(CaptureDeviceInfo notifyDevice, boolean save) - { - if ((this.notifyDevice != notifyDevice) || (notifyDevice == null)) - { - CaptureDeviceInfo oldValue = this.notifyDevice; - - this.notifyDevice = notifyDevice; - - if (save) - { - boolean isNull = (this.notifyDevice == null); - - if (isNull) - flags |= FLAG_NOTIFY_DEVICE_IS_NULL; - else - flags &= ~FLAG_NOTIFY_DEVICE_IS_NULL; - - saveDevice(PROP_NOTIFY_DEVICE, this.notifyDevice, isNull); - } - - CaptureDeviceInfo newValue = getNotifyDevice(); - - if (oldValue != newValue) - firePropertyChange(PROP_NOTIFY_DEVICE, oldValue, newValue); - } - } - - public void setPlaybackDevice( - CaptureDeviceInfo playbackDevice, - boolean save) - { - if ((this.playbackDevice != playbackDevice) || (playbackDevice == null)) - { - CaptureDeviceInfo oldValue = this.playbackDevice; - - this.playbackDevice = playbackDevice; - - if (save) - { - boolean isNull = (this.playbackDevice == null); - - if (isNull) - flags |= FLAG_PLAYBACK_DEVICE_IS_NULL; - else - flags &= ~FLAG_PLAYBACK_DEVICE_IS_NULL; - - saveDevice(PROP_PLAYBACK_DEVICE, this.playbackDevice, isNull); - } - - CaptureDeviceInfo newValue = getPlaybackDevice(); - - if (oldValue != newValue) - firePropertyChange(PROP_PLAYBACK_DEVICE, oldValue, newValue); - } - } - - protected void setPlaybackDevices(List playbackDevices) - { - this.playbackDevices - = (playbackDevices == null) - ? null - : new ArrayList(playbackDevices); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/DeviceConfiguration.java b/src/net/java/sip/communicator/impl/neomedia/device/DeviceConfiguration.java deleted file mode 100644 index 409f34c4f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/DeviceConfiguration.java +++ /dev/null @@ -1,1131 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.awt.*; -import java.beans.*; -import java.io.*; -import java.util.*; -import java.util.List; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.event.*; - -/** - * This class aims to provide a simple configuration interface for JMF. It - * retrieves stored configuration when started or listens to ConfigurationEvent - * for property changes and configures the JMF accordingly. - * - * @author Martin Andre - * @author Emil Ivov - * @author Lyubomir Marinov - */ -public class DeviceConfiguration - extends PropertyChangeNotifier - implements PropertyChangeListener -{ - - /** - * The name of the DeviceConfiguration property which represents - * the device used by DeviceConfiguration for audio capture. - */ - public static final String AUDIO_CAPTURE_DEVICE - = AudioSystem.PROP_CAPTURE_DEVICE; - - /** - * The name of the DeviceConfiguration property which represents - * the device used by DeviceConfiguration for audio notify. - */ - public static final String AUDIO_NOTIFY_DEVICE - = AudioSystem.PROP_NOTIFY_DEVICE; - - /** - * The name of the DeviceConfiguration property which represents - * the device used by DeviceConfiguration for audio playback. - */ - public static final String AUDIO_PLAYBACK_DEVICE - = AudioSystem.PROP_PLAYBACK_DEVICE; - - /** - * The list of class names of custom Renderer implementations to be - * registered with JMF. - */ - private static final String[] CUSTOM_RENDERERS - = new String[] - { - OSUtils.IS_ANDROID ? ".audio.AudioTrackRenderer" : null, - OSUtils.IS_ANDROID ? ".audio.OpenSLESRenderer" : null, - OSUtils.IS_LINUX ? ".audio.PulseAudioRenderer" : null, - OSUtils.IS_ANDROID ? null : ".audio.PortAudioRenderer", - ".video.JAWTRenderer" - }; - - /** - * The default value to be used for the {@link #PROP_AUDIO_DENOISE} property - * when it does not have a value. - */ - public static final boolean DEFAULT_AUDIO_DENOISE = true; - - /** - * The default value to be used for the {@link #PROP_AUDIO_ECHOCANCEL} - * property when it does not have a value. - */ - public static final boolean DEFAULT_AUDIO_ECHOCANCEL = true; - - /** - * The default value to be used for the - * {@link #PROP_AUDIO_ECHOCANCEL_FILTER_LENGTH_IN_MILLIS} property when it - * does not have a value. The recommended filter length is approximately the - * third of the room reverberation time. For example, in a small room, - * reverberation time is in the order of 300 ms, so a filter length of 100 - * ms is a good choice (800 samples at 8000 Hz sampling rate). - */ - public static final long DEFAULT_AUDIO_ECHOCANCEL_FILTER_LENGTH_IN_MILLIS - = 100; - - /** - * The default frame rate, -1 unlimited. - */ - public static final int DEFAULT_VIDEO_FRAMERATE = -1; - - /** - * The default video height. - */ - public static final int DEFAULT_VIDEO_HEIGHT = 480; - - /** - * The default value for video maximum bandwidth. - */ - public static final int DEFAULT_VIDEO_MAX_BANDWIDTH = 256; - - /** - * The default video width. - */ - public static final int DEFAULT_VIDEO_WIDTH = 640; - - /** - * The name of the boolean property which determines whether noise - * suppression is to be performed for captured audio. - */ - static final String PROP_AUDIO_DENOISE - = "net.java.sip.communicator.impl.neomedia.denoise"; - - /** - * The name of the boolean property which determines whether echo - * cancellation is to be performed for captured audio. - */ - static final String PROP_AUDIO_ECHOCANCEL - = "net.java.sip.communicator.impl.neomedia.echocancel"; - - /** - * The name of the long property which determines the filter length - * in milliseconds to be used by the echo cancellation implementation. The - * recommended filter length is approximately the third of the room - * reverberation time. For example, in a small room, reverberation time is - * in the order of 300 ms, so a filter length of 100 ms is a good choice - * (800 samples at 8000 Hz sampling rate). - */ - static final String PROP_AUDIO_ECHOCANCEL_FILTER_LENGTH_IN_MILLIS - = "net.java.sip.communicator.impl.neomedia.echocancel.filterLengthInMillis"; - - public static final String PROP_AUDIO_SYSTEM - = "net.java.sip.communicator.impl.neomedia.audioSystem"; - - public static final String PROP_AUDIO_SYSTEM_DEVICES - = PROP_AUDIO_SYSTEM + "." + DeviceSystem.PROP_DEVICES; - - /** - * The ConfigurationService property which stores the device used - * by DeviceConfiguration for video capture. - */ - private static final String PROP_VIDEO_DEVICE - = "net.java.sip.communicator.impl.neomedia.videoDevice"; - - /** - * The property we use to store the video framerate settings. - */ - private static final String PROP_VIDEO_FRAMERATE - = "net.java.sip.communicator.impl.neomedia.video.framerate"; - - /** - * The name of the property which specifies the height of the video. - */ - private static final String PROP_VIDEO_HEIGHT - = "net.java.sip.communicator.impl.neomedia.video.height"; - - /** - * The property we use to store the settings for maximum allowed video - * bandwidth. - */ - private static final String PROP_VIDEO_MAX_BANDWIDTH - = "net.java.sip.communicator.impl.neomedia.video.maxbandwidth"; - - /** - * The name of the property which specifies the width of the video. - */ - private static final String PROP_VIDEO_WIDTH - = "net.java.sip.communicator.impl.neomedia.video.width"; - - /** - * The currently supported resolutions we will show as option - * and user can select. - */ - public static final Dimension[] SUPPORTED_RESOLUTIONS - = new Dimension[] - { - // QVGA - new Dimension(160, 100), - //QCIF - new Dimension(176, 144), - // QVGA - new Dimension(320, 200), - // QVGA - new Dimension(320, 240), - //CIF - new Dimension(352, 288), - // VGA - new Dimension(640, 480), - // HD 720 - new Dimension(1280, 720) - }; - - /** - * The name of the DeviceConfiguration property which - * represents the device used by DeviceConfiguration for video - * capture. - */ - public static final String VIDEO_CAPTURE_DEVICE = "VIDEO_CAPTURE_DEVICE"; - - private AudioSystem audioSystem; - - /** - * The frame rate. - */ - private int frameRate = DEFAULT_VIDEO_FRAMERATE; - - /** - * The Logger used by this instance for logging output. - */ - private Logger logger = Logger.getLogger(DeviceConfiguration.class); - - /** - * The device that we'll be using for video capture. - */ - private CaptureDeviceInfo videoCaptureDevice; - - /** - * Current setting for video maximum bandwidth. - */ - private int videoMaxBandwidth = -1; - - /** - * The current resolution settings. - */ - private Dimension videoSize; - - /** - * Initializes a new DeviceConfiguration instance. - */ - public DeviceConfiguration() - { - // these seem to be throwing exceptions every now and then so we'll - // blindly catch them for now - try - { - DeviceSystem.initializeDeviceSystems(); - extractConfiguredCaptureDevices(); - - ConfigurationService cfg - = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - cfg.addPropertyChangeListener(PROP_VIDEO_HEIGHT, this); - cfg.addPropertyChangeListener(PROP_VIDEO_WIDTH, this); - cfg.addPropertyChangeListener(PROP_VIDEO_FRAMERATE, this); - cfg.addPropertyChangeListener(PROP_VIDEO_MAX_BANDWIDTH, this); - } - } - catch (Exception ex) - { - logger.error("Failed to initialize media.", ex); - } - - registerCustomRenderers(); - fixRenderers(); - } - - /** - * Fixes the list of Renderers registered with FMJ in order to - * resolve operating system-specific issues. - */ - private static void fixRenderers() - { - @SuppressWarnings("unchecked") - Vector renderers - = PlugInManager.getPlugInList(null, null, PlugInManager.RENDERER); - - /* - * JMF is no longer in use, FMJ is used in its place. FMJ has its own - * JavaSoundRenderer which is also extended into a JMF-compatible one. - */ - PlugInManager.removePlugIn( - "com.sun.media.renderer.audio.JavaSoundRenderer", - PlugInManager.RENDERER); - - if (OSUtils.IS_WINDOWS) - { - if (OSUtils.IS_WINDOWS32 && - (OSUtils.IS_WINDOWS_VISTA || OSUtils.IS_WINDOWS_7)) - { - /* - * DDRenderer will cause 32-bit Windows Vista/7 to switch its - * theme from Aero to Vista Basic so try to pick up a different - * Renderer. - */ - if (renderers.contains( - "com.sun.media.renderer.video.GDIRenderer")) - { - PlugInManager.removePlugIn( - "com.sun.media.renderer.video.DDRenderer", - PlugInManager.RENDERER); - } - } - else if (OSUtils.IS_WINDOWS64) - { - /* - * Remove the native Renderers for 64-bit Windows because native - * JMF libs are not available for 64-bit machines. - */ - PlugInManager.removePlugIn( - "com.sun.media.renderer.video.GDIRenderer", - PlugInManager.RENDERER); - PlugInManager.removePlugIn( - "com.sun.media.renderer.video.DDRenderer", - PlugInManager.RENDERER); - } - } - else if (!OSUtils.IS_LINUX32) - { - if (renderers.contains( - "com.sun.media.renderer.video.LightWeightRenderer") - || renderers.contains( - "com.sun.media.renderer.video.AWTRenderer")) - { - // Remove XLibRenderer because it is native and JMF is supported - // on 32-bit machines only. - PlugInManager.removePlugIn( - "com.sun.media.renderer.video.XLibRenderer", - PlugInManager.RENDERER); - } - } - } - - /** - * Detects capture devices configured through JMF and disable audio and/or - * video transmission if none were found. - */ - private void extractConfiguredCaptureDevices() - { - extractConfiguredAudioCaptureDevices(); - extractConfiguredVideoCaptureDevices(); - } - - /** - * Returns the configured video capture device with the specified - * output format. - * @param format the output format of the video format. - * @return CaptureDeviceInfo for the video device. - */ - private CaptureDeviceInfo extractConfiguredVideoCaptureDevice(Format format) - { - @SuppressWarnings("unchecked") - List videoCaptureDevices - = CaptureDeviceManager.getDeviceList(format); - CaptureDeviceInfo videoCaptureDevice = null; - - if (videoCaptureDevices.size() > 0) - { - ConfigurationService cfg - = NeomediaActivator.getConfigurationService(); - String videoDevName - = (cfg == null) ? null : cfg.getString(PROP_VIDEO_DEVICE); - - if (videoDevName == null) - videoCaptureDevice = videoCaptureDevices.get(0); - else - { - for (CaptureDeviceInfo captureDeviceInfo : videoCaptureDevices) - { - if (videoDevName.equals(captureDeviceInfo.getName())) - { - videoCaptureDevice = captureDeviceInfo; - break; - } - } - } - - if ((videoCaptureDevice != null) && logger.isInfoEnabled()) - { - logger.info( - "Found " - + videoCaptureDevice.getName() - + " as a " - + format - + " video capture device."); - } - } - return videoCaptureDevice; - } - - /** - * Returns a device that we could use for audio capture. - * - * @return the CaptureDeviceInfo of a device that we could use for audio - * capture. - */ - public CaptureDeviceInfo getAudioCaptureDevice() - { - AudioSystem audioSystem = getAudioSystem(); - - return (audioSystem == null) ? null : audioSystem.getCaptureDevice(); - } - - /** - * Gets the list of audio capture devices which are available through this - * DeviceConfiguration, amongst which is - * {@link #getAudioCaptureDevice()} and represent acceptable values - * for {@link #setAudioCaptureDevice(CaptureDeviceInfo, boolean)} - * - * @return an array of CaptureDeviceInfo describing the audio - * capture devices available through this - * DeviceConfiguration - */ - public List getAvailableAudioCaptureDevices() - { - @SuppressWarnings("unchecked") - Vector audioCaptureDevices - = CaptureDeviceManager.getDeviceList( - new AudioFormat(AudioFormat.LINEAR, -1, 16, -1)); - - return audioCaptureDevices; - } - - public AudioSystem getAudioSystem() - { - return audioSystem; - } - - public AudioSystem[] getAvailableAudioSystems() - { - AudioSystem[] audioSystems = AudioSystem.getAudioSystems(); - - if ((audioSystems == null) || (audioSystems.length == 0)) - return audioSystems; - else - { - List audioSystemsWithDevices - = new ArrayList(); - - for (AudioSystem audioSystem : audioSystems) - { - if (!NoneAudioSystem.LOCATOR_PROTOCOL.equalsIgnoreCase( - audioSystem.getLocatorProtocol())) - { - List captureDevices - = audioSystem.getCaptureDevices(); - - if ((captureDevices == null) - || (captureDevices.size() <= 0)) - { - if ((AudioSystem.FEATURE_NOTIFY_AND_PLAYBACK_DEVICES - & audioSystem.getFeatures()) - == 0) - { - continue; - } - else - { - List notifyDevices - = audioSystem.getNotifyDevices(); - - if ((notifyDevices == null) - || (notifyDevices.size() <= 0)) - { - List playbackDevices - = audioSystem.getPlaybackDevices(); - - if ((playbackDevices == null) - || (playbackDevices.size() <= 0)) - { - continue; - } - } - } - } - } - audioSystemsWithDevices.add(audioSystem); - } - - int audioSystemsWithDevicesCount = audioSystemsWithDevices.size(); - - return - (audioSystemsWithDevicesCount == audioSystems.length) - ? audioSystems - : audioSystemsWithDevices.toArray( - new AudioSystem[audioSystemsWithDevicesCount]); - } - } - - public void setAudioSystem(AudioSystem audioSystem, boolean save) - { - if (this.audioSystem != audioSystem) - { - if (this.audioSystem != null) - this.audioSystem.removePropertyChangeListener(this); - - AudioSystem oldValue = this.audioSystem; - - this.audioSystem = audioSystem; - - if (this.audioSystem != null) - this.audioSystem.addPropertyChangeListener(this); - - if (save) - { - ConfigurationService cfg - = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - if (this.audioSystem == null) - cfg.removeProperty(PROP_AUDIO_SYSTEM); - else - cfg.setProperty( - PROP_AUDIO_SYSTEM, - this.audioSystem.getLocatorProtocol()); - } - } - - firePropertyChange(PROP_AUDIO_SYSTEM, oldValue, this.audioSystem); - } - } - - /** - * Gets the list of video capture devices which are available through this - * DeviceConfiguration, amongst which is - * {@link #getVideoCaptureDevice(MediaUseCase)} and represent acceptable - * values for {@link #setVideoCaptureDevice(CaptureDeviceInfo, boolean)} - * - * @param useCase extract video capture devices that correspond to this - * MediaUseCase - * @return an array of CaptureDeviceInfo describing the video - * capture devices available through this - * DeviceConfiguration - */ - public List getAvailableVideoCaptureDevices( - MediaUseCase useCase) - { - Format[] formats - = new Format[] - { - new AVFrameFormat(), - new VideoFormat(VideoFormat.RGB), - new VideoFormat(VideoFormat.YUV), - new VideoFormat(Constants.H264) - }; - Set videoCaptureDevices - = new HashSet(); - - for (Format format : formats) - { - @SuppressWarnings("unchecked") - Vector cdis - = CaptureDeviceManager.getDeviceList(format); - - if (useCase != MediaUseCase.ANY) - { - for (CaptureDeviceInfo cdi : cdis) - { - MediaUseCase cdiUseCase - = DeviceSystem.LOCATOR_PROTOCOL_IMGSTREAMING - .equalsIgnoreCase( - cdi.getLocator().getProtocol()) - ? MediaUseCase.DESKTOP - : MediaUseCase.CALL; - - if (cdiUseCase.equals(useCase)) - videoCaptureDevices.add(cdi); - } - } - else - { - videoCaptureDevices.addAll(cdis); - } - } - - return new ArrayList(videoCaptureDevices); - } - - /** - * Returns a device that we could use for video capture. - * - * @param useCase MediaUseCase that will determined device - * we will use - * @return the CaptureDeviceInfo of a device that we could use for video - * capture. - */ - public CaptureDeviceInfo getVideoCaptureDevice(MediaUseCase useCase) - { - CaptureDeviceInfo dev = null; - - switch (useCase) - { - case ANY: - case CALL: - dev = videoCaptureDevice; - break; - case DESKTOP: - List devs - = getAvailableVideoCaptureDevices(MediaUseCase.DESKTOP); - - if (devs.size() > 0) - dev = devs.get(0); - break; - default: - break; - } - - return dev; - } - - /** - * Sets the device which is to be used by this - * DeviceConfiguration for video capture. - * - * @param device a CaptureDeviceInfo describing device to be - * used by this DeviceConfiguration for video - * capture. - * @param save whether we will save this option or not. - */ - public void setVideoCaptureDevice(CaptureDeviceInfo device, boolean save) - { - if (videoCaptureDevice != device) - { - CaptureDeviceInfo oldDevice = videoCaptureDevice; - - videoCaptureDevice = device; - - if (save) - { - ConfigurationService cfg - = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - cfg.setProperty( - PROP_VIDEO_DEVICE, - (videoCaptureDevice == null) - ? NoneAudioSystem.LOCATOR_PROTOCOL - : videoCaptureDevice.getName()); - } - } - - firePropertyChange(VIDEO_CAPTURE_DEVICE, oldDevice, device); - } - } - - /** - * @return the audioNotifyDevice - */ - public CaptureDeviceInfo getAudioNotifyDevice() - { - AudioSystem audioSystem = getAudioSystem(); - - return (audioSystem == null) ? null : audioSystem.getNotifyDevice(); - } - - /** - * Sets the indicator which determines whether echo cancellation is to be - * performed for captured audio. - * - * @param echoCancel true if echo cancellation is to be performed - * for captured audio; otherwise, false - */ - public void setEchoCancel(boolean echoCancel) - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - cfg.setProperty(PROP_AUDIO_ECHOCANCEL, echoCancel); - } - - /** - * Sets the indicator which determines whether noise suppression is to be - * performed for captured audio. - * - * @param denoise true if noise suppression is to be performed for - * captured audio; otherwise, false - */ - public void setDenoise(boolean denoise) - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - cfg.setProperty(PROP_AUDIO_DENOISE, denoise); - } - - /** - * Gets the indicator which determines whether echo cancellation is to be - * performed for captured audio. - * - * @return true if echo cancellation is to be performed for - * captured audio; otherwise, false - */ - public boolean isEchoCancel() - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - boolean value = DEFAULT_AUDIO_ECHOCANCEL; - - if (cfg != null) - value = cfg.getBoolean(PROP_AUDIO_ECHOCANCEL, value); - return value; - } - - /** - * Get the echo cancellation filter length (in milliseconds). - * - * @return echo cancel filter length in milliseconds - */ - public long getEchoCancelFilterLengthInMillis() - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - long value = DEFAULT_AUDIO_ECHOCANCEL_FILTER_LENGTH_IN_MILLIS; - - if (cfg != null) - { - value - = cfg.getLong( - PROP_AUDIO_ECHOCANCEL_FILTER_LENGTH_IN_MILLIS, - value); - } - return value; - } - - /** - * Gets the indicator which determines whether noise suppression is to be - * performed for captured audio - * - * @return true if noise suppression is to be performed for - * captured audio; otherwise, false - */ - public boolean isDenoise() - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - boolean value = DEFAULT_AUDIO_DENOISE; - - if (cfg != null) - value = cfg.getBoolean(PROP_AUDIO_DENOISE, value); - - return value; - } - - /** - * Registers the custom Renderer implementations defined by class - * name in {@link #CUSTOM_RENDERERS} with JMF. - */ - private void registerCustomRenderers() - { - @SuppressWarnings("unchecked") - Vector renderers - = PlugInManager.getPlugInList(null, null, PlugInManager.RENDERER); - boolean commit = false; - - for (String customRenderer : CUSTOM_RENDERERS) - { - if (customRenderer == null) - continue; - if (customRenderer.startsWith(".")) - { - customRenderer - = "net.java.sip.communicator.impl.neomedia" - + ".jmfext.media.renderer" - + customRenderer; - } - if ((renderers == null) || !renderers.contains(customRenderer)) - { - try - { - Renderer customRendererInstance - = (Renderer) - Class.forName(customRenderer).newInstance(); - - PlugInManager.addPlugIn( - customRenderer, - customRendererInstance.getSupportedInputFormats(), - null, - PlugInManager.RENDERER); - commit = true; - } - catch (Throwable t) - { - logger.error( - "Failed to register custom Renderer " - + customRenderer - + " with JMF.", - t); - } - } - } - - /* - * Just in case, bubble our JMF contributions at the top so that they - * are considered preferred. - */ - int pluginType = PlugInManager.RENDERER; - @SuppressWarnings("unchecked") - Vector plugins - = PlugInManager.getPlugInList(null, null, pluginType); - - if (plugins != null) - { - int pluginCount = plugins.size(); - int pluginBeginIndex = 0; - String preferred = "net.java.sip.communicator.impl.neomedia."; - - for (int pluginIndex = pluginCount - 1; - pluginIndex >= pluginBeginIndex;) - { - String plugin = plugins.get(pluginIndex); - - if (plugin.startsWith(preferred)) - { - plugins.remove(pluginIndex); - plugins.add(0, plugin); - pluginBeginIndex++; - commit = true; - } - else - pluginIndex--; - } - PlugInManager.setPlugInList(plugins, pluginType); - if (logger.isTraceEnabled()) - logger.trace("Reordered plug-in list:" + plugins); - } - - if (commit && !MediaServiceImpl.isJmfRegistryDisableLoad()) - { - try - { - PlugInManager.commit(); - } - catch (IOException ioex) - { - logger.warn( - "Failed to commit changes to the JMF plug-in list."); - } - } - } - - /** - * Gets the maximum allowed video bandwidth. - * - * @return the maximum allowed video bandwidth. The default value is - * {@link #DEFAULT_VIDEO_MAX_BANDWIDTH}. - */ - public int getVideoMaxBandwidth() - { - if (videoMaxBandwidth == -1) - { - ConfigurationService cfg - = NeomediaActivator.getConfigurationService(); - int value = DEFAULT_VIDEO_MAX_BANDWIDTH; - - if (cfg != null) - value = cfg.getInt(PROP_VIDEO_MAX_BANDWIDTH, value); - - videoMaxBandwidth = value; - } - return videoMaxBandwidth; - } - - /** - * Sets and stores the maximum allowed video bandwidth. - * - * @param videoMaxBandwidth the maximum allowed video bandwidth - */ - public void setVideoMaxBandwidth(int videoMaxBandwidth) - { - this.videoMaxBandwidth = videoMaxBandwidth; - - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - if (videoMaxBandwidth != DEFAULT_VIDEO_MAX_BANDWIDTH) - cfg.setProperty(PROP_VIDEO_MAX_BANDWIDTH, videoMaxBandwidth); - else - cfg.removeProperty(PROP_VIDEO_MAX_BANDWIDTH); - } - } - - /** - * Gets the frame rate set on this DeviceConfiguration. - * - * @return the frame rate set on this DeviceConfiguration. The - * default value is {@link #DEFAULT_VIDEO_FRAMERATE} - */ - public int getFrameRate() - { - if (frameRate == -1) - { - ConfigurationService cfg - = NeomediaActivator.getConfigurationService(); - int value = DEFAULT_VIDEO_FRAMERATE; - - if (cfg != null) - value = cfg.getInt(PROP_VIDEO_FRAMERATE, value); - - frameRate = value; - } - return frameRate; - } - - /** - * Sets and stores the frame rate. - * - * @param frameRate the frame rate to be set on this - * DeviceConfiguration - */ - public void setFrameRate(int frameRate) - { - this.frameRate = frameRate; - - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - if (frameRate != DEFAULT_VIDEO_FRAMERATE) - cfg.setProperty(PROP_VIDEO_FRAMERATE, frameRate); - else - cfg.removeProperty(PROP_VIDEO_FRAMERATE); - } - } - - /** - * Gets the video size set on this DeviceConfiguration. - * - * @return the video size set on this DeviceConfiguration - */ - public Dimension getVideoSize() - { - if(videoSize == null) - { - ConfigurationService cfg - = NeomediaActivator.getConfigurationService(); - int height = DEFAULT_VIDEO_HEIGHT; - int width = DEFAULT_VIDEO_WIDTH; - - if (cfg != null) - { - height = cfg.getInt(PROP_VIDEO_HEIGHT, height); - width = cfg.getInt(PROP_VIDEO_WIDTH, width); - } - - videoSize = new Dimension(width, height); - } - return videoSize; - } - - /** - * Sets and stores the video size. - * - * @param videoSize the video size to be set on this - * DeviceConfiguration - */ - public void setVideoSize(Dimension videoSize) - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - if ((videoSize.getHeight() != DEFAULT_VIDEO_HEIGHT) - || (videoSize.getWidth() != DEFAULT_VIDEO_WIDTH)) - { - cfg.setProperty(PROP_VIDEO_HEIGHT, videoSize.height); - cfg.setProperty(PROP_VIDEO_WIDTH, videoSize.width); - } - else - { - cfg.removeProperty(PROP_VIDEO_HEIGHT); - cfg.removeProperty(PROP_VIDEO_WIDTH); - } - } - - this.videoSize = videoSize; - - firePropertyChange( - VIDEO_CAPTURE_DEVICE, - videoCaptureDevice, videoCaptureDevice); - } - - /** - * Listens for changes in the configuration and if such happen - * we reset local values so next time we will update from - * the configuration. - * - * @param event the property change event - */ - public void propertyChange(PropertyChangeEvent event) - { - String propertyName = event.getPropertyName(); - - if (AudioSystem.PROP_CAPTURE_DEVICE.equals(propertyName) - || AudioSystem.PROP_NOTIFY_DEVICE.equals(propertyName) - || AudioSystem.PROP_PLAYBACK_DEVICE.equals(propertyName)) - { - firePropertyChange( - propertyName, - event.getOldValue(), - event.getNewValue()); - } - else if (DeviceSystem.PROP_DEVICES.equals(propertyName)) - { - if (event.getSource() instanceof AudioSystem) - firePropertyChange( - PROP_AUDIO_SYSTEM_DEVICES, - event.getOldValue(), - event.getNewValue()); - } - else if (PROP_VIDEO_FRAMERATE.equals(propertyName)) - { - frameRate = -1; - } - else if (PROP_VIDEO_HEIGHT.equals(propertyName) - || PROP_VIDEO_WIDTH.equals(propertyName)) - { - videoSize = null; - } - else if (PROP_VIDEO_MAX_BANDWIDTH.equals(propertyName)) - { - videoMaxBandwidth = -1; - } - } - - /** - * Detects audio capture devices configured through JMF and disable audio if - * none was found. - */ - private void extractConfiguredAudioCaptureDevices() - { - if (logger.isInfoEnabled()) - logger.info("Looking for configured audio devices."); - - AudioSystem[] availableAudioSystems = getAvailableAudioSystems(); - - if ((availableAudioSystems != null) - && (availableAudioSystems.length != 0)) - { - AudioSystem audioSystem = getAudioSystem(); - - if (audioSystem != null) - { - boolean audioSystemIsAvailable = false; - - for (AudioSystem availableAudioSystem : availableAudioSystems) - { - if (availableAudioSystem.equals(audioSystem)) - { - audioSystemIsAvailable = true; - break; - } - } - if (!audioSystemIsAvailable) - audioSystem = null; - } - - if (audioSystem == null) - { - ConfigurationService cfg - = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - String locatorProtocol = cfg.getString(PROP_AUDIO_SYSTEM); - - if (locatorProtocol != null) - { - for (AudioSystem availableAudioSystem - : availableAudioSystems) - { - if (locatorProtocol.equalsIgnoreCase( - availableAudioSystem.getLocatorProtocol())) - { - audioSystem = availableAudioSystem; - break; - } - } - } - } - - if (audioSystem == null) - audioSystem = availableAudioSystems[0]; - - setAudioSystem(audioSystem, false); - } - } - } - - /** - * Detects video capture devices configured through JMF and disable video if - * none was found. - */ - private void extractConfiguredVideoCaptureDevices() - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - String videoCaptureDeviceString - = (cfg == null) ? null : cfg.getString(PROP_VIDEO_DEVICE); - - if (NoneAudioSystem.LOCATOR_PROTOCOL.equalsIgnoreCase( - videoCaptureDeviceString)) - { - videoCaptureDevice = null; - } - else - { - if (logger.isInfoEnabled()) - logger.info("Scanning for configured Video Devices."); - - Format[] formats - = new Format[] - { - new AVFrameFormat(), - new VideoFormat(VideoFormat.RGB), - new VideoFormat(VideoFormat.YUV), - new VideoFormat(Constants.H264) - }; - - for (Format format : formats) - { - videoCaptureDevice - = extractConfiguredVideoCaptureDevice(format); - if (videoCaptureDevice != null) - break; - } - if ((videoCaptureDevice == null) && logger.isInfoEnabled()) - logger.info("No Video Device was found."); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/DeviceSystem.java b/src/net/java/sip/communicator/impl/neomedia/device/DeviceSystem.java deleted file mode 100644 index 350768047..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/DeviceSystem.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.io.*; -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.event.*; - -public abstract class DeviceSystem - extends PropertyChangeNotifier -{ - private static final Logger logger = Logger.getLogger(DeviceSystem.class); - - public static final int FEATURE_REINITIALIZE = 1; - - public static final String LOCATOR_PROTOCOL_CIVIL = "civil"; - - public static final String LOCATOR_PROTOCOL_DIRECTSHOW = "directshow"; - - public static final String LOCATOR_PROTOCOL_IMGSTREAMING = "imgstreaming"; - - public static final String LOCATOR_PROTOCOL_MEDIARECORDER = "mediarecorder"; - - public static final String LOCATOR_PROTOCOL_QUICKTIME = "quicktime"; - - public static final String LOCATOR_PROTOCOL_VIDEO4LINUX2 = "video4linux2"; - - public static final String PROP_DEVICES = "devices"; - - private static List deviceSystems - = new LinkedList(); - - protected static List filterDeviceListByLocatorProtocol( - List deviceList, - String locatorProtocol) - { - if ((deviceList != null) && (deviceList.size() > 0)) - { - Iterator deviceListIter = deviceList.iterator(); - - while (deviceListIter.hasNext()) - { - MediaLocator locator = deviceListIter.next().getLocator(); - - if ((locator == null) - || !locatorProtocol.equalsIgnoreCase( - locator.getProtocol())) - { - deviceListIter.remove(); - } - } - } - return deviceList; - } - - public static DeviceSystem[] getDeviceSystems(MediaType mediaType) - { - List ret; - - synchronized (deviceSystems) - { - ret = new ArrayList(deviceSystems.size()); - for (DeviceSystem deviceSystem : deviceSystems) - if (deviceSystem.getMediaType().equals(mediaType)) - ret.add(deviceSystem); - } - return ret.toArray(new DeviceSystem[ret.size()]); - } - - public static void initializeDeviceSystems() - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - - /* - * Detect the audio capture devices unless the configuration explicitly - * states that they are to not be detected. - */ - if (((cfg == null) - || !cfg.getBoolean( - MediaServiceImpl.DISABLE_AUDIO_SUPPORT_PNAME, - false)) - && !Boolean.getBoolean( - MediaServiceImpl.DISABLE_AUDIO_SUPPORT_PNAME)) - { - if (logger.isInfoEnabled()) - logger.info("Initializing audio devices"); - - initializeDeviceSystems(MediaType.AUDIO); - } - - /* - * Detect the video capture devices unless the configuration explicitly - * states that they are to not be detected. - */ - if ((cfg == null) - || !cfg.getBoolean( - MediaServiceImpl.DISABLE_VIDEO_SUPPORT_PNAME, - false)) - { - if (logger.isInfoEnabled()) - logger.info("Initializing video devices"); - - initializeDeviceSystems(MediaType.VIDEO); - } - } - - public static void initializeDeviceSystems(MediaType mediaType) - { - String[] classNames; - - switch (mediaType) - { - case AUDIO: - classNames - = new String[] - { - OSUtils.IS_ANDROID ? ".AudioRecordSystem" : null, - OSUtils.IS_ANDROID ? ".OpenSLESSystem" : null, - OSUtils.IS_LINUX ? ".PulseAudioSystem" : null, - OSUtils.IS_ANDROID ? null : ".PortAudioSystem", - ".NoneAudioSystem" - }; - break; - case VIDEO: - classNames - = new String[] - { - OSUtils.IS_ANDROID ? ".MediaRecorderSystem" : null, - OSUtils.IS_LINUX ? ".Video4Linux2System" : null, - OSUtils.IS_MAC ? ".QuickTimeSystem" : null, - OSUtils.IS_WINDOWS ? ".DirectShowSystem" : null, - ".ImgStreamingSystem" - }; - break; - default: - throw new IllegalArgumentException("mediaType"); - } - - initializeDeviceSystems(classNames); - } - - private static void initializeDeviceSystems(String[] classNames) - { - synchronized (deviceSystems) - { - String packageName = null; - - for (String className : classNames) - { - if (className == null) - continue; - - if (className.startsWith(".")) - { - if (packageName == null) - packageName = DeviceSystem.class.getPackage().getName(); - className = packageName + className; - } - - // Initialize a single instance per className. - DeviceSystem deviceSystem = null; - - for (DeviceSystem aDeviceSystem : deviceSystems) - if (aDeviceSystem.getClass().getName().equals(className)) - { - deviceSystem = aDeviceSystem; - break; - } - - boolean reinitialize; - - if (deviceSystem == null) - { - reinitialize = false; - - Object o = null; - - try - { - o = Class.forName(className).newInstance(); - } - catch (Throwable t) - { - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - else if (logger.isDebugEnabled()) - logger.debug( - "Failed to initialize " + className, - t); - } - if (o instanceof DeviceSystem) - { - deviceSystem = (DeviceSystem) o; - if (!deviceSystems.contains(deviceSystem)) - deviceSystems.add(deviceSystem); - } - } - else - reinitialize = true; - - // Reinitializing is an optional feature. - if (reinitialize - && ((deviceSystem.getFeatures() & FEATURE_REINITIALIZE) - != 0)) - { - try - { - deviceSystem.initialize(); - } - catch (Throwable t) - { - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - else if (logger.isDebugEnabled()) - logger.debug( - "Failed to reinitialize " + className, - t); - } - } - } - } - } - - private final int features; - - private final String locatorProtocol; - - private final MediaType mediaType; - - protected DeviceSystem(MediaType mediaType, String locatorProtocol) - throws Exception - { - this(mediaType, locatorProtocol, 0); - } - - protected DeviceSystem( - MediaType mediaType, - String locatorProtocol, - int features) - throws Exception - { - if (mediaType == null) - throw new NullPointerException("mediaType"); - if (locatorProtocol == null) - throw new NullPointerException("locatorProtocol"); - - this.mediaType = mediaType; - this.locatorProtocol = locatorProtocol; - this.features = features; - - initialize(); - } - - public Renderer createRenderer(boolean playback) - { - String className = getRendererClassName(); - - if (className != null) - { - try - { - return (Renderer) Class.forName(className).newInstance(); - } - catch (Throwable t) - { - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - else - logger.warn( - "Failed to initialize a new " - + className - + " instance", - t); - } - } - return null; - } - - protected abstract void doInitialize() - throws Exception; - - public final int getFeatures() - { - return features; - } - - public final String getLocatorProtocol() - { - return locatorProtocol; - } - - public final MediaType getMediaType() - { - return mediaType; - } - - protected String getRendererClassName() - { - return null; - } - - protected final void initialize() - throws Exception - { - preInitialize(); - try - { - doInitialize(); - } - finally - { - postInitialize(); - } - } - - protected void postInitialize() - { - firePropertyChange(PROP_DEVICES, null, null); - } - - protected void preInitialize() - { - Format format; - - switch (getMediaType()) - { - case AUDIO: - format = new AudioFormat(null); - break; - case VIDEO: - format = new VideoFormat(null); - break; - default: - format = null; - break; - } - - if (format != null) - { - @SuppressWarnings("unchecked") - Vector cdis - = CaptureDeviceManager.getDeviceList(format); - - if ((cdis != null) && (cdis.size() > 0)) - { - boolean commit = false; - - for (CaptureDeviceInfo cdi - : filterDeviceListByLocatorProtocol( - cdis, - getLocatorProtocol())) - { - CaptureDeviceManager.removeDevice(cdi); - commit = true; - } - if (commit && !MediaServiceImpl.isJmfRegistryDisableLoad()) - { - try - { - CaptureDeviceManager.commit(); - } - catch (IOException ioe) - { - /* - * We do not really need commit but we have it for - * historical reasons. - */ - if (logger.isDebugEnabled()) - logger.debug( - "Failed to commit CaptureDeviceManager", - ioe); - } - } - } - } - } - - @Override - public String toString() - { - return getLocatorProtocol(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/DirectShowSystem.java b/src/net/java/sip/communicator/impl/neomedia/device/DirectShowSystem.java deleted file mode 100644 index 2f8958428..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/DirectShowSystem.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import javax.media.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.impl.neomedia.directshow.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.directshow.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.util.*; - -/** - * Discovers and registers DirectShow video capture devices with JMF. - * - * @author Sebastien Vincent - */ -public class DirectShowSystem - extends DeviceSystem -{ - /** - * The Logger used by the DirectShowSystem class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(DirectShowSystem.class); - - /** - * The protocol of the MediaLocators identifying QuickTime/QTKit - * capture devices. - */ - private static final String LOCATOR_PROTOCOL = LOCATOR_PROTOCOL_DIRECTSHOW; - - /** - * Constructor. Discover and register DirectShow capture devices - * with JMF. - * - * @throws Exception if anything goes wrong while discovering and - * registering DirectShow capture defines with JMF - */ - public DirectShowSystem() - throws Exception - { - super(MediaType.VIDEO, LOCATOR_PROTOCOL); - } - - protected void doInitialize() - throws Exception - { - DSCaptureDevice devices[] = DSManager.getInstance().getCaptureDevices(); - boolean captureDeviceInfoIsAdded = false; - - for(int i = 0, count = (devices == null) ? 0 : devices.length; - i < count; - i++) - { - long pixelFormat = devices[i].getFormat().getPixelFormat(); - int ffmpegPixFmt = (int)DataSource.getFFmpegPixFmt(pixelFormat); - Format format = null; - - if(ffmpegPixFmt != FFmpeg.PIX_FMT_NONE) - { - format = new AVFrameFormat(ffmpegPixFmt, (int) pixelFormat); - } - else - { - logger.warn("No support for this webcam: " + - devices[i].getName() + "(format " + pixelFormat + - " not supported)"); - continue; - } - - if(logger.isInfoEnabled()) - { - for(DSFormat f : devices[i].getSupportedFormats()) - { - if(f.getWidth() != 0 && f.getHeight() != 0) - logger.info( - "Webcam available resolution for " - + devices[i].getName() - + ":" - + f.getWidth() - + "x" - + f.getHeight()); - } - } - - CaptureDeviceInfo device - = new CaptureDeviceInfo( - devices[i].getName(), - new MediaLocator( - LOCATOR_PROTOCOL + ':' + devices[i].getName()), - new Format[] { format }); - - if(logger.isInfoEnabled()) - logger.info("Found[" + i + "]: " + device.getName()); - - CaptureDeviceManager.addDevice(device); - captureDeviceInfoIsAdded = true; - } - - if (captureDeviceInfoIsAdded - && !MediaServiceImpl.isJmfRegistryDisableLoad()) - CaptureDeviceManager.commit(); - - DSManager.dispose(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/ImgStreamingSystem.java b/src/net/java/sip/communicator/impl/neomedia/device/ImgStreamingSystem.java deleted file mode 100644 index e2a04d8bb..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/ImgStreamingSystem.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.awt.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.util.*; - -/** - * Add ImageStreaming capture device. - * - * @author Sebastien Vincent - */ -public class ImgStreamingSystem - extends DeviceSystem -{ - /** - * The locator protocol used when creating or parsing - * MediaLocators. - */ - private static final String LOCATOR_PROTOCOL - = LOCATOR_PROTOCOL_IMGSTREAMING; - - /** - * Add capture devices. - * - * @throws Exception if problem when adding capture devices - */ - public ImgStreamingSystem() - throws Exception - { - super(MediaType.VIDEO, LOCATOR_PROTOCOL, FEATURE_REINITIALIZE); - } - - protected void doInitialize() - throws Exception - { - /* - * XXX The initialization of MediaServiceImpl is very complex so it is - * wise to not reference it at the early stage of its initialization. - */ - ScreenDevice[] screens = ScreenDeviceImpl.getAvailableScreenDevices(); - - String name = "Desktop Streaming"; - int i = 0; - boolean multipleMonitorOneScreen = false; - Dimension screenSize = null; - - /* - * On Linux, multiple monitors may result in a single X display (:0.0) - * which combines them. - */ - if(OSUtils.IS_LINUX) - { - Dimension size = new Dimension(0, 0); - - for(ScreenDevice screen : screens) - { - Dimension s = screen.getSize(); - - size.width += s.width; - size.height += s.height; - } - - try - { - screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - if(screenSize.width == size.width || - screenSize.height == size.height) - { - multipleMonitorOneScreen = true; - } - } - catch(Exception e) - { - } - } - - for(ScreenDevice screen : screens) - { - Dimension size = screenSize != null ? screenSize : screen.getSize(); - Format formats[] - = new Format[] - { - new AVFrameFormat( - size, - Format.NOT_SPECIFIED, - FFmpeg.PIX_FMT_ARGB, - Format.NOT_SPECIFIED), - new RGBFormat( - size, // size - Format.NOT_SPECIFIED, // maxDataLength - Format.byteArray, // dataType - Format.NOT_SPECIFIED, // frameRate - 32, // bitsPerPixel - 2 /* red */, 3 /* green */, 4 /* blue */) - }; - CaptureDeviceInfo devInfo - = new CaptureDeviceInfo( - name + " " + i, - new MediaLocator(LOCATOR_PROTOCOL + ":" + i), - formats); - - CaptureDeviceManager.addDevice(devInfo); - i++; - - if(multipleMonitorOneScreen) - break; - } - - if (!MediaServiceImpl.isJmfRegistryDisableLoad()) - CaptureDeviceManager.commit(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/JavaSoundSystem.java b/src/net/java/sip/communicator/impl/neomedia/device/JavaSoundSystem.java deleted file mode 100644 index 20a759f50..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/JavaSoundSystem.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.lang.reflect.Method; - -/** - * Auto-detection of FMJ audio capture devices. - * - * @author Ken Larson - */ -public class JavaSoundSystem - extends AudioSystem -{ - private static final String LOCATOR_PROTOCOL = LOCATOR_PROTOCOL_JAVASOUND; - - public JavaSoundSystem() - throws Exception - { - super(LOCATOR_PROTOCOL); - } - - protected void doInitialize() - throws Exception - { - // Done using reflection to avoid compile-time dependency on FMJ. - Class clazz - = Class.forName( - "net.sf.fmj.media.cdp.javasound.CaptureDevicePlugger"); - Method addCaptureDevices = clazz.getMethod("addCaptureDevices"); - Object captureDevicePlugger = clazz.newInstance(); - - addCaptureDevices.invoke(captureDevicePlugger); - } - - @Override - protected String getRendererClassName() - { - return "net.sf.fmj.media.renderer.audio.JavaSoundRenderer"; - } - - @Override - public String toString() - { - return "JavaSound"; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/LtiCivilSystem.java b/src/net/java/sip/communicator/impl/neomedia/device/LtiCivilSystem.java deleted file mode 100644 index 36daf97cb..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/LtiCivilSystem.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.lang.reflect.*; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * FMJ auto-detect of CIVIL video capture devices. - * - * @author Ken Larson - */ -public class LtiCivilSystem - extends DeviceSystem -{ - private static final String LOCATOR_PROTOCOL = LOCATOR_PROTOCOL_CIVIL; - - /** - * Creates an instance of LtiCivilSystem and auto-detects CIVIL video - * capture devices. - * - * @throws java.lang.Exception if FMJ is not present in the classpath or if - * detection fails for some other reason. - */ - public LtiCivilSystem() - throws Exception - { - super(MediaType.VIDEO, LOCATOR_PROTOCOL); - } - - protected void doInitialize() - throws Exception - { - // Done using reflection to avoid compile-time dependency on FMJ. - Class clazz - = Class.forName("net.sf.fmj.media.cdp.civil.CaptureDevicePlugger"); - Method addCaptureDevices = clazz.getMethod("addCaptureDevices"); - Object captureDevicePlugger = clazz.newInstance(); - - addCaptureDevices.invoke(captureDevicePlugger); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/MediaDeviceImpl.java b/src/net/java/sip/communicator/impl/neomedia/device/MediaDeviceImpl.java deleted file mode 100644 index 9a6d6b65b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/MediaDeviceImpl.java +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.awt.*; -import java.io.*; -import java.util.*; -import java.util.List; - -import javax.media.*; -import javax.media.control.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.format.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; -import net.java.sip.communicator.impl.neomedia.protocol.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; -import net.java.sip.communicator.util.*; - -/** - * Implements MediaDevice for the JMF CaptureDevice. - * - * @author Lyubomir Marinov - * @author Emil Ivov - */ -public class MediaDeviceImpl - extends AbstractMediaDevice -{ - - /** - * The Logger used by MediaDeviceImpl and its instances - * for logging output. - */ - private static final Logger logger - = Logger.getLogger(MediaDeviceImpl.class); - - /** - * The CaptureDeviceInfo of the device that this instance is - * representing. - */ - private final CaptureDeviceInfo captureDeviceInfo; - - /** - * The MediaType of this instance and the CaptureDevice - * that it wraps. - */ - private final MediaType mediaType; - - /** - * Initializes a new MediaDeviceImpl instance with a specific - * MediaType and with MediaDirection which does not allow - * sending. - * - * @param mediaType the MediaType of the new instance - */ - public MediaDeviceImpl(MediaType mediaType) - { - this.captureDeviceInfo = null; - this.mediaType = mediaType; - } - - /** - * Initializes a new MediaDeviceImpl instance which is to provide - * an implementation of MediaDevice for a CaptureDevice - * with a specific CaptureDeviceInfo and which is of a specific - * MediaType. - * - * @param captureDeviceInfo the CaptureDeviceInfo of the JMF - * CaptureDevice the new instance is to provide an implementation - * of MediaDevice for - * @param mediaType the MediaType of the new instance - */ - public MediaDeviceImpl( - CaptureDeviceInfo captureDeviceInfo, - MediaType mediaType) - { - if (captureDeviceInfo == null) - throw new NullPointerException("captureDeviceInfo"); - if (mediaType == null) - throw new NullPointerException("mediaType"); - - this.captureDeviceInfo = captureDeviceInfo; - this.mediaType = mediaType; - } - - /** - * Creates the JMF CaptureDevice this instance represents and - * provides an implementation of MediaDevice for. - * - * @return the JMF CaptureDevice this instance represents and - * provides an implementation of MediaDevice for; null - * if the creation fails - */ - CaptureDevice createCaptureDevice() - { - CaptureDevice captureDevice = null; - - if (getDirection().allowsSending()) - { - Throwable exception = null; - - try - { - captureDevice - = (CaptureDevice) - Manager.createDataSource( - captureDeviceInfo.getLocator()); - } - catch (IOException ioe) - { - // TODO - exception = ioe; - } - catch (NoDataSourceException ndse) - { - // TODO - exception = ndse; - } - - if (exception != null) - { - logger - .error( - "Failed to create CaptureDevice" - + " from CaptureDeviceInfo " - + captureDeviceInfo, - exception); - } - else - { - if(captureDevice instanceof AbstractPullBufferCaptureDevice) - { - ((AbstractPullBufferCaptureDevice)captureDevice) - .setCaptureDeviceInfo(captureDeviceInfo); - } - - // Try to enable tracing on captureDevice. - if (logger.isTraceEnabled()) - captureDevice - = createTracingCaptureDevice(captureDevice, logger); - } - } - return captureDevice; - } - - /** - * Creates a DataSource instance for this MediaDevice - * which gives access to the captured media. - * - * @return a DataSource instance which gives access to the media - * captured by this MediaDevice - * @see AbstractMediaDevice#createOutputDataSource() - */ - DataSource createOutputDataSource() - { - return - getDirection().allowsSending() - ? (DataSource) createCaptureDevice() - : null; - } - - /** - * Initializes a new Renderer instance which is to play back media - * on this MediaDevice. - * - * @return a new Renderer instance which is to play back media on - * this MediaDevice or null if a suitable - * Renderer is to be chosen irrespective of this - * MediaDevice - */ - Renderer createRenderer() - { - return null; - } - - /** - * Creates a new CaptureDevice which traces calls to a specific - * CaptureDevice for debugging purposes. - * - * @param captureDevice the CaptureDevice which is to have its - * calls traced for debugging output - * @param logger the Logger to be used for logging the trace - * messages - * @return a new CaptureDevice which traces the calls to the - * specified captureDevice - */ - public static CaptureDevice createTracingCaptureDevice( - CaptureDevice captureDevice, - final Logger logger) - { - if (captureDevice instanceof PushBufferDataSource) - captureDevice - = new CaptureDeviceDelegatePushBufferDataSource( - captureDevice) - { - @Override - public void connect() - throws IOException - { - super.connect(); - - if (logger.isTraceEnabled()) - logger - .trace( - "Connected " - + MediaDeviceImpl - .toString(this.captureDevice)); - } - - @Override - public void disconnect() - { - super.disconnect(); - - if (logger.isTraceEnabled()) - logger - .trace( - "Disconnected " - + MediaDeviceImpl - .toString(this.captureDevice)); - } - - @Override - public void start() - throws IOException - { - super.start(); - - if (logger.isTraceEnabled()) - logger - .trace( - "Started " - + MediaDeviceImpl - .toString(this.captureDevice)); - } - - @Override - public void stop() - throws IOException - { - super.stop(); - - if (logger.isTraceEnabled()) - logger - .trace( - "Stopped " - + MediaDeviceImpl - .toString(this.captureDevice)); - } - }; - return captureDevice; - } - - /** - * Gets the CaptureDeviceInfo of the JMF CaptureDevice - * represented by this instance. - * - * @return the CaptureDeviceInfo of the CaptureDevice - * represented by this instance - */ - public CaptureDeviceInfo getCaptureDeviceInfo() - { - return captureDeviceInfo; - } - - /** - * Returns the MediaDirection supported by this device. - * - * @return {@link MediaDirection#SENDONLY} if this is a read-only device, - * {@link MediaDirection#RECVONLY} if this is a write-only device or - * {@link MediaDirection#SENDRECV} if this MediaDevice can both - * capture and render media - * @see MediaDevice#getDirection() - */ - public MediaDirection getDirection() - { - if (captureDeviceInfo != null) - return MediaDirection.SENDRECV; - else - return - MediaType.AUDIO.equals(getMediaType()) - ? MediaDirection.INACTIVE - : MediaDirection.RECVONLY; - } - - /** - * Gets the MediaFormat in which this MediaDevice captures - * media. - * - * @return the MediaFormat in which this MediaDevice - * captures media - * @see MediaDevice#getFormat() - */ - public MediaFormat getFormat() - { - CaptureDevice captureDevice = createCaptureDevice(); - - if (captureDevice != null) - { - MediaType mediaType = getMediaType(); - - for (FormatControl formatControl - : captureDevice.getFormatControls()) - { - MediaFormat format - = MediaFormatImpl.createInstance(formatControl.getFormat()); - - if ((format != null) && format.getMediaType().equals(mediaType)) - return format; - } - } - return null; - } - - /** - * Gets the MediaType that this device supports. - * - * @return {@link MediaType#AUDIO} if this is an audio device or - * {@link MediaType#VIDEO} if this is a video device - * @see MediaDevice#getMediaType() - */ - public MediaType getMediaType() - { - return mediaType; - } - - /** - * Gets the list of MediaFormats supported by this - * MediaDevice. - * - * @param sendPreset the preset used to set some of the format parameters, - * used for video and settings. - * @param receivePreset the preset used to set the receive format - * parameters, used for video and settings. - * @return the list of MediaFormats supported by this device - * @see MediaDevice#getSupportedFormats() - */ - public List getSupportedFormats( - QualityPreset sendPreset, - QualityPreset receivePreset) - { - MediaServiceImpl mediaServiceImpl - = NeomediaActivator.getMediaServiceImpl(); - EncodingConfiguration encodingConfiguration - = mediaServiceImpl.getEncodingConfiguration(); - MediaFormat[] supportedEncodings - = encodingConfiguration.getSupportedEncodings(getMediaType()); - List supportedFormats = new ArrayList(); - - // If there is preset, check and set the format attributes where needed. - if (supportedEncodings != null) - { - for (MediaFormat f : supportedEncodings) - { - if("h264".equalsIgnoreCase(f.getEncoding())) - { - Map h264AdvancedAttributes - = f.getAdvancedAttributes(); - - if (h264AdvancedAttributes == null) - h264AdvancedAttributes = new HashMap(); - - MediaLocator captureDeviceInfoLocator; - Dimension sendSize = null; - - // change send size only for video calls - if ((captureDeviceInfo != null) - && ((captureDeviceInfoLocator - = captureDeviceInfo.getLocator()) - != null) - && !DeviceSystem.LOCATOR_PROTOCOL_IMGSTREAMING - .equals(captureDeviceInfoLocator.getProtocol())) - { - if (sendPreset != null) - sendSize = sendPreset.getResolution(); - else - sendSize - = mediaServiceImpl - .getDeviceConfiguration() - .getVideoSize(); - } - - Dimension receiveSize; - - // if there is specified preset, send its settings - if (receivePreset != null) - receiveSize = receivePreset.getResolution(); - else - { - // or just send the max video resolution of the PC - // as we do by default - ScreenDevice screen - = mediaServiceImpl.getDefaultScreenDevice(); - - receiveSize - = (screen == null) ? null : screen.getSize(); - } - - h264AdvancedAttributes.put( - "imageattr", - MediaUtils.createImageAttr(sendSize, receiveSize)); - - f - = mediaServiceImpl.getFormatFactory().createMediaFormat( - f.getEncoding(), - f.getClockRate(), - f.getFormatParameters(), - h264AdvancedAttributes); - } - - if (f != null) - supportedFormats.add(f); - } - } - - return supportedFormats; - } - - /** - * Gets a human-readable String representation of this instance. - * - * @return a String providing a human-readable representation of - * this instance - */ - @Override - public String toString() - { - CaptureDeviceInfo captureDeviceInfo = getCaptureDeviceInfo(); - - return - (captureDeviceInfo == null) - ? super.toString() - : captureDeviceInfo.toString(); - } - - /** - * Returns a human-readable representation of a specific - * CaptureDevice in the form of a String value. - * - * @param captureDevice the CaptureDevice to get a human-readable - * representation of - * @return a String value which gives a human-readable - * representation of the specified captureDevice - */ - private static String toString(CaptureDevice captureDevice) - { - StringBuffer str = new StringBuffer(); - - str.append("CaptureDevice with hashCode "); - str.append(captureDevice.hashCode()); - str.append(" and captureDeviceInfo "); - - CaptureDeviceInfo captureDeviceInfo - = captureDevice.getCaptureDeviceInfo(); - MediaLocator mediaLocator = captureDeviceInfo.getLocator(); - - str.append((mediaLocator == null) ? captureDeviceInfo : mediaLocator); - return str.toString(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/MediaDeviceSession.java b/src/net/java/sip/communicator/impl/neomedia/device/MediaDeviceSession.java deleted file mode 100644 index 64841be51..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/MediaDeviceSession.java +++ /dev/null @@ -1,2194 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.awt.Dimension; // disambiguation -import java.io.*; -import java.util.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; -import javax.media.protocol.*; -import javax.media.rtp.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.format.*; -import net.java.sip.communicator.impl.neomedia.protocol.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; -import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.event.*; - -/** - * Represents the use of a specific MediaDevice by a - * MediaStream. - * - * @author Lyubomir Marinov - * @author Damian Minkov - * @author Emil Ivov - */ -public class MediaDeviceSession - extends PropertyChangeNotifier -{ - /** - * The Logger used by the MediaDeviceSession class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(MediaDeviceSession.class); - - /** - * The name of the MediaDeviceSession instance property the value - * of which represents the output DataSource of the - * MediaDeviceSession instance which provides the captured (RTP) - * data to be sent by MediaStream to MediaStreamTarget. - */ - public static final String OUTPUT_DATA_SOURCE = "OUTPUT_DATA_SOURCE"; - - /** - * The name of the property that corresponds to the array of SSRC - * identifiers that we store in this MediaDeviceSession instance - * and that we update upon adding and removing ReceiveStream - */ - public static final String SSRC_LIST = "SSRC_LIST"; - - /** - * The JMF DataSource of {@link #device} through which this - * instance accesses the media captured by it. - */ - private DataSource captureDevice; - - /** - * The indicator which determines whether {@link DataSource#connect()} has - * been successfully executed on {@link #captureDevice}. - */ - private boolean captureDeviceIsConnected; - - /** - * The ContentDescriptor which specifies the content type in which - * this MediaDeviceSession is to output the media captured by its - * MediaDevice. - */ - private ContentDescriptor contentDescriptor; - - /** - * The MediaDevice used by this instance to capture and play back - * media. - */ - private final AbstractMediaDevice device; - - /** - * The last JMF Format set to this instance by a call to its - * {@link #setFormat(MediaFormat)} and to be set as the output format of - * {@link #processor}. - */ - private MediaFormatImpl format; - - /** - * The indicator which determines whether this MediaDeviceSession - * is set to output "silence" instead of the actual media captured from - * {@link #captureDevice}. - */ - private boolean mute = false; - - /** - * The list of playbacks of ReceiveStreams and/or - * DataSources performed by respective Players on the - * MediaDevice represented by this instance. - */ - private final List playbacks = new LinkedList(); - - /** - * The ControllerListener which listens to the Players of - * {@link #playbacks} for ControllerEvents. - */ - private ControllerListener playerControllerListener; - - /** - * The JMF Processor which transcodes {@link #captureDevice} into - * the format of this instance. - */ - private Processor processor; - - /** - * The ControllerListener which listens to {@link #processor} for - * ControllerEvents. - */ - private ControllerListener processorControllerListener; - - /** - * The indicator which determines whether {@link #processor} has received - * a ControllerClosedEvent at an unexpected time in its execution. - * A value of false does not mean that processor exists - * or that it is not closed, it just means that if processor failed - * to be initialized or it received a ControllerClosedEvent, it was - * at an expected time of its execution and that the fact in question was - * reflected, for example, by setting processor to null. - * If there is no processorIsPrematurelyClosed field and - * processor is set to null or left existing after the - * receipt of ControllerClosedEvent, it will either lead to not - * firing a PropertyChangeEvent for OUTPUT_DATA_SOURCE - * when it has actually changed and, consequently, cause the - * SendStreams of MediaStreamImpl to not be recreated or - * it will be impossible to detect that processor cannot have its - * format set and will thus be left broken even for subsequent calls to - * {@link #setFormat(MediaFormat)}. - */ - private boolean processorIsPrematurelyClosed; - - /** - * The list of SSRC identifiers representing the parties that we are - * currently handling receive streams from. - */ - private long[] ssrcList = null; - - /** - * The MediaDirection in which this MediaDeviceSession has - * been started. - */ - private MediaDirection startedDirection = MediaDirection.INACTIVE; - - /** - * If the player have to be disposed when we {@link #close()} this instance. - */ - private boolean disposePlayerOnClose = true; - - /** - * Whether output size has changed after latest processor config. - * Used for video streams. - */ - protected boolean outputsizeChanged = false; - - /** - * Initializes a new MediaDeviceSession instance which is to - * represent the use of a specific MediaDevice by a - * MediaStream. - * - * @param device the MediaDevice the use of which by a - * MediaStream is to be represented by the new instance - */ - protected MediaDeviceSession(AbstractMediaDevice device) - { - checkDevice(device); - - this.device = device; - } - - /** - * Sets the indicator which determines whether this instance is to dispose - * of its associated player upon closing. - * - * @param disposePlayerOnClose true to have this instance dispose - * of its associated player upon closing; otherwise, false - */ - public void setDisposePlayerOnClose(boolean disposePlayerOnClose) - { - this.disposePlayerOnClose = disposePlayerOnClose; - } - - /** - * Adds ssrc to the array of SSRC identifiers representing parties - * that this MediaDeviceSession is currently receiving streams - * from. We use this method mostly as a way of to caching SSRC identifiers - * during a conference call so that the streams that are sending CSRC lists - * could have them ready for use rather than have to construct them for - * every RTP packet. - * - * @param ssrc the new SSRC identifier that we'd like to add to the array of - * ssrc identifiers stored by this session. - */ - protected void addSSRC(long ssrc) - { - //init if necessary - if ( ssrcList == null) - { - setSsrcList(new long[]{ssrc}); - return; - } - - //check whether we already have this ssrc - for ( long i : ssrcList) - { - if ( i == ssrc) - return; - } - - //resize the array and add the new ssrc to the end. - long[] newSsrcList = new long[ssrcList.length + 1]; - - System.arraycopy(ssrcList, 0, newSsrcList, 0, ssrcList.length); - newSsrcList[newSsrcList.length - 1] = ssrc; - - setSsrcList(newSsrcList); - } - - /** - * For JPEG and H263, we know that they only work for particular sizes. So - * we'll perform extra checking here to make sure they are of the right - * sizes. - * - * @param sourceFormat the original format to check the size of - * @return the modified VideoFormat set to the size we support - */ - private static VideoFormat assertSize(VideoFormat sourceFormat) - { - int width, height; - - // JPEG - if (sourceFormat.matches(new Format(VideoFormat.JPEG_RTP))) - { - Dimension size = sourceFormat.getSize(); - - // For JPEG, make sure width and height are divisible by 8. - width = (size.width % 8 == 0) - ? size.width - : ((size.width / 8) * 8); - height = (size.height % 8 == 0) - ? size.height - : ((size.height / 8) * 8); - } - // H.263 - else if (sourceFormat.matches(new Format(VideoFormat.H263_RTP))) - { - // For H.263, we only support some specific sizes. -// if (size.width < 128) -// { -// width = 128; -// height = 96; -// } -// else if (size.width < 176) -// { -// width = 176; -// height = 144; -// } -// else -// { - width = 352; - height = 288; -// } - } - else - { - // We don't know this particular format. We'll just leave it alone - // then. - return sourceFormat; - } - - VideoFormat result - = new VideoFormat( - null, - new Dimension(width, height), - Format.NOT_SPECIFIED, - null, - Format.NOT_SPECIFIED); - return (VideoFormat) result.intersects(sourceFormat); - } - - /** - * Asserts that a specific MediaDevice is acceptable to be set as - * the MediaDevice of this instance. Allows extenders to override - * and customize the check. - * - * @param device the MediaDevice to be checked for suitability to - * become the MediaDevice of this instance - */ - protected void checkDevice(AbstractMediaDevice device) - { - } - - /** - * Releases the resources allocated by this instance in the course of its - * execution and prepares it to be garbage collected. - */ - public void close() - { - /** - * Here the order of stopping the playback and capture is important - * cause when we use echo cancellation the capturer access data from - * the render part and so there a synchronized so we don't get - * SEGFAULTS, but sometimes this synchronization can lead to slowly - * stopping of the renderer. Thats why we first stop the capturer. - */ - - // capture - disconnectCaptureDevice(); - closeProcessor(); - - // playback - if (disposePlayerOnClose) - disposePlayer(); - - processor = null; -// player = null; - captureDevice = null; - } - - /** - * Makes sure {@link #processor} is closed. - */ - private void closeProcessor() - { - if (processor != null) - { - if (processorControllerListener != null) - processor.removeControllerListener(processorControllerListener); - - processor.stop(); - if (logger.isTraceEnabled()) - logger - .trace( - "Stopped Processor with hashCode " - + processor.hashCode()); - - if (processor.getState() == Processor.Realized) - { - DataSource dataOutput; - - try - { - dataOutput = processor.getDataOutput(); - } - catch (NotRealizedError nre) - { - dataOutput = null; - } - if (dataOutput != null) - dataOutput.disconnect(); - } - - processor.deallocate(); - processor.close(); - processorIsPrematurelyClosed = false; - - /* - * Once the processor uses the captureDevice, the captureDevice has - * to be reconnected on its next use. - */ - disconnectCaptureDevice(); - } - } - - /** - * Creates the DataSource that this instance is to read captured - * media from. - * - * @return the DataSource that this instance is to read captured - * media from - */ - protected DataSource createCaptureDevice() - { - DataSource captureDevice = getDevice().createOutputDataSource(); - - if (!(captureDevice instanceof MuteDataSource)) - { - // Try to enable muting. - if (captureDevice instanceof PushBufferDataSource) - { - captureDevice - = new RewritablePushBufferDataSource( - (PushBufferDataSource) captureDevice); - } - else if (captureDevice instanceof PullBufferDataSource) - { - captureDevice - = new RewritablePullBufferDataSource( - (PullBufferDataSource) captureDevice); - } - } - if (captureDevice instanceof MuteDataSource) - ((MuteDataSource) captureDevice).setMute(mute); - - return captureDevice; - } - - /** - * Creates a new Player for a specific DataSource so that - * it is played back on the MediaDevice represented by this - * instance. - * - * @param dataSource the DataSource to create a new Player - * for - * @return a new Player for the specified dataSource - */ - protected Player createPlayer(DataSource dataSource) - { - Processor player = null; - Throwable exception = null; - - // A Player is documented to be created on a connected DataSource. - try - { - dataSource.connect(); - } - catch (IOException ioex) - { - // TODO - exception = ioex; - } - if (exception != null) - { - logger.error( - "Failed to connect to " - + MediaStreamImpl.toString(dataSource), - exception); - return player; - } - - try - { - player = Manager.createProcessor(dataSource); - } - catch (IOException ioe) - { - exception = ioe; - } - catch (NoPlayerException npe) - { - exception = npe; - } - if (exception != null) - { - logger.error( - "Failed to create Player for " - + MediaStreamImpl.toString(dataSource), - exception); - } - else - { - /* - * We cannot wait for the Player to get configured (e.g. with - * waitForState) because it will stay in the Configuring state until - * it reads some media. In the case of a ReceiveStream not sending - * media (e.g. abnormally stopped), it will leave us blocked. - */ - if (playerControllerListener == null) - playerControllerListener = new ControllerListener() - { - - /** - * Notifies this ControllerListener that the - * Controller which it is registered with has - * generated an event. - * - * @param event the ControllerEvent specifying the - * Controller which is the source of the event and - * the very type of the event - * @see ControllerListener#controllerUpdate(ControllerEvent) - */ - public void controllerUpdate(ControllerEvent event) - { - playerControllerUpdate(event); - } - }; - player.addControllerListener(playerControllerListener); - - player.configure(); - if (logger.isTraceEnabled()) - logger.trace( - "Created Player with hashCode " - + player.hashCode() - + " for " - + MediaStreamImpl.toString(dataSource)); - } - - if (player == null) - dataSource.disconnect(); - - return player; - } - - /** - * Initializes a new FMJ Processor which is to transcode - * {@link #captureDevice} into the format of this instance. - * - * @return a new FMJ Processor which is to transcode - * captureDevice into the format of this instance - */ - protected Processor createProcessor() - { - DataSource captureDevice = getConnectedCaptureDevice(); - - if (captureDevice != null) - { - Processor processor = null; - Throwable exception = null; - - try - { - processor = Manager.createProcessor(captureDevice); - } - catch (IOException ioe) - { - // TODO - exception = ioe; - } - catch (NoProcessorException npe) - { - // TODO - exception = npe; - } - - if (exception != null) - logger - .error( - "Failed to create Processor for " + captureDevice, - exception); - else - { - if (processorControllerListener == null) - processorControllerListener = new ControllerListener() - { - - /** - * Notifies this ControllerListener that - * the Controller which it is registered - * with has generated an event. - * - * @param event the ControllerEvent - * specifying the Controller which is the - * source of the event and the very type of the - * event - * @see ControllerListener#controllerUpdate( - * ControllerEvent) - */ - public void controllerUpdate(ControllerEvent event) - { - processorControllerUpdate(event); - } - }; - processor - .addControllerListener(processorControllerListener); - - if (waitForState(processor, Processor.Configured)) - { - this.processor = processor; - processorIsPrematurelyClosed = false; - } - else - { - if (processorControllerListener != null) - processor - .removeControllerListener( - processorControllerListener); - processor = null; - } - } - } - - return this.processor; - } - - /** - * Creates a ContentDescriptor to be set on a specific - * Processor of captured media to be sent to the remote peer. - * Allows extenders to override. The default implementation returns - * {@link ContentDescriptor#RAW_RTP}. - * - * @param processor the Processor of captured media to be sent to - * the remote peer which is to have its contentDescriptor set to - * the returned ContentDescriptor - * @return a ContentDescriptor to be set on the specified - * processor of captured media to be sent to the remote peer - */ - protected ContentDescriptor createProcessorContentDescriptor( - Processor processor) - { - return - (contentDescriptor == null) - ? new ContentDescriptor(ContentDescriptor.RAW_RTP) - : contentDescriptor; - } - - /** - * Makes sure {@link #captureDevice} is disconnected. - */ - private void disconnectCaptureDevice() - { - if (captureDevice != null) - { - /* - * As reported by Carlos Alexandre, stopping before disconnecting - * resolves a slow disconnect on Linux. - */ - try - { - captureDevice.stop(); - } - catch (IOException ioe) - { - /* - * We cannot do much about the exception because we're not - * really interested in the stopping but rather in calling - * DataSource#disconnect() anyway. - */ - logger - .error( - "Failed to properly stop captureDevice " - + captureDevice, - ioe); - } - - captureDevice.disconnect(); - captureDeviceIsConnected = false; - } - } - - /** - * Releases the resources allocated by the Players of - * {@link #playbacks} in the course of their execution and prepares them to - * be garbage collected. - */ - private void disposePlayer() - { - synchronized (playbacks) - { - for (Playback playback : playbacks) - if (playback.player != null) - { - disposePlayer(playback.player); - playback.player = null; - } - } - } - - /** - * Releases the resources allocated by a specific Player in the - * course of its execution and prepares it to be garbage collected. - * - * @param player the Player to dispose of - */ - protected void disposePlayer(Player player) - { - synchronized (playbacks) - { - if (playerControllerListener != null) - player.removeControllerListener(playerControllerListener); - player.stop(); - player.deallocate(); - player.close(); - } - } - - /** - * Finds the first Format instance in a specific list of - * Formats which matches a specific Format. The - * implementation considers a pair of Formats matching if they have - * the same encoding. - * - * @param formats the array of Formats to be searched for a match - * to the specified format - * @param format the Format to search for a match in the specified - * formats - * @return the first element of formats which matches - * format i.e. is of the same encoding - */ - private static Format findFirstMatchingFormat( - Format[] formats, - Format format) - { - double formatSampleRate - = (format instanceof AudioFormat) - ? ((AudioFormat) format).getSampleRate() - : Format.NOT_SPECIFIED; - ParameterizedVideoFormat parameterizedVideoFormat - = (format instanceof ParameterizedVideoFormat) - ? (ParameterizedVideoFormat) format - : null; - - for (Format match : formats) - { - if (match.isSameEncoding(format)) - { - /* - * The encoding alone is, of course, not enough. For example, - * AudioFormats may have different sample rates (i.e. clock - * rates as we call them in MediaFormat). - */ - if (match instanceof AudioFormat) - { - if (formatSampleRate != Format.NOT_SPECIFIED) - { - double matchSampleRate - = ((AudioFormat) match).getSampleRate(); - - if ((matchSampleRate != Format.NOT_SPECIFIED) - && (matchSampleRate != formatSampleRate)) - continue; - } - } - else if (match instanceof ParameterizedVideoFormat) - { - if (!((ParameterizedVideoFormat) match) - .formatParametersMatch(format)) - continue; - } - else if (parameterizedVideoFormat != null) - { - if (!parameterizedVideoFormat.formatParametersMatch(match)) - continue; - } - return match; - } - } - return null; - } - - /** - * Gets the DataSource that this instance uses to read captured - * media from. If it does not exist yet, it is created. - * - * @return the DataSource that this instance uses to read captured - * media from - */ - public synchronized DataSource getCaptureDevice() - { - if (captureDevice == null) - captureDevice = createCaptureDevice(); - return captureDevice; - } - - /** - * Gets {@link #captureDevice} in a connected state. If this instance is not - * connected to captureDevice yet, first tries to connect to it. - * Returns null if this instance fails to create - * captureDevice or to connect to it. - * - * @return {@link #captureDevice} in a connected state; null if - * this instance fails to create captureDevice or to connect to it - */ - protected DataSource getConnectedCaptureDevice() - { - DataSource captureDevice = getCaptureDevice(); - - if ((captureDevice != null) && !captureDeviceIsConnected) - { - /* - * Give this instance a chance to set up an optimized media codec - * chain by setting the output Format on the input CaptureDevice. - */ - try - { - if (this.format != null) - setCaptureDeviceFormat(captureDevice, this.format); - } - catch (Throwable t) - { - logger.warn( - "Failed to setup an optimized media codec chain" - + " by setting the output Format" - + " on the input CaptureDevice", - t); - } - - Throwable exception = null; - - try - { - getDevice().connect(captureDevice); - } - catch (IOException ioex) - { - exception = ioex; - } - - if (exception == null) - captureDeviceIsConnected = true; - else - { - logger.error( - "Failed to connect to " - + MediaStreamImpl.toString(captureDevice), - exception); - captureDevice = null; - } - } - return captureDevice; - } - - /** - * Gets the MediaDevice associated with this instance and the work - * of a MediaStream with which is represented by it. - * - * @return the MediaDevice associated with this instance and the - * work of a MediaStream with which is represented by it - */ - public AbstractMediaDevice getDevice() - { - return device; - } - - /** - * Gets the JMF Format in which this instance captures media. - * - * @return the JMF Format in which this instance captures media. - */ - public Format getProcessorFormat() - { - Processor processor = getProcessor(); - - if ((processor != null) - && (this.processor == processor) - && !processorIsPrematurelyClosed) - { - MediaType mediaType = getMediaType(); - - for (TrackControl trackControl : processor.getTrackControls()) - { - if (!trackControl.isEnabled()) - continue; - - Format jmfFormat = trackControl.getFormat(); - MediaType type - = (jmfFormat instanceof VideoFormat) - ? MediaType.VIDEO - : MediaType.AUDIO; - - if (mediaType.equals(type)) - return jmfFormat; - } - } - return null; - } - - /** - * Gets the MediaFormat in which this instance captures media from - * its associated MediaDevice. - * - * @return the MediaFormat in which this instance captures media - * from its associated MediaDevice - */ - public MediaFormatImpl getFormat() - { - /* - * If the Format of the processor is different than the format of this - * MediaDeviceSession, we'll likely run into unexpected issues so debug - * whether there are such cases. - */ - if (logger.isDebugEnabled() && (processor != null)) - { - Format processorFormat = getProcessorFormat(); - Format format - = (this.format == null) ? null : this.format.getFormat(); - boolean processorFormatMatchesFormat - = (processorFormat == null) - ? (format == null) - : processorFormat.matches(format); - - if (!processorFormatMatchesFormat) - { - logger.debug( - "processorFormat != format; processorFormat= `" - + processorFormat - + "`; format= `" - + format - + "`"); - } - } - - return format; - } - - /** - * Gets the MediaType of the media captured and played back by this - * instance. It is the same as the MediaType of its associated - * MediaDevice. - * - * @return the MediaType of the media captured and played back by - * this instance as reported by {@link MediaDevice#getMediaType()} of its - * associated MediaDevice - */ - private MediaType getMediaType() - { - return getDevice().getMediaType(); - } - - /** - * Gets the output DataSource of this instance which provides the - * captured (RTP) data to be sent by MediaStream to - * MediaStreamTarget. - * - * @return the output DataSource of this instance which provides - * the captured (RTP) data to be sent by MediaStream to - * MediaStreamTarget - */ - public DataSource getOutputDataSource() - { - Processor processor = getProcessor(); - DataSource outputDataSource; - - if ((processor == null) - || ((processor.getState() < Processor.Realized) - && !waitForState(processor, Processor.Realized))) - outputDataSource = null; - else - { - outputDataSource = processor.getDataOutput(); - if (logger.isTraceEnabled() && (outputDataSource != null)) - logger - .trace( - "Processor with hashCode " - + processor.hashCode() - + " provided " - + MediaStreamImpl.toString(outputDataSource)); - - /* - * Whoever wants the outputDataSource, they expect it to be started - * in accord with the previously-set direction. - */ - startProcessorInAccordWithDirection(processor); - } - return outputDataSource; - } - - /** - * Gets the information related to the playback of a specific - * DataSource on the MediaDevice represented by this - * MediaDeviceSession. - * - * @param dataSource the DataSource to get the information related - * to the playback of - * @return the information related to the playback of the specified - * DataSource on the MediaDevice represented by this - * MediaDeviceSession - */ - private Playback getPlayback(DataSource dataSource) - { - synchronized (playbacks) - { - for (Playback playback : playbacks) - if (playback.dataSource == dataSource) - return playback; - } - return null; - } - - /** - * Gets the information related to the playback of a specific - * ReceiveStream on the MediaDevice represented by this - * MediaDeviceSession. - * - * @param receiveStream the ReceiveStream to get the information - * related to the playback of - * @return the information related to the playback of the specified - * ReceiveStream on the MediaDevice represented by this - * MediaDeviceSession - */ - private Playback getPlayback(ReceiveStream receiveStream) - { - synchronized (playbacks) - { - for (Playback playback : playbacks) - if (playback.receiveStream == receiveStream) - return playback; - } - return null; - } - - /** - * Gets the Players rendering the ReceiveStreams of this - * instance on its associated MediaDevice. - * - * @return the Players rendering the ReceiveStreams of - * this instance on its associated MediaDevice - */ - protected List getPlayers() - { - List players; - - synchronized (playbacks) - { - players = new ArrayList(playbacks.size()); - for (Playback playback : playbacks) - if (playback.player != null) - players.add(playback.player); - } - return players; - } - - /** - * Gets the Players rendering the ReceiveStream - * corresponding to the given ssrc. - * - * @param ssrc the src-id of the receive stream, which player we're - * looking for - * @return the Players rendering the ReceiveStream - * corresponding to the given ssrc - */ - protected Player getPlayer(long ssrc) - { - synchronized (playbacks) - { - for (Playback playback : playbacks) - if (playback.receiveStream.getSSRC() == ssrc) - return playback.player; - } - return null; - } - - /** - * Gets the JMF Processor which transcodes the MediaDevice - * of this instance into the format of this instance. - * - * @return the JMF Processor which transcodes the - * MediaDevice of this instance into the format of this instance - */ - private Processor getProcessor() - { - if (processor == null) - processor = createProcessor(); - return processor; - } - - /** - * Gets a list of the ReceiveStreams being played back on the - * MediaDevice represented by this instance. - * - * @return a list of ReceiveStreams being played back on the - * MediaDevice represented by this instance - */ - public List getReceiveStreams() - { - List receiveStreams; - - synchronized (playbacks) - { - receiveStreams = new ArrayList(playbacks.size()); - for (Playback playback : playbacks) - if (playback.receiveStream != null) - receiveStreams.add(playback.receiveStream); - } - return receiveStreams; - } - - /** - * Returns the list of SSRC identifiers that this device session is handling - * streams from. In this case (i.e. the case of a device session handling - * a single remote party) we would rarely (if ever) have more than a single - * SSRC identifier returned. However, we would also be using the same method - * to query a device session operating over a mixer in which case we would - * have the SSRC IDs of all parties currently contributing to the mixing. - * - * @return a long[] array of SSRC identifiers that this device - * session is handling streams from. - */ - public long[] getRemoteSSRCList() - { - return ssrcList; - } - - /** - * Gets the MediaDirection in which this instance has been started. - * For example, a MediaDirection which returns true for - * allowsSending() signals that this instance is capturing media - * from its MediaDevice. - * - * @return the MediaDirection in which this instance has been - * started - */ - public MediaDirection getStartedDirection() - { - return startedDirection; - } - - /** - * Gets a list of the MediaFormats in which this instance is - * capable of capturing media from its associated MediaDevice. - * - * @return a new list of MediaFormats in which this instance is - * capable of capturing media from its associated MediaDevice - */ - public List getSupportedFormats() - { - Processor processor = getProcessor(); - Set supportedFormats = new HashSet(); - - if ((processor != null) - && (this.processor == processor) - && !processorIsPrematurelyClosed) - { - MediaType mediaType = getMediaType(); - - for (TrackControl trackControl : processor.getTrackControls()) - { - if (!trackControl.isEnabled()) - continue; - - for (Format supportedFormat : trackControl.getSupportedFormats()) - switch (mediaType) - { - case AUDIO: - if (supportedFormat instanceof AudioFormat) - supportedFormats.add(supportedFormat); - break; - case VIDEO: - if (supportedFormat instanceof VideoFormat) - supportedFormats.add(supportedFormat); - break; - } - } - } - - List supportedMediaFormats - = new ArrayList(supportedFormats.size()); - - for (Format format : supportedFormats) - supportedMediaFormats.add(MediaFormatImpl.createInstance(format)); - return supportedMediaFormats; - } - - /** - * Determines whether this MediaDeviceSession is set to output - * "silence" instead of the actual media fed from its - * CaptureDevice. - * - * @return true if this MediaDeviceSession is set to - * output "silence" instead of the actual media fed from its - * CaptureDevice; otherwise, false - */ - public boolean isMute() - { - DataSource captureDevice = this.captureDevice; - - if (captureDevice == null) - return mute; - if (captureDevice instanceof MuteDataSource) - return ((MuteDataSource) captureDevice).isMute(); - return false; - } - - /** - * Notifies this MediaDeviceSession that a DataSource has - * been added for playback on the represented MediaDevice. - * - * @param playbackDataSource the DataSource which has been added - * for playback on the represented MediaDevice - */ - protected void playbackDataSourceAdded(DataSource playbackDataSource) - { - } - - /** - * Notifies this MediaDeviceSession that a DataSource has - * been removed from playback on the represented MediaDevice. - * - * @param playbackDataSource the DataSource which has been removed - * from playback on the represented MediaDevice - */ - protected void playbackDataSourceRemoved(DataSource playbackDataSource) - { - } - - /** - * Notifies this instance that a specific Player of remote content - * has generated a ConfigureCompleteEvent. Allows extenders to - * carry out additional processing on the Player. - * - * @param player the Player which is the source of a - * ConfigureCompleteEvent - */ - protected void playerConfigureComplete(Processor player) - { - TrackControl[] tcs = player.getTrackControls(); - - if ((tcs != null) && (tcs.length != 0)) - { - AbstractMediaDevice device = getDevice(); - - for (int i = 0; i < tcs.length; i++) - { - TrackControl tc = tcs[i]; - Renderer renderer = device.createRenderer(); - - if (renderer != null) - try - { - tc.setRenderer(renderer); - } - catch (UnsupportedPlugInException upie) - { - logger.warn( - "Failed to set " - + renderer.getClass().getName() - + " renderer on track " - + i, - upie); - } - } - } - } - - /** - * Gets notified about ControllerEvents generated by a specific - * Player of remote content. - *

- * Extenders who choose to override are advised to override more specialized - * methods such as {@link #playerConfigureComplete(Processor)} and - * {@link #playerRealizeComplete(Processor)}. In any case, extenders - * overriding this method should call the super implementation. - *

- * - * @param event the ControllerEvent specifying the - * Controller which is the source of the event and the very type of - * the event - */ - protected void playerControllerUpdate(ControllerEvent event) - { - if (event instanceof ConfigureCompleteEvent) - { - Processor player = (Processor) event.getSourceController(); - - if (player != null) - { - playerConfigureComplete(player); - - /* - * To use the processor as a Player we must set its - * ContentDescriptor to null. - */ - try - { - player.setContentDescriptor(null); - } - catch (NotConfiguredError nce) - { - logger.error( - "Failed to set ContentDescriptor to Player.", - nce); - return; - } - - player.realize(); - } - } - else if (event instanceof RealizeCompleteEvent) - { - Processor player = (Processor) event.getSourceController(); - - if (player != null) - { - playerRealizeComplete(player); - - player.start(); - } - } - } - - /** - * Notifies this instance that a specific Player of remote content - * has generated a RealizeCompleteEvent. Allows extenders to carry - * out additional processing on the Player. - * - * @param player the Player which is the source of a - * RealizeCompleteEvent - */ - protected void playerRealizeComplete(Processor player) - { - } - - /** - * Gets notified about ControllerEvents generated by - * {@link #processor}. - * - * @param event the ControllerEvent specifying the - * Controller which is the source of the event and the very type of - * the event - */ - protected void processorControllerUpdate(ControllerEvent event) - { - if (event instanceof ConfigureCompleteEvent) - { - Processor processor = (Processor) event.getSourceController(); - - if (processor != null) - { - try - { - processor.setContentDescriptor( - createProcessorContentDescriptor(processor)); - } - catch (NotConfiguredError nce) - { - logger - .error( - "Failed to set ContentDescriptor to Processor.", - nce); - } - - if (format != null) - setProcessorFormat(processor, format); - } - } - else if (event instanceof ControllerClosedEvent) - { - Processor processor = (Processor) event.getSourceController(); - - /* - * If everything goes according to plan, we should've removed the - * ControllerListener from the processor by now. - */ - logger.warn(event); - - // TODO Should the access to processor be synchronized? - if ((processor != null) && (this.processor == processor)) - processorIsPrematurelyClosed = true; - } - } - - /** - * Removes ssrc from the array of SSRC identifiers representing - * parties that this MediaDeviceSession is currently receiving - * streams from. - * - * @param ssrc the SSRC identifier that we'd like to remove from the array - * of ssrc identifiers stored by this session. - */ - protected void removeSSRC(long ssrc) - { - //find the ssrc - int index = -1; - - if (ssrcList == null || ssrcList.length == 0) - { - //list is already empty so there's nothing to do. - return; - } - - for (int i = 0; i < ssrcList.length; i++) - { - if (ssrcList[i] == ssrc) - { - index = i; - break; - } - } - - if (index < 0 || index >= ssrcList.length) - { - //the ssrc we are trying to remove is not in the list so there's - //nothing to do. - return; - } - - //if we get here and the list has a single element this would mean we - //simply need to empty it as the only element is the one we are removing - if (ssrcList.length == 1) - { - setSsrcList(null); - return; - } - - long[] newSsrcList = new long[ssrcList.length]; - - System.arraycopy(ssrcList, 0, newSsrcList, 0, index); - if (index < ssrcList.length - 1) - { - System.arraycopy(ssrcList, index + 1, - newSsrcList, index, - ssrcList.length - index - 1); - } - - setSsrcList(newSsrcList); - } - - /** - * Notifies this instance that a specific ReceiveStream has been - * added to the list of playbacks of ReceiveStreams and/or - * DataSources performed by respective Players on the - * MediaDevice represented by this instance. - * - * @param receiveStream the ReceiveStream which has been added to - * the list of playbacks of ReceiveStreams and/or - * DataSources performed by respective Players on the - * MediaDevice represented by this instance - */ - protected void receiveStreamAdded(ReceiveStream receiveStream) - { - } - - /** - * Notifies this instance that a specific ReceiveStream has been - * removed from the list of playbacks of ReceiveStreams and/or - * DataSources performed by respective Players on the - * MediaDevice represented by this instance. - * - * @param receiveStream the ReceiveStream which has been removed - * from the list of playbacks of ReceiveStreams and/or - * DataSources performed by respective Players on the - * MediaDevice represented by this instance - */ - protected void receiveStreamRemoved(ReceiveStream receiveStream) - { - } - - protected void setCaptureDeviceFormat( - DataSource captureDevice, - MediaFormatImpl mediaFormat) - { - Format format = mediaFormat.getFormat(); - - if (format instanceof AudioFormat) - { - AudioFormat audioFormat = (AudioFormat) format; - int channels = Format.NOT_SPECIFIED; - double sampleRate - = OSUtils.IS_ANDROID - ? audioFormat.getSampleRate() - : Format.NOT_SPECIFIED; - - if ((channels != Format.NOT_SPECIFIED) - || (sampleRate != Format.NOT_SPECIFIED)) - { - FormatControl formatControl - = (FormatControl) - captureDevice.getControl( - FormatControl.class.getName()); - - if (formatControl != null) - { - Format[] supportedFormats - = formatControl.getSupportedFormats(); - - if ((supportedFormats != null) - && (supportedFormats.length != 0)) - { - if (sampleRate != Format.NOT_SPECIFIED) - { - /* - * As per RFC 3551.4.5.2, because of a mistake in - * RFC 1890 and for backward compatibility, G.722 - * should always be announced as 8000 even though it - * is wideband. - */ - String encoding = audioFormat.getEncoding(); - - if ((Constants.G722.equalsIgnoreCase(encoding) - || Constants.G722_RTP.equalsIgnoreCase( - encoding)) - && (sampleRate == 8000)) - { - sampleRate = 16000; - } - } - - Format supportedAudioFormat = null; - - for (int i = 0; i < supportedFormats.length; i++) - { - Format sf = supportedFormats[i]; - - if (sf instanceof AudioFormat) - { - AudioFormat saf = (AudioFormat) sf; - - if ((Format.NOT_SPECIFIED != channels) - && (saf.getChannels() != channels)) - continue; - if ((Format.NOT_SPECIFIED != sampleRate) - && (saf.getSampleRate() != sampleRate)) - continue; - - supportedAudioFormat = saf; - break; - } - } - - if (supportedAudioFormat != null) - formatControl.setFormat(supportedAudioFormat); - } - } - } - } - } - - /** - * Sets the ContentDescriptor which specifies the content type in - * which this MediaDeviceSession is to output the media captured by - * its MediaDevice. The default content type in which - * MediaDeviceSession outputs the media captured by its - * MediaDevice is {@link ContentDescriptor#RAW_RTP}. - * - * @param contentDescriptor the ContentDescriptor which specifies - * the content type in which this MediaDeviceSession is to output - * the media captured by its MediaDevice - */ - public void setContentDescriptor(ContentDescriptor contentDescriptor) - { - if (contentDescriptor == null) - throw new NullPointerException("contentDescriptor"); - - this.contentDescriptor = contentDescriptor; - } - - /** - * Sets the MediaFormat in which this MediaDeviceSession - * outputs the media captured by its MediaDevice. - * - * @param format the MediaFormat in which this - * MediaDeviceSession is to output the media captured by its - * MediaDevice - */ - public void setFormat(MediaFormat format) - { - if (!getMediaType().equals(format.getMediaType())) - throw new IllegalArgumentException("format"); - - /* - * We need javax.media.Format and we know how to convert MediaFormat to - * it only for MediaFormatImpl so assert early. - */ - @SuppressWarnings("unchecked") - MediaFormatImpl mediaFormatImpl - = (MediaFormatImpl) format; - - this.format = mediaFormatImpl; - if (logger.isTraceEnabled()) - { - logger.trace( - "Set format " + this.format - + " on " - + getClass().getSimpleName() + " " + hashCode()); - } - - /* - * If the processor is after Configured, setting a different format will - * silently fail. Recreate the processor in order to be able to set the - * different format. - */ - if (processor != null) - { - int processorState = processor.getState(); - - if (processorState == Processor.Configured) - setProcessorFormat(processor, this.format); - else if (processorIsPrematurelyClosed - || ((processorState > Processor.Configured) - && !this.format.getFormat().equals( - getProcessorFormat())) - || outputsizeChanged) - { - outputsizeChanged = false; - setProcessor(null); - } - } - } - - /** - * Sets the MediaFormatImpl in which a specific Processor - * producing media to be streamed to the remote peer is to output. - * - * @param processor the Processor to set the output - * MediaFormatImpl of - * @param mediaFormat the MediaFormatImpl to set on - * processor - */ - protected void setProcessorFormat( - Processor processor, - MediaFormatImpl mediaFormat) - { - TrackControl[] trackControls = processor.getTrackControls(); - MediaType mediaType = getMediaType(); - Format format = mediaFormat.getFormat(); - - for (int trackIndex = 0; - trackIndex < trackControls.length; - trackIndex++) - { - TrackControl trackControl = trackControls[trackIndex]; - - if (!trackControl.isEnabled()) - continue; - - Format[] supportedFormats = trackControl.getSupportedFormats(); - - if ((supportedFormats == null) || (supportedFormats.length < 1)) - { - trackControl.setEnabled(false); - continue; - } - - Format supportedFormat = null; - - switch (mediaType) - { - case AUDIO: - if (supportedFormats[0] instanceof AudioFormat) - { - supportedFormat - = findFirstMatchingFormat(supportedFormats, format); - - /* - * We've failed to find a supported format so try to use - * whatever we've been told and, if it fails, the caller - * will at least know why. - */ - if (supportedFormat == null) - supportedFormat = format; - } - break; - case VIDEO: - if (supportedFormats[0] instanceof VideoFormat) - { - supportedFormat - = findFirstMatchingFormat(supportedFormats, format); - - /* - * We've failed to find a supported format so try to use - * whatever we've been told and, if it fails, the caller - * will at least know why. - */ - if (supportedFormat == null) - supportedFormat = format; - if (supportedFormat != null) - supportedFormat - = assertSize((VideoFormat) supportedFormat); - } - break; - } - - if (supportedFormat == null) - trackControl.setEnabled(false); - else if (!supportedFormat.equals(trackControl.getFormat())) - { - Format setFormat - = setProcessorFormat( - trackControl, - mediaFormat, supportedFormat); - - if (setFormat == null) - logger.error( - "Failed to set format of track " - + trackIndex - + " to " - + supportedFormat - + ". Processor is in state " - + processor.getState()); - else if (setFormat != supportedFormat) - logger.warn( - "Failed to change format of track " - + trackIndex - + " from " - + setFormat - + " to " - + supportedFormat - + ". Processor is in state " - + processor.getState()); - else if (logger.isTraceEnabled()) - logger.trace( - "Set format of track " - + trackIndex - + " to " - + setFormat); - } - } - } - - /** - * Sets the MediaFormatImpl of a specific TrackControl of - * the Processor which produces the media to be streamed by this - * MediaDeviceSession to the remote peer. Allows extenders to - * override the set procedure and to detect when the JMF Format of - * the specified TrackControl changes. - * - * @param trackControl the TrackControl to set the JMF - * Format of - * @param mediaFormat the MediaFormatImpl to be set on the - * specified TrackControl. Though mediaFormat encapsulates - * a JMF Format, format is to be set on the specified - * trackControl because it may be more specific. In any case, the - * two JMF Formats match. The MediaFormatImpl is provided - * anyway because it carries additional information such as format - * parameters. - * @param format the JMF Format to be set on the specified - * TrackControl. Though mediaFormat encapsulates a JMF - * Format, the specified format is to be set on the - * specified trackControl because it may be more specific than the - * JMF Format of the mediaFormat - * @return the JMF Format set on TrackControl after the - * attempt to set the specified format or null if the - * specified format was found to be incompatible with - * trackControl - */ - protected Format setProcessorFormat( - TrackControl trackControl, - MediaFormatImpl mediaFormat, - Format format) - { - return trackControl.setFormat(format); - } - - /** - * Sets the indicator which determines whether this - * MediaDeviceSession is set to output "silence" instead of the - * actual media fed from its CaptureDevice. - * - * @param mute true to set this MediaDeviceSession to - * output "silence" instead of the actual media fed from its - * CaptureDevice; otherwise, false - */ - public void setMute(boolean mute) - { - if (this.mute != mute) - { - this.mute = mute; - - DataSource captureDevice = this.captureDevice; - - if (captureDevice instanceof MuteDataSource) - ((MuteDataSource) captureDevice).setMute(this.mute); - } - } - - /** - * Adds a new inband DTMF tone to send. - * - * @param tone the DTMF tone to send. - */ - public void addDTMF(DTMFInbandTone tone) - { - DataSource captureDevice = this.captureDevice; - - if (captureDevice instanceof InbandDTMFDataSource) - { - ((InbandDTMFDataSource) captureDevice).addDTMF(tone); - } - } - - /** - * Adds a specific DataSource to the list of playbacks of - * ReceiveStreams and/or DataSources performed by - * respective Players on the MediaDevice represented by - * this instance. - * - * @param playbackDataSource the DataSource which to be added to - * the list of playbacks of ReceiveStreams and/or - * DataSources performed by respective Players on the - * MediaDevice represented by this instance - */ - public void addPlaybackDataSource(DataSource playbackDataSource) - { - synchronized (playbacks) - { - Playback playback = getPlayback(playbackDataSource); - - if (playback == null) - { - if (playbackDataSource - instanceof ReceiveStreamPushBufferDataSource) - { - ReceiveStream receiveStream - = ((ReceiveStreamPushBufferDataSource) - playbackDataSource) - .getReceiveStream(); - - playback = getPlayback(receiveStream); - } - if (playback == null) - { - playback = new Playback(playbackDataSource); - playbacks.add(playback); - } - else - playback.dataSource = playbackDataSource; - - playback.player = createPlayer(playbackDataSource); - - playbackDataSourceAdded(playbackDataSource); - } - } - } - - /** - * Removes a specific DataSource from the list of playbacks of - * ReceiveStreams and/or DataSources performed by - * respective Players on the MediaDevice represented by - * this instance. - * - * @param playbackDataSource the DataSource which to be removed - * from the list of playbacks of ReceiveStreams and/or - * DataSources performed by respective Players on the - * MediaDevice represented by this instance - */ - public void removePlaybackDataSource(DataSource playbackDataSource) - { - synchronized (playbacks) - { - Playback playback = getPlayback(playbackDataSource); - - if (playback != null) - { - if (playback.player != null) - { - disposePlayer(playback.player); - playback.player = null; - } - - playback.dataSource = null; - if (playback.receiveStream == null) - playbacks.remove(playback); - - playbackDataSourceRemoved(playbackDataSource); - } - } - } - - /** - * Sets the JMF Processor which is to transcode - * {@link #captureDevice} into the format of this instance. - * - * @param processor the JMF Processor which is to transcode - * {@link #captureDevice} into the format of this instance - */ - private void setProcessor(Processor processor) - { - if (this.processor != processor) - { - closeProcessor(); - - this.processor = processor; - - /* - * Since the processor has changed, its output DataSource known to - * the public has also changed. - */ - firePropertyChange(OUTPUT_DATA_SOURCE, null, null); - } - } - - /** - * Adds a specific ReceiveStream to the list of playbacks of - * ReceiveStreams and/or DataSources performed by - * respective Players on the MediaDevice represented by - * this instance. - * - * @param receiveStream the ReceiveStream which to be added to the - * list of playbacks of ReceiveStreams and/or DataSources - * performed by respective Players on the MediaDevice - * represented by this instance - */ - public void addReceiveStream(ReceiveStream receiveStream) - { - synchronized (playbacks) - { - if (getPlayback(receiveStream) == null) - { - playbacks.add(new Playback(receiveStream)); - - addSSRC(receiveStream.getSSRC()); - - // playbackDataSource - DataSource receiveStreamDataSource - = receiveStream.getDataSource(); - - if (receiveStreamDataSource != null) - { - if (receiveStreamDataSource instanceof PushBufferDataSource) - { - receiveStreamDataSource - = new ReceiveStreamPushBufferDataSource( - receiveStream, - (PushBufferDataSource) - receiveStreamDataSource, - true); - } - else - { - logger.warn( - "Adding ReceiveStream with DataSource" - + " not of type PushBufferDataSource but " - + receiveStreamDataSource.getClass() - .getSimpleName() - + " which may prevent the ReceiveStream" - + " from properly transferring to another" - + " MediaDevice if such a need arises."); - } - addPlaybackDataSource(receiveStreamDataSource); - } - - receiveStreamAdded(receiveStream); - } - } - } - - /** - * Removes a specific ReceiveStream from the list of playbacks of - * ReceiveStreams and/or DataSources performed by - * respective Players on the MediaDevice represented by - * this instance. - * - * @param receiveStream the ReceiveStream which to be removed from - * the list of playbacks of ReceiveStreams and/or - * DataSources performed by respective Players on the - * MediaDevice represented by this instance - */ - public void removeReceiveStream(ReceiveStream receiveStream) - { - synchronized (playbacks) - { - Playback playback = getPlayback(receiveStream); - - if (playback != null) - { - removeSSRC(receiveStream.getSSRC()); - if (playback.dataSource != null) - removePlaybackDataSource(playback.dataSource); - - if (playback.dataSource != null) - { - logger.warn( - "Removing ReceiveStream" - + " with associated DataSource"); - } - playbacks.remove(playback); - - receiveStreamRemoved(receiveStream); - } - } - } - - /** - * Sets the list of SSRC identifiers that this device stores to - * newSsrcList and fires a PropertyChangeEvent for the - * SSRC_LIST property. - * - * @param newSsrcList that SSRC array that we'd like to replace the existing - * SSRC list with. - */ - private void setSsrcList(long[] newSsrcList) - { - // use getRemoteSSRCList() instead of direct access to ssrcList - // as the extender may override it - long[] oldSsrcList = getRemoteSSRCList(); - ssrcList = newSsrcList; - - firePropertyChange(SSRC_LIST, oldSsrcList, getRemoteSSRCList()); - } - - /** - * Starts the processing of media in this instance in a specific direction. - * - * @param direction a MediaDirection value which represents the - * direction of the processing of media to be started. For example, - * {@link MediaDirection#SENDRECV} to start both capture and playback of - * media in this instance or {@link MediaDirection#SENDONLY} to only start - * the capture of media in this instance - */ - public void start(MediaDirection direction) - { - if (direction == null) - throw new NullPointerException("direction"); - - MediaDirection oldValue = startedDirection; - - startedDirection = startedDirection.or(direction); - if (!oldValue.equals(startedDirection)) - startedDirectionChanged(oldValue, startedDirection); - } - - /** - * Notifies this instance that the value of its startedDirection - * property has changed from a specific oldValue to a specific - * newValue. Allows extenders to override and perform additional - * processing of the change. Overriding implementations must call this - * implementation in order to ensure the proper execution of this - * MediaDeviceSession. - * - * @param oldValue the MediaDirection which used to be the value of - * the startedDirection property of this instance - * @param newValue the MediaDirection which is the value of the - * startedDirection property of this instance - */ - protected void startedDirectionChanged( - MediaDirection oldValue, - MediaDirection newValue) - { - if (newValue.allowsSending()) - { - Processor processor = getProcessor(); - - if (processor != null) - startProcessorInAccordWithDirection(processor); - } - else if ((processor != null) - && (processor.getState() > Processor.Configured)) - { - processor.stop(); - if (logger.isTraceEnabled()) - { - logger.trace( - "Stopped Processor with hashCode " - + processor.hashCode()); - } - } - } - - /** - * Starts a specific Processor if this MediaDeviceSession - * has been started and the specified Processor is not started. - * - * @param processor the Processor to start - */ - protected void startProcessorInAccordWithDirection(Processor processor) - { - if (startedDirection.allowsSending() - && (processor.getState() != Processor.Started)) - { - processor.start(); - if (logger.isTraceEnabled()) - { - logger.trace( - "Started Processor with hashCode " - + processor.hashCode()); - } - } - } - - /** - * Stops the processing of media in this instance in a specific direction. - * - * @param direction a MediaDirection value which represents the - * direction of the processing of media to be stopped. For example, - * {@link MediaDirection#SENDRECV} to stop both capture and playback of - * media in this instance or {@link MediaDirection#SENDONLY} to only stop - * the capture of media in this instance - */ - public void stop(MediaDirection direction) - { - if (direction == null) - throw new NullPointerException("direction"); - - MediaDirection oldValue = startedDirection; - - switch (startedDirection) - { - case SENDRECV: - if (direction.allowsReceiving()) - startedDirection - = direction.allowsSending() - ? MediaDirection.INACTIVE - : MediaDirection.SENDONLY; - else if (direction.allowsSending()) - startedDirection = MediaDirection.RECVONLY; - break; - case SENDONLY: - if (direction.allowsSending()) - startedDirection = MediaDirection.INACTIVE; - break; - case RECVONLY: - if (direction.allowsReceiving()) - startedDirection = MediaDirection.INACTIVE; - break; - case INACTIVE: - /* - * This MediaDeviceSession is already inactive so there's nothing to - * stop. - */ - break; - default: - throw new IllegalArgumentException("direction"); - } - - if (!oldValue.equals(startedDirection)) - startedDirectionChanged(oldValue, startedDirection); - } - - /** - * Waits for the specified JMF Processor to enter the specified - * state and returns true if processor has - * successfully entered state or false if process - * has failed to enter state. - * - * @param processor the JMF Processor to wait on - * @param state the state as defined by the respective Processor - * state constants to wait processor to enter - * @return true if processor has successfully entered - * state; otherwise, false - */ - private static boolean waitForState(Processor processor, int state) - { - return new ProcessorUtility().waitForState(processor, state); - } - - /** - * Copies the playback part of a specific MediaDeviceSession into - * this instance. - * - * @param deviceSession the MediaDeviceSession to copy the playback - * part of into this instance - */ - public void copyPlayback(MediaDeviceSession deviceSession) - { - if (deviceSession.disposePlayerOnClose) - { - logger.error( - "Cannot copy playback" - + " if MediaDeviceSession has closed it"); - } - else - { - playbacks.addAll(deviceSession.playbacks); - setSsrcList(deviceSession.ssrcList); - } - } - - /** - * Represents the information related to the playback of a - * DataSource on the MediaDevice represented by a - * MediaDeviceSession. The DataSource may have an - * associated ReceiveStream. - */ - private static class Playback - { - /** - * The DataSource the information related to the playback of - * which is represented by this instance and which is associated with - * {@link #receiveStream}. - */ - public DataSource dataSource; - - /** - * The ReceiveStream the information related to the playback of - * which is represented by this instance and which is associated with - * {@link #dataSource}. - */ - public ReceiveStream receiveStream; - - /** - * The Player which performs the actual playback. - */ - public Player player; - - /** - * Initializes a new Playback instance which is to represent - * the information related to the playback of a specific - * DataSource. - * - * @param dataSource the DataSource the information related to - * the playback of which is to be represented by the new instance - */ - public Playback(DataSource dataSource) - { - this.dataSource = dataSource; - } - - /** - * Initializes a new Playback instance which is to represent - * the information related to the playback of a specific - * ReceiveStream. - * - * @param receiveStream the ReceiveStream the information - * related to the playback of which is to be represented by the new - * instance - */ - public Playback(ReceiveStream receiveStream) - { - this.receiveStream = receiveStream; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/NoneAudioSystem.java b/src/net/java/sip/communicator/impl/neomedia/device/NoneAudioSystem.java deleted file mode 100644 index 139dfb978..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/NoneAudioSystem.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -/** - * Implements an AudioSystem without any devices which allows the user - * to select to use no audio capture, notification and playback. - * - * @author Lyubomir Marinov - */ -public class NoneAudioSystem - extends AudioSystem -{ - public static final String LOCATOR_PROTOCOL = "none"; - - public NoneAudioSystem() - throws Exception - { - super(LOCATOR_PROTOCOL); - } - - protected void doInitialize() - throws Exception - { - } - - @Override - public String toString() - { - return "None"; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/PortAudioSystem.java b/src/net/java/sip/communicator/impl/neomedia/device/PortAudioSystem.java deleted file mode 100644 index d8638b8ea..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/PortAudioSystem.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.renderer.audio.*; -import net.java.sip.communicator.impl.neomedia.portaudio.*; -import net.java.sip.communicator.util.*; - -/** - * Creates PortAudio capture devices by enumerating all host devices that have - * input channels. - * - * @author Damian Minkov - * @author Lyubomir Marinov - */ -public class PortAudioSystem - extends AudioSystem -{ - /** - * The Logger used by the PortAudioSystem class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(PortAudioSystem.class); - - /** - * The protocol of the MediaLocators identifying PortAudio - * CaptureDevices - */ - private static final String LOCATOR_PROTOCOL = LOCATOR_PROTOCOL_PORTAUDIO; - - private Runnable devicesChangedCallback; - - /** - * Initializes a new PortAudioSystem instance which creates PortAudio - * capture devices by enumerating all host devices with input channels. - * - * @throws Exception if anything wrong happens while creating the PortAudio - * capture devices - */ - PortAudioSystem() - throws Exception - { - super( - LOCATOR_PROTOCOL, - FEATURE_DENOISE - | FEATURE_ECHO_CANCELLATION - | FEATURE_NOTIFY_AND_PLAYBACK_DEVICES - | FEATURE_REINITIALIZE); - } - - @Override - public Renderer createRenderer(boolean playback) - { - MediaLocator locator; - - if (playback) - locator = null; - else - { - CaptureDeviceInfo notifyDevice = getNotifyDevice(); - - if (notifyDevice == null) - return null; - else - locator = notifyDevice.getLocator(); - } - - PortAudioRenderer renderer = new PortAudioRenderer(playback); - - if ((renderer != null) && (locator != null)) - renderer.setLocator(locator); - - return renderer; - } - - protected void doInitialize() - throws Exception - { - /* - * If PortAudio fails to initialize because of, for example, a missing - * native counterpart, it will throw an exception here and the PortAudio - * Renderer will not be initialized. - */ - int deviceCount = PortAudio.Pa_GetDeviceCount(); - int channels = 1; - int sampleSizeInBits = 16; - long sampleFormat = PortAudio.getPaSampleFormat(sampleSizeInBits); - int defaultInputDeviceIndex = PortAudio.Pa_GetDefaultInputDevice(); - int defaultOutputDeviceIndex = PortAudio.Pa_GetDefaultOutputDevice(); - List captureDevices - = new LinkedList(); - List playbackDevices - = new LinkedList(); - - for (int deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++) - { - long deviceInfo = PortAudio.Pa_GetDeviceInfo(deviceIndex); - String name = PortAudio.PaDeviceInfo_getName(deviceInfo); - - if (name != null) - name = name.trim(); - - int maxInputChannels - = PortAudio.PaDeviceInfo_getMaxInputChannels(deviceInfo); - int maxOutputChannels - = PortAudio.PaDeviceInfo_getMaxOutputChannels(deviceInfo); - - CaptureDeviceInfo cdi - = new CaptureDeviceInfo( - name, - new MediaLocator(LOCATOR_PROTOCOL + ":#" + deviceIndex), - new Format[] - { - new AudioFormat( - AudioFormat.LINEAR, - (maxInputChannels > 0) - ? getSupportedSampleRate( - true, - deviceIndex, - channels, - sampleFormat) - : PortAudio.DEFAULT_SAMPLE_RATE, - sampleSizeInBits, - channels, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED /* frameSizeInBits */, - Format.NOT_SPECIFIED /* frameRate */, - Format.byteArray) - }); - - if (maxInputChannels > 0) - { - if (deviceIndex == defaultInputDeviceIndex) - { - captureDevices.add(0, cdi); - if (logger.isDebugEnabled()) - logger.debug("Added default capture device: " + name); - } - else - { - captureDevices.add(cdi); - if (logger.isDebugEnabled()) - logger.debug("Added capture device: " + name); - } - } - if (maxOutputChannels > 0) - { - if (deviceIndex == defaultOutputDeviceIndex) - { - playbackDevices.add(0, cdi); - if (logger.isDebugEnabled()) - logger.debug("Added default playback device: " + name); - } - else - { - playbackDevices.add(cdi); - if (logger.isDebugEnabled()) - logger.debug("Added playback device: " + name); - } - } - } - - setCaptureDevices(captureDevices); - setPlaybackDevices(playbackDevices); - - if (devicesChangedCallback == null) - { - devicesChangedCallback - = new Runnable() - { - public void run() - { - try - { - PortAudio.Pa_UpdateAvailableDeviceList(); - initialize(); - } - catch (Throwable t) - { - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - - logger.warn( - "Failed to reinitialize PortAudio devices", - t); - } - } - }; - PortAudio.setDevicesChangedCallback(devicesChangedCallback); - } - } - - /** - * Gets a sample rate supported by a PortAudio device with a specific device - * index with which it is to be registered with JMF. - * - * @param input true if the supported sample rate is to be retrieved for - * the PortAudio device with the specified device index as an input device - * or false for an output device - * @param deviceIndex the device index of the PortAudio device for which a - * supported sample rate is to be retrieved - * @param channelCount number of channel - * @param sampleFormat sample format - * @return a sample rate supported by the PortAudio device with the - * specified device index with which it is to be registered with JMF - */ - private static double getSupportedSampleRate( - boolean input, - int deviceIndex, - int channelCount, - long sampleFormat) - { - long deviceInfo = PortAudio.Pa_GetDeviceInfo(deviceIndex); - double supportedSampleRate; - - if (deviceInfo != 0) - { - double defaultSampleRate - = PortAudio.PaDeviceInfo_getDefaultSampleRate(deviceInfo); - - if (defaultSampleRate >= MediaUtils.MAX_AUDIO_SAMPLE_RATE) - supportedSampleRate = defaultSampleRate; - else - { - long streamParameters - = PortAudio.PaStreamParameters_new( - deviceIndex, - channelCount, - sampleFormat, - PortAudio.LATENCY_UNSPECIFIED); - - if (streamParameters == 0) - supportedSampleRate = defaultSampleRate; - else - { - try - { - long inputParameters; - long outputParameters; - - if (input) - { - inputParameters = streamParameters; - outputParameters = 0; - } - else - { - inputParameters = 0; - outputParameters = streamParameters; - } - - boolean formatIsSupported - = PortAudio.Pa_IsFormatSupported( - inputParameters, - outputParameters, - PortAudio.DEFAULT_SAMPLE_RATE); - - supportedSampleRate - = formatIsSupported - ? PortAudio.DEFAULT_SAMPLE_RATE - : defaultSampleRate; - } - finally - { - PortAudio.PaStreamParameters_free(streamParameters); - } - } - } - } - else - supportedSampleRate = PortAudio.DEFAULT_SAMPLE_RATE; - return supportedSampleRate; - } - - @Override - public String toString() - { - return "PortAudio"; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/PulseAudioSystem.java b/src/net/java/sip/communicator/impl/neomedia/device/PulseAudioSystem.java deleted file mode 100644 index ac3b528af..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/PulseAudioSystem.java +++ /dev/null @@ -1,628 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.io.*; -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.renderer.audio.*; -import net.java.sip.communicator.impl.neomedia.pulseaudio.*; -import net.java.sip.communicator.service.version.*; - -public class PulseAudioSystem - extends AudioSystem -{ - private static final String LOCATOR_PROTOCOL = LOCATOR_PROTOCOL_PULSEAUDIO; - - public static final String MEDIA_ROLE_EVENT = "event"; - - public static final String MEDIA_ROLE_PHONE = "phone"; - - private static final String NULL_DEV_CAPTURE_DEVICE_INFO_NAME = "Default"; - - public static void corkStream(long stream, boolean b) - throws IOException - { - if (stream == 0) - throw new IOException("stream"); - - long o = PA.stream_cork(stream, b, null); - - if (o == 0) - throw new IOException("pa_stream_cork"); - - PA.operation_unref(o); - } - - public static PulseAudioSystem getPulseAudioSystem() - { - AudioSystem audioSystem - = AudioSystem.getAudioSystem(PulseAudioSystem.LOCATOR_PROTOCOL); - - return - (audioSystem instanceof PulseAudioSystem) - ? (PulseAudioSystem) audioSystem - : null; - } - - private boolean createContext; - - private long context; - - private long mainloop; - - public PulseAudioSystem() - throws Exception - { - super(LOCATOR_PROTOCOL, FEATURE_NOTIFY_AND_PLAYBACK_DEVICES); - } - - private void createContext() - { - if (this.context != 0) - throw new IllegalStateException("context"); - - startMainloop(); - try - { - long proplist = PA.proplist_new(); - - if (proplist == 0) - throw new RuntimeException("pa_proplist_new"); - - try - { - populateContextProplist(proplist); - - long context - = PA.context_new_with_proplist( - PA.threaded_mainloop_get_api(mainloop), - null /* PA_PROP_APPLICATION_NAME */, - proplist); - - if (context == 0) - throw new RuntimeException("pa_context_new_with_proplist"); - - try - { - if (proplist != 0) - { - PA.proplist_free(proplist); - proplist = 0; - } - - Runnable stateCallback - = new Runnable() - { - public void run() - { - signalMainloop(false); - } - }; - - lockMainloop(); - try - { - PA.context_set_state_callback(context, stateCallback); - PA.context_connect( - context, - null, - PA.CONTEXT_NOFLAGS, - 0); - - try - { - int state - = waitForContextState( - context, - PA.CONTEXT_READY); - - if (state != PA.CONTEXT_READY) - throw new IllegalStateException( - "context.state"); - - this.context = context; - } - finally - { - if (this.context == 0) - PA.context_disconnect(context); - } - } - finally - { - unlockMainloop(); - } - } - finally - { - if (this.context == 0) - PA.context_unref(context); - } - } - finally - { - if (proplist != 0) - PA.proplist_free(proplist); - } - } - finally - { - if (this.context == 0) - stopMainloop(); - } - } - - @Override - public Renderer createRenderer(boolean playback) - { - MediaLocator locator; - - if (playback) - locator = null; - else - { - CaptureDeviceInfo notifyDevice = getNotifyDevice(); - - if (notifyDevice == null) - return null; - else - locator = notifyDevice.getLocator(); - } - - PulseAudioRenderer renderer - = new PulseAudioRenderer( - playback ? MEDIA_ROLE_PHONE : MEDIA_ROLE_EVENT); - - if ((renderer != null) && (locator != null)) - renderer.setLocator(locator); - - return renderer; - } - - public long createStream( - int sampleRate, - int channels, - String mediaName, - String mediaRole) - throws IllegalStateException, - RuntimeException - { - long context = getContext(); - - if (context == 0) - throw new IllegalStateException("context"); - - long sampleSpec - = PA.sample_spec_new(PA.SAMPLE_S16LE, sampleRate, channels); - - if (sampleSpec == 0) - throw new RuntimeException("pa_sample_spec_new"); - - long ret = 0; - - try - { - long proplist = PA.proplist_new(); - - if (proplist == 0) - throw new RuntimeException("pa_proplist_new"); - - try - { - PA.proplist_sets(proplist, PA.PROP_MEDIA_NAME, mediaRole); - PA.proplist_sets(proplist, PA.PROP_MEDIA_ROLE, mediaRole); - - long stream - = PA.stream_new_with_proplist( - context, - null, - sampleSpec, - 0, - proplist); - - if (stream == 0) - throw new RuntimeException( - "pa_stream_new_with_proplist"); - - try - { - ret = stream; - } - finally - { - if (ret == 0) - PA.stream_unref(stream); - } - } - finally - { - if (proplist != 0) - PA.proplist_free(proplist); - } - } - finally - { - if (sampleSpec != 0) - PA.sample_spec_free(sampleSpec); - } - - return ret; - } - - protected synchronized void doInitialize() - throws Exception - { - long context = getContext(); - - final List captureDevices - = new LinkedList(); - final List captureDeviceFormats = new LinkedList(); - PA.source_info_cb_t sourceInfoListCallback - = new PA.source_info_cb_t() - { - public void callback(long c, long i, int eol) - { - try - { - if ((eol == 0) && (i != 0)) - { - sourceInfoListCallback( - c, - i, - captureDevices, - captureDeviceFormats); - } - } - finally - { - signalMainloop(false); - } - } - }; - - final List playbackDevices - = new LinkedList(); - final List playbackDeviceFormats = new LinkedList(); - PA.sink_info_cb_t sinkInfoListCallback - = new PA.sink_info_cb_t() - { - public void callback(long c, long i, int eol) - { - try - { - if ((eol == 0) && (i != 0)) - { - sinkInfoListCallback( - c, - i, - playbackDevices, - playbackDeviceFormats); - } - } - finally - { - signalMainloop(false); - } - } - }; - - lockMainloop(); - try - { - long o - = PA.context_get_source_info_list( - context, - sourceInfoListCallback); - - if (o == 0) - throw new RuntimeException("pa_context_get_source_info_list"); - - try - { - while (PA.operation_get_state(o) == PA.OPERATION_RUNNING) - waitMainloop(); - } - finally - { - PA.operation_unref(o); - } - - o - = PA.context_get_sink_info_list( - context, - sinkInfoListCallback); - - if (o == 0) - throw new RuntimeException("pa_context_get_sink_info_list"); - - try - { - while (PA.operation_get_state(o) == PA.OPERATION_RUNNING) - waitMainloop(); - } - finally - { - PA.operation_unref(o); - } - } - finally - { - unlockMainloop(); - } - - if (!captureDeviceFormats.isEmpty()) - { - captureDevices.add( - 0, - new CaptureDeviceInfo( - NULL_DEV_CAPTURE_DEVICE_INFO_NAME, - new MediaLocator(LOCATOR_PROTOCOL + ":"), - captureDeviceFormats.toArray( - new Format[captureDeviceFormats.size()]))); - } - if (!playbackDevices.isEmpty()) - { - playbackDevices.add( - 0, - new CaptureDeviceInfo( - NULL_DEV_CAPTURE_DEVICE_INFO_NAME, - new MediaLocator(LOCATOR_PROTOCOL + ":"), - null)); - } - - setCaptureDevices(captureDevices); - setPlaybackDevices(playbackDevices); - } - - public synchronized long getContext() - { - if (context == 0) - { - if (!createContext) - { - createContext = true; - createContext(); - } - if (context == 0) - throw new IllegalStateException("context"); - } - return context; - } - - public void lockMainloop() - { - PA.threaded_mainloop_lock(mainloop); - } - - /** - * Populates a specific pa_proplist which is to be used with a - * pa_context with properties such as the application name and - * version. - * - * @param proplist the pa_proplist which is to be populated with - * pa_context-related properties such as the application name and - * version - */ - private void populateContextProplist(long proplist) - { - /* - * XXX For the sake of simplicity while working on libjitsi, get the - * version information in the form of System property values instead of - * going through the VersionService. - */ - String applicationName - = System.getProperty(Version.PNAME_APPLICATION_NAME); - - if (applicationName != null) - PA.proplist_sets( - proplist, - PA.PROP_APPLICATION_NAME, - applicationName); - - String applicationVersion - = System.getProperty(Version.PNAME_APPLICATION_VERSION); - - if (applicationVersion != null) - PA.proplist_sets( - proplist, - PA.PROP_APPLICATION_VERSION, - applicationVersion); - } - - public void signalMainloop(boolean waitForAccept) - { - PA.threaded_mainloop_signal(mainloop, waitForAccept); - } - - private void sinkInfoListCallback( - long context, - long sinkInfo, - List deviceList, - List formatList) - { - int sampleSpecFormat = PA.sink_info_get_sample_spec_format(sinkInfo); - - if (sampleSpecFormat != PA.SAMPLE_S16LE) - return; - - String description = PA.sink_info_get_description(sinkInfo); - String name = PA.sink_info_get_name(sinkInfo); - - if (description == null) - description = name; - deviceList.add( - new CaptureDeviceInfo( - description, - new MediaLocator( - LOCATOR_PROTOCOL - + ":" - + name), - null)); - } - - private void sourceInfoListCallback( - long context, - long sourceInfo, - List deviceList, - List formatList) - { - int monitorOfSink = PA.source_info_get_monitor_of_sink(sourceInfo); - - if (monitorOfSink != PA.INVALID_INDEX) - return; - - int sampleSpecFormat - = PA.source_info_get_sample_spec_format(sourceInfo); - - if (sampleSpecFormat != PA.SAMPLE_S16LE) - return; - - int channels = PA.source_info_get_sample_spec_channels(sourceInfo); - int rate = PA.source_info_get_sample_spec_rate(sourceInfo); - List sourceInfoFormatList = new LinkedList(); - - if ((MediaUtils.MAX_AUDIO_CHANNELS != Format.NOT_SPECIFIED) - && (MediaUtils.MAX_AUDIO_CHANNELS < channels)) - channels = MediaUtils.MAX_AUDIO_CHANNELS; - if ((MediaUtils.MAX_AUDIO_SAMPLE_RATE != Format.NOT_SPECIFIED) - && (MediaUtils.MAX_AUDIO_SAMPLE_RATE < rate)) - rate = (int) MediaUtils.MAX_AUDIO_SAMPLE_RATE; - - AudioFormat audioFormat - = new AudioFormat( - AudioFormat.LINEAR, - rate, - 16, - channels, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED /* frameSizeInBits */, - Format.NOT_SPECIFIED /* frameRate */, - Format.byteArray); - - if (!sourceInfoFormatList.contains(audioFormat)) - { - sourceInfoFormatList.add(audioFormat); - if (!formatList.contains(audioFormat)) - formatList.add(audioFormat); - } - if (!formatList.isEmpty()) - { - String description = PA.source_info_get_description(sourceInfo); - String name = PA.source_info_get_name(sourceInfo); - - if (description == null) - description = name; - deviceList.add( - new CaptureDeviceInfo( - description, - new MediaLocator( - LOCATOR_PROTOCOL - + ":" - + name), - sourceInfoFormatList.toArray( - new Format[sourceInfoFormatList.size()]))); - } - } - - private void startMainloop() - { - if (this.mainloop != 0) - throw new IllegalStateException("mainloop"); - - long mainloop = PA.threaded_mainloop_new(); - - if (mainloop == 0) - throw new RuntimeException("pa_threaded_mainloop_new"); - - try - { - if (PA.threaded_mainloop_start(mainloop) < 0) - throw new RuntimeException("pa_threaded_mainloop_start"); - - this.mainloop = mainloop; - } - finally - { - if (this.mainloop == 0) - PA.threaded_mainloop_free(mainloop); - } - } - - private void stopMainloop() - { - if (this.mainloop == 0) - throw new IllegalStateException("mainloop"); - - long mainloop = this.mainloop; - - this.mainloop = 0; - PA.threaded_mainloop_stop(mainloop); - PA.threaded_mainloop_free(mainloop); - } - - @Override - public String toString() - { - return "PulseAudio"; - } - - public void unlockMainloop() - { - PA.threaded_mainloop_unlock(mainloop); - } - - private int waitForContextState( - long context, - int stateToWaitFor) - { - int state; - - while (true) - { - state = PA.context_get_state(context); - if ((PA.CONTEXT_FAILED == state) - || (stateToWaitFor == state) - || (PA.CONTEXT_TERMINATED == state)) - break; - - waitMainloop(); - } - - return state; - } - - public int waitForStreamState( - long stream, - int stateToWaitFor) - { - int state; - - while (true) - { - state = PA.stream_get_state(stream); - if ((stateToWaitFor == state) - || (PA.STREAM_FAILED == state) - || (PA.STREAM_TERMINATED == state)) - break; - - waitMainloop(); - } - - return state; - } - - public void waitMainloop() - { - PA.threaded_mainloop_wait(mainloop); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/QuickTimeSystem.java b/src/net/java/sip/communicator/impl/neomedia/device/QuickTimeSystem.java deleted file mode 100644 index 6df89f6d7..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/QuickTimeSystem.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.impl.neomedia.quicktime.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.util.*; - -/** - * Discovers and registers QuickTime/QTKit capture devices with JMF. - * - * @author Lyubomir Marinov - */ -public class QuickTimeSystem - extends DeviceSystem -{ - - /** - * The Logger used by the QuickTimeSystem class and its - * instances for logging output. - */ - private static final Logger logger = Logger.getLogger(QuickTimeSystem.class); - - /** - * The protocol of the MediaLocators identifying QuickTime/QTKit - * capture devices. - */ - private static final String LOCATOR_PROTOCOL = LOCATOR_PROTOCOL_QUICKTIME; - - /** - * Initializes a new QuickTimeSystem instance which discovers and - * registers QuickTime/QTKit capture devices with JMF. - * - * @throws Exception if anything goes wrong while discovering and - * registering QuickTime/QTKit capture defines with JMF - */ - public QuickTimeSystem() - throws Exception - { - super(MediaType.VIDEO, LOCATOR_PROTOCOL); - } - - protected void doInitialize() - throws Exception - { - QTCaptureDevice[] inputDevices - = QTCaptureDevice.inputDevicesWithMediaType(QTMediaType.Video); - boolean captureDeviceInfoIsAdded = false; - - for (QTCaptureDevice inputDevice : inputDevices) - { - CaptureDeviceInfo device - = new CaptureDeviceInfo( - inputDevice.localizedDisplayName(), - new MediaLocator( - LOCATOR_PROTOCOL - + ':' - + inputDevice.uniqueID()), - new Format[] - { - new AVFrameFormat(FFmpeg.PIX_FMT_ARGB), - new RGBFormat() - }); - - if(logger.isInfoEnabled()) - { - for(QTFormatDescription f : inputDevice.formatDescriptions()) - { - logger.info( - "Webcam available resolution for " - + inputDevice.localizedDisplayName() - + ":" - + f.sizeForKey( - QTFormatDescription - .VideoEncodedPixelsSizeAttribute)); - } - } - - CaptureDeviceManager.addDevice(device); - captureDeviceInfoIsAdded = true; - if (logger.isDebugEnabled()) - logger.debug("Added CaptureDeviceInfo " + device); - } - if (captureDeviceInfoIsAdded - && !MediaServiceImpl.isJmfRegistryDisableLoad()) - CaptureDeviceManager.commit(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/ReceiveStreamPushBufferDataSource.java b/src/net/java/sip/communicator/impl/neomedia/device/ReceiveStreamPushBufferDataSource.java deleted file mode 100644 index 4bb895801..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/ReceiveStreamPushBufferDataSource.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import javax.media.protocol.*; -import javax.media.rtp.*; - -import net.java.sip.communicator.impl.neomedia.protocol.*; - -/** - * Wraps the DataSource of a specific ReceiveStream so that - * calls to its {@link DataSource#disconnect()} can be explicitly controlled. It - * is introduced because it seems that after the DataSource of a - * ReceiveStream is disconnected, it cannot be connected to or started - * and if a Processor is created on it, it freezes in the - * {@link javax.media.Processor#Configuring} state. - * - * @author Lubomir Marinov - */ -public class ReceiveStreamPushBufferDataSource - extends PushBufferDataSourceDelegate -{ - - /** - * The ReceiveStream which has its DataSource wrapped by - * this instance. Currently, remembered just to be made available to callers - * in case they need it and not used by this instance. - */ - private final ReceiveStream receiveStream; - - /** - * The indicator which determines whether {@link DataSource#disconnect()} is - * to be called on the wrapped DataSource when it is called on this - * instance. - */ - private boolean suppressDisconnect; - - /** - * Initializes a new ReceiveStreamPushBufferDataSource instance - * which is to wrap a specific DataSource of a specific - * ReceiveStream for the purposes of enabling explicity control of - * calls to its {@link DataSource#disconnect()}. - * - * @param receiveStream the ReceiveStream which is to have its - * DataSource - * @param dataSource the DataSource of receiveStream which - * is to be wrapped by this instance - */ - public ReceiveStreamPushBufferDataSource( - ReceiveStream receiveStream, - PushBufferDataSource dataSource) - { - super(dataSource); - - this.receiveStream = receiveStream; - } - - /** - * Initializes a new ReceiveStreamPushBufferDataSource instance - * which is to wrap a specific DataSource of a specific - * ReceiveStream for the purposes of enabling explicity control of - * calls to its {@link DataSource#disconnect()} and, optionally, activates - * the suppresses the call in question. - * - * @param receiveStream the ReceiveStream which is to have its - * DataSource - * @param dataSource the DataSource of receiveStream which - * is to be wrapped by this instance - * @param suppressDisconnect true if calls to - * DataSource#disconnect() on the wrapped dataSource are - * to be suppressed when there are such calls on the new instance; - * otherwise, false - */ - public ReceiveStreamPushBufferDataSource( - ReceiveStream receiveStream, - PushBufferDataSource dataSource, - boolean suppressDisconnect) - { - this(receiveStream, dataSource); - - setSuppressDisconnect(suppressDisconnect); - } - - /** - * Implements {@link DataSource#disconnect()}. Disconnects the wrapped - * DataSource if it has not been explicitly suppressed by setting - * the suppressDisconnect property of this instance. - */ - @Override - public void disconnect() - { - if (!suppressDisconnect) - super.disconnect(); - } - - /** - * Gets the ReceiveStream which has its DataSource wrapped - * by this instance. - * - * @return the ReceiveStream which has its DataSource - * wrapped by this instance - */ - public ReceiveStream getReceiveStream() - { - return receiveStream; - } - - /** - * Implements {@link PushBufferDataSource#getStreams()}. Delegates to the - * wrapped DataSource of the ReceiveStream. - * - * @return an array of the PushBufferStreams of the wrapped - * DataSource of the ReceiveStream - */ - public PushBufferStream[] getStreams() - { - return dataSource.getStreams(); - } - - /** - * Sets the indicator which determines whether calls to - * {@link DataSource#disconnect()} on the wrapped DataSource are to - * be suppressed when there are such calls on this instance. - * - * @param suppressDisconnect true to suppress calls to - * DataSource#disconnect() on the wrapped DataSource when - * there are such calls on this instance; otherwise, false - */ - public void setSuppressDisconnect(boolean suppressDisconnect) - { - this.suppressDisconnect = suppressDisconnect; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/ScreenDeviceImpl.java b/src/net/java/sip/communicator/impl/neomedia/device/ScreenDeviceImpl.java deleted file mode 100644 index 01220a6ba..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/ScreenDeviceImpl.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.awt.*; - -import net.java.sip.communicator.service.neomedia.device.*; - -/** - * Implementation of ScreenDevice. - * - * @author Sebastien Vincent - * @author Lyubomir Marinov - */ -public class ScreenDeviceImpl implements ScreenDevice -{ - private static final ScreenDevice[] EMPTY_SCREEN_DEVICE_ARRAY - = new ScreenDevice[0]; - - /** - * AWT GraphicsDevice. - */ - final GraphicsDevice screen; - - /** - * Screen index. - */ - private final int index; - - /** - * Returns all available ScreenDevice instances. - * - * @return array of ScreenDevice instances - */ - public static ScreenDevice[] getAvailableScreenDevices() - { - GraphicsEnvironment ge; - - try - { - ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - } - catch(NoClassDefFoundError ncdfe) - { - ge = null; - } - - ScreenDevice[] screens = null; - - /* - * Make sure the GraphicsEnvironment is not headless in order to avoid a - * HeadlessException. - */ - if ((ge != null) && !ge.isHeadlessInstance()) - { - GraphicsDevice[] devices = ge.getScreenDevices(); - - if ((devices != null) && (devices.length != 0)) - { - screens = new ScreenDevice[devices.length]; - - int i = 0; - - for (GraphicsDevice dev : devices) - { - // We know that GraphicsDevice type is TYPE_RASTER_SCREEN. - screens[i] = new ScreenDeviceImpl(i, dev); - i++; - } - } - } - - return (screens == null) ? EMPTY_SCREEN_DEVICE_ARRAY : screens; - } - - public static ScreenDevice getDefaultScreenDevice() - { - ScreenDevice[] screens = getAvailableScreenDevices(); - int width = 0; - int height = 0; - ScreenDevice best = null; - - for (ScreenDevice screen : screens) - { - java.awt.Dimension res = screen.getSize(); - - if ((res != null) && ((width < res.width) || (height < res.height))) - { - width = res.width; - height = res.height; - best = screen; - } - } - return best; - } - - /** - * Constructor. - * - * @param index screen index - * @param screen screen device - */ - protected ScreenDeviceImpl(int index, GraphicsDevice screen) - { - this.index = index; - this.screen = screen; - } - - /** - * Get the screen index. - * - * @return screen index - */ - public int getIndex() - { - return index; - } - - /** - * Get current resolution of ScreenDevice device. - * - * @return current resolution of the screen - */ - public Dimension getSize() - { - /* get current display resolution */ - DisplayMode mode = screen.getDisplayMode(); - - return - (mode == null) - ? null - : new Dimension(mode.getWidth(), mode.getHeight()); - } - - /** - * Get the identifier of the screen. - * - * @return ID of the screen - */ - public String getName() - { - return screen.getIDstring(); - } - - /** - * If the screen contains specified point. - * - * @param p point coordinate - * @return true if point belongs to screen, false otherwise - */ - public boolean containsPoint(Point p) - { - return screen.getDefaultConfiguration().getBounds().contains(p); - } - - /** - * Get bounds of the screen. - * - * @return bounds of the screen - */ - public Rectangle getBounds() - { - return screen.getDefaultConfiguration().getBounds(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/Video4Linux2System.java b/src/net/java/sip/communicator/impl/neomedia/device/Video4Linux2System.java deleted file mode 100644 index 436ff19ae..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/Video4Linux2System.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import javax.media.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.video4linux2.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.util.*; - -/** - * Discovers and registers CaptureDevices which implement the Video for - * Linux Two API Specification with JMF. - * - * @author Lyubomir Marinov - */ -public class Video4Linux2System - extends DeviceSystem -{ - /** - * The Logger used by the Video4Linux2System class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(Video4Linux2System.class); - - /** - * The protocol of the MediaLocators identifying - * CaptureDevice which implement the Video for Linux Two API - * Specification. - */ - private static final String LOCATOR_PROTOCOL - = LOCATOR_PROTOCOL_VIDEO4LINUX2; - - /** - * Initializes a new Video4Linux2System instance which discovers and - * registers CaptureDevices which implement the Video for Linux Two - * API Specification with JMF. - * - * @throws Exception if anything goes wrong while discovering and - * registering CaptureDevices which implement the Video for Linux - * Two API Specification with JMF - */ - public Video4Linux2System() - throws Exception - { - super(MediaType.VIDEO, LOCATOR_PROTOCOL); - } - - /** - * Discovers and registers a CaptureDevice implementing the Video - * for Linux Two API Specification with a specific device name with JMF. - * - * @param deviceName the device name of a candidate for a - * CaptureDevice implementing the Video for Linux Two API - * Specification to be discovered and registered with JMF - * @return true if a CaptureDeviceInfo for the specified - * CaptureDevice has been added to CaptureDeviceManager; - * otherwise, false - * @throws Exception if anything goes wrong while discovering and - * registering the specified CaptureDevice with JMF - */ - private boolean discoverAndRegister(String deviceName) - throws Exception - { - int fd = Video4Linux2.open(deviceName, Video4Linux2.O_RDWR); - boolean captureDeviceInfoIsAdded = false; - - if (-1 != fd) - { - try - { - long v4l2_capability = Video4Linux2.v4l2_capability_alloc(); - - if (0 != v4l2_capability) - { - try - { - if ((Video4Linux2.ioctl( - fd, - Video4Linux2.VIDIOC_QUERYCAP, - v4l2_capability) - != -1) - && ((Video4Linux2 - .v4l2_capability_getCapabilities( - v4l2_capability) - & Video4Linux2.V4L2_CAP_VIDEO_CAPTURE) - == Video4Linux2.V4L2_CAP_VIDEO_CAPTURE)) - { - captureDeviceInfoIsAdded - = register(deviceName, fd, v4l2_capability); - } - } - finally - { - Video4Linux2.free(v4l2_capability); - } - } - } - finally - { - Video4Linux2.close(fd); - } - } - return captureDeviceInfoIsAdded; - } - - protected void doInitialize() - throws Exception - { - String baseDeviceName = "/dev/video"; - boolean captureDeviceInfoIsAdded = discoverAndRegister(baseDeviceName); - - for (int deviceMinorNumber = 0; - deviceMinorNumber <= 63; - deviceMinorNumber++) - { - captureDeviceInfoIsAdded - = discoverAndRegister(baseDeviceName + deviceMinorNumber) - || captureDeviceInfoIsAdded; - } - if (captureDeviceInfoIsAdded - && !MediaServiceImpl.isJmfRegistryDisableLoad()) - CaptureDeviceManager.commit(); - } - - /** - * Registers a CaptureDevice implementing the Video for Linux Two - * API Specification with a specific device name, a specific open() - * file descriptor and a specific v4l2_capability with JMF. - * - * @param deviceName name of the device (i.e. /dev/videoX) - * @param fd file descriptor of the device - * @param v4l2_capability device V4L2 capability - * @return true if a CaptureDeviceInfo for the specified - * CaptureDevice has been added to CaptureDeviceManager; - * otherwise, false - * @throws Exception if anything goes wrong while registering the specified - * CaptureDevice with JMF - */ - private boolean register(String deviceName, int fd, long v4l2_capability) - throws Exception - { - long v4l2_format - = Video4Linux2.v4l2_format_alloc( - Video4Linux2.V4L2_BUF_TYPE_VIDEO_CAPTURE); - int pixelformat = 0; - String supportedRes = null; - - if (0 != v4l2_format) - { - try - { - if (Video4Linux2.ioctl( - fd, - Video4Linux2.VIDIOC_G_FMT, - v4l2_format) - != -1) - { - long fmtPix - = Video4Linux2.v4l2_format_getFmtPix(v4l2_format); - - pixelformat - = Video4Linux2.v4l2_pix_format_getPixelformat(fmtPix); - - if (FFmpeg.PIX_FMT_NONE - == DataSource.getFFmpegPixFmt(pixelformat)) - { - Video4Linux2.v4l2_pix_format_setPixelformat( - fmtPix, - Video4Linux2.V4L2_PIX_FMT_RGB24); - if (Video4Linux2.ioctl( - fd, - Video4Linux2.VIDIOC_S_FMT, - v4l2_format) - != -1) - { - pixelformat - = Video4Linux2.v4l2_pix_format_getPixelformat( - fmtPix); - } - } - - if(logger.isInfoEnabled()) - { - supportedRes = - Video4Linux2.v4l2_pix_format_getWidth(fmtPix) - + "x" - + Video4Linux2.v4l2_pix_format_getHeight(fmtPix); - } - } - } - finally - { - Video4Linux2.free(v4l2_format); - } - } - - Format format; - int ffmpegPixFmt = DataSource.getFFmpegPixFmt(pixelformat); - - if (FFmpeg.PIX_FMT_NONE != ffmpegPixFmt) - format = new AVFrameFormat(ffmpegPixFmt, pixelformat); - else - return false; - - String name = Video4Linux2.v4l2_capability_getCard(v4l2_capability); - - if ((name == null) || (name.length() == 0)) - name = deviceName; - else - name += " (" + deviceName + ")"; - - if(logger.isInfoEnabled() && supportedRes != null) - { - logger.info("Webcam available resolution for " + name - + ":" + supportedRes); - } - - CaptureDeviceManager.addDevice( - new CaptureDeviceInfo( - name, - new MediaLocator(LOCATOR_PROTOCOL + ":" + deviceName), - new Format[] { format })); - return true; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/VideoMediaDeviceSession.java b/src/net/java/sip/communicator/impl/neomedia/device/VideoMediaDeviceSession.java deleted file mode 100644 index 74368f274..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/VideoMediaDeviceSession.java +++ /dev/null @@ -1,1836 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.util.*; -import java.util.List; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; -import javax.media.protocol.*; -import javax.swing.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.impl.neomedia.codec.video.h264.*; -import net.java.sip.communicator.impl.neomedia.format.*; -import net.java.sip.communicator.impl.neomedia.transform.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.control.*; -import net.java.sip.communicator.service.neomedia.control.KeyFrameControl; // disambiguation -import net.java.sip.communicator.service.neomedia.format.*; -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.event.*; - -/** - * Extends MediaDeviceSession to add video-specific functionality. - * - * @author Lyubomir Marinov - * @author Sebastien Vincent - */ -public class VideoMediaDeviceSession - extends MediaDeviceSession -{ - /** - * The Logger used by the VideoMediaDeviceSession class - * and its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(VideoMediaDeviceSession.class); - - /** - * The image ID of the icon which is to be displayed as the local visual - * Component depicting the streaming of the desktop of the local - * peer to the remote peer. - */ - private static final String DESKTOP_STREAMING_ICON - = "impl.media.DESKTOP_STREAMING_ICON"; - - /** - * The KeyFrameControl used by thisVideoMediaDeviceSession - * as a means to control its key frame-related logic. - */ - private KeyFrameControl keyFrameControl; - - /** - * The KeyFrameRequester implemented by this - * VideoMediaDeviceSession and provided to - * {@link #keyFrameControl}. - */ - private KeyFrameControl.KeyFrameRequester keyFrameRequester; - - /** - * The Player which provides the local visual/video - * Component. - */ - private Player localPlayer; - - /** - * The Object which synchronizes the access to - * {@link #localPlayer}. - */ - private final Object localPlayerSyncRoot = new Object(); - - /** - * Local SSRC. - */ - private long localSSRC = -1; - - /** - * Output size of the stream. - * - * It is used to specify a different size (generally lesser ones) - * than the capture device provides. Typically one usage can be - * in desktop streaming/sharing session when sender desktop is bigger - * than remote ones. - */ - private Dimension outputSize; - - /** - * The SwScaler inserted into the codec chain of the - * Player rendering the media received from the remote peer and - * enabling the explicit setting of the video size. - */ - private SwScaler playerScaler; - - /** - * Remote SSRC. - */ - private long remoteSSRC = -1; - - /** - * The RTPConnector with which the RTPManager of this - * instance is to be or is already initialized. - */ - private AbstractRTPConnector rtpConnector; - - /** - * Use or not RTCP feedback Picture Loss Indication. - */ - private boolean usePLI = false; - - /** - * The facility which aids this instance in managing a list of - * VideoListeners and firing VideoEvents to them. - */ - private final VideoNotifierSupport videoNotifierSupport - = new VideoNotifierSupport(this, false); - - /** - * Tells to flip the local video display (true, in case of diplaying the - * webcam as a mirror), or not (false, for desktop streaming). - */ - private boolean flipLocalVideoDisplay = true; - - /** - * Initializes a new VideoMediaDeviceSession instance which is to - * represent the work of a MediaStream with a specific video - * MediaDevice. - * - * @param device the video MediaDevice the use of which by a - * MediaStream is to be represented by the new instance - */ - public VideoMediaDeviceSession(AbstractMediaDevice device) - { - super(device); - } - - /** - * Adds a specific VideoListener to this instance in order to - * receive notifications when visual/video Components are being - * added and removed. - *

- * Adding a listener which has already been added does nothing i.e. it is - * not added more than once and thus does not receive one and the same - * VideoEvent multiple times. - *

- * - * @param listener the VideoListener to be notified when - * visual/video Components are being added or removed in this - * instance - */ - public void addVideoListener(VideoListener listener) - { - videoNotifierSupport.addVideoListener(listener); - } - - /** - * Creates the DataSource that this instance is to read captured - * media from. - * - * @return the DataSource that this instance is to read captured - * media from - */ - @Override - protected DataSource createCaptureDevice() - { - /* - * Create our DataSource as SourceCloneable so we can use it to both - * display local video and stream to remote peer. - */ - DataSource captureDevice = super.createCaptureDevice(); - - if (captureDevice != null) - { - MediaLocator locator = captureDevice.getLocator(); - String protocol = (locator == null) ? null : locator.getProtocol(); - float frameRate; - DeviceConfiguration deviceConfig - = NeomediaActivator - .getMediaServiceImpl() - .getDeviceConfiguration(); - - // Apply the video size and the frame rate configured by the user. - if (DeviceSystem.LOCATOR_PROTOCOL_IMGSTREAMING.equals(protocol)) - { - /* - * It is not clear at this time what the default frame rate for - * desktop streaming should be. - */ - frameRate = 10; - } - else - { - Dimension videoSize = deviceConfig.getVideoSize(); - - // if we have an output size that is smaller than our current - // settings, respect that size - if(outputSize != null - && videoSize.height > outputSize.height - && videoSize.width > outputSize.width) - videoSize = outputSize; - - Dimension dim = VideoMediaStreamImpl.selectVideoSize( - captureDevice, - videoSize.width, videoSize.height); - - frameRate = deviceConfig.getFrameRate(); - - // print initial video resolution, when starting video - if(logger.isInfoEnabled() && dim != null) - logger.info("video send resolution: " - + dim.width + "x" + dim.height); - } - - FrameRateControl frameRateControl - = (FrameRateControl) - captureDevice.getControl(FrameRateControl.class.getName()); - - if (frameRateControl != null) - { - float maxSupportedFrameRate - = frameRateControl.getMaxSupportedFrameRate(); - - if ((maxSupportedFrameRate > 0) - && (frameRate > maxSupportedFrameRate)) - frameRate = maxSupportedFrameRate; - if(frameRate > 0) - frameRateControl.setFrameRate(frameRate); - - // print initial video frame rate, when starting video - if(logger.isInfoEnabled()) - { - logger.info("video send FPS: " + (frameRate == -1 ? - "default(no restriction)" : frameRate)); - } - } - - if (!(captureDevice instanceof SourceCloneable)) - { - DataSource cloneableDataSource - = Manager.createCloneableDataSource(captureDevice); - - if (cloneableDataSource != null) - captureDevice = cloneableDataSource; - } - } - return captureDevice; - } - - /** - * Asserts that a specific MediaDevice is acceptable to be set as - * the MediaDevice of this instance. Makes sure that its - * MediaType is {@link MediaType#VIDEO}. - * - * @param device the MediaDevice to be checked for suitability to - * become the MediaDevice of this instance - * @see MediaDeviceSession#checkDevice(AbstractMediaDevice) - */ - @Override - protected void checkDevice(AbstractMediaDevice device) - { - if (!MediaType.VIDEO.equals(device.getMediaType())) - throw new IllegalArgumentException("device"); - } - - /** - * Releases the resources allocated by a specific Player in the - * course of its execution and prepares it to be garbage collected. If the - * specified Player is rendering video, notifies the - * VideoListeners of this instance that its visual - * Component is to no longer be used by firing a - * {@link VideoEvent#VIDEO_REMOVED} VideoEvent. - * - * @param player the Player to dispose of - * @see MediaDeviceSession#disposePlayer(Player) - */ - @Override - protected void disposePlayer(Player player) - { - /* - * The player is being disposed so let the (interested) listeners know - * its Player#getVisualComponent() (if any) should be released. - */ - Component visualComponent = getVisualComponent(player); - - super.disposePlayer(player); - - if (visualComponent != null) - { - fireVideoEvent( - VideoEvent.VIDEO_REMOVED, visualComponent, VideoEvent.REMOTE, - false); - } - } - - /** - * Notifies the VideoListeners registered with this instance about - * a specific type of change in the availability of a specific visual - * Component depicting video. - * - * @param type the type of change as defined by VideoEvent in the - * availability of the specified visual Component depicting video - * @param visualComponent the visual Component depicting video - * which has been added or removed in this instance - * @param origin {@link VideoEvent#LOCAL} if the origin of the video is - * local (e.g. it is being locally captured); {@link VideoEvent#REMOTE} if - * the origin of the video is remote (e.g. a remote peer is streaming it) - * @param wait true if the call is to wait till the specified - * VideoEvent has been delivered to the VideoListeners; - * otherwise, false - * @return true if this event and, more specifically, the visual - * Component it describes have been consumed and should be - * considered owned, referenced (which is important because - * Components belong to a single Container at a time); - * otherwise, false - */ - protected boolean fireVideoEvent( - int type, Component visualComponent, int origin, - boolean wait) - { - if (logger.isTraceEnabled()) - { - logger.trace( - "Firing VideoEvent with type " - + VideoEvent.typeToString(type) - + " and origin " - + VideoEvent.originToString(origin)); - } - - return - videoNotifierSupport.fireVideoEvent( - type, visualComponent, origin, - wait); - } - - /** - * Notifies the VideoListeners registered with this instance about - * a specific VideoEvent. - * - * @param videoEvent the VideoEvent to be fired to the - * VideoListeners registered with this instance - * @param wait true if the call is to wait till the specified - * VideoEvent has been delivered to the VideoListeners; - * otherwise, false - */ - protected void fireVideoEvent(VideoEvent videoEvent, boolean wait) - { - videoNotifierSupport.fireVideoEvent(videoEvent, wait); - } - - /** - * Gets the JMF Format of the captureDevice of this - * MediaDeviceSession. - * - * @return the JMF Format of the captureDevice of this - * MediaDeviceSession - */ - private Format getCaptureDeviceFormat() - { - DataSource captureDevice = getCaptureDevice(); - - if (captureDevice != null) - { - FormatControl[] formatControls = null; - - if (captureDevice instanceof CaptureDevice) - { - formatControls - = ((CaptureDevice) captureDevice).getFormatControls(); - } - if ((formatControls == null) || (formatControls.length == 0)) - { - FormatControl formatControl - = (FormatControl) - captureDevice.getControl(FormatControl.class.getName()); - - if (formatControl != null) - formatControls = new FormatControl[] { formatControl }; - } - if (formatControls != null) - { - for (FormatControl formatControl : formatControls) - { - Format format = formatControl.getFormat(); - - if (format != null) - return format; - } - } - } - return null; - } - - /** - * Initializes a new Player instance which is to provide the local - * visual/video Component. The new instance is initialized to - * render the media of the captureDevice of this - * MediaDeviceSession. - * - * @return a new Player instance which is to provide the local - * visual/video Component - */ - private Player createLocalPlayer() - { - return createLocalPlayer(getCaptureDevice()); - } - - /** - * Initializes a new Player instance which is to provide the local - * visual/video Component. The new instance is initialized to - * render the media of a specific DataSource. - * - * @param captureDevice the DataSource which is to have its media - * rendered by the new instance as the local visual/video Component - * @return a new Player instance which is to provide the local - * visual/video Component - */ - protected Player createLocalPlayer(DataSource captureDevice) - { - DataSource dataSource - = (captureDevice instanceof SourceCloneable) - ? ((SourceCloneable) captureDevice).createClone() - : null; - Processor localPlayer = null; - - if (dataSource != null) - { - Exception exception = null; - - try - { - localPlayer = Manager.createProcessor(dataSource); - } - catch (Exception ex) - { - exception = ex; - } - - if (exception == null) - { - if (localPlayer != null) - { - localPlayer.addControllerListener( - new ControllerListener() - { - public void controllerUpdate(ControllerEvent event) - { - controllerUpdateForCreateLocalVisualComponent( - event); - } - }); - localPlayer.configure(); - } - } - else - { - logger.error( - "Failed to connect to " - + MediaStreamImpl.toString(dataSource), - exception); - } - } - - return localPlayer; - } - - /** - * Gets notified about ControllerEvents generated by - * {@link #localPlayer}. - * - * @param controllerEvent the ControllerEvent specifying the - * Controller which is the source of the event and the very type of - * the event - */ - private void controllerUpdateForCreateLocalVisualComponent( - ControllerEvent controllerEvent) - { - if (controllerEvent instanceof ConfigureCompleteEvent) - { - Processor player - = (Processor) controllerEvent.getSourceController(); - - /* - * Use SwScaler for the scaling since it produces an image with - * better quality and add the "flip" effect to the video. - */ - TrackControl[] trackControls = player.getTrackControls(); - - if ((trackControls != null) && (trackControls.length != 0)) - try - { - for (TrackControl trackControl : trackControls) - { - // If the local video is a desktop sharing stream, then - // we do not need to flip the video. - if (!this.flipLocalVideoDisplay) - { - trackControl.setCodecChain( - new Codec[]{new SwScaler()}); - } - // else the local video is a webcam stream, then - // we need to flip the video in order to display it like - // a mirror. - else - { - trackControl.setCodecChain( - new Codec[]{new HFlip(), new SwScaler()}); - } - break; - } - } - catch (UnsupportedPlugInException upiex) - { - logger.warn( - "Failed to add SwScaler/VideoFlipEffect to " + - "codec chain", upiex); - } - - // Turn the Processor into a Player. - try - { - player.setContentDescriptor(null); - } - catch (NotConfiguredError nce) - { - logger.error( - "Failed to set ContentDescriptor of Processor", - nce); - } - - player.realize(); - } - else if (controllerEvent instanceof RealizeCompleteEvent) - { - Player player = (Player) controllerEvent.getSourceController(); - Component visualComponent = player.getVisualComponent(); - boolean start; - - if (visualComponent == null) - start = false; - else - { - start - = fireVideoEvent( - VideoEvent.VIDEO_ADDED, - visualComponent, - VideoEvent.LOCAL, - true); - } - if (start) - player.start(); - else - { - // No listener is interested in our event so free the resources. - synchronized (localPlayerSyncRoot) - { - if (localPlayer == player) - localPlayer = null; - } - - player.stop(); - player.deallocate(); - player.close(); - } - } - } - - /** - * Creates the visual Component depicting the video being streamed - * from the local peer to the remote peer. - * - * @param flipLocalVideoDisplay Tells to flip the local video display (true, - * in case of diplaying the webcam as a mirror), or not (false, for desktop - * streaming). - * - * @return the visual Component depicting the video being streamed - * from the local peer to the remote peer if it was immediately created or - * null if it was not immediately created and it is to be delivered - * to the currently registered VideoListeners in a - * VideoEvent with type {@link VideoEvent#VIDEO_ADDED} and origin - * {@link VideoEvent#LOCAL} - */ - public Component createLocalVisualComponent(boolean flipLocalVideoDisplay) - { - this.flipLocalVideoDisplay = flipLocalVideoDisplay; - - /* - * Displaying the currently streamed desktop is perceived as unnecessary - * because the user sees the whole desktop anyway. Instead, a static - * image will be presented. - */ - DataSource captureDevice = getCaptureDevice(); - - if (captureDevice != null) - { - MediaLocator locator = captureDevice.getLocator(); - - if ((locator != null) - && DeviceSystem.LOCATOR_PROTOCOL_IMGSTREAMING.equals( - locator.getProtocol())) - return createLocalVisualComponentForDesktopStreaming(); - } - - /* - * The visual Component to depict the video being streamed from the - * local peer to the remote peer is created by JMF and its Player so it - * is likely to take noticeably long time. Consequently, we will deliver - * it to the currently registered VideoListeners in a VideoEvent after - * returning from the call. - */ - Component localVisualComponent; - - synchronized (localPlayerSyncRoot) - { - if (localPlayer == null) - localPlayer = createLocalPlayer(); - localVisualComponent - = (localPlayer == null) - ? null - : getVisualComponent(localPlayer); - } - /* - * If the local visual/video Component exists at this time, it has - * likely been created by a previous call to this method. However, the - * caller may still depend on a VIDEO_ADDED event being fired for it. - */ - if (localVisualComponent != null) - fireVideoEvent( - VideoEvent.VIDEO_ADDED, - localVisualComponent, - VideoEvent.LOCAL, - false); - return localVisualComponent; - } - - /** - * Creates the visual Component to depict the streaming of the - * desktop of the local peer to the remote peer. - * - * @return the visual Component to depict the streaming of the - * desktop of the local peer to the remote peer - */ - private Component createLocalVisualComponentForDesktopStreaming() - { - ResourceManagementService resources = NeomediaActivator.getResources(); - ImageIcon icon - = (resources == null) - ? null - : resources.getImage(DESKTOP_STREAMING_ICON); - Canvas canvas; - - if (icon == null) - canvas = null; - else - { - final Image img = icon.getImage(); - - canvas = new Canvas() - { - public static final long serialVersionUID = 0L; - - @Override - public void paint(Graphics g) - { - int width = getWidth(); - int height = getHeight(); - - g.setColor(Color.BLACK); - g.fillRect(0, 0, width, height); - - int imgWidth = img.getWidth(this); - int imgHeight = img.getHeight(this); - - if ((imgWidth < 1) || (imgHeight < 1)) - return; - - boolean scale = false; - float scaleFactor = 1; - - if (imgWidth > width) - { - scale = true; - scaleFactor = width / (float) imgWidth; - } - if (imgHeight > height) - { - scale = true; - scaleFactor - = Math.min(scaleFactor, height / (float) imgHeight); - } - - int dstWidth; - int dstHeight; - - if (scale) - { - dstWidth = Math.round(imgWidth * scaleFactor); - dstHeight = Math.round(imgHeight * scaleFactor); - } - else - { - dstWidth = imgWidth; - dstHeight = imgHeight; - } - - int dstX = (width - dstWidth) / 2; - int dstY = (height - dstWidth) / 2; - - g.drawImage( - img, - dstX, dstY, dstX + dstWidth, dstY + dstHeight, - 0, 0, imgWidth, imgHeight, - this); - } - }; - - Dimension iconSize - = new Dimension(icon.getIconWidth(), icon.getIconHeight()); - - canvas.setMaximumSize(iconSize); - canvas.setPreferredSize(iconSize); - - /* - * Set a clue so that we can recognize it if it gets received as an - * argument to #disposeLocalVisualComponent(). - */ - canvas.setName(DESKTOP_STREAMING_ICON); - - fireVideoEvent( - VideoEvent.VIDEO_ADDED, canvas, VideoEvent.LOCAL, - false); - } - return canvas; - } - - /** - * Disposes of the local visual Component of the local peer. - * - * @param component the local visual Component of the local peer to - * dispose of - */ - public void disposeLocalVisualComponent(Component component) - { - if (component != null) - { - /* - * Desktop streaming does not use a Player but a Canvas with its - * name equal to the value of DESKTOP_STREAMING_ICON. - */ - if (DESKTOP_STREAMING_ICON.equals(component.getName())) - { - fireVideoEvent( - VideoEvent.VIDEO_REMOVED, component, VideoEvent.LOCAL, - false); - } - else - { - Player localPlayer; - - synchronized (localPlayerSyncRoot) - { - localPlayer = this.localPlayer; - } - if (localPlayer != null) - { - Component localPlayerVisualComponent - = getVisualComponent(localPlayer); - - if ((localPlayerVisualComponent == null) - || (localPlayerVisualComponent == component)) - disposeLocalPlayer(localPlayer); - } - } - } - } - - /** - * Releases the resources allocated by a specific local Player in - * the course of its execution and prepares it to be garbage collected. If - * the specified Player is rendering video, notifies the - * VideoListeners of this instance that its visual - * Component is to no longer be used by firing a - * {@link VideoEvent#VIDEO_REMOVED} VideoEvent. - * - * @param player the Player to dispose of - * @see MediaDeviceSession#disposePlayer(Player) - */ - private void disposeLocalPlayer(Player player) - { - /* - * The player is being disposed so let the (interested) listeners know - * its Player#getVisualComponent() (if any) should be released. - */ - Component visualComponent = null; - - try - { - visualComponent = getVisualComponent(player); - - player.stop(); - player.deallocate(); - player.close(); - } - finally - { - synchronized (localPlayerSyncRoot) - { - if (localPlayer == player) - localPlayer = null; - } - - if (visualComponent != null) - fireVideoEvent( - VideoEvent.VIDEO_REMOVED, visualComponent, VideoEvent.LOCAL, - false); - } - } - - /** - * Gets the visual Components where video from the remote peer is - * being rendered. - * - * @return the visual Components where video from the remote peer - * is being rendered - */ - public List getVisualComponents() - { - List visualComponents = new LinkedList(); - - /* - * When we know (through means such as SDP) that we don't want to - * receive, it doesn't make sense to wait for the remote peer to - * acknowledge our desire. So we'll just stop depicting the video of the - * remote peer regardless of whether it stops or continues its sending. - */ - if (getStartedDirection().allowsReceiving()) - { - for (Player player : getPlayers()) - { - Component visualComponent = getVisualComponent(player); - - if (visualComponent != null) - visualComponents.add(visualComponent); - } - } - return visualComponents; - } - - /** - * Gets the visual Components rendering the ReceiveStream - * corresponding to the given ssrc. - * - * @param ssrc the src-id of the receive stream, which visual - * Component we're looking for - * @return the visual Component rendering the - * ReceiveStream corresponding to the given ssrc - */ - public Component getVisualComponent(long ssrc) - { - Player player = getPlayer(ssrc); - - if (player != null) - return player.getVisualComponent(); - - return null; - } - - /** - * Gets the visual Component of a specific Player if it - * has one and ignores the failure to access it if the specified - * Player is unrealized. - * - * @param player the Player to get the visual Component of - * if it has one - * @return the visual Component of the specified Player if - * it has one; null if the specified Player does not have - * a visual Component or the Player is unrealized - */ - private static Component getVisualComponent(Player player) - { - Component visualComponent = null; - - if (player.getState() >= Player.Realized) - { - try - { - visualComponent = player.getVisualComponent(); - } - catch (NotRealizedError nre) - { - if (logger.isDebugEnabled()) - logger.debug( - "Called Player#getVisualComponent() " - + "on unrealized player " - + player, - nre); - } - } - return visualComponent; - } - - /** - * Notifies this instance that a specific Player of remote content - * has generated a ConfigureCompleteEvent. - * - * @param player the Player which is the source of a - * ConfigureCompleteEvent - * @see MediaDeviceSession#playerConfigureComplete(Processor) - */ - @Override - protected void playerConfigureComplete(final Processor player) - { - super.playerConfigureComplete(player); - - TrackControl[] trackControls = player.getTrackControls(); - SwScaler playerScaler = null; - - if ((trackControls != null) && (trackControls.length != 0)) - { - try - { - for (TrackControl trackControl : trackControls) - { - /* - * Since SwScaler will scale any input size into the - * configured output size, we may never get SizeChangeEvent - * from the player. We'll generate it ourselves then. - */ - playerScaler = new PlayerScaler(player); - - /* - * For H.264, we will use RTCP feedback. For example, to - * tell the sender that we've missed a frame. - */ - if ("h264/rtp".equalsIgnoreCase( - getFormat().getJMFEncoding())) - { - final DePacketizer depacketizer = new DePacketizer(); - JNIDecoder decoder = new JNIDecoder(); - - if (keyFrameControl != null) - { - depacketizer.setKeyFrameControl(keyFrameControl); - decoder.setKeyFrameControl( - new KeyFrameControlAdapter() - { - @Override - public boolean requestKeyFrame( - boolean urgent) - { - return - depacketizer.requestKeyFrame( - urgent); - } - }); - } - - trackControl.setCodecChain( - new Codec[] - { - depacketizer, - decoder, - playerScaler - }); - } - else - { - trackControl.setCodecChain( - new Codec[] { playerScaler }); - } - break; - } - } - catch (UnsupportedPlugInException upiex) - { - logger.error( - "Failed to add SwScaler or H.264 DePacketizer to codec" - + " chain", - upiex); - playerScaler = null; - } - } - this.playerScaler = playerScaler; - } - - /** - * Gets notified about ControllerEvents generated by a specific - * Player of remote content. - * - * @param event the ControllerEvent specifying the - * Controller which is the source of the event and the very type of - * the event - * @see MediaDeviceSession#playerControllerUpdate(ControllerEvent) - */ - @Override - protected void playerControllerUpdate(ControllerEvent event) - { - super.playerControllerUpdate(event); - - /* - * If SwScaler is in the chain and it forces a specific size of the - * output, the SizeChangeEvents of the Player do not really notify about - * changes in the size of the input. Besides, playerScaler will take - * care of the events in such a case. - */ - if ((event instanceof SizeChangeEvent) - && ((playerScaler == null) - || (playerScaler.getOutputSize() == null))) - { - SizeChangeEvent sizeChangeEvent = (SizeChangeEvent) event; - - playerSizeChange( - sizeChangeEvent.getSourceController(), - sizeChangeEvent.getWidth(), - sizeChangeEvent.getHeight()); - } - } - - /** - * Notifies this instance that a specific Player of remote content - * has generated a RealizeCompleteEvent. - * - * @param player the Player which is the source of a - * RealizeCompleteEvent. - * @see MediaDeviceSession#playerRealizeComplete(Processor) - */ - @Override - protected void playerRealizeComplete(final Processor player) - { - super.playerRealizeComplete(player); - - Component visualComponent = getVisualComponent(player); - - if (visualComponent != null) - { - /* - * SwScaler seems to be very good at scaling with respect to image - * quality so use it for the scaling in the player replacing the - * scaling it does upon rendering. - */ - visualComponent.addComponentListener(new ComponentAdapter() - { - @Override - public void componentResized(ComponentEvent e) - { - playerVisualComponentResized(player, e); - } - }); - - fireVideoEvent( - VideoEvent.VIDEO_ADDED, visualComponent, VideoEvent.REMOTE, - false); - } - } - - /** - * Notifies this instance that a specific Player of remote content - * has generated a SizeChangeEvent. - * - * @param sourceController the Player which is the source of the - * event - * @param width the width reported in the event - * @param height the height reported in the event - * @see SizeChangeEvent - */ - protected void playerSizeChange( - final Controller sourceController, - final int width, - final int height) - { - /* - * Invoking anything that is likely to change the UI in the Player - * thread seems like a performance hit so bring it into the event - * thread. - */ - if (!SwingUtilities.isEventDispatchThread()) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - playerSizeChange(sourceController, width, height); - } - }); - return; - } - - Player player = (Player) sourceController; - Component visualComponent = getVisualComponent(player); - - if (visualComponent != null) - { - fireVideoEvent( - new SizeChangeVideoEvent( - this, - visualComponent, - SizeChangeVideoEvent.REMOTE, - width, - height), - false); - } - } - - /** - * Notifies this instance that the visual Component of a - * Player rendering remote content has been resized. - * - * @param player the Player rendering remote content the visual - * Component of which has been resized - * @param e a ComponentEvent which specifies the resized - * Component - */ - private void playerVisualComponentResized( - Processor player, - ComponentEvent e) - { - if (playerScaler == null) - return; - - Component visualComponent = e.getComponent(); - - /* - * When the visualComponent is not in an UI hierarchy, its size isn't - * expected to be representative of what the user is seeing. - */ - if (visualComponent.getParent() == null) - return; - - Dimension outputSize = visualComponent.getSize(); - float outputWidth = outputSize.width; - float outputHeight = outputSize.height; - - if ((outputWidth < 1) || (outputHeight < 1)) - return; - - /* - * The size of the output video will be calculated so that it fits into - * the visualComponent and the video aspect ratio is preserved. The - * presumption here is that the inputFormat holds the video size with - * the correct aspect ratio. - */ - Format inputFormat = playerScaler.getInputFormat(); - - if (inputFormat == null) - return; - - Dimension inputSize = ((VideoFormat) inputFormat).getSize(); - - if (inputSize == null) - return; - - int inputWidth = inputSize.width; - int inputHeight = inputSize.height; - - if ((inputWidth < 1) || (inputHeight < 1)) - return; - - // Preserve the aspect ratio. - outputHeight = outputWidth * inputHeight / (float) inputWidth; - - // Fit the output video into the visualComponent. - boolean scale = false; - float widthRatio; - float heightRatio; - - if (Math.abs(outputWidth - inputWidth) < 1) - { - scale = true; - widthRatio = outputWidth / (float) inputWidth; - } - else - widthRatio = 1; - if (Math.abs(outputHeight - inputHeight) < 1) - { - scale = true; - heightRatio = outputHeight / (float) inputHeight; - } - else - heightRatio = 1; - if (scale) - { - float scaleFactor = Math.min(widthRatio, heightRatio); - - outputWidth = inputWidth * scaleFactor; - outputHeight = inputHeight * scaleFactor; - } - - outputSize.width = (int) outputWidth; - outputSize.height = (int) outputHeight; - - Dimension playerScalerOutputSize = playerScaler.getOutputSize(); - - if (playerScalerOutputSize == null) - playerScaler.setOutputSize(outputSize); - else - { - /* - * If we are not going to make much of a change, do not even bother - * because any scaling in the Renderer will not be noticeable - * anyway. - */ - int outputWidthDelta - = outputSize.width - playerScalerOutputSize.width; - int outputHeightDelta - = outputSize.height - playerScalerOutputSize.height; - - if ((outputWidthDelta < -1) - || (outputWidthDelta > 1) - || (outputHeightDelta < -1) - || (outputHeightDelta > 1)) - { - playerScaler.setOutputSize(outputSize); - } - } - } - - /** - * Removes a specific VideoListener from this instance in order to - * have to no longer receive notifications when visual/video - * Components are being added and removed. - * - * @param listener the VideoListener to no longer be notified when - * visual/video Components are being added or removed in this - * instance - */ - public void removeVideoListener(VideoListener listener) - { - videoNotifierSupport.removeVideoListener(listener); - } - - /** - * Use or not RTCP feedback Picture Loss Indication. - * - * @param usePLI true to use PLI; otherwise, false - */ - public void setRtcpFeedbackPLI(boolean usePLI) - { - if (this.usePLI != usePLI) - { - this.usePLI = usePLI; - - if (this.usePLI) - { - if (keyFrameRequester == null) - { - keyFrameRequester - = new KeyFrameControl.KeyFrameRequester() - { - public boolean requestKeyFrame() - { - boolean requested = false; - - if (VideoMediaDeviceSession.this.usePLI) - { - try - { - new RTCPFeedbackPacket( - 1, - 206, - localSSRC, - remoteSSRC) - .writeTo( - rtpConnector - .getControlOutputStream()); - requested = true; - } - catch (IOException ioe) - { - /* - * Apart from logging the ioe, there are - * not a lot of ways to handle it. - */ - } - } - return requested; - } - }; - } - if (keyFrameControl != null) - keyFrameControl.addKeyFrameRequester(-1, keyFrameRequester); - } - else if (keyFrameRequester != null) - { - if (keyFrameControl != null) - keyFrameControl.removeKeyFrameRequester(keyFrameRequester); - keyFrameRequester = null; - } - } - } - - /** - * Sets the size of the output video. - * - * @param size the size of the output video - */ - public void setOutputSize(Dimension size) - { - if((size != null && outputSize == null) - || (size == null && outputSize != null) - || (size != null && outputSize != null && !outputSize.equals(size))) - outputsizeChanged = true; - - outputSize = size; - } - - /** - * Sets the RTPConnector that will be used to - * initialize some codec for RTCP feedback. - * - * @param rtpConnector the RTP connector - */ - public void setConnector(AbstractRTPConnector rtpConnector) - { - this.rtpConnector = rtpConnector; - } - - /** - * Sets the KeyFrameControl to be used by this - * VideoMediaDeviceSession as a means of control over its - * key frame-related logic. - * - * @param keyFrameControl the KeyFrameControl to be used by this - * VideoMediaDeviceSession as a means of control over its - * key frame-related logic - */ - public void setKeyFrameControl(KeyFrameControl keyFrameControl) - { - if (this.keyFrameControl != keyFrameControl) - { - if ((this.keyFrameControl != null) && (keyFrameRequester != null)) - this.keyFrameControl.removeKeyFrameRequester(keyFrameRequester); - - this.keyFrameControl = keyFrameControl; - - if ((this.keyFrameControl != null) && (keyFrameRequester != null)) - this.keyFrameControl.addKeyFrameRequester(-1, keyFrameRequester); - } - } - - /** - * Set the local SSRC. - * - * @param localSSRC local SSRC - */ - public void setLocalSSRC(long localSSRC) - { - this.localSSRC = localSSRC; - } - - /** - * Set the remote SSRC. - * - * @param remoteSSRC remote SSRC - */ - public void setRemoteSSRC(long remoteSSRC) - { - this.remoteSSRC = remoteSSRC; - } - - /** - * Sets the MediaFormatImpl in which a specific Processor - * producing media to be streamed to the remote peer is to output. - * - * @param processor the Processor to set the output - * MediaFormatImpl of - * @param mediaFormat the MediaFormatImpl to set on - * processor - * @see MediaDeviceSession#setProcessorFormat(Processor, MediaFormatImpl) - */ - @Override - protected void setProcessorFormat( - Processor processor, - MediaFormatImpl mediaFormat) - { - Format format = mediaFormat.getFormat(); - - if ("h263-1998/rtp".equalsIgnoreCase(format.getEncoding())) - { - /* - * If no output size has been defined, then no SDP fmtp has been - * found with QCIF, CIF, VGA or CUSTOM parameters. Let's default to - * QCIF (176x144). - */ - if (outputSize == null) - outputSize = new Dimension(176, 144); - } - - /* - * Add a size in the output format. As VideoFormat has no setter, we - * recreate the object. Also check whether capture device can output - * such a size. - */ - if ((outputSize != null) - && (outputSize.width > 0) - && (outputSize.height > 0)) - { - Dimension deviceSize - = ((VideoFormat) getCaptureDeviceFormat()).getSize(); - - if ((deviceSize != null) - && ((deviceSize.width > outputSize.width) - || (deviceSize.height > outputSize.height))) - { - VideoFormat videoFormat = (VideoFormat) format; - - format - = new VideoFormat( - videoFormat.getEncoding(), - outputSize, - videoFormat.getMaxDataLength(), - videoFormat.getDataType(), - videoFormat.getFrameRate()); - } - else - { - VideoFormat videoFormat = (VideoFormat) format; - - format - = new VideoFormat( - videoFormat.getEncoding(), - deviceSize, - videoFormat.getMaxDataLength(), - videoFormat.getDataType(), - videoFormat.getFrameRate()); - - outputSize = null; - } - } - else - outputSize = null; - - super.setProcessorFormat(processor, mediaFormat); - } - - /** - * Sets the MediaFormatImpl of a specific TrackControl of - * the Processor which produces the media to be streamed by this - * MediaDeviceSession to the remote peer. Allows extenders to - * override the set procedure and to detect when the JMF Format of - * the specified TrackControl changes. - * - * @param trackControl the TrackControl to set the JMF - * Format of - * @param mediaFormat the MediaFormatImpl to be set on the - * specified TrackControl. Though mediaFormat encapsulates - * a JMF Format, format is to be set on the specified - * trackControl because it may be more specific. In any case, the - * two JMF Formats match. The MediaFormatImpl is provided - * anyway because it carries additional information such as format - * parameters. - * @param format the JMF Format to be set on the specified - * TrackControl. Though mediaFormat encapsulates a JMF - * Format, the specified format is to be set on the - * specified trackControl because it may be more specific than the - * JMF Format of the mediaFormat - * @return the JMF Format set on TrackControl after the - * attempt to set the specified mediaFormat or null if the - * specified format was found to be incompatible with - * trackControl - * @see MediaDeviceSession#setProcessorFormat(TrackControl, MediaFormatImpl, - * Format) - */ - @Override - protected Format setProcessorFormat( - TrackControl trackControl, - MediaFormatImpl mediaFormat, - Format format) - { - JNIEncoder encoder = null; - SwScaler scaler = null; - int codecCount = 0; - - /* - * For H.264 we will monitor RTCP feedback. For example, if we receive a - * PLI/FIR message, we will send a keyframe. - */ - if ("h264/rtp".equalsIgnoreCase(format.getEncoding())) - { - encoder = new JNIEncoder(); - - // packetization-mode - { - Map formatParameters - = mediaFormat.getFormatParameters(); - String packetizationMode - = (formatParameters == null) - ? null - : formatParameters.get( - JNIEncoder.PACKETIZATION_MODE_FMTP); - - encoder.setPacketizationMode(packetizationMode); - } - - // additional codec settings - { - Map settings = - mediaFormat.getAdditionalCodecSettings(); - - encoder.setAdditionalCodecSettings(settings); - } - - if (usePLI) - { - /* - * The H.264 encoder needs to be notified of RTCP feedback - * messages. - */ - try - { - ((ControlTransformInputStream) - rtpConnector.getControlInputStream()) - .addRTCPFeedbackListener(encoder); - } - catch (IOException ioe) - { - logger.error("Error cannot get RTCP input stream", ioe); - } - } - if (keyFrameControl != null) - encoder.setKeyFrameControl(keyFrameControl); - - codecCount++; - } - - if (outputSize != null) - { - /* We have been explicitly told to use a specified output size so - * create a custom SwScaler that will scale and convert color spaces - * in one call. - */ - scaler = new SwScaler(); - scaler.setOutputSize(outputSize); - codecCount++; - } - - Codec[] codecs = new Codec[codecCount]; - - codecCount = 0; - if(scaler != null) - codecs[codecCount++] = scaler; - if(encoder != null) - codecs[codecCount++] = encoder; - - if (codecCount != 0) - { - /* Add our custom SwScaler and possibly RTCP aware codec to the - * codec chain so that it will be used instead of default. - */ - try - { - trackControl.setCodecChain(codecs); - } - catch(UnsupportedPlugInException upiex) - { - logger.error( - "Failed to add SwScaler/JNIEncoder to codec chain", - upiex); - } - } - - return super.setProcessorFormat(trackControl, mediaFormat, format); - } - - /** - * Sets the MediaFormat in which this MediaDeviceSession - * outputs the media captured by its MediaDevice. - * - * @param format the MediaFormat in which this - * MediaDeviceSession is to output the media captured by its - * MediaDevice - */ - public void setFormat(MediaFormat format) - { - if(format instanceof VideoMediaFormat && - ((VideoMediaFormat)format).getFrameRate() != -1) - { - FrameRateControl frameRateControl - = (FrameRateControl) - getCaptureDevice().getControl(FrameRateControl.class.getName()); - - if (frameRateControl != null) - { - float frameRate = ((VideoMediaFormat)format).getFrameRate(); - - float maxSupportedFrameRate - = frameRateControl.getMaxSupportedFrameRate(); - - if ((maxSupportedFrameRate > 0) - && (frameRate > maxSupportedFrameRate)) - frameRate = maxSupportedFrameRate; - if(frameRate > 0) - { - frameRateControl.setFrameRate(frameRate); - - if(logger.isInfoEnabled()) - { - logger.info("video send FPS: " + frameRate); - } - } - } - } - - super.setFormat(format); - } - - /** - * Notifies this instance that the value of its startedDirection - * property has changed from a specific oldValue to a specific - * newValue. - * - * @param oldValue the MediaDirection which used to be the value of - * the startedDirection property of this instance - * @param newValue the MediaDirection which is the value of the - * startedDirection property of this instance - */ - @Override - protected void startedDirectionChanged( - MediaDirection oldValue, - MediaDirection newValue) - { - super.startedDirectionChanged(oldValue, newValue); - - for (Player player : getPlayers()) - { - int state = player.getState(); - - /* - * The visual Component of a Player is safe to access and, - * respectively, report through a VideoEvent only when the Player is - * Realized. - */ - if (state < Player.Realized) - continue; - - if (newValue.allowsReceiving()) - { - if (state != Player.Started) - { - player.start(); - - Component visualComponent = getVisualComponent(player); - - if (visualComponent != null) - { - fireVideoEvent( - VideoEvent.VIDEO_ADDED, - visualComponent, - VideoEvent.REMOTE, - false); - } - } - } - else if (state > Processor.Configured) - { - Component visualComponent = getVisualComponent(player); - - player.stop(); - - if (visualComponent != null) - { - fireVideoEvent( - VideoEvent.VIDEO_REMOVED, - visualComponent, - VideoEvent.REMOTE, - false); - } - } - } - } - - /** - * Extends SwScaler in order to provide scaling with high quality - * to a specific Player of remote video. - */ - private class PlayerScaler - extends SwScaler - { - /** - * The last size reported in the form of a SizeChangeEvent. - */ - private Dimension lastSize; - - /** - * The Player into the codec chain of which this - * SwScaler is set. - */ - private final Player player; - - /** - * Initializes a new PlayerScaler instance which is to provide - * scaling with high quality to a specific Player of remote - * video. - * - * @param player the Player of remote video into the codec - * chain of which the new instance is to be set - */ - public PlayerScaler(Player player) - { - super(true); - - this.player = player; - } - - /** - * Determines when the input video sizes changes and reports it as a - * SizeChangeVideoEvent because Player is unable to - * do it when this SwScaler is scaling to a specific - * outputSize. - * - * @param input input buffer - * @param output output buffer - * @return the native PaSampleFormat - * @see SwScaler#process(Buffer, Buffer) - */ - @Override - public int process(Buffer input, Buffer output) - { - int result = super.process(input, output); - - if (result == BUFFER_PROCESSED_OK) - { - Format inputFormat = getInputFormat(); - - if (inputFormat != null) - { - Dimension size = ((VideoFormat) inputFormat).getSize(); - - if ((size != null) - && ((lastSize == null) || !lastSize.equals(size))) - { - lastSize = size; - playerSizeChange( - player, - lastSize.width, lastSize.height); - } - } - } - return result; - } - - /** - * Ensures that this SwScaler preserves the aspect ratio of its - * input video when scaling. - * - * @param inputFormat format to set - * @return format - * @see SwScaler#setInputFormat(Format) - */ - @Override - public Format setInputFormat(Format inputFormat) - { - inputFormat = super.setInputFormat(inputFormat); - if (inputFormat instanceof VideoFormat) - { - Dimension inputSize = ((VideoFormat) inputFormat).getSize(); - - if ((inputSize != null) && (inputSize.width > 0)) - { - Dimension outputSize = getOutputSize(); - - if ((outputSize != null) && (outputSize.width > 0)) - { - int outputHeight - = (int) - (outputSize.width - * inputSize.height - / (float) inputSize.width); - int outputHeightDelta - = outputHeight - outputSize.height; - - if ((outputHeightDelta < -1) || (outputHeightDelta > 1)) - { - outputSize.height = outputHeight; - setOutputSize(outputSize); - } - } - } - } - return inputFormat; - } - } - - /** - * Returns the format of the video we are receiving from the remote peer. - * - * @return The video format of the received video. Null, if no video is - * received. - */ - public VideoFormat getReceivedVideoFormat() - { - if(this.playerScaler != null) - { - Format format = this.playerScaler.getInputFormat(); - - if (format instanceof VideoFormat) - { - return ((VideoFormat) format); - } - } - - return null; - } - - /** - * Returns the format of the video we are streaming to the remote peer. - * - * @return The video format of the sent video. Null, if no video is sent. - */ - public VideoFormat getSentVideoFormat() - { - DataSource capture = this.getCaptureDevice(); - if(capture instanceof PullBufferDataSource) - { - PullBufferStream[] streams = - ((PullBufferDataSource) capture).getStreams(); - for(int i = 0; i < streams.length; ++i) - { - VideoFormat format = (VideoFormat) streams[i].getFormat(); - if(format != null) - { - return format; - } - } - } - return null; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/device/VideoTranslatorMediaDevice.java b/src/net/java/sip/communicator/impl/neomedia/device/VideoTranslatorMediaDevice.java deleted file mode 100644 index 06d62939e..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/device/VideoTranslatorMediaDevice.java +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.device; - -import java.util.*; - -import javax.media.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.format.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; - -/** - * Implements a MediaDevice which is to be used in video conferencing - * implemented with an RTP translator. - * - * @author Lyubomir Marinov - */ -public class VideoTranslatorMediaDevice - extends AbstractMediaDevice - implements MediaDeviceWrapper -{ - /** - * The MediaDevice which this instance enables to be used in a - * video conference implemented with an RTP translator. - */ - private final MediaDeviceImpl device; - - /** - * The MediaDeviceSession of {@link #device} the - * outputDataSource of which is the captureDevice of - * {@link #streamDeviceSessions}. - */ - private MediaDeviceSession deviceSession; - - /** - * The MediaStreamMediaDeviceSessions sharing the - * outputDataSource of {@link #device} as their - * captureDevice. - */ - private final List streamDeviceSessions - = new LinkedList(); - - /** - * Initializes a new VideoTranslatorMediaDevice which enables a - * specific MediaDevice to be used in video conferencing - * implemented with an RTP translator. - * - * @param device the MediaDevice which the new instance is to - * enable to be used in video conferencing implemented with an RTP - * translator - */ - public VideoTranslatorMediaDevice(MediaDeviceImpl device) - { - this.device = device; - } - - /** - * Releases the resources allocated by this instance in the course of its - * execution and prepares it to be garbage collected when all - * {@link #streamDeviceSessions} have been closed. - * - * @param streamDeviceSession the MediaStreamMediaDeviceSession - * which has been closed - */ - private synchronized void close( - MediaStreamMediaDeviceSession streamDeviceSession) - { - streamDeviceSessions.remove(streamDeviceSession); - if (streamDeviceSessions.isEmpty()) - { - if(deviceSession != null) - deviceSession.close(); - deviceSession = null; - } - else - updateDeviceSessionStartedDirection(); - } - - /** - * Creates a DataSource instance for this MediaDevice - * which gives access to the captured media. - * - * @return a DataSource instance which gives access to the media - * captured by this MediaDevice - * @see AbstractMediaDevice#createOutputDataSource() - */ - synchronized DataSource createOutputDataSource() - { - if (deviceSession == null) - { - MediaFormatImpl format = null; - MediaDirection startedDirection = MediaDirection.INACTIVE; - - for (MediaStreamMediaDeviceSession streamDeviceSession - : streamDeviceSessions) - { - MediaFormatImpl streamFormat - = streamDeviceSession.getFormat(); - - if ((streamFormat != null) && (format == null)) - format = streamFormat; - startedDirection - = startedDirection.or( - streamDeviceSession.getStartedDirection()); - } - - deviceSession = device.createSession(); - if (format != null) - deviceSession.setFormat(format); - deviceSession.start(startedDirection); - } - return - (deviceSession == null) - ? null - : deviceSession.getOutputDataSource(); - } - - /** - * Initializes a new Renderer instance which is to play back media - * on this MediaDevice. - * - * @return a new Renderer instance which is to play back media on - * this MediaDevice or null if a suitable - * Renderer is to be chosen irrespective of this - * MediaDevice - */ - Renderer createRenderer() - { - return null; - } - - /** - * Creates a new MediaDeviceSession instance which is to represent - * the use of this MediaDevice by a MediaStream. - * - * @return a new MediaDeviceSession instance which is to represent - * the use of this MediaDevice by a MediaStream - * @see AbstractMediaDevice#createSession() - */ - @Override - public synchronized MediaDeviceSession createSession() - { - MediaStreamMediaDeviceSession streamDeviceSession - = new MediaStreamMediaDeviceSession(); - - streamDeviceSessions.add(streamDeviceSession); - return streamDeviceSession; - } - - /** - * Returns the MediaDirection supported by this device. - * - * @return MediaDirection.SENDONLY if this is a read-only device, - * MediaDirection.RECVONLY if this is a write-only device and - * MediaDirection.SENDRECV if this MediaDevice can both - * capture and render media - * @see MediaDevice#getDirection() - */ - public MediaDirection getDirection() - { - return device.getDirection(); - } - - /** - * Returns the MediaFormat that this device is currently set to use - * when capturing data. - * - * @return the MediaFormat that this device is currently set to - * provide media in. - * @see MediaDevice#getFormat() - */ - public MediaFormat getFormat() - { - return device.getFormat(); - } - - /** - * Returns the MediaType that this device supports. - * - * @return MediaType.AUDIO if this is an audio device or - * MediaType.VIDEO in case of a video device - * @see MediaDevice#getMediaType() - */ - public MediaType getMediaType() - { - return device.getMediaType(); - } - - /** - * Returns a list of MediaFormat instances representing the media - * formats supported by this MediaDevice. - * - * @param localPreset the preset used to set the send format parameters, - * used for video and settings - * @param remotePreset the preset used to set the receive format parameters, - * used for video and settings - * @return the list of MediaFormats supported by this device - * @see MediaDevice#getSupportedFormats(QualityPreset, QualityPreset) - */ - public List getSupportedFormats( - QualityPreset localPreset, - QualityPreset remotePreset) - { - return device.getSupportedFormats(localPreset, remotePreset); - } - - /** - * Gets the actual MediaDevice which this MediaDevice is - * effectively built on top of and forwarding to. - * - * @return the actual MediaDevice which this MediaDevice - * is effectively built on top of and forwarding to - * @see MediaDeviceWrapper#getWrappedDevice() - */ - public MediaDevice getWrappedDevice() - { - return device; - } - - /** - * Updates the value of the startedDirection property of - * {@link #deviceSession} to be in accord with the values of the property - * of {@link #streamDeviceSessions}. - */ - private synchronized void updateDeviceSessionStartedDirection() - { - if (deviceSession == null) - return; - - MediaDirection startDirection = MediaDirection.INACTIVE; - - for (MediaStreamMediaDeviceSession streamDeviceSession - : streamDeviceSessions) - { - startDirection - = startDirection.or(streamDeviceSession.getStartedDirection()); - } - deviceSession.start(startDirection); - - MediaDirection stopDirection = MediaDirection.INACTIVE; - - if (!startDirection.allowsReceiving()) - stopDirection = stopDirection.or(MediaDirection.RECVONLY); - if (!startDirection.allowsSending()) - stopDirection = stopDirection.or(MediaDirection.SENDONLY); - deviceSession.stop(stopDirection); - } - - /** - * Represents the use of this VideoTranslatorMediaDevice by a - * MediaStream. - */ - private class MediaStreamMediaDeviceSession - extends VideoMediaDeviceSession - { - /** - * Initializes a new MediaStreamMediaDeviceSession which is to - * represent the use of this VideoTranslatorMediaDevice by a - * MediaStream. - */ - public MediaStreamMediaDeviceSession() - { - super(VideoTranslatorMediaDevice.this); - } - - /** - * Releases the resources allocated by this instance in the course of - * its execution and prepares it to be garbage collected. - */ - @Override - public void close() - { - super.close(); - - VideoTranslatorMediaDevice.this.close(this); - } - - /** - * Creates the DataSource that this instance is to read - * captured media from. - * - * @return the DataSource that this instance is to read - * captured media from - * @see VideoMediaDeviceSession#createCaptureDevice() - */ - @Override - protected DataSource createCaptureDevice() - { - return VideoTranslatorMediaDevice.this.createOutputDataSource(); - } - - /** - * Initializes a new Player instance which is to provide the - * local visual/video Component. The new instance is - * initialized to render the media of a specific DataSource. - * - * @param captureDevice the DataSource which is to have its - * media rendered by the new instance as the local visual/video - * Component - * @return a new Player instance which is to provide the local - * visual/video Component - */ - @Override - protected Player createLocalPlayer(DataSource captureDevice) - { - synchronized (VideoTranslatorMediaDevice.this) - { - if (deviceSession != null) - captureDevice = deviceSession.getCaptureDevice(); - } - - return super.createLocalPlayer(captureDevice); - } - - /** - * Initializes a new FMJ Processor which is to transcode - * {@link #captureDevice} into the format of this instance. - * - * @return a new FMJ Processor which is to transcode - * captureDevice into the format of this instance - */ - @Override - protected Processor createProcessor() - { - return null; - } - - /** - * Gets the output DataSource of this instance which provides - * the captured (RTP) data to be sent by MediaStream to - * MediaStreamTarget. - * - * @return the output DataSource of this instance which - * provides the captured (RTP) data to be sent by MediaStream - * to MediaStreamTarget - * @see MediaDeviceSession#getOutputDataSource() - */ - @Override - public DataSource getOutputDataSource() - { - return getConnectedCaptureDevice(); - } - - /** - * Notifies this instance that the value of its - * startedDirection property has changed from a specific - * oldValue to a specific newValue. - * - * @param oldValue the MediaDirection which used to be the - * value of the startedDirection property of this instance - * @param newValue the MediaDirection which is the value of the - * startedDirection property of this instance - */ - @Override - protected void startedDirectionChanged( - MediaDirection oldValue, - MediaDirection newValue) - { - super.startedDirectionChanged(oldValue, newValue); - - VideoTranslatorMediaDevice.this - .updateDeviceSessionStartedDirection(); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/directshow/DSCaptureDevice.java b/src/net/java/sip/communicator/impl/neomedia/directshow/DSCaptureDevice.java deleted file mode 100644 index 49e28f039..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/directshow/DSCaptureDevice.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.directshow; - -/** - * DirectShow capture device. - * - * @author Sebastien Vincent - */ -public class DSCaptureDevice -{ - /** - * Empty array with DSFormat element type. Explicitly defined - * in order to avoid unnecessary allocations. - */ - private static final DSFormat EMPTY_FORMATS[] = new DSFormat[0]; - - /** - * Native pointer of DSCaptureDevice. - * - * This pointer is hold and will be released by DSManager - * singleton. - */ - private long ptr = 0; - - /** - * Constructor. - * - * @param ptr native pointer - */ - public DSCaptureDevice(long ptr) - { - /* do not allow 0 pointer value */ - if(ptr == 0) - throw new IllegalArgumentException("invalid ptr value (0)"); - - this.ptr = ptr; - } - - /** - * Open and initialize the capture device. - */ - public void open() - { - open(ptr); - } - - /** - * Stop and close the capture device. - */ - public void close() - { - close(ptr); - } - - /** - * Get name of the capture device. - * - * @return name of the capture device - */ - public String getName() - { - return getName(ptr).trim(); - } - - /** - * Set format to use with this capture device. - * - * @param format format to set - */ - public void setFormat(DSFormat format) - { - setFormat(ptr, format); - } - - /** - * Get current format. - * - * @return current format used - */ - public DSFormat getFormat() - { - return getFormat(ptr); - } - - /** - * Get the supported video format this capture device supports. - * - * @return array of DSFormat - */ - public DSFormat[] getSupportedFormats() - { - DSFormat formats[] = getSupportedFormats(ptr); - - if(formats == null) - { - formats = EMPTY_FORMATS; - } - - return formats; - } - - /** - * Set a delegate to use when a frame is received. - * @param delegate delegate - */ - public void setDelegate(GrabberDelegate delegate) - { - setDelegate(ptr, delegate); - } - - /** - * Native method to open capture device. - * - * @param ptr native pointer of DSCaptureDevice - */ - private native void open(long ptr); - - /** - * Native method to close capture device. - * - * @param ptr native pointer of DSCaptureDevice - */ - private native void close(long ptr); - - /** - * Native method to get name of the capture device. - * - * @param ptr native pointer of DSCaptureDevice - * @return name of the capture device - */ - private native String getName(long ptr); - - /** - * Native method to set format on the capture device. - * - * @param ptr native pointer of DSCaptureDevice - * @param format format to set - */ - private native void setFormat(long ptr, DSFormat format); - - /** - * Native method to get format on the capture device. - * - * @param ptr native pointer of DSCaptureDevice - * @return format current format - */ - private native DSFormat getFormat(long ptr); - - /** - * Native method to get supported formats from capture device. - * - * @param ptr native pointer of DSCaptureDevice - * @return array of native pointer corresponding to formats - */ - private native DSFormat[] getSupportedFormats(long ptr); - - /** - * Native method to set a delegate to use when a frame is received. - * @param ptr native pointer - * @param delegate delegate - */ - public native void setDelegate(long ptr, GrabberDelegate delegate); - - /** - * Get bytes from buf native pointer and copy them - * to ptr byte native pointer. - * - * @param ptr pointer to native data - * @param buf byte native pointer (see ByteBufferPool) - * @param length length of buf pointed by ptr - * @return length written to buf - */ - public static native int getBytes(long ptr, long buf, int length); - - /** - * Delegate class to handle grabbing frames. - * - * @author Sebastien Vincent - */ - public static abstract class GrabberDelegate - { - /** - * Callback method when receiving frames. - * - * @param ptr native pointer to data - * @param length length of data - */ - public abstract void frameReceived(long ptr, int length); - } -} - diff --git a/src/net/java/sip/communicator/impl/neomedia/directshow/DSFormat.java b/src/net/java/sip/communicator/impl/neomedia/directshow/DSFormat.java deleted file mode 100644 index ca4f9e7ef..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/directshow/DSFormat.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.directshow; - -/** - * DirectShow video format. - * - * @author Sebastien Vincent - */ -public class DSFormat -{ - - static - { - System.loadLibrary("jndirectshow"); - - RGB24 = getRGB24PixelFormat(); - RGB32 = getRGB32PixelFormat(); - ARGB32 = getARGBPixelFormat(); - YUY2 = getYUY2PixelFormat(); - UYVY = getUYVYPixelFormat(); - NV12 = getNV12PixelFormat(); - Y411 = getY411PixelFormat(); - Y41P = getY41PPixelFormat(); - I420 = getI420PixelFormat(); - } - - /* supported formats */ - - /** - * The RGB24 constant. - */ - public static final long RGB24; - - /** - * The RGB32 constant. - */ - public static final long RGB32; - - /** - * The ARGB32 constant. - */ - public static final long ARGB32; - - /** - * The YUY2 constant. - */ - public static final long YUY2; - - /** - * The UYVY constant. - */ - public static final long UYVY; - - /** - * The Y411 constant. - */ - public static final long Y411; - - /** - * The Y41P constant. - */ - public static final long Y41P; - - /** - * The NV12 constant. - */ - public static final long NV12; - - /** - * The I420 constant. - */ - public static final long I420; - - /** - * Video width. - */ - private int width = 0; - - /** - * Video height. - */ - private int height = 0; - - /** - * Color space. - */ - private long pixelFormat = -1; - - /** - * Constructor. - * - * @param width video width - * @param height video height - * @param pixelFormat pixel format - */ - public DSFormat(int width, int height, long pixelFormat) - { - this.width = width; - this.height = height; - this.pixelFormat = pixelFormat; - } - - /** - * Get video width. - * - * @return video width - */ - public int getWidth() - { - return width; - } - - /** - * Get video height. - * - * @return video height - */ - public int getHeight() - { - return height; - } - - /** - * Get color space. - * - * @return color space - */ - public long getPixelFormat() - { - return pixelFormat; - } - - /* RGB */ - /** - * Get the RGB24 native pixel format - * - * @return RGB24 native format value - */ - public static native long getRGB24PixelFormat(); - - /** - * Get the RGB32 native pixel format - * - * @return RGB32 native format value - */ - public static native long getRGB32PixelFormat(); - - /** - * Get the ARGB32 native pixel format - * - * @return ARGB32 native format value - */ - public static native long getARGBPixelFormat(); - - /* YUV */ - - /** - * Get the AYUV native pixel format - * - * @return AYUV native format value - */ - public static native long getAYUVPixelFormat(); - - /** - * Get the YUY2 native pixel format - * - * @return YUY2 native format value - */ - public static native long getYUY2PixelFormat(); - - /** - * Get the UYVY native pixel format - * - * @return UYVY native format value - */ - public static native long getUYVYPixelFormat(); - - /** - * Get the IMC1 native pixel format - * - * @return IMC1 native format value - */ - public static native long getIMC1PixelFormat(); - - /** - * Get the IMC2 native pixel format - * - * @return IMC2 native format value - */ - public static native long getIMC2PixelFormat(); - - /** - * Get the IMC3 native pixel format - * - * @return IMC3 native format value - */ - public static native long getIMC3PixelFormat(); - - /** - * Get the IMC4 native pixel format - * - * @return IMC4 native format value - */ - public static native long getIMC4PixelFormat(); - - /** - * Get the YV12 native pixel format - * - * @return YV12 native format value - */ - public static native long getYV12PixelFormat(); - - /** - * Get the NV12 native pixel format - * - * @return NV12 native format value - */ - public static native long getNV12PixelFormat(); - - /** - * Get the IF09 native pixel format - * - * @return IF09 native format value - */ - public static native long getIF09PixelFormat(); - - /** - * Get the IYUV native pixel format - * - * @return IYUV native format value - */ - public static native long getIYUVPixelFormat(); - - /** - * Get the Y211 native pixel format - * - * @return Y211 native format value - */ - public static native long getY211PixelFormat(); - - /** - * Get the Y411 native pixel format - * - * @return Y411 native format value - */ - public static native long getY411PixelFormat(); - - /** - * Get the Y41P native pixel format - * - * @return Y41P native format value - */ - public static native long getY41PPixelFormat(); - - /** - * Get the YVU9 native pixel format - * - * @return YVU9 native format value - */ - public static native long getYVU9PixelFormat(); - - /** - * Get the YVYU native pixel format - * - * @return YVYU native format value - */ - public static native long getYVYUPixelFormat(); - - /** - * Get the I420 native pixel format - * - * @return I420 native format value - */ - public static native long getI420PixelFormat(); -} - diff --git a/src/net/java/sip/communicator/impl/neomedia/directshow/DSManager.java b/src/net/java/sip/communicator/impl/neomedia/directshow/DSManager.java deleted file mode 100644 index 0ab7eb421..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/directshow/DSManager.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.directshow; - -/** - * DirectShow capture device manager. - * - * DSManager act as a singleton. When you need it - * call getInstance and don't forget to call dispose() - * when you have finished. - * - * - * DSManager manager = DSManager.getInstance(); - * - * DSCaptureDevice[] devices = manager.getCaptureDevices(); - * - * // do stuff with capture devices - * // ... - * - * DSManager.dispose(); - * - * // do not use any of DSCaptureDevice objects obtained by - * // manager - * - * - * @author Sebastien Vincent - */ -public class DSManager -{ - static - { - /* load DLL */ - System.loadLibrary("jndirectshow"); - } - - /** - * Empty array of DSCaptureDevices. Explicitly defined in order to - * avoid unnecessary allocations. - */ - private static DSCaptureDevice[] EMPTY_DEVICES = new DSCaptureDevice[0]; - - /** - * Unique instance of DSManager. - */ - private static DSManager instance = null; - - /** - * Reference count. - */ - private static int ref = 0; - - /** - * Synchronization object. - */ - private static Object sync = new Object(); - - /** - * Array of all DSCaptureDevice found - * on the OS. - */ - private DSCaptureDevice[] devices = null; - - /** - * Native pointer. - */ - private long ptr = 0; - - /** - * Get the instance. - * - * @return unique instance of DSManager - */ - public static synchronized DSManager getInstance() - { - synchronized(sync) - { - if(instance == null) - { - long ptr = init(); - - if(ptr != 0) - { - instance = new DSManager(ptr); - } - } - - /* increment reference if object is valid */ - if(instance != null) - { - ref++; - } - } - return instance; - } - - /** - * Dispose the object. - */ - public static synchronized void dispose() - { - synchronized(sync) - { - ref--; - - if(ref == 0 && instance != null && instance.ptr != 0) - { - destroy(instance.ptr); - } - instance = null; - ref = 0; - } - } - - /** - * Constructor. - * - * @param ptr native pointer of DSManager - */ - private DSManager(long ptr) - { - if(ptr == 0) - { - throw new IllegalArgumentException("invalid ptr value (0)"); - } - - this.ptr = ptr; - } - - /** - * Get the array of capture devices. - * - * @return array of DSCaptureDevices - */ - public DSCaptureDevice[] getCaptureDevices() - { - if(devices == null) - { - long nativeDevices[] = getCaptureDevices(ptr); - - if(nativeDevices != null && nativeDevices.length > 0) - { - devices = new DSCaptureDevice[nativeDevices.length]; - - for(int i = 0 ; i < nativeDevices.length ; i++) - { - devices[i] = new DSCaptureDevice(nativeDevices[i]); - } - } - else - { - devices = EMPTY_DEVICES; - } - } - return devices; - } - - /** - * Initialize and gather existing capture device. - * - * @return native pointer - */ - private static native long init(); - - /** - * Delete native pointer. - * - * @param ptr native pointer to delete - */ - private static native void destroy(long ptr); - - /** - * Native method to get capture devices pointers. - * - * @param ptr native pointer of DSManager - * @return array of native pointer to DSCaptureDevice - */ - private native long[] getCaptureDevices(long ptr); -} - diff --git a/src/net/java/sip/communicator/impl/neomedia/format/AudioMediaFormatImpl.java b/src/net/java/sip/communicator/impl/neomedia/format/AudioMediaFormatImpl.java deleted file mode 100644 index 7471960a7..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/format/AudioMediaFormatImpl.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.format; - -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.format.*; - -/** - * Implements AudioMediaFormat for the JMF AudioFormat. - * - * @author Lubomir Marinov - */ -public class AudioMediaFormatImpl - extends MediaFormatImpl - implements AudioMediaFormat -{ - - /** - * Initializes a new AudioMediaFormatImpl instance which is to - * provide an implementation of AudioMediaFormat for a specific - * JMF AudioFormat. - * - * @param format the JMF AudioFormat the new instance is to wrap - * and provide an implementation of AudioMediaFormat for - */ - AudioMediaFormatImpl(AudioFormat format) - { - this(format, null, null); - } - - /** - * Initializes a new AudioMediaFormatImpl instance which is to - * provide an implementation of AudioMediaFormat for a specific - * JMF AudioFormat and to have a specific set of format-specific - * parameters. - * - * @param format the JMF AudioFormat the new instance is to wrap - * and provide an implementation of AudioMediaFormat for - * @param formatParameters the set of format-specific parameters of the new - * instance - * @param advancedParameters the set of format-specific parameters of the new - * instance - */ - AudioMediaFormatImpl( - AudioFormat format, - Map formatParameters, - Map advancedParameters) - { - super(fixChannels(format), formatParameters, advancedParameters); - } - - /** - * Initializes a new AudioMediaFormatImpl instance with the - * specified encoding and a single audio channel. - * - * @param encoding the encoding of the new AudioMediaFormatImpl - * instance - */ - public AudioMediaFormatImpl(String encoding) - { - this(new AudioFormat(encoding)); - } - - /** - * Initializes a new AudioMediaFormatImpl instance with the - * specified encoding and clock rate and a single audio channel. - * - * @param encoding the encoding of the new AudioMediaFormatImpl - * instance - * @param clockRate the clock (i.e. sample) rate of the new - * AudioMediaFormatImpl instance - */ - AudioMediaFormatImpl(String encoding, double clockRate) - { - this(encoding, clockRate, 1); - } - - /** - * Initializes a new AudioMediaFormatImpl instance with the - * specified encoding, clock rate and number of audio channels. - * - * @param encoding the encoding of the new AudioMediaFormatImpl - * instance - * @param clockRate the clock (i.e. sample) rate of the new - * AudioMediaFormatImpl instance - * @param channels the number of available channels (1 for mono, 2 for - * stereo) - */ - AudioMediaFormatImpl(String encoding, double clockRate, int channels) - { - this(encoding, clockRate, channels, null, null); - } - - /** - * Initializes a new AudioMediaFormatImpl instance with the - * specified encoding, clock rate and format parameters and a single audio - * channel. - * - * @param encoding the encoding of the new AudioMediaFormatImpl - * instance - * @param clockRate the clock (i.e. sample) rate of the new - * AudioMediaFormatImpl instance - * @param formatParameters any codec-specific parameters that have been - * received via SIP/SDP or XMPP/Jingle. - * @param advancedParameters set of advanced parameters that have been - * received by SIP/SDP or XMPP/Jingle - */ - AudioMediaFormatImpl( - String encoding, - double clockRate, - Map formatParameters, - Map advancedParameters) - { - this(encoding, clockRate, 1, formatParameters, advancedParameters); - } - - /** - * Initializes a new AudioMediaFormatImpl instance with the - * specified encoding, clock rate, number of audio channels and format - * parameters. - * - * @param encoding the encoding of the new AudioMediaFormatImpl - * instance - * @param clockRate the clock (i.e. sample) rate of the new - * AudioMediaFormatImpl instance - * @param channels the number of available channels (1 for mono, 2 for - * stereo) - * @param formatParameters any codec-specific parameters that have been - * received via SIP/SDP or XMPP/Jingle - * @param advancedParameters any parameters that have been - * received via SIP/SDP or XMPP/Jingle - */ - AudioMediaFormatImpl( - String encoding, - double clockRate, - int channels, - Map formatParameters, - Map advancedParameters) - { - this( - new AudioFormat( - encoding, - clockRate, - AudioFormat.NOT_SPECIFIED, - channels), - formatParameters, - advancedParameters); - } - - /** - * Gets an AudioFormat instance which matches a specific - * AudioFormat and has 1 channel if the specified - * AudioFormat has its number of channels not specified. - * - * @param format the AudioFormat to get a match of - * @return if the specified format has a specific number of - * channels, format; otherwise, a new AudioFormat instance - * which matches format and has 1 channel - */ - private static AudioFormat fixChannels(AudioFormat format) - { - if (Format.NOT_SPECIFIED == format.getChannels()) - format - = (AudioFormat) - format - .intersects( - new AudioFormat( - format.getEncoding(), - format.getSampleRate(), - format.getSampleSizeInBits(), - 1)); - return format; - } - - /** - * Gets the number of audio channels associated with this - * AudioMediaFormat. - * - * @return the number of audio channels associated with this - * AudioMediaFormat - * @see AudioMediaFormat#getChannels() - */ - public int getChannels() - { - int channels = format.getChannels(); - - return (Format.NOT_SPECIFIED == channels) ? 1 : channels; - } - - /** - * Gets the clock rate associated with this MediaFormat. - * - * @return the clock rate associated with this MediaFormat - * @see MediaFormat#getClockRate() - */ - public double getClockRate() - { - return format.getSampleRate(); - } - - /** - * Gets the type of this MediaFormat which is - * {@link MediaType#AUDIO} for AudioMediaFormatImpl instances. - * - * @return the MediaType that this format represents and which is - * MediaType.AUDIO for AudioMediaFormatImpl instances - * @see MediaFormat#getMediaType() - */ - public final MediaType getMediaType() - { - return MediaType.AUDIO; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/format/MediaFormatFactoryImpl.java b/src/net/java/sip/communicator/impl/neomedia/format/MediaFormatFactoryImpl.java deleted file mode 100644 index 75a27c964..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/format/MediaFormatFactoryImpl.java +++ /dev/null @@ -1,487 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.format; - -import java.util.*; -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.format.*; -import net.java.sip.communicator.util.*; - -/** - * Implements MediaFormatFactory for the JMF Format types. - * - * @author Lyubomir Marinov - */ -public class MediaFormatFactoryImpl - implements MediaFormatFactory -{ - /** - * The Logger used by the MediaFormatFactoryImpl class and - * its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(MediaFormatFactoryImpl.class); - - /** - * Creates an unknown MediaFormat. - * - * @param type MediaType - * @return unknown MediaFormat - */ - public MediaFormat createUnknownMediaFormat(MediaType type) - { - Format unknown = null; - - /* - * FIXME Why is a VideoFormat instance created for MediaType.AUDIO and - * an AudioFormat instance for MediaType.VIDEO? - */ - if(type.equals(MediaType.AUDIO)) - unknown = new VideoFormat("unknown"); - else if(type.equals(MediaType.VIDEO)) - unknown = new AudioFormat("unknown"); - return MediaFormatImpl.createInstance(unknown); - } - - /** - * Creates a MediaFormat for the specified encoding with - * default clock rate and set of format parameters. If encoding is - * known to this MediaFormatFactory, returns a - * MediaFormat which is either an AudioMediaFormat or a - * VideoMediaFormat instance. Otherwise, returns null. - * - * @param encoding the well-known encoding (name) to create a - * MediaFormat for - * @return a MediaFormat with the specified encoding which - * is either an AudioMediaFormat or a VideoMediaFormat - * instance if encoding is known to this - * MediaFormatFactory; otherwise, null - * @see MediaFormatFactory#createMediaFormat(String) - */ - public MediaFormat createMediaFormat(String encoding) - { - return createMediaFormat(encoding, CLOCK_RATE_NOT_SPECIFIED); - } - - /** - * Creates a MediaFormat for the specified RTP payload type with - * default clock rate and set of format parameters. If - * rtpPayloadType is known to this MediaFormatFactory, - * returns a MediaFormat which is either an - * AudioMediaFormat or a VideoMediaFormat instance. - * Otherwise, returns null. - * - * @param rtpPayloadType the RTP payload type of the MediaFormat to - * create - * @return a MediaFormat with the specified rtpPayloadType - * which is either an AudioMediaFormat or a - * VideoMediaFormat instance if rtpPayloadType is known to - * this MediaFormatFactory; otherwise, null - * @see MediaFormatFactory#createMediaFormat(byte) - */ - public MediaFormat createMediaFormat(byte rtpPayloadType) - { - /* - * We know which are the MediaFormat instances with the specified - * rtpPayloadType but we cannot directly return them because they do not - * reflect the user's configuration with respect to being enabled and - * disabled. - */ - for (MediaFormat rtpPayloadTypeMediaFormat - : MediaUtils.getMediaFormats(rtpPayloadType)) - { - MediaFormat mediaFormat - = createMediaFormat( - rtpPayloadTypeMediaFormat.getEncoding(), - rtpPayloadTypeMediaFormat.getClockRate()); - if (mediaFormat != null) - return mediaFormat; - } - return null; - } - - /** - * Creates a MediaFormat for the specified encoding with - * the specified clockRate and a default set of format parameters. - * If encoding is known to this MediaFormatFactory, - * returns a MediaFormat which is either an - * AudioMediaFormat or a VideoMediaFormat instance. - * Otherwise, returns null. - * - * @param encoding the well-known encoding (name) to create a - * MediaFormat for - * @param clockRate the clock rate in Hz to create a MediaFormat - * for - * @return a MediaFormat with the specified encoding and - * clockRate which is either an AudioMediaFormat or a - * VideoMediaFormat instance if encoding is known to this - * MediaFormatFactory; otherwise, null - * @see MediaFormatFactory#createMediaFormat(String, double) - */ - public MediaFormat createMediaFormat(String encoding, double clockRate) - { - return createMediaFormat(encoding, clockRate, 1); - } - - /** - * Creates a MediaFormat for the specified encoding, - * clockRate and channels and a default set of format - * parameters. If encoding is known to this - * MediaFormatFactory, returns a MediaFormat which is - * either an AudioMediaFormat or a VideoMediaFormat - * instance. Otherwise, returns null. - * - * @param encoding the well-known encoding (name) to create a - * MediaFormat for - * @param clockRate the clock rate in Hz to create a MediaFormat - * for - * @param channels the number of available channels (1 for mono, 2 for - * stereo) if it makes sense for the MediaFormat with the specified - * encoding; otherwise, ignored - * @return a MediaFormat with the specified encoding, - * clockRate and channels and a default set of format - * parameters which is either an AudioMediaFormat or a - * VideoMediaFormat instance if encoding is known to this - * MediaFormatFactory; otherwise, null - * @see MediaFormatFactory#createMediaFormat(String, double, int) - */ - public MediaFormat createMediaFormat( - String encoding, double clockRate, int channels) - { - return createMediaFormat(encoding, clockRate, channels, null); - } - - private MediaFormat createMediaFormat( - String encoding, double clockRate, int channels, - Map fmtps) - { - for (MediaFormat format : getSupportedMediaFormats(encoding, clockRate)) - { - /* - * The mediaType, encoding and clockRate properties are sure to - * match because format is the result of the search for encoding and - * clockRate. We just want to make sure that the channels and the - * format parameters match. - */ - if (AbstractMediaStream.matches( - format, - format.getMediaType(), - format.getEncoding(), format.getClockRate(), channels, - fmtps)) - return format; - } - return null; - } - - /** - * Creates a MediaFormat for the specified encoding, - * clockRate and set of format parameters. If encoding is - * known to this MediaFormatFactory, returns a MediaFormat - * which is either an AudioMediaFormat or a - * VideoMediaFormat instance. Otherwise, returns null. - * - * @param encoding the well-known encoding (name) to create a - * MediaFormat for - * @param clockRate the clock rate in Hz to create a MediaFormat - * for - * @param formatParams any codec specific parameters which have been - * received via SIP/SDP or XMPP/Jingle - * @return a MediaFormat with the specified encoding, - * clockRate and set of format parameters which is either an - * AudioMediaFormat or a VideoMediaFormat instance if - * encoding is known to this MediaFormatFactory; - * otherwise, null - * @see MediaFormatFactory#createMediaFormat(String, double, Map, Map) - */ - public MediaFormat createMediaFormat( - String encoding, double clockRate, - Map formatParams, - Map advancedParams) - { - return - createMediaFormat( - encoding, clockRate, 1, -1, - formatParams, - advancedParams); - } - - /** - * Creates a MediaFormat for the specified encoding, - * clockRate, channels and set of format parameters. If - * encoding is known to this MediaFormatFactory, returns a - * MediaFormat which is either an AudioMediaFormat or a - * VideoMediaFormat instance. Otherwise, returns null. - * - * @param encoding the well-known encoding (name) to create a - * MediaFormat for - * @param clockRate the clock rate in Hz to create a MediaFormat - * for - * @param frameRate the frame rate in number of frames per second to - * create a MediaFormat for - * @param channels the number of available channels (1 for mono, 2 for - * stereo) if it makes sense for the MediaFormat with the specified - * encoding; otherwise, ignored - * @param formatParams any codec specific parameters which have been - * received via SIP/SDP or XMPP/Jingle - * @param advancedParams any parameters which have been - * received via SIP/SDP or XMPP/Jingle - * @return a MediaFormat with the specified encoding, - * clockRate, channels and set of format parameters which - * is either an AudioMediaFormat or a VideoMediaFormat - * instance if encoding is known to this - * MediaFormatFactory; otherwise, null - * @see MediaFormatFactory#createMediaFormat(String, double, int, float, Map, Map) - */ - public MediaFormat createMediaFormat( - String encoding, double clockRate, int channels, float frameRate, - Map formatParams, - Map advancedParams) - { - MediaFormat mediaFormat - = createMediaFormat(encoding, clockRate, channels, formatParams); - - if (mediaFormat == null) - return null; - - /* - * MediaFormatImpl is immutable so if the caller wants to change the - * format parameters and/or the advanced attributes, we'll have to - * create a new MediaFormatImpl. - */ - Map formatParameters = null; - Map advancedParameters = null; - - if ((formatParams != null) && !formatParams.isEmpty()) - formatParameters = formatParams; - if ((advancedParams != null ) && !advancedParams.isEmpty()) - advancedParameters = advancedParams; - - if ((formatParameters != null) || (advancedParameters != null)) - { - switch (mediaFormat.getMediaType()) - { - case AUDIO: - mediaFormat - = new AudioMediaFormatImpl( - ((AudioMediaFormatImpl) mediaFormat).getFormat(), - formatParameters, advancedParameters); - break; - case VIDEO: - VideoMediaFormatImpl videoMediaFormatImpl - = (VideoMediaFormatImpl) mediaFormat; - - /* - * If the format of VideoMediaFormatImpl is - * a ParameterizedVideoFormat, it's possible for the format - * parameters of that ParameterizedVideoFormat and of the new - * VideoMediaFormatImpl (to be created) to be out of sync. While - * it's not technically perfect, it should be practically safe - * for the format parameters which distinguish VideoFormats with - * the same encoding and clock rate because mediaFormat has - * already been created in sync with formatParams (with respect - * to the format parameters which distinguish VideoFormats with - * the same encoding and clock rate). - */ - mediaFormat - = new VideoMediaFormatImpl( - videoMediaFormatImpl.getFormat(), - videoMediaFormatImpl.getClockRate(), - frameRate, - formatParameters, advancedParameters); - break; - default: - mediaFormat = null; - } - } - return mediaFormat; - } - - /** - * Creates a MediaFormat either for the specified - * rtpPayloadType or for the specified encoding, - * clockRate, channels and set of format parameters. If - * encoding is known to this MediaFormatFactory, ignores - * rtpPayloadType and returns a MediaFormat which is - * either an AudioMediaFormat or a VideoMediaFormat - * instance. If rtpPayloadType is not - * {@link MediaFormat#RTP_PAYLOAD_TYPE_UNKNOWN} and encoding is - * null, uses the encoding associated with rtpPayloadType. - * - * @param rtpPayloadType the RTP payload type to create a - * MediaFormat for; {@link MediaFormat#RTP_PAYLOAD_TYPE_UNKNOWN} if - * encoding is not null. If rtpPayloadType is not - * MediaFormat#RTP_PAYLOAD_TYPE_UNKNOWN and encoding is - * not null, rtpPayloadType is ignored - * @param encoding the well-known encoding (name) to create a - * MediaFormat for; null - * @param clockRate the clock rate in Hz to create a MediaFormat - * for - * @param frameRate the frame rate in number of frames per second to - * create a MediaFormat for - * @param channels the number of available channels (1 for mono, 2 for - * stereo) if it makes sense for the MediaFormat with the specified - * encoding; otherwise, ignored - * @param formatParams any codec specific parameters which have been - * received via SIP/SDP or XMPP/Jingle - * @param advancedParams any parameters which have been - * received via SIP/SDP or XMPP/Jingle - * @return a MediaFormat with the specified encoding, - * clockRate, channels and set of format parameters which - * is either an AudioMediaFormat or a VideoMediaFormat - * instance if encoding is known to this - * MediaFormatFactory; otherwise, null - */ - public MediaFormat createMediaFormat( - byte rtpPayloadType, - String encoding, double clockRate, int channels, float frameRate, - Map formatParams, - Map advancedParams) - { - - /* - * If rtpPayloadType is specified, use it only to figure out encoding - * and/or clockRate in case either one of them is unknown. - */ - if ((MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN != rtpPayloadType) - && ((encoding == null) - || (CLOCK_RATE_NOT_SPECIFIED == clockRate))) - { - MediaFormat[] rtpPayloadTypeMediaFormats - = MediaUtils.getMediaFormats(rtpPayloadType); - - if (rtpPayloadTypeMediaFormats.length > 0) - { - if (encoding == null) - encoding = rtpPayloadTypeMediaFormats[0].getEncoding(); - - // Assign or check the clock rate. - if (CLOCK_RATE_NOT_SPECIFIED == clockRate) - clockRate = rtpPayloadTypeMediaFormats[0].getClockRate(); - else - { - boolean clockRateIsValid = false; - - for (MediaFormat rtpPayloadTypeMediaFormat - : rtpPayloadTypeMediaFormats) - if (rtpPayloadTypeMediaFormat - .getEncoding().equals(encoding) - && (rtpPayloadTypeMediaFormat.getClockRate() - == clockRate)) - { - clockRateIsValid = true; - break; - } - - if (!clockRateIsValid) - return null; - } - } - } - - return - createMediaFormat( - encoding, clockRate, channels, frameRate, - formatParams, - advancedParams); - } - - /** - * Gets the MediaFormats among the specified mediaFormats - * which have the specified encoding and, optionally, - * clockRate. - * - * @param mediaFormats the MediaFormats from which to filter out - * only the ones which have the specified encoding and, optionally, - * clockRate - * @param encoding the well-known encoding (name) of the - * MediaFormats to be retrieved - * @param clockRate the clock rate of the MediaFormats to be - * retrieved; {@link #CLOCK_RATE_NOT_SPECIFIED} if any clock rate is - * acceptable - * @return a List of the MediaFormats among - * mediaFormats which have the specified encoding and, - * optionally, clockRate - */ - private List getMatchingMediaFormats( - MediaFormat[] mediaFormats, - String encoding, double clockRate) - { - /* - * XXX Use String#equalsIgnoreCase(String) because some clients transmit - * some of the codecs starting with capital letters. - */ - - /* - * As per RFC 3551.4.5.2, because of a mistake in RFC 1890 and for - * backward compatibility, G.722 should always be announced as 8000 even - * though it is wideband. So, if someone is looking for G722/16000, - * then: Forgive them, for they know not what they do! - */ - if("G722".equalsIgnoreCase(encoding) && (16000 == clockRate)) - { - clockRate = 8000; - if (logger.isInfoEnabled()) - logger.info("Suppressing erroneous 16000 announcement for G.722"); - } - - List supportedMediaFormats = new ArrayList(); - - for (MediaFormat mediaFormat : mediaFormats) - { - if (mediaFormat.getEncoding().equalsIgnoreCase(encoding) - && ((CLOCK_RATE_NOT_SPECIFIED == clockRate) - || (mediaFormat.getClockRate() == clockRate))) - { - supportedMediaFormats.add(mediaFormat); - } - } - return supportedMediaFormats; - } - - /** - * Gets the MediaFormats supported by this - * MediaFormatFactory and the MediaService associated with - * it and having the specified encoding and, optionally, - * clockRate. - * - * @param encoding the well-known encoding (name) of the - * MediaFormats to be retrieved - * @param clockRate the clock rate of the MediaFormats to be - * retrieved; {@link #CLOCK_RATE_NOT_SPECIFIED} if any clock rate is - * acceptable - * @return a List of the MediaFormats supported by the - * MediaService associated with this MediaFormatFactory - * and having the specified encoding and, optionally, clock rate - */ - private List getSupportedMediaFormats( - String encoding, double clockRate) - { - EncodingConfiguration encodingConfiguration - = NeomediaActivator.getMediaServiceImpl() - .getEncodingConfiguration(); - List supportedMediaFormats - = getMatchingMediaFormats( - encodingConfiguration.getSupportedEncodings( - MediaType.AUDIO), - encoding, - clockRate); - - if (supportedMediaFormats.isEmpty()) - supportedMediaFormats - = getMatchingMediaFormats( - encodingConfiguration.getSupportedEncodings( - MediaType.VIDEO), - encoding, - clockRate); - return supportedMediaFormats; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/format/MediaFormatImpl.java b/src/net/java/sip/communicator/impl/neomedia/format/MediaFormatImpl.java deleted file mode 100644 index 5f0c13f11..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/format/MediaFormatImpl.java +++ /dev/null @@ -1,611 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.format; - -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.format.*; - -/** - * Implements MediaFormat for the JMF Format. - * - * @param the type of the wrapped Format - * - * @author Lyubomir Marinov - */ -public abstract class MediaFormatImpl - implements MediaFormat -{ - /** - * The name of the clockRate property of MediaFormatImpl. - */ - public static final String CLOCK_RATE_PNAME = "clockRate"; - - /** - * The value of the formatParameters property of - * MediaFormatImpl when no codec-specific parameters have been - * received via SIP/SDP or XMPP/Jingle. Explicitly defined in order to - * reduce unnecessary allocations. - */ - static final Map EMPTY_FORMAT_PARAMETERS - = Collections.emptyMap(); - - /** - * The value of the codecSettings property of - * MediaFormatImpl when no codec-specific settings. - * Explicitly defined in order to reduce unnecessary allocations. - */ - static final Map EMPTY_CODEC_SETTINGS - = Collections.emptyMap(); - - /** - * The name of the encoding property of MediaFormatImpl. - */ - public static final String ENCODING_PNAME = "encoding"; - - /** - * The name of the formatParameters property of - * MediaFormatImpl. - */ - public static final String FORMAT_PARAMETERS_PNAME = "fmtps"; - - /** - * The additional codec settings. - */ - private Map codecSettings = EMPTY_CODEC_SETTINGS; - - /** - * Creates a new MediaFormat instance for a specific JMF - * Format. - * - * @param format the JMF Format the new instance is to provide an - * implementation of MediaFormat for - * @return a new MediaFormat instance for the specified JMF - * Format - */ - public static MediaFormat createInstance(Format format) - { - MediaFormat mediaFormat = MediaUtils.getMediaFormat(format); - - if (mediaFormat == null) - { - if (format instanceof AudioFormat) - mediaFormat = new AudioMediaFormatImpl((AudioFormat) format); - else if (format instanceof VideoFormat) - mediaFormat = new VideoMediaFormatImpl((VideoFormat) format); - } - return mediaFormat; - } - - /** - * Creates a new MediaFormat instance for a specific JMF - * Format and assigns it specific clock rate and set of - * format-specific parameters. - * - * @param format the JMF Format the new instance is to provide an - * implementation of MediaFormat for - * @param clockRate the clock rate of the new instance - * @param formatParameters the set of format-specific parameters of the new - * instance - * @param advancedAttrs advanced attributes of the new instance - * @return a new MediaFormat instance for the specified JMF - * Format and with the specified clock rate and set of - * format-specific parameters - */ - public static MediaFormatImpl createInstance( - Format format, - double clockRate, - Map formatParameters, - Map advancedAttrs) - { - if (format instanceof AudioFormat) - { - AudioFormat audioFormat = (AudioFormat) format; - AudioFormat clockRateAudioFormat - = new AudioFormat( - audioFormat.getEncoding(), - clockRate, - audioFormat.getSampleSizeInBits(), - audioFormat.getChannels()); - - return - new AudioMediaFormatImpl( - (AudioFormat) - clockRateAudioFormat.intersects(audioFormat), - formatParameters, - advancedAttrs); - } - else if (format instanceof VideoFormat) - return - new VideoMediaFormatImpl( - (VideoFormat) format, - clockRate, - -1, - formatParameters, - advancedAttrs); - else - return null; - } - - /** - * Determines whether a specific set of advanced attributes is equal to - * another set of advanced attributes in the sense that they define an equal - * number of parameters and assign them equal values. Since the values are - * Strings, presumes that a value of null is equal to the - * empty String. - *

- * - * @param adv the first set of advanced attributes to be tested for - * equality - * @param adv2 the second set of advanced attributes to be tested for - * equality - * @return true if the specified sets of advanced attributes - * equal; false, otherwise - */ - public boolean advancedAttributesAreEqual(Map adv, - Map adv2) - { - if(adv == null && adv2 != null || adv != null && adv2 == null) - return false; - - if(adv == null && adv2 == null) - return true; - - if(adv.size() != adv2.size()) - return false; - - for(Map.Entry a : adv.entrySet()) - { - String value = adv2.get(a.getKey()); - if(value == null) - return false; - else - if(!value.equals(a.getValue())) - return false; - } - return true; - } - - /** - * Determines whether a specific set of format parameters is equal to - * another set of format parameters in the sense that they define an equal - * number of parameters and assign them equal values. Since the values are - * Strings, presumes that a value of null is equal to the - * empty String. - *

- * The two Map instances of format parameters to be checked for - * equality are presumed to be modifiable in the sense that if the lack of a - * format parameter in a given Map is equivalent to it having a - * specific value, an association of the format parameter to the value in - * question may be added to or removed from the respective Map - * instance for the purposes of determining equality. - *

- * - * @param fmtps1 the first set of format parameters to be tested for - * equality - * @param fmtps2 the second set of format parameters to be tested for - * equality - * @return true if the specified sets of format parameters are - * equal; false, otherwise - */ - protected boolean formatParametersAreEqual( - Map fmtps1, - Map fmtps2) - { - return formatParametersAreEqual(getEncoding(), fmtps1, fmtps2); - } - - /** - * Determines whether a specific set of format parameters is equal to - * another set of format parameters in the sense that they define an equal - * number of parameters and assign them equal values. Since the values are - * Strings, presumes that a value of null is equal to the - * empty String. - *

- * The two Map instances of format parameters to be checked for - * equality are presumed to be modifiable in the sense that if the lack of a - * format parameter in a given Map is equivalent to it having a - * specific value, an association of the format parameter to the value in - * question may be added to or removed from the respective Map - * instance for the purposes of determining equality. - *

- * - * @param encoding the encoding (name) related to the two sets of format - * parameters to be tested for equality - * @param fmtps1 the first set of format parameters to be tested for - * equality - * @param fmtps2 the second set of format parameters to be tested for - * equality - * @return true if the specified sets of format parameters are - * equal; false, otherwise - */ - public static boolean formatParametersAreEqual( - String encoding, - Map fmtps1, Map fmtps2) - { - if (fmtps1 == null) - return (fmtps2 == null) || fmtps2.isEmpty(); - if (fmtps2 == null) - return (fmtps1 == null) || fmtps1.isEmpty(); - if (fmtps1.size() == fmtps2.size()) - { - for (Map.Entry fmtp1 : fmtps1.entrySet()) - { - String key1 = fmtp1.getKey(); - - if (!fmtps2.containsKey(key1)) - return false; - - String value1 = fmtp1.getValue(); - String value2 = fmtps2.get(key1); - - /* - * Since the values are strings, allow null to be equal to the - * empty string. - */ - if ((value1 == null) || (value1.length() == 0)) - { - if ((value2 != null) && (value2.length() != 0)) - return false; - } - else if (!value1.equals(value2)) - return false; - } - return true; - } - else - return false; - } - - /** - * {@inheritDoc} - *

- * The default implementation of MediaFormatImpl always returns - * true because format parameters in general do not cause the - * distinction of payload types. - *

- */ - public boolean formatParametersMatch(Map fmtps) - { - return true; - } - - /** - * The JMF Format this instance wraps and provides an - * implementation of MediaFormat for. - */ - protected final T format; - - /** - * The codec-specific parameters of this instance which have been received - * via SIP/SDP or XMPP/Jingle. - */ - private final Map formatParameters; - - /** - * The advanced parameters of this instance which have been received - * via SIP/SDP or XMPP/Jingle. - */ - private final Map advancedParameters; - - /** - * Initializes a new MediaFormatImpl instance which is to provide - * an implementation of MediaFormat for a specific Format. - * - * @param format the JMF Format the new instance is to provide an - * implementation of MediaFormat for - */ - protected MediaFormatImpl(T format) - { - this(format, null, null); - } - - /** - * Initializes a new MediaFormatImpl instance which is to provide - * an implementation of MediaFormat for a specific Format - * and which is to have a specific set of codec-specific parameters. - * - * @param format the JMF Format the new instance is to provide an - * implementation of MediaFormat for - * @param formatParameters any codec-specific parameters that have been - * received via SIP/SDP or XMPP/Jingle - * @param advancedParameters any parameters that have been - * received via SIP/SDP or XMPP/Jingle - */ - protected MediaFormatImpl( - T format, - Map formatParameters, - Map advancedParameters) - { - if (format == null) - throw new NullPointerException("format"); - - this.format = format; - this.formatParameters - = ((formatParameters == null) || formatParameters.isEmpty()) - ? EMPTY_FORMAT_PARAMETERS - : new HashMap(formatParameters); - this.advancedParameters - = ((advancedParameters == null) || advancedParameters.isEmpty()) - ? EMPTY_FORMAT_PARAMETERS - : new HashMap(advancedParameters); - } - - /** - * Implements MediaFormat#equals(Object) and actually compares the - * encapsulated JMF Format instances. - * - * @param mediaFormat the object that we'd like to compare this one - * to. - 8* - * @return true if the JMF Format instances encapsulated - * by this class are equal and false otherwise. - */ - @Override - public boolean equals(Object mediaFormat) - { - if (this == mediaFormat) - return true; - - if (!getClass().isInstance(mediaFormat)) - return false; - - @SuppressWarnings("unchecked") - MediaFormatImpl mediaFormatImpl = (MediaFormatImpl) mediaFormat; - - return getFormat().equals(mediaFormatImpl.getFormat()) - && formatParametersAreEqual( - getFormatParameters(), - mediaFormatImpl.getFormatParameters()); - } - - /** - * Implements MediaFormat#getEncoding() and returns the encoding of the JMF - * Format that we are encapsulating here but it is the RFC-known - * encoding and not the internal JMF encoding. - * - * @return the RFC-known encoding of the JMF Format that we are - * encapsulating - */ - public String getEncoding() - { - String jmfEncoding = getJMFEncoding(); - String encoding = MediaUtils.jmfEncodingToEncoding(jmfEncoding); - - if (encoding == null) - { - encoding = jmfEncoding; - - int encodingLength = encoding.length(); - - if (encodingLength > 3) - { - int rtpPos = encodingLength - 4; - - if ("/rtp".equalsIgnoreCase(encoding.substring(rtpPos))) - encoding = encoding.substring(0, rtpPos); - } - } - return encoding; - } - - /** - * Returns the JMF Format instance that we are wrapping here. - * - * @return a reference to that JMF Format instance that this class - * is wrapping. - */ - public T getFormat() - { - return format; - } - - /** - * Implements MediaFormat#getFormatParameters(). Returns a copy of the - * format properties of this instance. Modifications to the returned Map do - * no affect the format properties of this instance. - * - * @return a copy of the format properties of this instance. Modifications - * to the returned Map do no affect the format properties of this instance. - */ - public Map getFormatParameters() - { - return (formatParameters == EMPTY_FORMAT_PARAMETERS) - ? EMPTY_FORMAT_PARAMETERS - : new HashMap(formatParameters); - } - - /** - * Implements MediaFormat#getAdvancedParameters(). Returns a copy of the - * attribute properties of this instance. Modifications to the returned Map - * do no affect the format properties of this instance. - * - * @return a copy of the attribute properties of this instance. - * Modifications to the returned Map do no affect the format properties of - * this instance. - */ - public Map getAdvancedAttributes() - { - return (advancedParameters == EMPTY_FORMAT_PARAMETERS) - ? EMPTY_FORMAT_PARAMETERS - : new HashMap(advancedParameters); - } - - /** - * Gets the encoding of the JMF Format represented by this - * instance as it is known to JMF (in contrast to its RFC name). - * - * @return the encoding of the JMF Format represented by this - * instance as it is known to JMF (in contrast to its RFC name) - */ - public String getJMFEncoding() - { - return format.getEncoding(); - } - - /** - * Gets the RTP payload type (number) of this MediaFormat as it is - * known in RFC 3551 "RTP Profile for Audio and Video Conferences with - * Minimal Control". - * - * @return the RTP payload type of this MediaFormat if it is known - * in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal - * Control"; otherwise, {@link #RTP_PAYLOAD_TYPE_UNKNOWN} - * @see MediaFormat#getRTPPayloadType() - */ - public byte getRTPPayloadType() - { - return MediaUtils.getRTPPayloadType(getJMFEncoding(), getClockRate()); - } - - /** - * Overrides Object#hashCode() because Object#equals(Object) is overridden. - * - * @return a hash code value for this MediaFormat. - */ - @Override - public int hashCode() - { - /* - * XXX We've experienced a case of JMF's VideoFormat#hashCode() - * returning different values for instances which are reported equal by - * VideoFormat#equals(Object) which is inconsistent with the protocol - * covering the two methods in question and causes problems, - * for example, with Map. While jmfEncoding is more generic than format, - * it still provides a relatively good distribution given that we do not - * have a lot of instances with one and the same jmfEncoding. - */ - return getJMFEncoding().hashCode() | getFormatParameters().hashCode(); - } - - /** - * Returns a String representation of the clock rate associated - * with this MediaFormat making sure that the value appears as - * an integer (i.e. its long-casted value is equal to its original one) - * unless it is actually a non integer. - * - * @return a String representation of the clock rate associated - * with this MediaFormat. - */ - public String getClockRateString() - { - double clockRate = getClockRate(); - long clockRateL = (long) clockRate; - - if (clockRateL == clockRate) - return Long.toString(clockRateL); - else - return Double.toString(clockRate); - } - - /** - * Returns a String representation of the real used clock rate - * associated with this MediaFormat making sure that the value - * appears as an integer (i.e. contains no decimal point) unless it is - * actually a non integer. - * This function corrects the problem of the G.722 codec which advertises - * its clock rate to be 8 kHz while 16 kHz is really used to encode the - * stream (that's an error noted in the respective RFC and kept for the sake - * of compatibility.). - * - * @return a String representation of the real used clock rate - * associated with this MediaFormat. - */ - public String getRealUsedClockRateString() - { - // RFC 1890 erroneously assigned 8 kHz to the RTP clock rate for the - // G722 payload format. The actual sampling rate for G.722 audio is 16 - // kHz. - if(this.getEncoding().equalsIgnoreCase("G722")) - { - return "16000"; - } - return this.getClockRateString(); - } - - /** - * Sets additional codec settings. - * - * @param settings additional settings represented by a map. - */ - public void setAdditionalCodecSettings(Map settings) - { - codecSettings = settings; - } - - /** - * Returns additional codec settings. - * - * @return additional settings represented by a map. - */ - public Map getAdditionalCodecSettings() - { - return codecSettings; - } - - /** - * Returns a String representation of this MediaFormat - * containing, among other things, its encoding and clockrate values. - * - * @return a String representation of this MediaFormat. - */ - @Override - public String toString() - { - StringBuffer str = new StringBuffer(); - - str.append("rtpmap:"); - str.append(getRTPPayloadType()); - str.append(' '); - str.append(getEncoding()); - str.append('/'); - str.append(getClockRateString()); - - /* - * If the number of channels is 1, it does not have to be mentioned - * because it is the default. - */ - if (MediaType.AUDIO.equals(getMediaType())) - { - int channels = ((AudioFormat) getFormat()).getChannels(); - - if (channels != 1) - { - str.append('/'); - str.append(channels); - } - } - - Map formatParameters = getFormatParameters(); - - if (!formatParameters.isEmpty()) - { - str.append(" fmtp:"); - - boolean prependSeparator = false; - - for (Map.Entry formatParameter - : formatParameters.entrySet()) - { - if (prependSeparator) - str.append(';'); - else - prependSeparator = true; - str.append(formatParameter.getKey()); - str.append('='); - str.append(formatParameter.getValue()); - } - } - - return str.toString(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/format/ParameterizedVideoFormat.java b/src/net/java/sip/communicator/impl/neomedia/format/ParameterizedVideoFormat.java deleted file mode 100644 index 390f69826..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/format/ParameterizedVideoFormat.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.format; - -import java.awt.*; -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -/** - * Implements a VideoFormat with format parameters (like - * {@link VideoMediaFormatImpl}) (some of) which (could) distinguish payload - * types. - * - * @author Lyubomir Marinov - */ -public class ParameterizedVideoFormat - extends VideoFormat -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * The format parameters of this ParameterizedVideoFormat instance. - */ - private Map fmtps; - - /** - * Constructs a new ParametizedVideoFormat. - * - * @param encoding encoding - * @param size video size - * @param maxDataLength maximum data length - * @param dataType data type - * @param frameRate frame rate - * @param fmtps format parameters - */ - public ParameterizedVideoFormat( - String encoding, - Dimension size, - int maxDataLength, - Class dataType, - float frameRate, - Map fmtps) - { - super(encoding, size, maxDataLength, dataType, frameRate); - - this.fmtps - = ((fmtps == null) || fmtps.isEmpty()) - ? MediaFormatImpl.EMPTY_FORMAT_PARAMETERS - : new HashMap(fmtps); - } - - /** - * Initializes a new ParameterizedVideoFormat with a specific - * encoding and a specific set of format parameters. - * - * @param encoding the encoding of the new instance - * @param fmtps the format parameters of the new instance - */ - public ParameterizedVideoFormat(String encoding, Map fmtps) - { - super(encoding); - - this.fmtps - = ((fmtps == null) || fmtps.isEmpty()) - ? MediaFormatImpl.EMPTY_FORMAT_PARAMETERS - : new HashMap(fmtps); - } - - /** - * Initializes a new ParameterizedVideoFormat with a specific - * encoding and a specific set of format parameters. - * - * @param encoding the encoding of the new instance - * @param fmtps the format parameters of the new instance in the form of an - * array of Strings in which the key and the value of an - * association are expressed as consecutive elements. - */ - public ParameterizedVideoFormat(String encoding, String... fmtps) - { - this(encoding, toMap(fmtps)); - } - - /** - * Initializes a new ParameterizedVideoFormat instance which has - * the same properties as this instance. - * - * @return a new ParameterizedVideoFormat instance which has the - * same properties as this instance - */ - @Override - public Object clone() - { - ParameterizedVideoFormat f - = new ParameterizedVideoFormat( - getEncoding(), - getSize(), - getMaxDataLength(), - getDataType(), - getFrameRate(), - /* - * The formatParameters will be copied by - * ParameterizedVideoFormat#copy(Format) bellow. - */ - null); - - f.copy(this); - return f; - } - - /** - * Copies the properties of the specified Format into this - * instance. - * - * @param f the Format the properties of which are to be copied - * into this instance - */ - @Override - protected void copy(Format f) - { - super.copy(f); - - if (f instanceof ParameterizedVideoFormat) - { - ParameterizedVideoFormat pvf = (ParameterizedVideoFormat) f; - Map pvfFmtps = pvf.getFormatParameters(); - - fmtps - = ((pvfFmtps == null) || pvfFmtps.isEmpty()) - ? MediaFormatImpl.EMPTY_FORMAT_PARAMETERS - : new HashMap(pvfFmtps); - } - } - - /** - * Determines whether a specific Object represents a value that is - * equal to the value represented by this instance. - * - * @param obj the Object to be determined whether it represents a - * value that is equal to the value represented by this instance - * @return true if the specified obj represents a value - * that is equal to the value represented by this instance; otherwise, - * false - */ - @Override - public boolean equals(Object obj) - { - if (!super.equals(obj)) - return false; - - Map objFmtps = null; - - if (obj instanceof ParameterizedVideoFormat) - objFmtps = ((ParameterizedVideoFormat) obj).getFormatParameters(); - return - VideoMediaFormatImpl.formatParametersAreEqual( - getEncoding(), - getFormatParameters(), objFmtps); - } - - /** - * Returns whether or not the format parameters match. - * - * @param format format to test - * @return true if the format parameters match. - */ - public boolean formatParametersMatch(Format format) - { - Map formatFmtps = null; - - if (format instanceof ParameterizedVideoFormat) - formatFmtps - = ((ParameterizedVideoFormat) format).getFormatParameters(); - return - VideoMediaFormatImpl.formatParametersMatch( - getEncoding(), - getFormatParameters(), formatFmtps); - } - - /** - * Returns the format parameters value for the specified name. - * - * @param name format parameters name - * @return value for the specified format parameters name - */ - public String getFormatParameter(String name) - { - return fmtps.get(name); - } - - /** - * Returns the format parameters Map. - * - * @return the format parameters Map. - */ - public Map getFormatParameters() - { - return new HashMap(fmtps); - } - - /** - * Finds the attributes shared by two matching Formats. If the - * specified Format does not match this one, the result is - * undefined. - * - * @param format the matching Format to intersect with this one - * @return a Format with its attributes set to the attributes - * common to this instance and the specified format - */ - @Override - public Format intersects(Format format) - { - Format intersection = super.intersects(format); - - if (intersection == null) - return null; - - ((ParameterizedVideoFormat) intersection).fmtps - = fmtps.isEmpty() - ? MediaFormatImpl.EMPTY_FORMAT_PARAMETERS - : getFormatParameters(); - return intersection; - } - - /** - * Determines whether a specific format matches this instance i.e. whether - * their attributes match according to the definition of "match" given by - * {@link Format#matches(Format)}. - * - * @param format the Format to compare to this instance - * @return true if the specified format matches this one; - * otherwise, false - */ - @Override - public boolean matches(Format format) - { - return super.matches(format) && formatParametersMatch(format); - } - - /** - * Initializes a new Map from an array in which the key and the - * value of an association are expressed as consecutive elements. - * - * @param the very type of the keys and the values to be associated in - * the new Map - * @param entries the associations to be created in the new Map - * where the key and value of an association are expressed as consecutive - * elements - * @return a new Map with the associations specified by - * entries - */ - public static Map toMap(T... entries) - { - Map map; - - if ((entries == null) || (entries.length == 0)) - map = null; - else - { - map = new HashMap(); - for (int i = 0; i < entries.length; i++) - map.put(entries[i++], entries[i]); - } - return map; - } - - @Override - public String toString() - { - StringBuilder s = new StringBuilder(); - - s.append(super.toString()); - - // fmtps - { - s.append(", fmtps={"); - for (Map.Entry fmtp : fmtps.entrySet()) - { - s.append(fmtp.getKey()); - s.append('='); - s.append(fmtp.getValue()); - s.append(','); - } - - int lastIndex = s.length() - 1; - - if (s.charAt(lastIndex) == ',') - s.setCharAt(lastIndex, '}'); - else - s.append('}'); - } - return s.toString(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/format/VideoMediaFormatImpl.java b/src/net/java/sip/communicator/impl/neomedia/format/VideoMediaFormatImpl.java deleted file mode 100644 index b23186b4f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/format/VideoMediaFormatImpl.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.format; - -import java.awt.*; -import java.util.*; - -import javax.media.format.*; - -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.format.*; - -/** - * Implements VideoMediaFormat for the JMF VideoFormat. - * - * @author Lyubomir Marinov - */ -public class VideoMediaFormatImpl - extends MediaFormatImpl - implements VideoMediaFormat -{ - - /** - * The default value of the clockRate property of - * VideoMediaFormatImpl. - */ - public static final double DEFAULT_CLOCK_RATE = 90000; - - /** - * The clock rate of this VideoMediaFormat. - */ - private final double clockRate; - - /** - * Initializes a new VideoMediaFormatImpl instance with a specific - * encoding. - * - * @param encoding the encoding of the new VideoMediaFormatImpl - * instance - */ - VideoMediaFormatImpl(String encoding) - { - this(encoding, DEFAULT_CLOCK_RATE); - } - - /** - * Initializes a new VideoMediaFormatImpl instance with a specific - * encoding and a specific clock rate. - * - * @param encoding the encoding of the new VideoMediaFormatImpl - * instance - * @param clockRate the clock rate of the new VideoMediaFormatImpl - * instance - */ - VideoMediaFormatImpl(String encoding, double clockRate) - { - this(new VideoFormat(encoding), clockRate); - } - - /** - * Initializes a new VideoMediaFormatImpl instance which is to - * provide an implementation of VideoMediaFormat for a specific - * JMF VideoFormat. - * - * @param format the JMF VideoFormat the new instance is to wrap - * and provide an implementation of VideoMediaFormat for - */ - VideoMediaFormatImpl(VideoFormat format) - { - this(format, DEFAULT_CLOCK_RATE); - } - - /** - * Initializes a new VideoMediaFormatImpl instance which is to - * provide an implementation of VideoMediaFormat for a specific - * JMF VideoFormat and to have a specific clock rate. - * - * @param format the JMF VideoFormat the new instance is to wrap - * and provide an implementation of VideoMediaFormat for - * @param clockRate the clock rate of the new VideoMediaFormatImpl - * instance - */ - VideoMediaFormatImpl(VideoFormat format, double clockRate) - { - this(format, clockRate, -1, null, null); - } - - /** - * Initializes a new VideoMediaFormatImpl instance which is to - * provide an implementation of VideoMediaFormat for a specific - * JMF VideoFormat and to have specific clock rate and set of - * format-specific parameters. - * - * @param format the JMF VideoFormat the new instance is to wrap - * and provide an implementation of VideoMediaFormat for - * @param clockRate the clock rate of the new VideoMediaFormatImpl - * instance - * @param frameRate the frame rate of the new VideoMediaFormatImpl - * instance - * @param formatParameters the set of format-specific parameters of the new - * instance - * @param advancedParameters set of advanced parameters of the new instance - */ - VideoMediaFormatImpl( - VideoFormat format, - double clockRate, - float frameRate, - Map formatParameters, - Map advancedParameters) - { - super( - new ParameterizedVideoFormat( - format.getEncoding(), - format.getSize(), - format.getMaxDataLength(), - format.getDataType(), - frameRate, - formatParameters), - formatParameters, - advancedParameters); - - this.clockRate = clockRate; - } - - /** - * Implements MediaFormat#equals(Object) and actually compares the - * encapsulated JMF Format instances. - * - * @param mediaFormat the object that we'd like to compare this one - * to - * @return true if the JMF Format instances encapsulated - * by this instance and their other characteristics are equal; - * false, otherwise. - * @see MediaFormatImpl#equals(Object) - */ - @Override - public boolean equals(Object mediaFormat) - { - if (this == mediaFormat) - return true; - - if (!super.equals(mediaFormat)) - return false; - - VideoMediaFormatImpl videoMediaFormatImpl - = (VideoMediaFormatImpl) mediaFormat; - - double clockRate = getClockRate(); - double videoMediaFormatImplClockRate - = videoMediaFormatImpl.getClockRate(); - - if (MediaFormatFactory.CLOCK_RATE_NOT_SPECIFIED == clockRate) - clockRate = DEFAULT_CLOCK_RATE; - if (MediaFormatFactory.CLOCK_RATE_NOT_SPECIFIED - == videoMediaFormatImplClockRate) - videoMediaFormatImplClockRate = DEFAULT_CLOCK_RATE; - - return (clockRate == videoMediaFormatImplClockRate); - } - - /** - * {@inheritDoc} - *

- * Takes into account RFC 3984 "RTP Payload Format for H.264 Video" which - * says that "[w]hen the value of packetization-mode [format parameter] - * is equal to 0 or packetization-mode is not present, the single NAL mode, - * as defined in section 6.2 of RFC 3984, MUST be used." - *

- * - * @see MediaFormatImpl#formatParametersAreEqual(Map, Map) - */ - @Override - protected boolean formatParametersAreEqual( - Map fmtps1, - Map fmtps2) - { - return formatParametersAreEqual(getEncoding(), fmtps1, fmtps2); - } - - /** - * Determines whether a specific set of format parameters is equal to - * another set of format parameters in the sense that they define an equal - * number of parameters and assign them equal values. Since the values are - * Strings, presumes that a value of null is equal to the - * empty String. - *

- * The two Map instances of format parameters to be checked for - * equality are presumed to be modifiable in the sense that if the lack of a - * format parameter in a given Map is equivalent to it having a - * specific value, an association of the format parameter to the value in - * question may be added to or removed from the respective Map - * instance for the purposes of determining equality. - *

- * - * @param encoding the encoding (name) related to the two sets of format - * parameters to be tested for equality - * @param fmtps1 the first set of format parameters to be tested for - * equality - * @param fmtps2 the second set of format parameters to be tested for - * equality - * @return true if the specified sets of format parameters are - * equal; false, otherwise - */ - public static boolean formatParametersAreEqual( - String encoding, - Map fmtps1, Map fmtps2) - { - /* - * RFC 3984 "RTP Payload Format for H.264 Video" says that "[w]hen the - * value of packetization-mode is equal to 0 or packetization-mode is - * not present, the single NAL mode, as defined in section 6.2 of RFC - * 3984, MUST be used." - */ - if ("H264".equalsIgnoreCase(encoding) - || "h264/rtp".equalsIgnoreCase(encoding)) - { - String packetizationMode = "packetization-mode"; - String pm1 = null; - String pm2 = null; - - if (fmtps1 != null) - pm1 = fmtps1.remove(packetizationMode); - if (fmtps2 != null) - pm2 = fmtps2.remove(packetizationMode); - - if (pm1 == null) - pm1 = "0"; - if (pm2 == null) - pm2 = "0"; - if (!pm1.equals(pm2)) - return false; - } - - return - MediaFormatImpl.formatParametersAreEqual(encoding, fmtps1, fmtps2); - } - - /** - * Determines whether the format parameters of this MediaFormat - * match a specific set of format parameters. - *

- * VideoMediaFormat reflects the fact that the - * packetization-mode format parameter distinguishes H.264 payload - * types. - *

- * - * @param fmtps the set of format parameters to match to the format - * parameters of this MediaFormat - * @return true if this MediaFormat considers - * fmtps matching its format parameters; otherwise, false - */ - @Override - public boolean formatParametersMatch(Map fmtps) - { - return - formatParametersMatch(getEncoding(), getFormatParameters(), fmtps) - && super.formatParametersMatch(fmtps); - } - - /** - * Determines whether two sets of format parameters match in the context of - * a specific encoding. - * - * @param encoding the encoding (name) related to the two sets of format - * parameters to be matched. - * @param fmtps1 the first set of format parameters which is to be matched - * against fmtps2 - * @param fmtps2 the second set of format parameters which is to be matched - * against fmtps1 - * @return true if the two sets of format parameters match in the - * context of the specified encoding; otherwise, false - */ - public static boolean formatParametersMatch( - String encoding, - Map fmtps1 , Map fmtps2) - { - /* - * RFC 3984 "RTP Payload Format for H.264 Video" says that "[w]hen the - * value of packetization-mode is equal to 0 or packetization-mode is - * not present, the single NAL mode, as defined in section 6.2 of RFC - * 3984, MUST be used." - */ - if ("H264".equalsIgnoreCase(encoding) - || "h264/rtp".equalsIgnoreCase(encoding)) - { - String packetizationMode = "packetization-mode"; - String pm1 - = (fmtps1 == null) ? null : fmtps1.get(packetizationMode); - String pm2 - = (fmtps2 == null) ? null : fmtps2.get(packetizationMode); - - if (pm1 == null) - pm1 = "0"; - if (pm2 == null) - pm2 = "0"; - if (!pm1.equals(pm2)) - return false; - } - - return true; - } - - /** - * Gets the clock rate associated with this MediaFormat. - * - * @return the clock rate associated with this MediaFormat - * @see MediaFormat#getClockRate() - */ - public double getClockRate() - { - return clockRate; - } - - /** - * Gets the frame rate associated with this MediaFormat. - * - * @return the frame rate associated with this MediaFormat - * @see VideoMediaFormat#getFrameRate() - */ - public float getFrameRate() - { - return format.getFrameRate(); - } - - /** - * Gets the type of this MediaFormat which is - * {@link MediaType#VIDEO} for AudioMediaFormatImpl instances. - * - * @return the MediaType that this format represents and which is - * MediaType.VIDEO for AudioMediaFormatImpl instances - * @see MediaFormat#getMediaType() - */ - public final MediaType getMediaType() - { - return MediaType.VIDEO; - } - - /** - * Gets the size of the image that this VideoMediaFormat describes. - * - * @return a {@link Dimension} instance indicating the image size (in - * pixels) of this VideoMediaFormat - * @see VideoMediaFormat#getSize() - */ - public Dimension getSize() - { - return format.getSize(); - } - - /** - * Overrides MediaFormatImpl#hashCode() because - * Object#equals(Object) is overridden. - * - * @return a hash code value for this VideoMediaFormatImpl - * @see MediaFormatImpl#hashCode() - */ - @Override - public int hashCode() - { - double clockRate = getClockRate(); - - /* - * The implementation of #equals(Object) of this instance assumes that - * MediaFormatFactory#CLOCK_RATE_NOT_SPECIFIED and #DEFAULT_CLOCK_RATE - * are equal. - */ - if (MediaFormatFactory.CLOCK_RATE_NOT_SPECIFIED == clockRate) - clockRate = DEFAULT_CLOCK_RATE; - return (super.hashCode() | Double.valueOf(clockRate).hashCode()); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/imgstreaming/DesktopInteract.java b/src/net/java/sip/communicator/impl/neomedia/imgstreaming/DesktopInteract.java deleted file mode 100644 index 45d3b2226..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/imgstreaming/DesktopInteract.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.imgstreaming; - -import java.awt.image.*; - -/** - * Interface to capture desktop screen. - * - * @author Sebastien Vincent - */ -public interface DesktopInteract -{ - /** - * Capture the full desktop screen using native grabber. - * - * Contrary to other captureScreen method, it only returns raw bytes - * and not BufferedImage. It is done in order to limit - * slow operation such as converting ARGB images (uint32_t) to bytes - * especially for big big screen. For example a 1920x1200 desktop consumes - * 9 MB of memory for grabbing and another 9 MB array for conversion - * operation. - * - * @param display index of display - * @param output output buffer to store bytes in. - * Be sure that output length is sufficient - * @return true if success, false if JNI error or output length too short - */ - public boolean captureScreen(int display, byte output[]); - - /** - * Capture the full desktop screen using native grabber. - * - * Contrary to other captureScreen method, it only returns raw bytes - * and not BufferedImage. It is done in order to limit - * slow operation such as converting ARGB images (uint32_t) to bytes - * especially for big big screen. For example a 1920x1200 desktop consumes - * 9 MB of memory for grabbing and another 9 MB array for conversion - * operation. - * - * @param display index of display - * @param buffer native output buffer to store bytes in. - * Be sure that output length is sufficient - * @param bufferLength length of native buffer - * @return true if success, false if JNI error or output length too short - */ - public boolean captureScreen(int display, long buffer, int bufferLength); - - /** - * Capture a part of the desktop screen using native grabber. - * - * Contrary to other captureScreen method, it only returns raw bytes - * and not BufferedImage. It is done in order to limit - * slow operation such as converting ARGB images (uint32_t) to bytes - * especially for big big screen. For example a 1920x1200 desktop consumes - * 9 MB of memory for grabbing and another 9 MB array for conversion - * operation. - * - * @param display index of display - * @param x x position to start capture - * @param y y position to start capture - * @param width capture width - * @param height capture height - * @param output output buffer to store bytes in. - * Be sure that output length is sufficient - * @return true if success, false if JNI error or output length too short - */ - public boolean captureScreen(int display, int x, int y, int width, - int height, byte output[]); - - /** - * Capture a part of the desktop screen using native grabber. - * - * Contrary to other captureScreen method, it only returns raw bytes - * and not BufferedImage. It is done in order to limit - * slow operation such as converting ARGB images (uint32_t) to bytes - * especially for big big screen. For example a 1920x1200 desktop consumes - * 9 MB of memory for grabbing and another 9 MB array for conversion - * operation. - * - * @param display index of display - * @param x x position to start capture - * @param y y position to start capture - * @param width capture width - * @param height capture height - * @param buffer native output buffer to store bytes in. - * Be sure that output length is sufficient - * @param bufferLength length of native buffer - * @return true if success, false if JNI error or output length too short - */ - public boolean captureScreen(int display, int x, int y, int width, - int height, long buffer, int bufferLength); - - /** - * Capture the full desktop screen. - * - * @return BufferedImage of the desktop screen - */ - public BufferedImage captureScreen(); - - /** - * Capture a part of the desktop screen. - * - * @param x x position to start capture - * @param y y position to start capture - * @param width capture width - * @param height capture height - * @return BufferedImage of a part of the desktop screen - * or null if Robot problem - */ - public BufferedImage captureScreen(int x, int y, int width, int height); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/imgstreaming/DesktopInteractImpl.java b/src/net/java/sip/communicator/impl/neomedia/imgstreaming/DesktopInteractImpl.java deleted file mode 100644 index c5f89ae0e..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/imgstreaming/DesktopInteractImpl.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.imgstreaming; - -import java.awt.*; -import java.awt.image.*; - -import net.java.sip.communicator.util.*; - -/** - * Capture desktop screen either via native code (JNI) if available or by using - * java.awt.Robot. - * - * @see java.awt.Robot - * @author Sebastien Vincent - */ -public class DesktopInteractImpl implements DesktopInteract -{ - /** - * The Logger. - */ - private static final Logger logger = - Logger.getLogger(DesktopInteractImpl.class); - - /** - * Screen capture robot. - */ - private Robot robot = null; - - /** - * Constructor. - * - * @throws AWTException if platform configuration does not allow low-level - * input control - * @throws SecurityException if Robot creation is not permitted - */ - public DesktopInteractImpl() throws AWTException, SecurityException - { - robot = new Robot(); - } - - /** - * Capture the full desktop screen using native grabber. - * - * Contrary to other captureScreen method, it only returns raw bytes - * and not BufferedImage. It is done in order to limit - * slow operation such as converting ARGB images (uint32_t) to bytes - * especially for big big screen. For example a 1920x1200 desktop consumes - * 9 MB of memory for grabbing and another 9 MB array for conversion - * operation. - * - * @param display index of display - * @param output output buffer to store bytes in. - * Be sure that output length is sufficient - * @return true if success, false if JNI error or output length too short - */ - public boolean captureScreen(int display, byte output[]) - { - Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); - - return captureScreen(display, 0, 0, dim.width, dim.height, output); - } - - /** - * Capture the full desktop screen using native grabber. - * - * Contrary to other captureScreen method, it only returns raw bytes - * and not BufferedImage. It is done in order to limit - * slow operation such as converting ARGB images (uint32_t) to bytes - * especially for big big screen. For example a 1920x1200 desktop consumes - * 9 MB of memory for grabbing and another 9 MB array for conversion - * operation. - * - * @param display index of display - * @param buffer native output buffer to store bytes in. - * Be sure that output length is sufficient - * @param bufferLength length of native buffer - * @return true if success, false if JNI error or output length too short - */ - public boolean captureScreen(int display, long buffer, int bufferLength) - { - Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); - return captureScreen(display, 0, 0, dim.width, dim.height, buffer, - bufferLength); - } - - /** - * Capture a part of the desktop screen using native grabber. - * - * Contrary to other captureScreen method, it only returns raw bytes - * and not BufferedImage. It is done in order to limit - * slow operation such as converting ARGB images (uint32_t) to bytes - * especially for big big screen. For example a 1920x1200 desktop consumes - * 9 MB of memory for grabbing and another 9 MB array for conversion - * operation. - * - * @param display index of display - * @param x x position to start capture - * @param y y position to start capture - * @param width capture width - * @param height capture height - * @param output output buffer to store bytes in. - * Be sure that output length is sufficient - * @return true if success, false if JNI error or output length too short - */ - public boolean captureScreen(int display, int x, int y, int width, - int height, byte output[]) - { - if(OSUtils.IS_LINUX || OSUtils.IS_FREEBSD || OSUtils.IS_WINDOWS - || OSUtils.IS_MAC) - { - return NativeScreenCapture.grabScreen( - display, x, y, width, height, output); - } - - return false; - } - - /** - * Capture a part of the desktop screen using native grabber. - * - * Contrary to other captureScreen method, it only returns raw bytes - * and not BufferedImage. It is done in order to limit - * slow operation such as converting ARGB images (uint32_t) to bytes - * especially for big big screen. For example a 1920x1200 desktop consumes - * 9 MB of memory for grabbing and another 9 MB array for conversion - * operation. - * - * @param display index of display - * @param x x position to start capture - * @param y y position to start capture - * @param width capture width - * @param height capture height - * @param buffer native output buffer to store bytes in. - * Be sure that output length is sufficient - * @param bufferLength length of native buffer - * @return true if success, false if JNI error or output length too short - */ - public boolean captureScreen(int display, int x, int y, int width, - int height, long buffer, int bufferLength) - { - if(OSUtils.IS_LINUX || OSUtils.IS_FREEBSD || OSUtils.IS_WINDOWS - || OSUtils.IS_MAC) - { - return NativeScreenCapture.grabScreen( - display, x, y, width, height, buffer, bufferLength); - } - - return false; - } - - /** - * Capture the full desktop screen using java.awt.Robot. - * - * @return BufferedImage of the desktop screen - */ - public BufferedImage captureScreen() - { - Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); - - return captureScreen(0, 0, dim.width, dim.height); - } - - /** - * Capture a part of the desktop screen using java.awt.Robot. - * - * @param x x position to start capture - * @param y y position to start capture - * @param width capture width - * @param height capture height - * @return BufferedImage of a part of the desktop screen - * or null if Robot problem - */ - public BufferedImage captureScreen(int x, int y, int width, int height) - { - BufferedImage img = null; - Rectangle rect = null; - - if(robot == null) - { - /* Robot has not been created so abort */ - return null; - } - - if (logger.isInfoEnabled()) - logger.info("Begin capture: " + System.nanoTime()); - rect = new Rectangle(x, y, width, height); - img = robot.createScreenCapture(rect); - if (logger.isInfoEnabled()) - logger.info("End capture: " + System.nanoTime()); - - return img; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/imgstreaming/ImageStreamingUtils.java b/src/net/java/sip/communicator/impl/neomedia/imgstreaming/ImageStreamingUtils.java deleted file mode 100644 index 00afdf6ab..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/imgstreaming/ImageStreamingUtils.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.imgstreaming; - -import java.awt.geom.*; -import java.awt.image.*; - -/** - * This class provides utility functions and fields for image streaming. - * - * @author Sebastien Vincent - */ -public class ImageStreamingUtils -{ - /** - * Get a scaled BufferedImage. - * - * Mainly inspired by: - * http://java.developpez.com/faq/gui/?page=graphique_general_images - * #GRAPHIQUE_IMAGE_redimensionner - * - * @param src source image - * @param width width of scaled image - * @param height height of scaled image - * @param type BufferedImage type - * @return scaled BufferedImage - */ - public static BufferedImage getScaledImage(BufferedImage src, - int width, - int height, - int type) - { - double scaleWidth = width / ((double)src.getWidth()); - double scaleHeight = height / ((double)src.getHeight()); - AffineTransform tx = new AffineTransform(); - - // Skip rescaling if input and output size are the same. - if ((Double.compare(scaleWidth, 1) != 0) - || (Double.compare(scaleHeight, 1) != 0)) - tx.scale(scaleWidth, scaleHeight); - - AffineTransformOp op - = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); - BufferedImage dst = new BufferedImage(width, height, type); - - return op.filter(src, dst); - } - - /** - * Get raw bytes from ARGB BufferedImage. - * - * @param src ARGB - * @param output output buffer, if not null and if its length is at least - * image's (width * height) * 4, method will put bytes in it. - * @return raw bytes or null if src is not an ARGB - * BufferedImage - */ - public static byte[] getImageBytes(BufferedImage src, byte output[]) - { - if(src.getType() != BufferedImage.TYPE_INT_ARGB) - throw new IllegalArgumentException("src.type"); - - WritableRaster raster = src.getRaster(); - int width = src.getWidth(); - int height = src.getHeight(); - int size = width * height * 4; - int off = 0; - int pixel[] = new int[4]; - byte data[] = null; - - if(output == null || output.length < size) - { - /* allocate our bytes array */ - data = new byte[size]; - } - else - { - /* use output */ - data = output; - } - - for(int y = 0 ; y < height ; y++) - for(int x = 0 ; x < width ; x++) - { - raster.getPixel(x, y, pixel); - data[off++] = (byte)pixel[0]; - data[off++] = (byte)pixel[1]; - data[off++] = (byte)pixel[2]; - data[off++] = (byte)pixel[3]; - } - - return data; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/imgstreaming/NativeScreenCapture.java b/src/net/java/sip/communicator/impl/neomedia/imgstreaming/NativeScreenCapture.java deleted file mode 100644 index ce3d9c529..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/imgstreaming/NativeScreenCapture.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.imgstreaming; - -/** - * This class uses native code to capture desktop screen. - * - * It should work for Windows, Mac OS X and X11-based Unix such as Linux - * and FreeBSD. - * - * @author Sebastien Vincent - */ -public class NativeScreenCapture -{ - static - { - System.loadLibrary("jnscreencapture"); - } - - /** - * Grab desktop screen and get raw bytes. - * - * @param display index of display - * @param x x position to start capture - * @param y y position to start capture - * @param width capture width - * @param height capture height - * @param output output buffer to store screen bytes - * @return true if grab success, false otherwise - */ - public static native boolean grabScreen(int display, int x, int y, - int width, int height, byte output[]); - - /** - * Grab desktop screen and get raw bytes. - * - * @param display index of display - * @param x x position to start capture - * @param y y position to start capture - * @param width capture width - * @param height capture height - * @param output native output buffer to store screen bytes - * @param outputLength native output length - * @return true if grab success, false otherwise - */ - public static native boolean grabScreen(int display, int x, int y, - int width, int height, long output, int outputLength); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractBufferCaptureDevice.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractBufferCaptureDevice.java deleted file mode 100644 index 1e31b5583..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractBufferCaptureDevice.java +++ /dev/null @@ -1,873 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; - -import javax.media.*; -import javax.media.Controls; // disambiguation -import javax.media.control.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.control.*; -import net.java.sip.communicator.util.*; - -import net.sf.fmj.media.util.*; - -/** - * Facilitates the implementations of the CaptureDevice and - * DataSource interfaces provided by - * AbstractPullBufferCaptureDevice and - * AbstractPushBufferCaptureDevice. - * - * @param the type of AbstractBufferStream - * through which this AbstractBufferCaptureDevice is to give access to - * its media data - * - * @author Lyubomir Marinov - */ -public abstract class AbstractBufferCaptureDevice - - implements CaptureDevice, - Controls -{ - /** - * The Logger used by the AbstractBufferCaptureDevice - * class and its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(AbstractBufferCaptureDevice.class); - - /** - * The value of the formatControls property of - * AbstractBufferCaptureDevice which represents an empty array of - * FormatControls. Explicitly defined in order to reduce - * unnecessary allocations. - */ - private static final FormatControl[] EMPTY_FORMAT_CONTROLS - = new FormatControl[0]; - - /** - * The indicator which determines whether a connection to the media source - * specified by the MediaLocator of this DataSource has - * been opened. - */ - private boolean connected = false; - - /** - * The array of FormatControl instances each one of which can be - * used before {@link #connect()} to get and set the capture Format - * of each one of the capture streams. - */ - private FormatControl[] formatControls; - - /** - * The FrameRateControls of this - * AbstractBufferCaptureDevice. - */ - private FrameRateControl[] frameRateControls; - - /** - * The RTPInfos of this AbstractBufferCaptureDevice. - */ - private RTPInfo[] rtpInfos; - - /** - * The indicator which determines whether the transfer of media data from - * this DataSource has been started. - */ - private boolean started = false; - - /** - * The PushBufferStreams through which this - * PushBufferDataSource gives access to its media data. - *

- * Warning: Caution is advised when directly using the field and access to - * it is to be synchronized with sync root this. - *

- */ - private AbstractBufferStream[] streams; - - /** - * Opens a connection to the media source of this - * AbstractBufferCaptureDevice. - * - * @throws IOException if anything goes wrong while opening the connection - * to the media source of this AbstractBufferCaptureDevice - */ - public synchronized void connect() - throws IOException - { - if (!connected) - { - doConnect(); - connected = true; - } - } - - /** - * Creates a new FormatControl instance which is to be associated - * with a PushBufferStream at a specific zero-based index in the - * list of streams of this PushBufferDataSource. As the - * FormatControls of a PushBufferDataSource can be - * requested before {@link #connect()}, its PushBufferStreams may - * not exist at the time of the request for the creation of the - * FormatControl. - * - * @param streamIndex the zero-based index of the PushBufferStream - * in the list of streams of this PushBufferDataSource which is to - * be associated with the new FormatControl instance - * @return a new FormatControl instance which is to be associated - * with a PushBufferStream at the specified streamIndex in - * the list of streams of this PushBufferDataSource - */ - protected FormatControl createFormatControl(final int streamIndex) - { - return - new AbstractFormatControl() - { - /** - * The Format of this FormatControl and, - * respectively, of the media data of its owner. - */ - private Format format; - - /** - * Gets the Format of the media data of the owner of - * this FormatControl. - * - * @return the Format of the media data of the owner of - * this FormatControl - */ - public Format getFormat() - { - format - = AbstractBufferCaptureDevice.this.internalGetFormat( - streamIndex, - format); - return format; - } - - /** - * Gets the Formats in which the owner of this - * FormatControl is capable of providing media data. - * - * @return an array of Formats in which the owner of - * this FormatControl is capable of providing media - * data - */ - public Format[] getSupportedFormats() - { - return - AbstractBufferCaptureDevice.this.getSupportedFormats( - streamIndex); - } - - /** - * Implements {@link FormatControl#setFormat(Format)}. Attempts - * to set the Format in which the owner of this - * FormatControl is to provide media data. - * - * @param format the Format to be set on this instance - * @return the currently set Format after the attempt - * to set it on this instance if format is supported by - * this instance and regardless of whether it was actually set; - * null if format is not supported by this - * instance - */ - @Override - public Format setFormat(Format format) - { - Format setFormat = super.setFormat(format); - - if (setFormat != null) - { - setFormat - = AbstractBufferCaptureDevice.this - .internalSetFormat( - streamIndex, - setFormat, - format); - if (setFormat != null) - this.format = setFormat; - } - return setFormat; - } - }; - } - - /** - * Creates the FormatControls of this CaptureDevice. - * - * @return an array of the FormatControls of this - * CaptureDevice - */ - protected FormatControl[] createFormatControls() - { - FormatControl formatControl = createFormatControl(0); - - return - (formatControl == null) - ? EMPTY_FORMAT_CONTROLS - : new FormatControl[] { formatControl }; - } - - /** - * Creates a new FrameRateControl instance which is to allow the - * getting and setting of the frame rate of this - * AbstractBufferCaptureDevice. - * - * @return a new FrameRateControl instance which is to allow the - * getting and setting of the frame rate of this - * AbstractBufferCaptureDevice - */ - protected FrameRateControl createFrameRateControl() - { - return null; - } - - /** - * Creates a new RTPInfo instance of this - * AbstractBufferCaptureDevice. - * - * @return a new RTPInfo instance of this - * AbstractBufferCaptureDevice - */ - protected RTPInfo createRTPInfo() - { - return - new RTPInfo() - { - public String getCNAME() - { - // TODO Auto-generated method stub - return null; - } - }; - } - - /** - * Create a new AbstractBufferStream which is to be at a specific - * zero-based index in the list of streams of this - * AbstractBufferCaptureDevice. The Format-related - * information of the new instance is to be abstracted by a specific - * FormatControl. - * - * @param streamIndex the zero-based index of the - * AbstractBufferStream in the list of streams of this - * AbstractBufferCaptureDevice - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - * @return a new AbstractBufferStream which is to be at the - * specified streamIndex in the list of streams of this - * AbstractBufferCaptureDevice and which has its - * Format-related information abstracted by the specified - * formatControl - */ - protected abstract AbstractBufferStreamT createStream( - int streamIndex, - FormatControl formatControl); - - /** - * Provides the default implementation of - * AbstractBufferCaptureDevice for {@link #doStart()}. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this AbstractBufferCaptureDevice - * @see #doStart() - */ - final void defaultDoStart() - throws IOException - { - if (streams != null) - for (AbstractBufferStream stream : streams) - stream.start(); - } - - /** - * Provides the default implementation of - * AbstractBufferCaptureDevice for {@link #doStop()}. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this AbstractBufferCaptureDevice - * @see #doStop() - */ - final void defaultDoStop() - throws IOException - { - if (streams != null) - for (AbstractBufferStream stream : streams) - stream.stop(); - } - - /** - * Provides the default implementation of - * AbstractBufferCaptureDevice for {@link #getControls()}. - * - * @return an array of Objects which represent the controls - * available for this instance - */ - final Object[] defaultGetControls() - { - FormatControl[] formatControls = internalGetFormatControls(); - int formatControlCount - = (formatControls == null) ? 0 : formatControls.length; - FrameRateControl[] frameRateControls = internalGetFrameRateControls(); - int frameRateControlCount - = (frameRateControls == null) ? 0 : frameRateControls.length; - RTPInfo[] rtpInfos = internalGetRTPInfos(); - int rtpInfoCount = (rtpInfos == null) ? 0 : rtpInfos.length; - - if ((formatControlCount == 0) - && (frameRateControlCount == 0) - && (rtpInfoCount == 0)) - return ControlsAdapter.EMPTY_CONTROLS; - else - { - Object[] controls - = new Object[ - formatControlCount - + frameRateControlCount - + rtpInfoCount]; - int offset = 0; - - if (formatControlCount != 0) - { - System.arraycopy( - formatControls, 0, - controls, offset, - formatControlCount); - offset += formatControlCount; - } - if (frameRateControlCount != 0) - { - System.arraycopy( - frameRateControls, 0, - controls, offset, - frameRateControlCount); - offset += frameRateControlCount; - } - if (rtpInfoCount != 0) - { - System.arraycopy(rtpInfos, 0, controls, offset, rtpInfoCount); - offset += rtpInfoCount; - } - return controls; - } - } - - /** - * Provides the default implementation of - * AbstractBufferCaptureDevice for {@link #getFormat(int, Format)}. - * - * @param streamIndex the zero-based index of the - * AbstractBufferStream the Format of which is to be - * retrieved - * @param oldValue the last-known Format for the - * AbstractBufferStream at the specified streamIndex - * @return the Format to be reported by the FormatControl - * of the AbstractBufferStream at the specified - * streamIndex in the list of streams of this - * AbstractBufferCaptureDevice - * @see #getFormat(int, Format) - */ - final Format defaultGetFormat(int streamIndex, Format oldValue) - { - if (oldValue != null) - return oldValue; - - Format[] supportedFormats = getSupportedFormats(streamIndex); - - return - ((supportedFormats == null) || (supportedFormats.length < 1)) - ? null - : supportedFormats[0]; - } - - /** - * Provides the default implementation of - * AbstractBufferCaptureDevice for - * {@link #getSupportedFormats(int)}. - * - * @param streamIndex the zero-based index of the - * AbstractBufferStream for which the specified - * FormatControl is to report the list of supported - * Formats - * @return an array of Formats to be reported by a - * FormatControl as the supported formats for the - * AbstractBufferStream at the specified streamIndex in - * the list of streams of this AbstractBufferCaptureDevice - */ - final Format[] defaultGetSupportedFormats(int streamIndex) - { - CaptureDeviceInfo captureDeviceInfo = getCaptureDeviceInfo(); - - return - (captureDeviceInfo == null) ? null : captureDeviceInfo.getFormats(); - } - - /** - * Closes the connection to the media source specified of this - * AbstractBufferCaptureDevice. If such a connection has not been - * opened, the call is ignored. - */ - public synchronized void disconnect() - { - try - { - stop(); - } - catch (IOException ioex) - { - logger.error("Failed to stop " + getClass().getSimpleName(), ioex); - } - - if (connected) - { - doDisconnect(); - connected = false; - } - } - - /** - * Opens a connection to the media source of this - * AbstractBufferCaptureDevice. Allows extenders to override and be - * sure that there will be no request to open a connection if the connection - * has already been opened. - * - * @throws IOException if anything goes wrong while opening the connection - * to the media source of this AbstractBufferCaptureDevice - */ - protected abstract void doConnect() - throws IOException; - - /** - * Closes the connection to the media source of this - * AbstractBufferCaptureDevice. Allows extenders to override and be - * sure that there will be no request to close a connection if the - * connection has not been opened yet. - */ - protected abstract void doDisconnect(); - - /** - * Starts the transfer of media data from this - * AbstractBufferCaptureDevice. Allows extenders to override and be - * sure that there will be no request to start the transfer of media data if - * it has already been started. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this AbstractBufferCaptureDevice - */ - protected abstract void doStart() - throws IOException; - - /** - * Stops the transfer of media data from this - * AbstractBufferCaptureDevice. Allows extenders to override and be - * sure that there will be no request to stop the transfer of media data if - * it has not been started yet. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this AbstractBufferCaptureDevice - */ - protected abstract void doStop() - throws IOException; - - /** - * Gets the CaptureDeviceInfo of this CaptureDevice which - * describes it. - * - * @return the CaptureDeviceInfo of this CaptureDevice - * which describes it - */ - public abstract CaptureDeviceInfo getCaptureDeviceInfo(); - - /** - * Gets the CaptureDeviceInfo of a specific CaptureDevice - * by locating its registration in JMF using its MediaLocator. - * - * @param captureDevice the CaptureDevice to gets the - * CaptureDeviceInfo of - * @return the CaptureDeviceInfo of the specified - * CaptureDevice as registered in JMF - */ - public static CaptureDeviceInfo getCaptureDeviceInfo( - DataSource captureDevice) - { - /* - * TODO The implemented search for the CaptureDeviceInfo of this - * CaptureDevice by looking for its MediaLocator is inefficient. - */ - @SuppressWarnings("unchecked") - Vector captureDeviceInfos - = (Vector) - CaptureDeviceManager.getDeviceList(null); - MediaLocator locator = captureDevice.getLocator(); - - for (CaptureDeviceInfo captureDeviceInfo : captureDeviceInfos) - if (captureDeviceInfo.getLocator().toString().equals( - locator.toString())) - return captureDeviceInfo; - return null; - } - - /** - * Gets the control of the specified type available for this instance. - * - * @param controlType the type of the control available for this instance to - * be retrieved - * @return an Object which represents the control of the specified - * type available for this instance if such a control is indeed available; - * otherwise, null - */ - public Object getControl(String controlType) - { - return AbstractControls.getControl(this, controlType); - } - - /** - * Implements {@link javax.media.Controls#getControls()}. Gets the controls - * available for this instance. - * - * @return an array of Objects which represent the controls - * available for this instance - */ - public Object[] getControls() - { - return defaultGetControls(); - } - - /** - * Gets the Format to be reported by the FormatControl of - * an AbstractBufferStream at a specific zero-based index in the - * list of streams of this AbstractBufferCaptureDevice. The - * AbstractBufferStream may not exist at the time of requesting its - * Format. Allows extenders to override the default behavior which - * is to report any last-known format or the first Format from the - * list of supported formats as defined in the JMF registration of this - * CaptureDevice. - * - * @param streamIndex the zero-based index of the - * AbstractBufferStream the Format of which is to be - * retrieved - * @param oldValue the last-known Format for the - * PushBufferStream at the specified streamIndex - * @return the Format to be reported by the FormatControl - * of the PushBufferStream at the specified streamIndex in - * the list of streams of this PushBufferDataSource. - */ - protected abstract Format getFormat(int streamIndex, Format oldValue); - - /** - * Gets an array of FormatControl instances each one of which can - * be used before {@link #connect()} to get and set the capture - * Format of each one of the capture streams. - * - * @return an array of FormatControl instances each one of which - * can be used before {@link #connect()} to get and set the capture - * Format of each one of the capture streams - */ - public FormatControl[] getFormatControls() - { - return AbstractFormatControl.getFormatControls(this); - } - - /** - * Gets the Object which is to synchronize the access to - * {@link #streams()} and its return value. - * - * @return the Object which is to synchronize the access to - * {@link #streams()} and its return value - */ - Object getStreamSyncRoot() - { - return this; - } - - /** - * Gets the AbstractBufferStreams through which this - * AbstractBufferCaptureDevice gives access to its media data. - * - * @param the type of SourceStream which is to be - * the element type of the returned array - * @param clz the Class of SourceStream which is to be the - * element type of the returned array - * @return an array of the SourceStreams through which this - * AbstractBufferCaptureDevice gives access to its media data - */ - public synchronized - - SourceStreamT[] getStreams(Class clz) - { - if (streams == null) - { - FormatControl[] formatControls = internalGetFormatControls(); - - if (formatControls != null) - { - int formatControlCount = formatControls.length; - - streams = new AbstractBufferStream[formatControlCount]; - for (int i = 0; i < formatControlCount; i++) - streams[i] = createStream(i, formatControls[i]); - - /* - * Start the streams if this DataSource has already been - * started. - */ - if (started) - for (AbstractBufferStream stream : streams) - try - { - stream.start(); - } - catch (IOException ioex) - { - throw new UndeclaredThrowableException(ioex); - } - } - } - - int streamCount = (streams == null) ? 0 : streams.length; - @SuppressWarnings("unchecked") - SourceStreamT[] clone - = (SourceStreamT[]) Array.newInstance(clz, streamCount); - - if (streamCount != 0) - System.arraycopy(streams, 0, clone, 0, streamCount); - return clone; - } - - /** - * Gets the Formats which are to be reported by a - * FormatControl as supported formats for a - * AbstractBufferStream at a specific zero-based index in the list - * of streams of this AbstractBufferCaptureDevice. - * - * @param streamIndex the zero-based index of the - * AbstractBufferStream for which the specified - * FormatControl is to report the list of supported - * Formats - * @return an array of Formats to be reported by a - * FormatControl as the supported formats for the - * AbstractBufferStream at the specified streamIndex in - * the list of streams of this AbstractBufferCaptureDevice - */ - protected abstract Format[] getSupportedFormats(int streamIndex); - - /** - * Gets the Format to be reported by the FormatControl of - * a PushBufferStream at a specific zero-based index in the list of - * streams of this PushBufferDataSource. The - * PushBufferStream may not exist at the time of requesting its - * Format. - * - * @param streamIndex the zero-based index of the PushBufferStream - * the Format of which is to be retrieved - * @param oldValue the last-known Format for the - * PushBufferStream at the specified streamIndex - * @return the Format to be reported by the FormatControl - * of the PushBufferStream at the specified streamIndex in - * the list of streams of this PushBufferDataSource. - */ - private Format internalGetFormat(int streamIndex, Format oldValue) - { - synchronized (this) - { - if (streams != null) - { - AbstractBufferStream stream = streams[streamIndex]; - - if (stream != null) - { - Format streamFormat = stream.internalGetFormat(); - - if (streamFormat != null) - return streamFormat; - } - } - } - return getFormat(streamIndex, oldValue); - } - - /** - * Gets an array of FormatControl instances each one of which can - * be used before {@link #connect()} to get and set the capture - * Format of each one of the capture streams. - * - * @return an array of FormatControl instances each one of which - * can be used before {@link #connect()} to get and set the capture - * Format of each one of the capture streams - */ - private synchronized FormatControl[] internalGetFormatControls() - { - if (formatControls == null) - formatControls = createFormatControls(); - return formatControls; - } - - /** - * Gets an array of FrameRateControl instances which can be used to - * get and/or set the output frame rate of this - * AbstractBufferCaptureDevice. - * - * @return an array of FrameRateControl instances which can be used - * to get and/or set the output frame rate of this - * AbstractBufferCaptureDevice. - */ - private synchronized FrameRateControl[] internalGetFrameRateControls() - { - if (frameRateControls == null) - { - FrameRateControl frameRateControl = createFrameRateControl(); - - // Don't try to create the FrameRateControl more than once. - frameRateControls - = (frameRateControl == null) - ? new FrameRateControl[0] - : new FrameRateControl[] { frameRateControl }; - } - return frameRateControls; - } - - /** - * Gets an array of RTPInfo instances of this - * AbstractBufferCaptureDevice. - * - * @return an array of RTPInfo instances of this - * AbstractBufferCaptureDevice. - */ - private synchronized RTPInfo[] internalGetRTPInfos() - { - if (rtpInfos == null) - { - RTPInfo rtpInfo = createRTPInfo(); - - // Don't try to create the RTPInfo more than once. - rtpInfos - = (rtpInfo == null) - ? new RTPInfo[0] - : new RTPInfo[] { rtpInfo }; - } - return rtpInfos; - } - - /** - * Attempts to set the Format to be reported by the - * FormatControl of a PushBufferStream at a specific - * zero-based index in the list of streams of this - * PushBufferDataSource. - * - * @param streamIndex the zero-based index of the PushBufferStream - * the Format of which is to be set - * @param oldValue the last-known Format for the - * PushBufferStream at the specified streamIndex - * @param newValue the Format which is to be set - * @return the Format to be reported by the FormatControl - * of the PushBufferStream at the specified streamIndex - * in the list of streams of this PushBufferStream or null - * if the attempt to set the Format did not success and any - * last-known Format is to be left in effect - */ - private Format internalSetFormat( - int streamIndex, - Format oldValue, Format newValue) - { - synchronized (this) - { - if (streams != null) - { - AbstractBufferStream stream = streams[streamIndex]; - - if (stream != null) - return stream.internalSetFormat(newValue); - } - } - return setFormat(streamIndex, oldValue, newValue); - } - - /** - * Attempts to set the Format to be reported by the - * FormatControl of a AbstractBufferStream at a specific - * zero-based index in the list of streams of this - * AbstractBufferCaptureDevice. The AbstractBufferStream - * does not exist at the time of the attempt to set its Format. - * Allows extenders to override the default behavior which is to not attempt - * to set the specified Format so that they can enable setting the - * Format prior to creating the AbstractBufferStream. If - * setting the Format of an existing AbstractBufferStream - * is desired, AbstractBufferStream#doSetFormat(Format) should be - * overridden instead. - * - * @param streamIndex the zero-based index of the - * AbstractBufferStream the Format of which is to be set - * @param oldValue the last-known Format for the - * AbstractBufferStream at the specified streamIndex - * @param newValue the Format which is to be set - * @return the Format to be reported by the FormatControl - * of the AbstractBufferStream at the specified - * streamIndex in the list of streams of this - * AbstractBufferStream or null if the attempt to set the - * Format did not success and any last-known Format is to - * be left in effect - */ - protected abstract Format setFormat( - int streamIndex, - Format oldValue, Format newValue); - - /** - * Starts the transfer of media data from this - * AbstractBufferCaptureDevice. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this AbstractBufferCaptureDevice - */ - public synchronized void start() - throws IOException - { - if (!started) - { - if (!connected) - throw new IOException(getClass().getName() + " not connected"); - - doStart(); - started = true; - } - } - - /** - * Stops the transfer of media data from this - * AbstractBufferCaptureDevice. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this AbstractBufferCaptureDevice - */ - public synchronized void stop() - throws IOException - { - if (started) - { - doStop(); - started = false; - } - } - - /** - * Gets the internal array of AbstractBufferStreams through which - * this AbstractBufferCaptureDevice gives access to its media data. - * - * @return the internal array of AbstractBufferStreams through - * which this AbstractBufferCaptureDevice gives access to its media - * data - */ - AbstractBufferStream[] streams() - { - return streams; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractBufferStream.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractBufferStream.java deleted file mode 100644 index d3bb205e5..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractBufferStream.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol; - -import java.io.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.control.*; -import net.java.sip.communicator.util.*; - -/** - * Provides a base implementation of SourceStream in order to - * facilitate implementers by taking care of boilerplate in the most common - * cases. - * - * @author Lyubomir Marinov - */ -abstract class AbstractBufferStream - extends AbstractControls - implements SourceStream -{ - /** - * The Logger used by the AbstractBufferStream class and - * its instances. - */ - private static final Logger logger - = Logger.getLogger(AbstractBufferStream.class); - - /** - * The (default) ContentDescriptor of the - * AbstractBufferStream instances. - */ - private static final ContentDescriptor CONTENT_DESCRIPTOR - = new ContentDescriptor(ContentDescriptor.RAW); - - /** - * The DataSource which has created this instance and which - * contains it as one of its streams. - */ - protected final DataSource dataSource; - - /** - * The FormatControl which gives access to the Format of - * the media data provided by this SourceStream and which, - * optionally, allows setting it. - */ - protected final FormatControl formatControl; - - /** - * Initializes a new AbstractBufferStream instance which is to have - * its Format-related information abstracted by a specific - * FormatControl. - * - * @param dataSource the DataSource which is creating the new - * instance so that it becomes one of its streams - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - */ - protected AbstractBufferStream( - DataSource dataSource, - FormatControl formatControl) - { - this.dataSource = dataSource; - this.formatControl = formatControl; - } - - /** - * Releases the resources used by this instance throughout its existence and - * makes it available for garbage collection. This instance is considered - * unusable after closing. - */ - public void close() - { - try - { - stop(); - } - catch (IOException ioex) - { - logger.error("Failed to stop " + getClass().getSimpleName(), ioex); - } - } - - /** - * Gets the Format of this AbstractBufferStream as - * directly known by it. Allows extenders to override the Format - * known to the DataSource which created this instance and possibly - * provide more details on the currently set Format. - * - * @return the Format of this AbstractBufferStream as - * directly known by it or null if this - * AbstractBufferStream does not directly know its Format - * and it relies on the DataSource which created it to report its - * Format - */ - protected Format doGetFormat() - { - return null; - } - - /** - * Attempts to set the Format of this - * AbstractBufferStream. Allows extenders to enable setting the - * Format of an existing AbstractBufferStream (in contract - * to setting it before the AbstractBufferStream is created by the - * DataSource which will provide it). - * - * @param format the Format to be set as the format of this - * AbstractBufferStream - * @return the Format of this AbstractBufferStream or - * null if the attempt to set the Format did not succeed - * and any last-known Format is to be left in effect - */ - protected Format doSetFormat(Format format) - { - return null; - } - - /** - * Determines whether the end of this SourceStream has been - * reached. The AbstractBufferStream implementation always returns - * false. - * - * @return true if the end of this SourceStream has been - * reached; otherwise, false - */ - public boolean endOfStream() - { - return false; - } - - /** - * Gets a ContentDescriptor which describes the type of the content - * made available by this SourceStream. The - * AbstractBufferStream implementation always returns a - * ContentDescriptor with content type equal to - * ContentDescriptor#RAW. - * - * @return a ContentDescriptor which describes the type of the - * content made available by this SourceStream - */ - public ContentDescriptor getContentDescriptor() - { - return CONTENT_DESCRIPTOR; - } - - /** - * Gets the length in bytes of the content made available by this - * SourceStream. The AbstractBufferStream implementation - * always returns LENGTH_UNKNOWN. - * - * @return the length in bytes of the content made available by this - * SourceStream if it is known; otherwise, LENGTH_UKNOWN - */ - public long getContentLength() - { - return LENGTH_UNKNOWN; - } - - /** - * Implements {@link javax.media.protocol.Controls#getControls()}. Gets the - * controls available for this instance. - * - * @return an array of Objects which represent the controls - * available for this instance - */ - public Object[] getControls() - { - if (formatControl != null) - return new Object[] { formatControl }; - else - return ControlsAdapter.EMPTY_CONTROLS; - } - - /** - * Gets the Format of the media data made available by this - * AbstractBufferStream. - * - * @return the Format of the media data made available by this - * AbstractBufferStream - */ - public Format getFormat() - { - return (formatControl == null) ? null : formatControl.getFormat(); - } - - /** - * Gets the Format of this AbstractBufferStream as - * directly known by it. - * - * @return the Format of this AbstractBufferStream as - * directly known by it - */ - Format internalGetFormat() - { - return doGetFormat(); - } - - /** - * Attempts to set the Format of this - * AbstractBufferStream. - * - * @param format the Format to be set as the format of this - * AbstractBufferStream - * @return the Format of this AbstractBufferStream or - * null if the attempt to set the Format did not succeed - * and any last-known Format is to be left in effect - */ - Format internalSetFormat(Format format) - { - return doSetFormat(format); - } - - /** - * Starts the transfer of media data from this - * AbstractBufferStream. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this AbstractBufferStream - */ - public void start() - throws IOException - { - } - - /** - * Stops the transfer of media data from this AbstractBufferStream. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this AbstractBufferStream - */ - public void stop() - throws IOException - { - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractPullBufferCaptureDevice.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractPullBufferCaptureDevice.java deleted file mode 100644 index 26e1d0dc0..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractPullBufferCaptureDevice.java +++ /dev/null @@ -1,476 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol; - -import java.io.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.protocol.*; - -/** - * Provides a base implementation of PullBufferDataSource and - * CaptureDevice in order to facilitate implementers by taking care of - * boilerplate in the most common cases. - * - * @author Lyubomir Marinov - */ -public abstract class AbstractPullBufferCaptureDevice - extends PullBufferDataSource - implements CaptureDevice -{ - - /** - * The CaptureDeviceInfo. - */ - private CaptureDeviceInfo deviceInfo; - - /** - * The AbstractBufferCaptureDevice which provides the - * implementation of this AbstractPullBufferCaptureDevice. - */ - private final AbstractBufferCaptureDevice impl - = new AbstractBufferCaptureDevice() - { - @Override - protected FrameRateControl createFrameRateControl() - { - return - AbstractPullBufferCaptureDevice.this - .createFrameRateControl(); - } - - protected AbstractPullBufferStream createStream( - int streamIndex, - FormatControl formatControl) - { - return - AbstractPullBufferCaptureDevice.this.createStream( - streamIndex, - formatControl); - } - - protected void doConnect() - throws IOException - { - AbstractPullBufferCaptureDevice.this.doConnect(); - } - - protected void doDisconnect() - { - AbstractPullBufferCaptureDevice.this.doDisconnect(); - } - - protected void doStart() - throws IOException - { - AbstractPullBufferCaptureDevice.this.doStart(); - } - - protected void doStop() - throws IOException - { - AbstractPullBufferCaptureDevice.this.doStop(); - } - - public CaptureDeviceInfo getCaptureDeviceInfo() - { - return - AbstractPullBufferCaptureDevice.this - .getCaptureDeviceInfo(); - } - - protected Format getFormat(int streamIndex, Format oldValue) - { - return - AbstractPullBufferCaptureDevice.this.getFormat( - streamIndex, - oldValue); - } - - protected Format[] getSupportedFormats(int streamIndex) - { - return - AbstractPullBufferCaptureDevice.this - .getSupportedFormats(streamIndex); - } - - protected Format setFormat( - int streamIndex, - Format oldValue, Format newValue) - { - return - AbstractPullBufferCaptureDevice.this.setFormat( - streamIndex, - oldValue, newValue); - } - }; - - /** - * Initializes a new AbstractPullBufferCaptureDevice instance. - */ - protected AbstractPullBufferCaptureDevice() - { - } - - /** - * Initializes a new AbstractPullBufferCaptureDevice instance from - * a specific MediaLocator. - * - * @param locator the MediaLocator to create the new instance from - */ - protected AbstractPullBufferCaptureDevice(MediaLocator locator) - { - setLocator(locator); - } - - /** - * Opens a connection to the media source specified by the - * MediaLocator of this DataSource. - * - * @throws IOException if anything goes wrong while opening the connection - * to the media source specified by the MediaLocator of this - * DataSource - */ - public void connect() - throws IOException - { - impl.connect(); - } - - /** - * Creates a new FrameRateControl instance which is to allow the - * getting and setting of the frame rate of this - * AbstractPullBufferCaptureDevice. - * - * @return a new FrameRateControl instance which is to allow the - * getting and setting of the frame rate of this - * AbstractPullBufferCaptureDevice - */ - protected FrameRateControl createFrameRateControl() - { - return null; - } - - /** - * Creates a new PullBufferStream which is to be at a specific - * zero-based index in the list of streams of this - * PullBufferDataSource. The Format-related information of - * the new instance is to be abstracted by a specific - * FormatControl. - * - * @param streamIndex the zero-based index of the PullBufferStream - * in the list of streams of this PullBufferDataSource - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - * @return a new PullBufferStream which is to be at the specified - * streamIndex in the list of streams of this - * PullBufferDataSource and which has its Format-related - * information abstracted by the specified formatControl - */ - protected abstract AbstractPullBufferStream createStream( - int streamIndex, - FormatControl formatControl); - - /** - * Closes the connection to the media source specified by the - * MediaLocator of this DataSource. If such a connection - * has not been opened, the call is ignored. - */ - public void disconnect() - { - impl.disconnect(); - } - - /** - * Opens a connection to the media source specified by the - * MediaLocator of this DataSource. Allows extenders to - * override and be sure that there will be no request to open a connection - * if the connection has already been opened. - * - * @throws IOException if anything goes wrong while opening the connection - * to the media source specified by the MediaLocator of this - * DataSource - */ - protected void doConnect() - throws IOException - { - } - - /** - * Closes the connection to the media source specified by the - * MediaLocator of this DataSource. Allows extenders to - * override and be sure that there will be no request to close a connection - * if the connection has not been opened yet. - */ - protected void doDisconnect() - { - /* - * While it is not clear whether the streams can be released upon - * disconnect, com.imb.media.protocol.SuperCloneableDataSource gets the - * streams of the DataSource it adapts (i.e. this DataSource when - * SourceCloneable support is to be created for it) before #connect(). - * Unfortunately, it means that it isn't clear when the streams are to - * be disposed. - */ - } - - /** - * Starts the transfer of media data from this DataSource. Allows - * extenders to override and be sure that there will be no request to start - * the transfer of media data if it has already been started. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this DataSource - */ - protected void doStart() - throws IOException - { - impl.defaultDoStart(); - } - - /** - * Stops the transfer of media data from this DataSource. Allows - * extenders to override and be sure that there will be no request to stop - * the transfer of media data if it has not been started yet. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this DataSource - */ - protected void doStop() - throws IOException - { - impl.defaultDoStop(); - } - - /** - * Gets the CaptureDeviceInfo of this CaptureDevice which - * describes it. - * - * @return the CaptureDeviceInfo of this CaptureDevice - * which describes it - */ - public CaptureDeviceInfo getCaptureDeviceInfo() - { - return - (deviceInfo == null) - ? AbstractBufferCaptureDevice.getCaptureDeviceInfo(this) - : deviceInfo; - } - - /** - * Gets the content type of the media represented by this instance. The - * AbstractPullBufferCaptureDevice implementation always returns - * {@link ContentDescriptor#RAW}. - * - * @return the content type of the media represented by this instance - */ - public String getContentType() - { - return ContentDescriptor.RAW; - } - - /** - * Gets the control of the specified type available for this instance. - * - * @param controlType the type of the control available for this instance to - * be retrieved - * @return an Object which represents the control of the specified - * type available for this instance if such a control is indeed available; - * otherwise, null - */ - public Object getControl(String controlType) - { - return impl.getControl(controlType); - } - - /** - * Implements {@link javax.media.Controls#getControls()}. Gets the controls - * available for this instance. - * - * @return an array of Objects which represent the controls - * available for this instance - */ - public Object[] getControls() - { - return impl.getControls(); - } - - /** - * Gets the duration of the media represented by this instance. The - * AbstractPullBufferCaptureDevice always returns - * {@link #DURATION_UNBOUNDED}. - * - * @return the duration of the media represented by this instance - */ - public Time getDuration() - { - return DURATION_UNBOUNDED; - } - - /** - * Gets the Format to be reported by the FormatControl of - * a PullBufferStream at a specific zero-based index in the list of - * streams of this PullBufferDataSource. The - * PullBufferStream may not exist at the time of requesting its - * Format. Allows extenders to override the default behavior which - * is to report any last-known format or the first Format from the - * list of supported formats as defined in the JMF registration of this - * CaptureDevice. - * - * @param streamIndex the zero-based index of the PullBufferStream - * the Format of which is to be retrieved - * @param oldValue the last-known Format for the - * PullBufferStream at the specified streamIndex - * @return the Format to be reported by the FormatControl - * of the PullBufferStream at the specified streamIndex in - * the list of streams of this PullBufferDataSource. - */ - protected Format getFormat(int streamIndex, Format oldValue) - { - return impl.defaultGetFormat(streamIndex, oldValue); - } - - /** - * Gets an array of FormatControl instances each one of which can - * be used before {@link #connect()} to get and set the capture - * Format of each one of the capture streams. - * - * @return an array of FormatControl instances each one of which - * can be used before {@link #connect()} to get and set the capture - * Format of each one of the capture streams - */ - public FormatControl[] getFormatControls() - { - return impl.getFormatControls(); - } - - /** - * Gets the Object which is to synchronize the access to - * {@link #streams()} and its return value. - * - * @return the Object which is to synchronize the access to - * {@link #streams()} and its return value - */ - protected Object getStreamSyncRoot() - { - return impl.getStreamSyncRoot(); - } - - /** - * Gets the PullBufferStreams through which this - * PullBufferDataSource gives access to its media data. - * - * @return an array of the PullBufferStreams through which this - * PullBufferDataSource gives access to its media data - */ - public PullBufferStream[] getStreams() - { - return impl.getStreams(PullBufferStream.class); - } - - /** - * Gets the Formats which are to be reported by a - * FormatControl as supported formats for a - * PullBufferStream at a specific zero-based index in the list of - * streams of this PullBufferDataSource. - * - * @param streamIndex the zero-based index of the PullBufferStream - * for which the specified FormatControl is to report the list of - * supported Formats - * @return an array of Formats to be reported by a - * FormatControl as the supported formats for the - * PullBufferStream at the specified streamIndex in the - * list of streams of this PullBufferDataSource - */ - protected Format[] getSupportedFormats(int streamIndex) - { - return impl.defaultGetSupportedFormats(streamIndex); - } - - /** - * Sets a specific CaptureDeviceInfo on this - * CaptureDevice. - * - * @param deviceInfo the CaptureDeviceInfo on this - * CaptureDevice - */ - public void setCaptureDeviceInfo(CaptureDeviceInfo deviceInfo) - { - this.deviceInfo = deviceInfo; - } - - /** - * Attempts to set the Format to be reported by the - * FormatControl of a PullBufferStream at a specific - * zero-based index in the list of streams of this - * PullBufferDataSource. The PullBufferStream does not - * exist at the time of the attempt to set its Format. Allows - * extenders to override the default behavior which is to not attempt to set - * the specified Format so that they can enable setting the - * Format prior to creating the PullBufferStream. If - * setting the Format of an existing PullBufferStream is - * desired, AbstractPullBufferStream#doSetFormat(Format) should be - * overridden instead. - * - * @param streamIndex the zero-based index of the PullBufferStream - * the Format of which is to be set - * @param oldValue the last-known Format for the - * PullBufferStream at the specified streamIndex - * @param newValue the Format which is to be set - * @return the Format to be reported by the FormatControl - * of the PullBufferStream at the specified streamIndex - * in the list of streams of this PullBufferStream or null - * if the attempt to set the Format did not success and any - * last-known Format is to be left in effect - */ - protected Format setFormat( - int streamIndex, - Format oldValue, - Format newValue) - { - return oldValue; - } - - /** - * Starts the transfer of media data from this DataSource - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this DataSource - */ - public synchronized void start() - throws IOException - { - impl.start(); - } - - /** - * Stops the transfer of media data from this DataSource. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this DataSource - */ - public synchronized void stop() - throws IOException - { - impl.stop(); - } - - /** - * Gets the internal array of AbstractPushBufferStreams through - * which this AbstractPushBufferCaptureDevice gives access to its - * media data. - * - * @return the internal array of AbstractPushBufferStreams through - * which this AbstractPushBufferCaptureDevice gives access to its - * media data - */ - protected AbstractBufferStream[] streams() - { - return impl.streams(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractPullBufferStream.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractPullBufferStream.java deleted file mode 100644 index 10725febe..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractPullBufferStream.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol; - -import javax.media.*; -import javax.media.control.*; -import javax.media.protocol.*; - -/** - * Provides a base implementation of PullBufferStream in order to - * facilitate implementers by taking care of boilerplate in the most common - * cases. - * - * @author Lyubomir Marinov - */ -public abstract class AbstractPullBufferStream - extends AbstractBufferStream - implements PullBufferStream -{ - - /** - * Initializes a new AbstractPullBufferStream instance which is to - * have its Format-related information abstracted by a specific - * FormatControl. - * - * @param dataSource the PullBufferDataSource which is creating the - * new instance so that it becomes one of its streams - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - */ - protected AbstractPullBufferStream( - PullBufferDataSource dataSource, - FormatControl formatControl) - { - super(dataSource, formatControl); - } - - /** - * Determines if {@link #read(Buffer)} will block. - * - * @return true if read block, false otherwise - */ - public boolean willReadBlock() - { - return true; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractPushBufferCaptureDevice.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractPushBufferCaptureDevice.java deleted file mode 100644 index 1d962022a..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractPushBufferCaptureDevice.java +++ /dev/null @@ -1,467 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol; - -import java.io.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.protocol.*; - -/** - * Provides a base implementation of PushBufferDataSource and - * CaptureDevice in order to facilitate implementers by taking care of - * boilerplate in the most common cases. - * - * @author Lyubomir Marinov - */ -public abstract class AbstractPushBufferCaptureDevice - extends PushBufferDataSource - implements CaptureDevice -{ - /** - * The AbstractBufferCaptureDevice which provides the - * implementation of this AbstractPushBufferCaptureDevice. - */ - private final AbstractBufferCaptureDevice impl - = new AbstractBufferCaptureDevice() - { - @Override - protected FrameRateControl createFrameRateControl() - { - return - AbstractPushBufferCaptureDevice.this - .createFrameRateControl(); - } - - protected AbstractPushBufferStream createStream( - int streamIndex, - FormatControl formatControl) - { - return - AbstractPushBufferCaptureDevice.this.createStream( - streamIndex, - formatControl); - } - - protected void doConnect() - throws IOException - { - AbstractPushBufferCaptureDevice.this.doConnect(); - } - - protected void doDisconnect() - { - AbstractPushBufferCaptureDevice.this.doDisconnect(); - } - - protected void doStart() - throws IOException - { - AbstractPushBufferCaptureDevice.this.doStart(); - } - - protected void doStop() - throws IOException - { - AbstractPushBufferCaptureDevice.this.doStop(); - } - - public CaptureDeviceInfo getCaptureDeviceInfo() - { - return - AbstractPushBufferCaptureDevice.this - .getCaptureDeviceInfo(); - } - - /** - * Overrides {@link AbstractBufferCaptureDevice#getControls()} to - * add controls specific to this - * AbstractPushBufferCaptureDevice. - * - * {@inheritDoc} - */ - @Override - public Object[] getControls() - { - return AbstractPushBufferCaptureDevice.this.getControls(); - } - - protected Format getFormat(int streamIndex, Format oldValue) - { - return - AbstractPushBufferCaptureDevice.this.getFormat( - streamIndex, - oldValue); - } - - protected Format[] getSupportedFormats(int streamIndex) - { - return - AbstractPushBufferCaptureDevice.this - .getSupportedFormats(streamIndex); - } - - protected Format setFormat( - int streamIndex, - Format oldValue, Format newValue) - { - return - AbstractPushBufferCaptureDevice.this.setFormat( - streamIndex, - oldValue, newValue); - } - }; - - /** - * Initializes a new AbstractPushBufferCaptureDevice instance. - */ - protected AbstractPushBufferCaptureDevice() - { - } - - /** - * Initializes a new AbstractPushBufferCaptureDevice instance from - * a specific MediaLocator. - * - * @param locator the MediaLocator to create the new instance from - */ - protected AbstractPushBufferCaptureDevice(MediaLocator locator) - { - setLocator(locator); - } - - /** - * Opens a connection to the media source specified by the - * MediaLocator of this DataSource. - * - * @throws IOException if anything goes wrong while opening the connection - * to the media source specified by the MediaLocator of this - * DataSource - */ - public void connect() - throws IOException - { - impl.connect(); - } - - /** - * Creates a new FrameRateControl instance which is to allow the - * getting and setting of the frame rate of this - * AbstractPushBufferCaptureDevice. - * - * @return a new FrameRateControl instance which is to allow the - * getting and setting of the frame rate of this - * AbstractPushBufferCaptureDevice - */ - protected FrameRateControl createFrameRateControl() - { - return null; - } - - /** - * Create a new PushBufferStream which is to be at a specific - * zero-based index in the list of streams of this - * PushBufferDataSource. The Format-related information of - * the new instance is to be abstracted by a specific - * FormatControl. - * - * @param streamIndex the zero-based index of the PushBufferStream - * in the list of streams of this PushBufferDataSource - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - * @return a new PushBufferStream which is to be at the specified - * streamIndex in the list of streams of this - * PushBufferDataSource and which has its Format-related - * information abstracted by the specified formatControl - */ - protected abstract AbstractPushBufferStream createStream( - int streamIndex, - FormatControl formatControl); - - /** - * Closes the connection to the media source specified by the - * MediaLocator of this DataSource. If such a connection - * has not been opened, the call is ignored. - */ - public void disconnect() - { - impl.disconnect(); - } - - /** - * Opens a connection to the media source specified by the - * MediaLocator of this DataSource. Allows extenders to - * override and be sure that there will be no request to open a connection - * if the connection has already been opened. - * - * @throws IOException if anything goes wrong while opening the connection - * to the media source specified by the MediaLocator of this - * DataSource - */ - protected void doConnect() - throws IOException - { - } - - /** - * Closes the connection to the media source specified by the - * MediaLocator of this DataSource. Allows extenders to - * override and be sure that there will be no request to close a connection - * if the connection has not been opened yet. - */ - protected void doDisconnect() - { - /* - * While it is not clear whether the streams can be released upon - * disconnect, com.imb.media.protocol.SuperCloneableDataSource gets the - * streams of the DataSource it adapts (i.e. this DataSource when - * SourceCloneable support is to be created for it) before #connect(). - * Unfortunately, it means that it isn't clear when the streams are to - * be disposed. - */ - } - - /** - * Starts the transfer of media data from this DataSource. Allows - * extenders to override and be sure that there will be no request to start - * the transfer of media data if it has already been started. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this DataSource - */ - protected void doStart() - throws IOException - { - impl.defaultDoStart(); - } - - /** - * Stops the transfer of media data from this DataSource. Allows - * extenders to override and be sure that there will be no request to stop - * the transfer of media data if it has not been started yet. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this DataSource - */ - protected void doStop() - throws IOException - { - impl.defaultDoStop(); - } - - /** - * Gets the CaptureDeviceInfo of this CaptureDevice which - * describes it. - * - * @return the CaptureDeviceInfo of this CaptureDevice - * which describes it - */ - public CaptureDeviceInfo getCaptureDeviceInfo() - { - return AbstractBufferCaptureDevice.getCaptureDeviceInfo(this); - } - - /** - * Gets the content type of the media represented by this instance. The - * AbstractPushBufferCaptureDevice implementation always returns - * {@link ContentDescriptor#RAW}. - * - * @return the content type of the media represented by this instance - */ - public String getContentType() - { - return ContentDescriptor.RAW; - } - - /** - * Gets the control of the specified type available for this instance. - * - * @param controlType the type of the control available for this instance to - * be retrieved - * @return an Object which represents the control of the specified - * type available for this instance if such a control is indeed available; - * otherwise, null - */ - public Object getControl(String controlType) - { - return impl.getControl(controlType); - } - - /** - * Implements {@link javax.media.protocol.DataSource#getControls()}. Gets - * the controls available for this instance. - * - * @return an array of Objects which represent the controls - * available for this instance - */ - public Object[] getControls() - { - return impl.defaultGetControls(); - } - - /** - * Gets the duration of the media represented by this instance. The - * AbstractPushBufferCaptureDevice always returns - * {@link #DURATION_UNBOUNDED}. - * - * @return the duration of the media represented by this instance - */ - public Time getDuration() - { - return DURATION_UNBOUNDED; - } - - /** - * Gets the Format to be reported by the FormatControl of - * a PushBufferStream at a specific zero-based index in the list of - * streams of this PushBufferDataSource. The - * PushBufferStream may not exist at the time of requesting its - * Format. Allows extenders to override the default behavior which - * is to report any last-known format or the first Format from the - * list of supported formats as defined in the JMF registration of this - * CaptureDevice. - * - * @param streamIndex the zero-based index of the PushBufferStream - * the Format of which is to be retrieved - * @param oldValue the last-known Format for the - * PushBufferStream at the specified streamIndex - * @return the Format to be reported by the FormatControl - * of the PushBufferStream at the specified streamIndex in - * the list of streams of this PushBufferDataSource. - */ - protected Format getFormat(int streamIndex, Format oldValue) - { - return impl.defaultGetFormat(streamIndex, oldValue); - } - - /** - * Gets an array of FormatControl instances each one of which can - * be used before {@link #connect()} to get and set the capture - * Format of each one of the capture streams. - * - * @return an array of FormatControl instances each one of which - * can be used before {@link #connect()} to get and set the capture - * Format of each one of the capture streams - */ - public FormatControl[] getFormatControls() - { - return impl.getFormatControls(); - } - - /** - * Gets the Object which is to synchronize the access to - * {@link #streams()} and its return value. - * - * @return the Object which is to synchronize the access to - * {@link #streams()} and its return value - */ - protected Object getStreamSyncRoot() - { - return impl.getStreamSyncRoot(); - } - - /** - * Gets the PushBufferStreams through which this - * PushBufferDataSource gives access to its media data. - * - * @return an array of the PushBufferStreams through which this - * PushBufferDataSource gives access to its media data - */ - public PushBufferStream[] getStreams() - { - return impl.getStreams(PushBufferStream.class); - } - - /** - * Gets the Formats which are to be reported by a - * FormatControl as supported formats for a - * PushBufferStream at a specific zero-based index in the list of - * streams of this PushBufferDataSource. - * - * @param streamIndex the zero-based index of the PushBufferStream - * for which the specified FormatControl is to report the list of - * supported Formats - * @return an array of Formats to be reported by a - * FormatControl as the supported formats for the - * PushBufferStream at the specified streamIndex in the - * list of streams of this PushBufferDataSource - */ - protected Format[] getSupportedFormats(int streamIndex) - { - return impl.defaultGetSupportedFormats(streamIndex); - } - - /** - * Attempts to set the Format to be reported by the - * FormatControl of a PushBufferStream at a specific - * zero-based index in the list of streams of this - * PushBufferDataSource. The PushBufferStream does not - * exist at the time of the attempt to set its Format. Allows - * extenders to override the default behavior which is to not attempt to set - * the specified Format so that they can enable setting the - * Format prior to creating the PushBufferStream. If - * setting the Format of an existing PushBufferStream is - * desired, AbstractPushBufferStream#doSetFormat(Format) should be - * overridden instead. - * - * @param streamIndex the zero-based index of the PushBufferStream - * the Format of which is to be set - * @param oldValue the last-known Format for the - * PushBufferStream at the specified streamIndex - * @param newValue the Format which is to be set - * @return the Format to be reported by the FormatControl - * of the PushBufferStream at the specified streamIndex - * in the list of streams of this PushBufferStream or null - * if the attempt to set the Format did not success and any - * last-known Format is to be left in effect - */ - protected Format setFormat( - int streamIndex, - Format oldValue, Format newValue) - { - return oldValue; - } - - /** - * Starts the transfer of media data from this DataSource. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this DataSource - */ - public void start() - throws IOException - { - impl.start(); - } - - /** - * Stops the transfer of media data from this DataSource. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this DataSource - */ - public void stop() - throws IOException - { - impl.stop(); - } - - /** - * Gets the internal array of AbstractPushBufferStreams through - * which this AbstractPushBufferCaptureDevice gives access to its - * media data. - * - * @return the internal array of AbstractPushBufferStreams through - * which this AbstractPushBufferCaptureDevice gives access to its - * media data - */ - protected AbstractBufferStream[] streams() - { - return impl.streams(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractPushBufferStream.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractPushBufferStream.java deleted file mode 100644 index 7ab691624..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractPushBufferStream.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol; - -import javax.media.control.*; -import javax.media.protocol.*; - -/** - * Provides a base implementation of PushBufferStream in order to - * facilitate implementers by taking care of boilerplate in the most common - * cases. - * - * @author Lyubomir Marinov - */ -public abstract class AbstractPushBufferStream - extends AbstractBufferStream - implements PushBufferStream -{ - - /** - * The BufferTransferHandler which is notified by this - * PushBufferStream when data is available for reading. - */ - protected BufferTransferHandler transferHandler; - - /** - * Initializes a new AbstractPushBufferStream instance which is to - * have its Format-related information abstracted by a specific - * FormatControl. - * - * @param dataSource the PushBufferDataSource which is creating the - * new instance so that it becomes one of its streams - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - */ - protected AbstractPushBufferStream( - PushBufferDataSource dataSource, - FormatControl formatControl) - { - super(dataSource, formatControl); - } - - /** - * Sets the BufferTransferHandler which is to be notified by this - * PushBufferStream when data is available for reading. - * - * @param transferHandler the BufferTransferHandler which is to be - * notified by this PushBufferStream when data is available for - * reading - */ - public void setTransferHandler(BufferTransferHandler transferHandler) - { - this.transferHandler = transferHandler; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractVideoPullBufferCaptureDevice.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractVideoPullBufferCaptureDevice.java deleted file mode 100644 index 46b0a1f23..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractVideoPullBufferCaptureDevice.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol; - -import javax.media.*; -import javax.media.control.*; - -import net.java.sip.communicator.impl.neomedia.control.*; - -/** - * Provides a base implementation of PullBufferDataSource and - * CaptureDevice for the purposes of video in order to facilitate - * implementers by taking care of boilerplate in the most common cases. - * - * @author Lyubomir Marinov - */ -public abstract class AbstractVideoPullBufferCaptureDevice - extends AbstractPullBufferCaptureDevice -{ - - /** - * Initializes a new AbstractVideoPullBufferCaptureDevice instance. - */ - protected AbstractVideoPullBufferCaptureDevice() - { - } - - /** - * Initializes a new AbstractVideoPullBufferCaptureDevice instance - * from a specific MediaLocator. - * - * @param locator the MediaLocator to create the new instance from - */ - protected AbstractVideoPullBufferCaptureDevice(MediaLocator locator) - { - super(locator); - } - - /** - * Creates a new FrameRateControl instance which is to allow the - * getting and setting of the frame rate of this - * AbstractVideoPullBufferCaptureDevice. - * - * @return a new FrameRateControl instance which is to allow the - * getting and setting of the frame rate of this - * AbstractVideoPullBufferCaptureDevice - * @see AbstractPullBufferCaptureDevice#createFrameRateControl() - */ - @Override - protected FrameRateControl createFrameRateControl() - { - return - new FrameRateControlAdapter() - { - /** - * The output frame rate of this - * AbstractVideoPullBufferCaptureDevice. - */ - private float frameRate = -1; - - @Override - public float getFrameRate() - { - return frameRate; - } - - @Override - public float setFrameRate(float frameRate) - { - this.frameRate = frameRate; - return this.frameRate; - } - }; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractVideoPullBufferStream.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractVideoPullBufferStream.java deleted file mode 100644 index 62a7f8be1..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractVideoPullBufferStream.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol; - -import java.io.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.protocol.*; - -/** - * Provides a base implementation of PullBufferStream for video in - * order to facilitate implementers by taking care of boilerplate in the most - * common cases. - * - * @author Lyubomir Marinov - */ -public abstract class AbstractVideoPullBufferStream - extends AbstractPullBufferStream -{ - - /** - * The output frame rate of this AbstractVideoPullBufferStream - * which has been specified by {@link #frameRateControl} and depending on - * which {@link #minimumVideoFrameInterval} has been calculated. - */ - private float frameRate; - - /** - * The FrameRateControl which gets and sets the output frame rate - * of this AbstractVideoPullBufferStream. - */ - private FrameRateControl frameRateControl; - - /** - * The minimum interval in milliseconds between consecutive video frames - * i.e. the reverse of {@link #frameRate}. - */ - private long minimumVideoFrameInterval; - - /** - * Initializes a new AbstractVideoPullBufferStream instance which - * is to have its Format-related information abstracted by a - * specific FormatControl. - * - * @param dataSource the PullBufferDataSource which is creating the - * new instance so that it becomes one of its streams - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - */ - protected AbstractVideoPullBufferStream( - PullBufferDataSource dataSource, - FormatControl formatControl) - { - super(dataSource, formatControl); - } - - /** - * Blocks and reads into a Buffer from this - * PullBufferStream. - * - * @param buffer the Buffer this PullBufferStream is to - * read into - * @throws IOException if an I/O error occurs while this - * PullBufferStream reads into the specified Buffer - */ - protected abstract void doRead(Buffer buffer) - throws IOException; - - /** - * Blocks and reads into a Buffer from this - * PullBufferStream. - * - * @param buffer the Buffer this PullBufferStream is to - * read into - * @throws IOException if an I/O error occurs while this - * PullBufferStream reads into the specified Buffer - */ - public void read(Buffer buffer) - throws IOException - { - FrameRateControl frameRateControl = this.frameRateControl; - - if (frameRateControl != null) - { - float frameRate = frameRateControl.getFrameRate(); - - if (frameRate > 0) - { - if (this.frameRate != frameRate) - { - minimumVideoFrameInterval = (long) (1000 / frameRate); - this.frameRate = frameRate; - } - if (minimumVideoFrameInterval > 0) - { - long startTime = System.currentTimeMillis(); - - doRead(buffer); - - if (!buffer.isDiscard()) - { - boolean interrupted = false; - - while (true) - { - // Sleep to respect the frame rate as much as possible. - long sleep - = minimumVideoFrameInterval - - (System.currentTimeMillis() - startTime); - - if (sleep > 0) - { - try - { - Thread.sleep(sleep); - } - catch (InterruptedException ie) - { - interrupted = true; - } - } - else - { - // Yield a little bit to not use all the whole CPU. - Thread.yield(); - break; - } - } - if (interrupted) - Thread.currentThread().interrupt(); - } - - // We've executed #doRead(Buffer). - return; - } - } - } - - // If there is no frame rate to be respected, just #doRead(Buffer). - doRead(buffer); - } - - /** - * Starts the transfer of media data from this - * AbstractBufferStream. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this AbstractBufferStream - * @see AbstractBufferStream#start() - */ - @Override - public void start() - throws IOException - { - super.start(); - - frameRateControl - = (FrameRateControl) - dataSource.getControl(FrameRateControl.class.getName()); - } - - /** - * Stops the transfer of media data from this AbstractBufferStream. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this AbstractBufferStream - * @see AbstractBufferStream#stop() - */ - @Override - public void stop() - throws IOException - { - super.stop(); - - frameRateControl = null; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractVideoPushBufferCaptureDevice.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractVideoPushBufferCaptureDevice.java deleted file mode 100644 index f831e28db..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/AbstractVideoPushBufferCaptureDevice.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol; - -import javax.media.*; -import javax.media.control.*; - -/** - * Provides a base implementation of PushBufferDataSource and - * CaptureDevice for the purposes of video in order to facilitate - * implementers by taking care of boilerplate in the most common cases. - * - * @author Lyubomir Marinov - */ -public abstract class AbstractVideoPushBufferCaptureDevice - extends AbstractPushBufferCaptureDevice -{ - - /** - * Initializes a new AbstractVideoPushBufferCaptureDevice instance. - */ - protected AbstractVideoPushBufferCaptureDevice() - { - } - - /** - * Initializes a new AbstractVideoPushBufferCaptureDevice instance - * from a specific MediaLocator. - * - * @param locator the MediaLocator to create the new instance from - */ - protected AbstractVideoPushBufferCaptureDevice(MediaLocator locator) - { - super(locator); - } - - /** - * Creates a new FrameRateControl instance which is to allow the - * getting and setting of the frame rate of this - * AbstractVideoPushBufferCaptureDevice. - * - * @return a new FrameRateControl instance which is to allow the - * getting and setting of the frame rate of this - * AbstractVideoPushBufferCaptureDevice - * @see AbstractPushBufferCaptureDevice#createFrameRateControl() - */ - @Override - protected FrameRateControl createFrameRateControl() - { - return null; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/ByteBufferPool.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/ByteBufferPool.java deleted file mode 100644 index 4c11c0f98..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/ByteBufferPool.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol; - -import java.util.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.util.*; - -/** - * Represents a pool of ByteBuffers which reduces the allocations and - * deallocations of ByteBuffers in the Java heap and of native memory - * in the native heap. - * - * @author Lubomir Marinov - */ -public class ByteBufferPool -{ - - /** - * The Logger used by the ByteBufferPool class and its - * instances for logging output. - */ - private static final Logger logger = Logger.getLogger(ByteBufferPool.class); - - /** - * The ByteBuffers which are managed by this - * ByteBufferPool. - */ - private final List buffers = new ArrayList(); - - /** - * The indicator which determines whether this ByteBufferPool has - * been closed. Introduced to determine when ByteBuffers are to be - * disposed of and no longer be pooled. - */ - private boolean closed = false; - - /** - * Closes this ByteBufferPool i.e. releases the resource allocated - * by this ByteBufferPool during its existence and prepares it to - * be garbage collected. - */ - public void close() - { - synchronized (buffers) - { - closed = true; - - Iterator bufferIter = buffers.iterator(); - boolean loggerIsTraceEnabled = logger.isTraceEnabled(); - int leakedCount = 0; - - while (bufferIter.hasNext()) - { - ByteBuffer buffer = bufferIter.next(); - - if (buffer.isFree()) - { - bufferIter.remove(); - FFmpeg.av_free(buffer.ptr); - } - else if (loggerIsTraceEnabled) - leakedCount++; - } - if (loggerIsTraceEnabled) - { - if (logger.isTraceEnabled()) - logger.trace( - "Leaking " + leakedCount + " ByteBuffer instances."); - } - } - } - - /** - * Gets a ByteBuffer out of the pool of free ByteBuffers - * (i.e. ByteBuffers ready for writing captured media data into - * them) which is capable to receiving at least capacity number of - * bytes. - * - * @param capacity the minimal number of bytes that the returned - * ByteBuffer is to be capable of receiving - * @return a ByteBuffer which is ready for writing captured media - * data into and which is capable of receiving at least capacity - * number of bytes - */ - public ByteBuffer getFreeBuffer(int capacity) - { - synchronized (buffers) - { - if (closed) - return null; - - int bufferCount = buffers.size(); - ByteBuffer freeBuffer = null; - - /* - * XXX Pad with FF_INPUT_BUFFER_PADDING_SIZE or hell will break - * loose. - */ - capacity += FFmpeg.FF_INPUT_BUFFER_PADDING_SIZE; - - for (int bufferIndex = 0; bufferIndex < bufferCount; bufferIndex++) - { - ByteBuffer buffer = buffers.get(bufferIndex); - - if (buffer.isFree() && (buffer.capacity >= capacity)) - { - freeBuffer = buffer; - break; - } - } - if (freeBuffer == null) - { - freeBuffer = new ByteBuffer(capacity); - buffers.add(freeBuffer); - } - freeBuffer.setFree(false); - return freeBuffer; - } - } - - /** - * Returns a specific ByteBuffer into the pool of free - * ByteBuffers (i.e. ByteBuffers ready for writing - * captured media data into them). - * - * @param buffer the ByteBuffer to be returned into the pool of - * free ByteBuffers - */ - public void returnFreeBuffer(ByteBuffer buffer) - { - synchronized (buffers) - { - buffer.setFree(true); - if (closed && buffers.remove(buffer)) - FFmpeg.av_free(buffer.ptr); - } - } - - /** - * Returns a specific ByteBuffer given by the pointer to the native - * memory that it represents into the pool of free ByteBuffers - * (i.e. ByteBuffers ready for writing captured media data into - * them). - * - * @param bufferPtr the pointer to the native memory represented by the - * ByteBuffer to be returned into the pool of free - * ByteBuffers - */ - public void returnFreeBuffer(long bufferPtr) - { - synchronized (buffers) - { - for (ByteBuffer buffer : buffers) - if (buffer.ptr == bufferPtr) - { - returnFreeBuffer(buffer); - break; - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/alsa/AlsaStream.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/alsa/AlsaStream.java deleted file mode 100644 index fb50fedc2..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/alsa/AlsaStream.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.alsa; - -import java.io.*; - -import javax.media.*; -import javax.media.format.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.control.*; - -/** - * low-latency ALSA access through JNI wrapper - * - * @author Jean Lorchat - * @author Lubomir Marinov - */ -public class AlsaStream - extends ControlsAdapter - implements PushBufferStream, - Runnable -{ - protected ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW); - protected int maxDataLength; - protected AudioFormat audioFormat; - protected boolean started; - protected Thread thread; - protected BufferTransferHandler transferHandler; - - private native void jni_alsa_init(); - private native void jni_alsa_read(byte [] arr); - private native void jni_alsa_delete(); - - int seqNo = 0; - - /** - * Dynamically loads JNI object. Will fail if non-Linux - * or when libjmf_alsa.so is outside of the LD_LIBRARY_PATH - */ - static { - System.loadLibrary("jmf_alsa"); - } - - /** - * We only provide 8 kbps access to the device for now - * In addition, datablock size is fixed to 160 samples (320 bytes) - * This turns out to be 20ms worth of samples at 8kbps - * Very convenient for ilbc 20ms mode... - */ - public AlsaStream() { - - audioFormat = new AudioFormat(AudioFormat.LINEAR, - 8000.0, - 16, - 1, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - 16, - Format.NOT_SPECIFIED, - Format.byteArray); - - maxDataLength = 160; - - jni_alsa_init(); - thread = new Thread(this); - } - - /** - * Methods required for SourceStream interface - * - */ - - /** - * We are providing access to raw data - * - */ - public ContentDescriptor getContentDescriptor() { - return cd; - } - - /** - * Come on, we are streaming. Can't guess when the user wants to stop... - * - */ - public long getContentLength() { - return LENGTH_UNKNOWN; - } - - /** - * The stream of happiness never ends, somehow. - * - */ - public boolean endOfStream() { - return false; - } - - /** - * Tell whoever has interest how we are going to send the data - * - */ - public Format getFormat() { - return audioFormat; - } - - /** - * Reads sample data using native call - * - * @param buffer A Buffer with byte array as data, large enough to be - * filled with sample data. If this is not the case, we are going - * to allocate it ourselves anyway and replace the current data. - * - * @throws IOException Native method might throw an exception. - * Well actually that would surprise me because it is not - * implemented, but we love to be future-proof, isn't it ? - */ - public void read(Buffer buffer) throws IOException { - synchronized (this) { - Object outdata = buffer.getData(); - - if (outdata == null || - !(outdata.getClass() == Format.byteArray) || - ((byte[])outdata).length < maxDataLength) { - outdata = new byte[maxDataLength]; - buffer.setData(outdata); - } - - buffer.setFormat(audioFormat); - buffer.setTimeStamp(1000000000 / 8); - jni_alsa_read((byte[])outdata); - buffer.setSequenceNumber(seqNo); - buffer.setLength(maxDataLength); - buffer.setFlags(0); - buffer.setHeader(null); - seqNo++; - } - } - - /** - * Dunno about that piece yet... - * - */ - public void setTransferHandler(BufferTransferHandler transferHandler) { - synchronized (this) { - this.transferHandler = transferHandler; - notifyAll(); - } - } - - /** - * Starts a new thread for the stream operation - * - */ - void start(boolean started) { - synchronized (this) { - this.started = started; - if (started && !thread.isAlive()) { - thread = new Thread(this); - thread.start(); - } - notifyAll(); - } - } - - /** - * Transfer Buffer information through current thread then sleep - * until next data slice is ready. - * - */ - public void run() { - while (started) { - - synchronized (this) { - while (transferHandler == null && started) { - try { - wait(1000); - } catch (InterruptedException ie) { - } - } - } - - if (started && transferHandler != null) { - transferHandler.transferData(this); - try { - Thread.sleep(1); - } catch (InterruptedException ise) { - } - } - - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/alsa/DataSource.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/alsa/DataSource.java deleted file mode 100644 index 7ed310461..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/alsa/DataSource.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.alsa; - -import java.io.*; - -import javax.media.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.control.*; - -/** - * low-latency ALSA access through JNI wrapper - * - * @author Jean Lorchat - * @author Lubomir Marinov - */ -public class DataSource - extends PushBufferDataSource -{ - protected boolean started = false; - protected boolean connected = false; - protected Time duration = DURATION_UNKNOWN; - protected AlsaStream [] streams = null; - protected AlsaStream stream = null; - - /** - * Constructs a new ALSA DataSource. - */ - public DataSource() - { - } - - /** - * Gets the type of the content made available by this DataSource - * (i.e. raw). - * - * @return the type of the content made available by this - * DataSource (i.e. raw) - */ - public String getContentType() - { - return ContentDescriptor.RAW; - } - - /** - * Connect the datasource - */ - public void connect() throws IOException - { - if (connected) - return; - connected = true; - } - - /** - * Disconnect the datasource - */ - public void disconnect() - { - try - { - if (started) - stop(); - } - catch (IOException e) {} - connected = false; - } - - /** - * Start the datasource and the underlying stream - */ - public void start() throws IOException - { - if (!connected) - throw new java.lang.Error("DataSource must be connected"); - - if (started) - return; - - started = true; - stream.start(true); - } - - /** - * Stop the datasource and it's underlying stream - */ - public void stop() throws IOException - { - if ((!connected) || (!started)) - return; - - started = false; - stream.start(false); - } - - /** - * Gives control information to the caller. - */ - public Object [] getControls() - { - return ControlsAdapter.EMPTY_CONTROLS; - } - - /** - * Return required control from the Control[] array - * if exists, that is - */ - public Object getControl(String controlType) - { - return AbstractControls.getControl(this, controlType); - } - - /** - * Gives to the caller the duration information of our stream - * Which is, obviously unknown. Better turn on that premonition - * switch again, Mrs Cake. - * - * @return DURATION_UNKNOWN - */ - public Time getDuration() - { - return duration; - } - - /** - * Returns an array of PushBufferStream containing all the streams - * i.e. only one in our case : only sound - * - * If no stream actually exists, instanciate one on the fly - * - * @return Array of one stream - */ - public PushBufferStream [] getStreams() - { - if (streams == null) - { - streams = new AlsaStream[1]; - stream = streams[0] = new AlsaStream(); - } - return streams; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/directshow/DataSource.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/directshow/DataSource.java deleted file mode 100644 index 989c98f0a..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/directshow/DataSource.java +++ /dev/null @@ -1,472 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.directshow; - -import java.io.*; -import java.util.*; -import java.awt.Dimension; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.impl.neomedia.control.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.directshow.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; -import net.java.sip.communicator.util.*; - -/** - * Implements a CaptureDevice and a DataSource using - * DirectShow. - * - * @author Lyubomir Marinov - * @author Sebastien Vincent - */ -public class DataSource - extends AbstractVideoPushBufferCaptureDevice -{ - /** - * The Logger used by the DataSource class and its - * instances for logging output. - */ - private static final Logger logger = Logger.getLogger(DataSource.class); - - /** - * DirectShow capture device. - */ - private DSCaptureDevice device = null; - - /** - * Delegate grabber. Each frame captured by device will be pass through this - * grabber. - */ - private DSCaptureDevice.GrabberDelegate grabber = null; - - - /** - * DirectShow manager. - */ - private DSManager manager = null; - - /** - * The map of DirectShow pixel formats to FFmpeg - * pixel formats which allows converting between the two. - */ - private static final long[] DS_TO_FFMPEG_PIX_FMT - = new long[] - { - DSFormat.RGB24, - FFmpeg.PIX_FMT_RGB24, - DSFormat.RGB32, - FFmpeg.PIX_FMT_RGB32, - DSFormat.ARGB32, - FFmpeg.PIX_FMT_ARGB, - DSFormat.YUY2, - FFmpeg.PIX_FMT_YUYV422, - DSFormat.UYVY, - FFmpeg.PIX_FMT_UYVY422, - DSFormat.Y411, - FFmpeg.PIX_FMT_UYYVYY411, - DSFormat.Y41P, - FFmpeg.PIX_FMT_UYYVYY411, - DSFormat.NV12, - FFmpeg.PIX_FMT_NV12, - DSFormat.I420, - FFmpeg.PIX_FMT_YUV420P, - }; - - /** - * Last known native DirectShow format. - */ - private DSFormat nativeFormat = null; - - /** - * Constructor. - */ - public DataSource() - { - manager = DSManager.getInstance(); - } - - /** - * Initializes a new DataSource instance from a specific - * MediaLocator. - * - * @param locator the MediaLocator to create the new instance from - */ - public DataSource(MediaLocator locator) - { - super(locator); - manager = DSManager.getInstance(); - } - - /** - * Sets the MediaLocator which specifies the media source of this - * DataSource. - * - * @param locator the MediaLocator which specifies the media source - * of this DataSource - * @see DataSource#setLocator(MediaLocator) - */ - @Override - public void setLocator(MediaLocator locator) - { - DSCaptureDevice device = null; - logger.info("set locator to " + locator); - - if(getLocator() == null) - super.setLocator(locator); - locator = getLocator(); - logger.info("getLocator() returns " + locator); - - if((locator != null) && - DeviceSystem.LOCATOR_PROTOCOL_DIRECTSHOW.equalsIgnoreCase( - locator.getProtocol())) - { - DSCaptureDevice[] devices = manager.getCaptureDevices(); - - logger.info("Search directshow device..."); - - /* find device */ - for(int i = 0 ; i < devices.length ; i++) - { - if(devices[i].getName().equals(locator.getRemainder())) - { - device = devices[i]; - logger.info("Set directshow device: " + device); - break; - } - } - - if(device == null) - { - logger.info("No devices matches locator's remainder: " + - locator.getRemainder()); - } - } - else - { - logger.info( - "MediaLocator either null or does not have right protocol"); - device = null; - } - setDevice(device); - } - - /** - * Sets the DSCaptureDevice which represents the media source of - * this DataSource. - * - * @param device the DSCaptureDevice which represents the media - * source of this DataSource - */ - private void setDevice(DSCaptureDevice device) - { - if(this.device != device) - { - this.device = device; - } - } - - /** - * Creates a new FrameRateControl instance which is to allow the - * getting and setting of the frame rate of this - * AbstractVideoPushBufferCaptureDevice. - * - * @return a new FrameRateControl instance which is to allow the - * getting and setting of the frame rate of this - * AbstractVideoPushBufferCaptureDevice - * @see AbstractPushBufferCaptureDevice#createFrameRateControl() - */ - @Override - protected FrameRateControl createFrameRateControl() - { - return - new FrameRateControlAdapter() - { - /** - * The output frame rate of this - * AbstractVideoPullBufferCaptureDevice. - */ - private float frameRate = -1; - - @Override - public float getFrameRate() - { - return frameRate; - } - - @Override - public float setFrameRate(float frameRate) - { - this.frameRate = frameRate; - return this.frameRate; - } - }; - } - - /** - * Create a new PushBufferStream which is to be at a specific - * zero-based index in the list of streams of this - * PushBufferDataSource. The Format-related information of - * the new instance is to be abstracted by a specific - * FormatControl. - * - * @param streamIndex the zero-based index of the PushBufferStream - * in the list of streams of this PushBufferDataSource - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - * @return a new PushBufferStream which is to be at the specified - * streamIndex in the list of streams of this - * PushBufferDataSource and which has its Format-related - * information abstracted by the specified formatControl - * @see AbstractPushBufferCaptureDevice#createStream(int, FormatControl) - */ - protected AbstractPushBufferStream createStream( - int streamIndex, - FormatControl formatControl) - { - DirectShowStream stream = new DirectShowStream(this, formatControl); - - if (logger.isTraceEnabled()) - { - DSFormat deviceFmts[] = device.getSupportedFormats(); - - for (DSFormat deviceFmt : deviceFmts) - { - logger.trace( - "width= " + deviceFmt.getWidth() - + ", height= " + deviceFmt.getHeight() - + ", pixelFormat= " + deviceFmt.getPixelFormat()); - } - } - - grabber = stream.grabber; - - return stream; - } - - /** - * Gets the Formats which are to be reported by a - * FormatControl as supported formats for a - * PushBufferStream at a specific zero-based index in the list of - * streams of this PushBufferDataSource. - * - * @param streamIndex the zero-based index of the PushBufferStream - * for which the specified FormatControl is to report the list of - * supported Formats - * @return an array of Formats to be reported by a - * FormatControl as the supported formats for the - * PushBufferStream at the specified streamIndex in the - * list of streams of this PushBufferDataSource - * @see AbstractPushBufferCaptureDevice#getSupportedFormats(int) - */ - @Override - protected Format[] getSupportedFormats(int streamIndex) - { - if(device == null) - return new Format[0]; - - DSFormat[] deviceFmts = device.getSupportedFormats(); - List fmts = new ArrayList(deviceFmts.length); - - for (DSFormat deviceFmt : deviceFmts) - { - Dimension size - = new Dimension(deviceFmt.getWidth(), deviceFmt.getHeight()); - long devicePixFmt = deviceFmt.getPixelFormat(); - int pixFmt = (int) getFFmpegPixFmt(devicePixFmt); - - fmts.add( - new AVFrameFormat( - size, - Format.NOT_SPECIFIED, - pixFmt, (int) devicePixFmt)); - } - return fmts.toArray(new Format[fmts.size()]); - } - - /** - * Attempts to set the Format to be reported by the - * FormatControl of a PushBufferStream at a specific - * zero-based index in the list of streams of this - * PushBufferDataSource. The PushBufferStream does not - * exist at the time of the attempt to set its Format. - * - * @param streamIndex the zero-based index of the PushBufferStream - * the Format of which is to be set - * @param oldValue the last-known Format for the - * PushBufferStream at the specified streamIndex - * @param newValue the Format which is to be set - * @return the Format to be reported by the FormatControl - * of the PushBufferStream at the specified streamIndex - * in the list of streams of this PushBufferStream or null - * if the attempt to set the Format did not success and any - * last-known Format is to be left in effect - * @see AbstractPushBufferCaptureDevice#setFormat(int, Format, Format) - */ - @Override - protected Format setFormat( - int streamIndex, - Format oldValue, Format newValue) - { - if(newValue instanceof VideoFormat) - { - if(newValue instanceof AVFrameFormat) - { - AVFrameFormat newAVFrameFormatValue - = (AVFrameFormat) newValue; - long pixelFormat = newAVFrameFormatValue.getDevicePixFmt(); - - if(pixelFormat != -1) - { - Dimension size = newAVFrameFormatValue.getSize(); - - /* - * We will set the native format in doStart() because a - * connect-disconnect-connect sequence of the native - * capture device may reorder its formats in a different - * way. Consequently, in the absence of further calls to - * setFormat() by JMF, a crash may occur later (typically, - * during scaling) because of a wrong format. - */ - nativeFormat - = new DSFormat( - size.width, size.height, - pixelFormat); - } - } - - // This DataSource supports setFormat. - return newValue; - } - else - return super.setFormat(streamIndex, oldValue, newValue); - } - - /** - * Opens a connection to the media source specified by the - * MediaLocator of this DataSource. - * - * @throws IOException if anything goes wrong while opening the connection - * to the media source specified by the MediaLocator of this - * DataSource - * @see AbstractPushBufferCaptureDevice#doConnect() - */ - @Override - protected void doConnect() throws IOException - { - if (logger.isInfoEnabled()) - logger.info("doConnect"); - - if(manager == null) - manager = DSManager.getInstance(); - - setLocator(getLocator()); - - super.doConnect(); - } - - /** - * Closes the connection to the media source specified by the - * MediaLocator of this DataSource. - * - * @see AbstractPushBufferCaptureDevice#doDisconnect() - */ - @Override - protected void doDisconnect() - { - if (logger.isInfoEnabled()) - logger.info("doDisconnect"); - - super.doDisconnect(); - - if(manager != null) - { - device.setDelegate(null); - device = null; - - DSManager.dispose(); - manager = null; - } - } - - /** - * Starts the transfer of media data from this DataSource. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this DataSource - * @see AbstractPushBufferCaptureDevice#doStart() - */ - @Override - protected void doStart() throws IOException - { - if (logger.isInfoEnabled()) - logger.info("start"); - - /* open and start capture */ - device.open(); - if(nativeFormat != null) - device.setFormat(nativeFormat); - - device.setDelegate(grabber); - - super.doStart(); - } - - /** - * Stops the transfer of media data from this DataSource. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this DataSource - * @see AbstractPushBufferCaptureDevice#doStop() - */ - @Override - protected void doStop() throws IOException - { - if (logger.isInfoEnabled()) - logger.info("stop"); - - /* close capture */ - super.doStop(); - device.close(); - } - - /** - * Gets the DirectShow pixel format matching a specific FFmpeg pixel - * format. - * - * @param dsPixFmt the DirectShow pixel format to get the matching - * FFmpeg pixel format of - * @return the FFmpeg pixel format matching the specified DirectShow pixel - */ - public static long getFFmpegPixFmt(long dsPixFmt) - { - for (int i = 0; i < DS_TO_FFMPEG_PIX_FMT.length; i += 2) - if (DS_TO_FFMPEG_PIX_FMT[i] == dsPixFmt) - return DS_TO_FFMPEG_PIX_FMT[i + 1]; - return FFmpeg.PIX_FMT_NONE; - } - - /** - * Gets the FFmpeg pixel format matching a specific DirectShow - * Specification pixel format. - * - * @param ffmpegPixFmt FFmpeg format - * @return the DirectShow pixel format matching the specified FFmpeg format - */ - public static long getDSPixFmt(int ffmpegPixFmt) - { - for (int i = 0; i < DS_TO_FFMPEG_PIX_FMT.length; i += 2) - if (DS_TO_FFMPEG_PIX_FMT[i + 1] == ffmpegPixFmt) - return DS_TO_FFMPEG_PIX_FMT[i]; - return -1; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/directshow/DirectShowStream.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/directshow/DirectShowStream.java deleted file mode 100644 index 02d83f68b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/directshow/DirectShowStream.java +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.directshow; - -import java.io.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.impl.neomedia.directshow.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; - -/** - * Implements a PushBufferStream using DirectShow. - * - * @author Lyubomir Marinov - * @author Sebastien Vincent - */ -public class DirectShowStream extends AbstractPushBufferStream -{ - /** - * The pool of ByteBuffers this instances is using to transfer the - * media data captured by {@link #grabber} out of this instance - * through the Buffers specified in its {@link #read(Buffer)}. - */ - private final ByteBufferPool bufferPool = new ByteBufferPool(); - - /** - * The captured media data to be returned in {@link #read(Buffer)}. - */ - private ByteBuffer data; - - /** - * The Object which synchronizes the access to the - * {@link #data}-related fields of this instance. - */ - private final Object dataSyncRoot = new Object(); - - /** - * The time stamp in nanoseconds of {@link #data}. - */ - private long dataTimeStamp; - - /** - * The last-known Format of the media data made available by this - * PushBufferStream. - */ - private final Format format; - - /** - * The captured media data to become the value of {@link #data} as soon as - * the latter becomes is consumed. Thus prepares this - * DirectShowStream to provide the latest available frame and not - * wait for DirectShow to capture a new one. - */ - private ByteBuffer nextData = null; - - /** - * The time stamp in nanoseconds of {@link #nextData}. - */ - private long nextDataTimeStamp; - - /** - * The Thread which is to call - * {@link BufferTransferHandler#transferData(PushBufferStream)} for this - * DirectShowStream so that the call is not made in DirectShow - * and we can drop late frames when - * {@link #automaticallyDropsLateVideoFrames} is false. - */ - private Thread transferDataThread; - - /** - * The indicator which determines whether {@link #grabber} - * automatically drops late frames. If false, we have to drop them - * ourselves because DirectShow will buffer them all and the video will - * be late. - */ - private boolean automaticallyDropsLateVideoFrames = false; - - /** - * Delegate class to handle video data. - */ - final DSCaptureDevice.GrabberDelegate grabber - = new DSCaptureDevice.GrabberDelegate() - { - @Override - public void frameReceived(long ptr, int length) - { - processFrame(ptr, length); - } - }; - - /** - * Initializes a new DirectShowStream instance which is to have its - * Format-related information abstracted by a specific - * FormatControl. - * - * @param dataSource the DataSource which is creating the new - * instance so that it becomes one of its streams - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - */ - DirectShowStream(DataSource dataSource, FormatControl formatControl) - { - super(dataSource, formatControl); - - format = (VideoFormat) formatControl.getFormat(); - } - - /** - * Process received frames from DirectShow capture device - * - * @param ptr native pointer to data - * @param length length of data - */ - private void processFrame(long ptr, int length) - { - boolean transferData = false; - - synchronized (dataSyncRoot) - { - if(!automaticallyDropsLateVideoFrames && (data != null)) - { - if(nextData != null) - { - bufferPool.returnFreeBuffer(nextData); - nextData = null; - } - - nextData - = bufferPool.getFreeBuffer(length); - if(nextData != null) - { - nextData.setLength( - DSCaptureDevice.getBytes(ptr, - nextData.ptr, - nextData.capacity)); - nextDataTimeStamp = System.nanoTime(); - } - - return; - } - - if(data != null) - { - bufferPool.returnFreeBuffer(data); - data = null; - } - - data = bufferPool.getFreeBuffer(length); - if(data != null) - { - data.setLength(DSCaptureDevice.getBytes(ptr, - data.ptr, data.capacity)); - dataTimeStamp = System.nanoTime(); - } - - if(nextData != null) - { - bufferPool.returnFreeBuffer(nextData); - nextData = null; - } - - if(automaticallyDropsLateVideoFrames) - transferData = (data != null); - else - { - transferData = false; - dataSyncRoot.notifyAll(); - } - } - - if(transferData) - { - BufferTransferHandler transferHandler = this.transferHandler; - - if(transferHandler != null) - transferHandler.transferData(this); - } - } - - /** - * Gets the Format of this PushBufferStream as directly - * known by it. - * - * @return the Format of this PushBufferStream as directly - * known by it or null if this PushBufferStream does not - * directly know its Format and it relies on the - * PushBufferDataSource which created it to report its - * Format - */ - @Override - protected Format doGetFormat() - { - return (this.format == null) ? super.doGetFormat() : this.format; - } - - /** - * Releases the resources used by this instance throughout its existence and - * makes it available for garbage collection. This instance is considered - * unusable after closing. - * - * @see AbstractPushBufferStream#close() - */ - @Override - public void close() - { - bufferPool.close(); - } - - /** - * Calls {@link BufferTransferHandler#transferData(PushBufferStream)} from - * inside {@link #transferDataThread} so that the call is not made in - * DirectShow and we can drop late frames in the meantime. - */ - private void runInTransferDataThread() - { - boolean transferData = false; - FrameRateControl frameRateControl - = (FrameRateControl) - dataSource.getControl(FrameRateControl.class.getName()); - long transferDataTimeStamp = -1; - - while (Thread.currentThread().equals(transferDataThread)) - { - if (transferData) - { - BufferTransferHandler transferHandler = this.transferHandler; - - if (transferHandler != null) - { - /* - * Respect the frame rate specified through the - * FrameRateControl of the associated DataSource. - */ - if (frameRateControl != null) - { - float frameRate; - long newTransferDataTimeStamp - = System.currentTimeMillis(); - - if ((transferDataTimeStamp != -1) - && ((frameRate - = frameRateControl.getFrameRate()) - > 0)) - { - long minimumVideoFrameInterval - = (long) (1000 / frameRate); - - if (minimumVideoFrameInterval > 0) - { - long t - = newTransferDataTimeStamp - - transferDataTimeStamp; - - if ((t > 0) && (t < minimumVideoFrameInterval)) - { - boolean interrupted = false; - - try - { - Thread.sleep( - minimumVideoFrameInterval - t); - } - catch (InterruptedException ie) - { - interrupted = true; - } - if (interrupted) - Thread.currentThread().interrupt(); - continue; - } - } - } - - transferDataTimeStamp = newTransferDataTimeStamp; - } - - transferHandler.transferData(this); - } - - synchronized (dataSyncRoot) - { - if(data != null) - { - bufferPool.returnFreeBuffer(data); - data = null; - } - - data = nextData; - dataTimeStamp = nextDataTimeStamp; - nextData = null; - } - } - - synchronized (dataSyncRoot) - { - if (data == null) - { - data = nextData; - dataTimeStamp = nextDataTimeStamp; - nextData = null; - } - if (data == null) - { - boolean interrupted = false; - - try - { - dataSyncRoot.wait(); - } - catch (InterruptedException iex) - { - interrupted = true; - } - if(interrupted) - Thread.currentThread().interrupt(); - - transferData = (data != null); - } - else - transferData = true; - } - } - } - - /** - * Starts the transfer of media data from this PushBufferStream. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this PushBufferStream - */ - @Override - public void start() throws IOException - { - if(!automaticallyDropsLateVideoFrames) - { - transferDataThread - = new Thread(getClass().getSimpleName()) - { - @Override - public void run() - { - runInTransferDataThread(); - } - }; - transferDataThread.start(); - } - } - - /** - * Stops the transfer of media data from this PushBufferStream. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this PushBufferStream - */ - @Override - public void stop() throws IOException - { - transferDataThread = null; - - synchronized (dataSyncRoot) - { - if(data != null) - { - bufferPool.returnFreeBuffer(data); - data = null; - } - - if(nextData != null) - { - bufferPool.returnFreeBuffer(nextData); - nextData = null; - } - - if(!automaticallyDropsLateVideoFrames) - dataSyncRoot.notifyAll(); - } - } - - /** - * Reads media data from this PushBufferStream into a specific - * Buffer without blocking. - * - * @param buffer the Buffer in which media data is to be read from - * this PushBufferStream - * @throws IOException if anything goes wrong while reading media data from - * this PushBufferStream into the specified buffer - */ - public void read(Buffer buffer) throws IOException - { - synchronized (dataSyncRoot) - { - if(data == null) - { - buffer.setLength(0); - return; - } - - Format bufferFormat = buffer.getFormat(); - - if(bufferFormat == null) - { - bufferFormat = getFormat(); - if(bufferFormat != null) - buffer.setFormat(bufferFormat); - } - if(bufferFormat instanceof AVFrameFormat) - { - FinalizableAVFrame.read( - buffer, - bufferFormat, - data, - bufferPool); - } - else - { - Object bufferData = buffer.getData(); - byte[] bufferByteData; - int dataLength = data.getLength(); - - if(bufferData instanceof byte[]) - { - bufferByteData = (byte[]) bufferData; - if(bufferByteData.length < dataLength) - bufferByteData = null; - } - else - bufferByteData = null; - if(bufferByteData == null) - { - bufferByteData = new byte[dataLength]; - buffer.setData(bufferByteData); - } - - /* XXX */ - //DSCaptureDevice.getBytes(bufferByteData, 0, dataLength, - // data.ptr); - //CVPixelBuffer.memcpy(bufferByteData, 0, dataLength, data.ptr); - - buffer.setLength(dataLength); - buffer.setOffset(0); - - bufferPool.returnFreeBuffer(data); - } - - buffer.setFlags(Buffer.FLAG_LIVE_DATA | Buffer.FLAG_SYSTEM_TIME); - buffer.setTimeStamp(dataTimeStamp); - - data = null; - if(!automaticallyDropsLateVideoFrames) - dataSyncRoot.notifyAll(); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/DataSource.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/DataSource.java deleted file mode 100644 index 4e5e5898d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/DataSource.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.imgstreaming; - -import javax.media.*; -import javax.media.control.*; - -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; -import net.java.sip.communicator.impl.neomedia.protocol.*; - -/** - * Implements CaptureDevice and DataSource for the purposes of - * image and desktop streaming. - * - * @author Sebastien Vincent - * @author Lyubomir Marinov - * @author Damian Minkov - */ -public class DataSource - extends AbstractVideoPullBufferCaptureDevice - implements Controls -{ - /** - * Stream created. - */ - private ImageStream stream = null; - - /** - * Initializes a new DataSource instance. - */ - public DataSource() - { - } - - /** - * Initializes a new DataSource instance. - * - * @param locator associated MediaLocator - */ - public DataSource(MediaLocator locator) - { - super(locator); - } - - /** - * Set origin of ImageStream. - * - * @param streamIndex stream index - * @param monitorIndex monitor index - * @param x x coordinate - * @param y y coordinate - */ - public void setOrigin(int streamIndex, int monitorIndex, int x, int y) - { - if(stream != null) - { - stream.setOrigin(x, y); - stream.setDisplayIndex(monitorIndex); - } - } - - /** - * Creates a new PullBufferStream which is to be at a specific - * zero-based index in the list of streams of this - * PullBufferDataSource. The Format-related information of - * the new instance is to be abstracted by a specific - * FormatControl. - * - * @param streamIndex the zero-based index of the PullBufferStream - * in the list of streams of this PullBufferDataSource - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - * @return a new PullBufferStream which is to be at the specified - * streamIndex in the list of streams of this - * PullBufferDataSource and which has its Format-related - * information abstracted by the specified formatControl - * @see AbstractPullBufferCaptureDevice#createStream(int, FormatControl) - */ - protected AbstractPullBufferStream createStream( - int streamIndex, - FormatControl formatControl) - { - /* - * full desktop: remainder => index - * part of desktop: remainder => index,x,y - */ - String remainder = getLocator().getRemainder(); - String split[] = remainder.split(","); - int index = -1; - int x = 0; - int y = 0; - - if ((split != null) && (split.length > 1)) - { - index = Integer.parseInt(split[0]); - x = Integer.parseInt(split[1]); - y = Integer.parseInt(split[2]); - } - else - { - index = Integer.parseInt(remainder); - } - - ImageStream stream = new ImageStream(this, formatControl); - - stream.setDisplayIndex(index); - stream.setOrigin(x, y); - - this.stream = stream; - return stream; - } - - /** - * Implements {@link Controls#getControl(String)}. Invokes - * {@link #getControls()} and then looks for a control of the specified type - * in the returned array of controls. - * - * @param controlType a String value naming the type of the control - * of this instance to be retrieved - * @return an Object which represents the control of this instance - * with the specified type - */ - public Object getControl(String controlType) - { - if(controlType == this.getClass().getName()) - { - return this; - } - else - { - return super.getControl(controlType); - } - } - - /** - * Implements {@link Controls#getControl(String)}. Invokes - * {@link #getControls()} and then looks for a control of the specified type - * in the returned array of controls. - * - * @param controlType a String value naming the type of the control - * of this instance to be retrieved - * @return an Object which represents the control of this instance - * with the specified type - */ - public Object[] getControls() - { - Object[] thisControls; - Object[] superControls = super.getControls(); - if(superControls != null) - { - thisControls = new Object[superControls.length + 1]; - System.arraycopy( - superControls, 0, - thisControls, 0, - superControls.length); - thisControls[superControls.length] = this; - } - else - { - thisControls = new Object[]{this}; - } - return thisControls; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/ImageStream.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/ImageStream.java deleted file mode 100644 index 588dd9ef4..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/ImageStream.java +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.imgstreaming; - -import java.awt.*; -import java.awt.image.*; -import java.io.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.impl.neomedia.imgstreaming.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; -import net.java.sip.communicator.util.*; - -/** - * The stream used by JMF for our image streaming. - * - * @author Sebastien Vincent - * @author Lyubomir Marinov - * @author Damian Minkov - */ -public class ImageStream - extends AbstractVideoPullBufferStream -{ - /** - * The Logger - */ - private static final Logger logger = Logger.getLogger(ImageStream.class); - - /** - * Sequence number. - */ - private long seqNo = 0; - - /** - * Desktop interaction (screen capture, key press, ...). - */ - private DesktopInteract desktopInteract = null; - - /** - * Native buffer pointer. - */ - private ByteBuffer data = null; - - /** - * If stream has been reinitialized. - */ - private boolean reinit = false; - - /** - * Index of display that we will capture from. - */ - private int displayIndex = -1; - - /** - * X origin. - */ - private int x = 0; - - /** - * Y origin. - */ - private int y = 0; - - /** - * Initializes a new ImageStream instance which is to have a - * specific FormatControl - * - * @param dataSource the DataSource which is creating the new - * instance so that it becomes one of its streams - * @param formatControl the FormatControl of the new instance which - * is to specify the format in which it is to provide its media data - */ - ImageStream(DataSource dataSource, FormatControl formatControl) - { - super(dataSource, formatControl); - } - - /** - * Blocks and reads into a Buffer from this - * PullBufferStream. - * - * @param buffer the Buffer this PullBufferStream is to - * read into - * @throws IOException if an I/O error occurs while this - * PullBufferStream reads into the specified Buffer - * @see AbstractVideoPullBufferStream#doRead(Buffer) - */ - protected void doRead(Buffer buffer) - throws IOException - { - /* - * Determine the Format in which we're expected to output. We cannot - * rely on the Format always being specified in the Buffer because it is - * not its responsibility, the DataSource of this ImageStream knows the - * output Format. - */ - Format bufferFormat = buffer.getFormat(); - - if (bufferFormat == null) - { - bufferFormat = getFormat(); - if (bufferFormat != null) - buffer.setFormat(bufferFormat); - } - - if(bufferFormat instanceof AVFrameFormat) - { - /* - * Native transfer: we keep data in native memory rather than the - * Java heap until we reach SwScaler. - */ - Object dataAv = buffer.getData(); - AVFrame bufferFrame = null; - long bufferFramePtr = 0; - - if (dataAv instanceof AVFrame) - { - bufferFrame = (AVFrame)dataAv; - bufferFramePtr = bufferFrame.getPtr(); - } - else - { - bufferFrame = new FinalizableAVFrame(); - bufferFramePtr = bufferFrame.getPtr(); - } - - AVFrameFormat bufferFrameFormat = (AVFrameFormat) bufferFormat; - Dimension bufferFrameSize = bufferFrameFormat.getSize(); - - if(readScreenNative(bufferFrameSize)) - { - FFmpeg.avpicture_fill( - bufferFramePtr, - data.ptr, - bufferFrameFormat.getPixFmt(), - bufferFrameSize.width, bufferFrameSize.height); - buffer.setData(bufferFrame); - } - else - { - /* this can happen when we disconnect a monitor from computer - * before or during grabbing - */ - throw new IOException("Failed to grab screen"); - } - } - else - { - byte dataByte[] = (byte[])buffer.getData(); - int dataLength = (dataByte != null) ? dataByte.length : 0; - - if((dataByte != null) || (dataLength != 0)) - { - Dimension bufferFrameSize = - ((VideoFormat)bufferFormat).getSize(); - byte buf[] = readScreen(dataByte, bufferFrameSize); - - if(buf != dataByte) - { - /* readScreen returns us a different buffer than JMF ones, - * it means that JMF's initial buffer was too short. - */ - //System.out.println("use our own buffer"); - buffer.setData(buf); - } - - buffer.setOffset(0); - buffer.setLength(buf.length); - } - } - - buffer.setHeader(null); - buffer.setTimeStamp(System.nanoTime()); - buffer.setSequenceNumber(seqNo); - buffer.setFlags(Buffer.FLAG_SYSTEM_TIME | Buffer.FLAG_LIVE_DATA); - seqNo++; - } - - /** - * Set display index. - * - * @param index display index - */ - public void setDisplayIndex(int index) - { - displayIndex = index; - } - - /** - * Set Origin of capture. - * - * @param x x coordinate - * @param y y coordinate - */ - public void setOrigin(int x, int y) - { - this.x = x; - this.y = y; - } - - /** - * Start desktop capture stream. - * - * @see AbstractPullBufferStream#start() - */ - @Override - public void start() - { - if(desktopInteract == null) - { - try - { - desktopInteract = new DesktopInteractImpl(); - } - catch(Exception e) - { - logger.warn("Cannot create DesktopInteract object!"); - } - } - - reinit = true; - } - - /** - * Stop desktop capture stream. - * - * @see AbstractPullBufferStream#stop() - */ - @Override - public void stop() - { - if (logger.isInfoEnabled()) - logger.info("Stop stream"); - } - - /** - * Read screen and store result in native buffer. - * - * @param dim dimension of the video - * @return true if success, false otherwise - */ - private boolean readScreenNative(Dimension dim) - { - int size = dim.width * dim.height * 4; - - /* pad the buffer */ - size += FFmpeg.FF_INPUT_BUFFER_PADDING_SIZE; - - /* allocate native array */ - if(data == null || reinit) - { - data = new ByteBuffer(size); - data.setLength(size); - reinit = false; - } - else if(data.capacity < size) - { - /* reallocate native array if capacity is not enough */ - data.setFree(true); - FFmpeg.av_free(data.ptr); - data = new ByteBuffer(size); - data.setLength(size); - } - - /* get desktop screen via native grabber */ - return desktopInteract.captureScreen(displayIndex, x, y, dim.width, - dim.height, data.ptr, data.getLength()); - } - - /** - * Read screen. - * - * @param output output buffer for screen bytes - * @param dim dimension of the screen - * @return raw bytes, it could be equal to output or not. Take care in the - * caller to check if output is the returned value. - */ - public byte[] readScreen(byte output[], Dimension dim) - { - VideoFormat format = (VideoFormat) getFormat(); - Dimension formatSize = format.getSize(); - int width = (int) formatSize.getWidth(); - int height = (int) formatSize.getHeight(); - BufferedImage scaledScreen = null; - BufferedImage screen = null; - byte data[] = null; - int size = width * height * 4; - - /* check if output buffer can hold all the screen - * if not allocate our own buffer - */ - if(output.length < size) - { - output = null; - output = new byte[size]; - } - - /* get desktop screen via native grabber if available */ - if(desktopInteract.captureScreen(displayIndex, x, y, dim.width, - dim.height, output)) - { - return output; - } - - System.out.println("failed to grab with native! " + output.length); - - /* OK native grabber failed or is not available, - * try with AWT Robot and convert it to the right format - * - * Note that it is very memory consuming since memory are allocated - * to capture screen (via Robot) and then for converting to raw bytes - * Moreover support for multiple display has not yet been investigated - * - * Normally not of our supported platform (Windows (x86, x64), - * Linux (x86, x86-64), Mac OS X (i386, x86-64, ppc) and - * FreeBSD (x86, x86-64) should go here. - */ - screen = desktopInteract.captureScreen(); - - if(screen != null) - { - /* convert to ARGB BufferedImage */ - scaledScreen - = ImageStreamingUtils - .getScaledImage( - screen, - width, - height, - BufferedImage.TYPE_INT_ARGB); - - /* get raw bytes */ - data = ImageStreamingUtils.getImageBytes(scaledScreen, output); - } - - screen = null; - scaledScreen = null; - return data; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/portaudio/DataSource.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/portaudio/DataSource.java deleted file mode 100644 index 0130ec28e..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/portaudio/DataSource.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.portaudio; - -import java.io.*; - -import javax.media.*; -import javax.media.control.*; - -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; -import net.java.sip.communicator.impl.neomedia.portaudio.*; -import net.java.sip.communicator.util.*; - -/** - * Implements DataSource and CaptureDevice for PortAudio. - * - * @author Damian Minkov - * @author Lyubomir Marinov - */ -public class DataSource - extends AbstractPullBufferCaptureDevice -{ - /** - * The Logger used by the DataSource class and its - * instances for logging output. - */ - private static final Logger logger = Logger.getLogger(DataSource.class); - - /** - * The indicator which determines whether this DataSource will - * use audio quality improvement in accord with the preferences of the user. - */ - private final boolean audioQualityImprovement; - - /** - * The list of Formats in which this DataSource is - * capable of capturing audio data. - */ - private final Format[] supportedFormats; - - /** - * Initializes a new DataSource instance. - */ - public DataSource() - { - this.supportedFormats = null; - this.audioQualityImprovement = true; - } - - /** - * Initializes a new DataSource instance from a specific - * MediaLocator. - * - * @param locator the MediaLocator to create the new instance from - */ - public DataSource(MediaLocator locator) - { - this(locator, null, true); - } - - /** - * Initializes a new DataSource instance from a specific - * MediaLocator and which has a specific list of Format - * in which it is capable of capturing audio data overriding its - * registration with JMF and optionally uses audio quality improvement in - * accord with the preferences of the user. - * - * @param locator the MediaLocator to create the new instance from - * @param supportedFormats the list of Formats in which the new - * instance is to be capable of capturing audio data - * @param audioQualityImprovement true if audio quality improvement - * is to be enabled in accord with the preferences of the user or - * false to completely disable audio quality improvement - */ - public DataSource( - MediaLocator locator, - Format[] supportedFormats, - boolean audioQualityImprovement) - { - super(locator); - - this.supportedFormats - = (supportedFormats == null) - ? null - : supportedFormats.clone(); - this.audioQualityImprovement = audioQualityImprovement; - } - - /** - * Creates a new PullBufferStream which is to be at a specific - * zero-based index in the list of streams of this - * PullBufferDataSource. The Format-related information of - * the new instance is to be abstracted by a specific - * FormatControl. - * - * @param streamIndex the zero-based index of the PullBufferStream - * in the list of streams of this PullBufferDataSource - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - * @return a new PullBufferStream which is to be at the specified - * streamIndex in the list of streams of this - * PullBufferDataSource and which has its Format-related - * information abstracted by the specified formatControl - * @see AbstractPullBufferCaptureDevice#createStream(int, FormatControl) - */ - protected AbstractPullBufferStream createStream( - int streamIndex, - FormatControl formatControl) - { - return - new PortAudioStream(this, formatControl, audioQualityImprovement); - } - - /** - * Opens a connection to the media source specified by the - * MediaLocator of this DataSource. - * - * @throws IOException if anything goes wrong while opening the connection - * to the media source specified by the MediaLocator of this - * DataSource - * @see AbstractPullBufferCaptureDevice#doConnect() - */ - @Override - protected void doConnect() - throws IOException - { - super.doConnect(); - - int deviceIndex = getDeviceIndex(); - - synchronized (getStreamSyncRoot()) - { - for (Object stream : getStreams()) - ((PortAudioStream) stream).setDeviceIndex(deviceIndex); - } - } - - /** - * Closes the connection to the media source specified by the - * MediaLocator of this DataSource. Allows extenders to - * override and be sure that there will be no request to close a connection - * if the connection has not been opened yet. - */ - @Override - protected void doDisconnect() - { - try - { - synchronized (getStreamSyncRoot()) - { - Object[] streams = streams(); - - if (streams != null) - { - for (Object stream : streams) - { - try - { - ((PortAudioStream) stream).setDeviceIndex( - PortAudio.paNoDevice); - } - catch (IOException ioex) - { - logger.error( - "Failed to close " - + stream.getClass().getSimpleName(), - ioex); - } - } - } - } - } - finally - { - super.doDisconnect(); - } - } - - /** - * Gets the device index of the PortAudio device identified by the - * MediaLocator of this DataSource. - * - * @return the device index of a PortAudio device identified by the - * MediaLocator of this DataSource - */ - private int getDeviceIndex() - { - MediaLocator locator = getLocator(); - - if (locator == null) - throw new NullPointerException("locator"); - return getDeviceIndex(locator); - } - - /** - * Gets the device index of a PortAudio device from a specific - * MediaLocator identifying it. - * - * @param locator the MediaLocator identifying the device index of - * a PortAudio device to get - * @return the device index of a PortAudio device identified by - * locator - */ - public static int getDeviceIndex(MediaLocator locator) - { - if (AudioSystem.LOCATOR_PROTOCOL_PORTAUDIO.equalsIgnoreCase( - locator.getProtocol())) - { - return Integer.parseInt(locator.getRemainder().replace("#", "")); - } - else - { - throw new IllegalArgumentException("locator.protocol"); - } - } - - /** - * Gets the Formats which are to be reported by a - * FormatControl as supported formats for a - * PullBufferStream at a specific zero-based index in the list of - * streams of this PullBufferDataSource. - * - * @param streamIndex the zero-based index of the PullBufferStream - * for which the specified FormatControl is to report the list of - * supported Formats - * @return an array of Formats to be reported by a - * FormatControl as the supported formats for the - * PullBufferStream at the specified streamIndex in the - * list of streams of this PullBufferDataSource - * @see AbstractPullBufferCaptureDevice#getSupportedFormats(int) - */ - @Override - protected Format[] getSupportedFormats(int streamIndex) - { - return - (supportedFormats == null) - ? super.getSupportedFormats(streamIndex) - : supportedFormats; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/portaudio/PortAudioStream.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/portaudio/PortAudioStream.java deleted file mode 100644 index ea6195ecc..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/portaudio/PortAudioStream.java +++ /dev/null @@ -1,452 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.portaudio; - -import java.io.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; -import net.java.sip.communicator.impl.neomedia.portaudio.*; -import net.java.sip.communicator.util.*; - -/** - * Implements PullBufferStream for PortAudio. - * - * @author Damian Minkov - * @author Lyubomir Marinov - */ -public class PortAudioStream - extends AbstractPullBufferStream -{ - /** - * The Logger used by the PortAudioStream class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(PortAudioStream.class); - - /** - * The indicator which determines whether audio quality improvement is - * enabled for this PortAudioStream in accord with the preferences - * of the user. - */ - private final boolean audioQualityImprovement; - - /** - * The number of bytes to read from a native PortAudio stream in a single - * invocation. Based on {@link #framesPerBuffer}. - */ - private int bytesPerBuffer; - - /** - * The device index of the PortAudio device read through this - * PullBufferStream. - */ - private int deviceIndex = PortAudio.paNoDevice; - - /** - * The last-known Format of the media data made available by this - * PullBufferStream. - */ - private AudioFormat format; - - /** - * The number of frames to read from a native PortAudio stream in a single - * invocation. - */ - private int framesPerBuffer; - - /** - * The GainControl through which the volume/gain of captured media - * is controlled. - */ - private final GainControl gainControl; - - /** - * Native pointer to a PaStreamParameters object. - */ - private long inputParameters = 0; - - /** - * Current sequence number. - */ - private int sequenceNumber = 0; - - /** - * The input PortAudio stream represented by this instance. - */ - private long stream = 0; - - /** - * The indicator which determines whether {@link #stream} is busy and should - * not, for example, be closed. - */ - private boolean streamIsBusy = false; - - /** - * Initializes a new PortAudioStream instance which is to have its - * Format-related information abstracted by a specific - * FormatControl. - * - * @param dataSource the DataSource which is creating the new - * instance so that it becomes one of its streams - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - * @param audioQualityImprovement true to enable audio quality - * improvement for the new instance in accord with the preferences of the - * user or false to completely disable audio quality improvement - */ - public PortAudioStream( - DataSource dataSource, - FormatControl formatControl, - boolean audioQualityImprovement) - { - super(dataSource, formatControl); - - this.audioQualityImprovement = audioQualityImprovement; - - MediaServiceImpl mediaServiceImpl - = NeomediaActivator.getMediaServiceImpl(); - - gainControl - = (mediaServiceImpl == null) - ? null - : (GainControl) mediaServiceImpl.getInputVolumeControl(); - } - - /** - * Gets the Format of this PullBufferStream as directly - * known by it. - * - * @return the Format of this PullBufferStream as directly - * known by it or null if this PullBufferStream does not - * directly know its Format and it relies on the - * PullBufferDataSource which created it to report its - * Format - * @see AbstractPullBufferStream#doGetFormat() - */ - @Override - protected Format doGetFormat() - { - return (format == null) ? super.doGetFormat() : format; - } - - /** - * Reads media data from this PullBufferStream into a specific - * Buffer with blocking. - * - * @param buffer the Buffer in which media data is to be read from - * this PullBufferStream - * @throws IOException if anything goes wrong while reading media data from - * this PullBufferStream into the specified buffer - */ - public void read(Buffer buffer) - throws IOException - { - synchronized (this) - { - if (stream == 0) - { - buffer.setLength(0); - return; - } - else - streamIsBusy = true; - } - try - { - /* - * Reuse the data of buffer in order to not perform unnecessary - * allocations. - */ - Object data = buffer.getData(); - byte[] bufferData = null; - - if (data instanceof byte[]) - { - bufferData = (byte[]) data; - if (bufferData.length < bytesPerBuffer) - bufferData = null; - } - if (bufferData == null) - { - bufferData = new byte[bytesPerBuffer]; - buffer.setData(bufferData); - } - - try - { - PortAudio.Pa_ReadStream(stream, bufferData, framesPerBuffer); - } - catch (PortAudioException paex) - { - IOException ioex = new IOException(paex.getLocalizedMessage()); - - ioex.initCause(paex); - throw ioex; - } - - // if we have some volume setting apply them - if (gainControl != null) - { - AbstractVolumeControl.applyGain( - gainControl, - bufferData, 0, bytesPerBuffer); - } - - long bufferTimeStamp = System.nanoTime(); - - buffer.setFlags(Buffer.FLAG_SYSTEM_TIME); - if (format != null) - buffer.setFormat(format); - buffer.setHeader(null); - buffer.setLength(bytesPerBuffer); - buffer.setOffset(0); - buffer.setSequenceNumber(sequenceNumber++); - buffer.setTimeStamp(bufferTimeStamp); - } - finally - { - synchronized (this) - { - streamIsBusy = false; - notifyAll(); - } - } - } - - /** - * Sets the device index of the PortAudio device to be read through this - * PullBufferStream. - * - * @param deviceIndex the device index of the PortAudio device to be read - * through this PullBufferStream - * @throws IOException if input/output error occurred - */ - synchronized void setDeviceIndex(int deviceIndex) - throws IOException - { - if (this.deviceIndex == deviceIndex) - return; - - // DataSource#disconnect - if (this.deviceIndex != PortAudio.paNoDevice) - { - if (stream != 0) - { - try - { - PortAudio.Pa_CloseStream(stream); - } - catch (PortAudioException paex) - { - logger.error( - "Failed to close " + getClass().getSimpleName(), - paex); - - IOException ioex - = new IOException(paex.getLocalizedMessage()); - - ioex.initCause(paex); - throw ioex; - } - stream = 0; - if (inputParameters != 0) - { - PortAudio.PaStreamParameters_free(inputParameters); - inputParameters = 0; - } - - /* - * Make sure this AbstractPullBufferStream asks its DataSource - * for the Format in which it is supposed to output audio data - * next time it's opened instead of using its Format from a - * previous open. - */ - this.format = null; - } - } - this.deviceIndex = deviceIndex; - // DataSource#connect - if (this.deviceIndex != PortAudio.paNoDevice) - { - AudioFormat format = (AudioFormat) getFormat(); - int channels = format.getChannels(); - int sampleSizeInBits = format.getSampleSizeInBits(); - long sampleFormat = PortAudio.getPaSampleFormat(sampleSizeInBits); - double sampleRate = format.getSampleRate(); - int framesPerBuffer - = (int) - ((sampleRate * PortAudio.DEFAULT_MILLIS_PER_BUFFER) - / (channels * 1000)); - - try - { - inputParameters - = PortAudio.PaStreamParameters_new( - this.deviceIndex, - channels, - sampleFormat, - PortAudio.getSuggestedLatency()); - - stream - = PortAudio.Pa_OpenStream( - inputParameters, - 0 /* outputParameters */, - sampleRate, - framesPerBuffer, - PortAudio.STREAM_FLAGS_CLIP_OFF - | PortAudio.STREAM_FLAGS_DITHER_OFF, - null /* streamCallback */); - } - catch (PortAudioException paex) - { - logger.error( - "Failed to open " + getClass().getSimpleName(), - paex); - - IOException ioex = new IOException(paex.getLocalizedMessage()); - - ioex.initCause(paex); - throw ioex; - } - finally - { - if ((stream == 0) && (inputParameters != 0)) - { - PortAudio.PaStreamParameters_free(inputParameters); - inputParameters = 0; - } - } - if (stream == 0) - throw new IOException("Pa_OpenStream"); - - this.framesPerBuffer = framesPerBuffer; - bytesPerBuffer - = PortAudio.Pa_GetSampleSize(sampleFormat) - * channels - * framesPerBuffer; - - /* - * Know the Format in which this PortAudioStream will output audio - * data so that it can report it without going through its - * DataSource. - */ - this.format - = new AudioFormat( - AudioFormat.LINEAR, - sampleRate, - sampleSizeInBits, - channels, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED /* frameSizeInBits */, - Format.NOT_SPECIFIED /* frameRate */, - Format.byteArray); - - MediaServiceImpl mediaServiceImpl - = NeomediaActivator.getMediaServiceImpl(); - boolean denoise = DeviceConfiguration.DEFAULT_AUDIO_DENOISE; - boolean echoCancel = DeviceConfiguration.DEFAULT_AUDIO_ECHOCANCEL; - long echoCancelFilterLengthInMillis - = DeviceConfiguration - .DEFAULT_AUDIO_ECHOCANCEL_FILTER_LENGTH_IN_MILLIS; - - if (mediaServiceImpl != null) - { - DeviceConfiguration devCfg - = mediaServiceImpl.getDeviceConfiguration(); - - if (devCfg != null) - { - denoise = devCfg.isDenoise(); - echoCancel = devCfg.isEchoCancel(); - echoCancelFilterLengthInMillis - = devCfg.getEchoCancelFilterLengthInMillis(); - } - } - - PortAudio.setDenoise(stream, audioQualityImprovement && denoise); - PortAudio.setEchoFilterLengthInMillis( - stream, - (audioQualityImprovement && echoCancel) - ? echoCancelFilterLengthInMillis - : 0); - } - } - - /** - * Starts the transfer of media data from this PullBufferStream. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this PullBufferStream - */ - @Override - public synchronized void start() - throws IOException - { - try - { - PortAudio.Pa_StartStream(stream); - } - catch (PortAudioException paex) - { - logger.error("Failed to start " + getClass().getSimpleName(), paex); - - IOException ioex = new IOException(paex.getLocalizedMessage()); - - ioex.initCause(paex); - throw ioex; - } - } - - /** - * Stops the transfer of media data from this PullBufferStream. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this PullBufferStream - */ - @Override - public synchronized void stop() - throws IOException - { - boolean interrupted = false; - - while (streamIsBusy) - { - try - { - wait(); - } - catch (InterruptedException iex) - { - interrupted = true; - } - } - if (interrupted) - Thread.currentThread().interrupt(); - - try - { - PortAudio.Pa_StopStream(stream); - } - catch (PortAudioException paex) - { - logger.error("Failed to stop " + getClass().getSimpleName(), paex); - - IOException ioex = new IOException(paex.getLocalizedMessage()); - - ioex.initCause(paex); - throw ioex; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/pulseaudio/DataSource.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/pulseaudio/DataSource.java deleted file mode 100644 index 8967fd098..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/pulseaudio/DataSource.java +++ /dev/null @@ -1,649 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.pulseaudio; - -import java.io.*; -import java.util.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; -import net.java.sip.communicator.impl.neomedia.pulseaudio.*; -import net.java.sip.communicator.util.*; - -public class DataSource - extends AbstractPullBufferCaptureDevice -{ - /** - * The Logger used by the DataSource class and its - * instances for logging output. - */ - private static final Logger logger = Logger.getLogger(DataSource.class); - - private static final int BUFFER_IN_TENS_OF_MILLIS = 10; - - private static final boolean DEBUG = logger.isDebugEnabled(); - - private static final int FRAGSIZE_IN_TENS_OF_MILLIS = 2; - - private static final boolean SOFTWARE_GAIN; - - static { - boolean softwareGain = true; - - try - { - String libraryVersion = PA.get_library_version(); - - if (libraryVersion != null) - { - StringTokenizer st = new StringTokenizer(libraryVersion, "."); - int major = Integer.parseInt(st.nextToken()); - int minor = Integer.parseInt(st.nextToken()); - - if ((major >= 1) && (minor >= 0)) - { - softwareGain = false; - if (logger.isDebugEnabled()) - { - logger.debug( - "Will control the volume" - + " through the native PulseAudio API."); - } - } - } - } - catch (Throwable t) - { - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - } - SOFTWARE_GAIN = softwareGain; - } - - private class PulseAudioStream - extends AbstractPullBufferStream - { - private byte[] buffer; - - private int channels; - - private boolean corked = true; - - private long cvolume; - - private int fragsize; - - private final GainControl gainControl; - - private float gainControlLevel; - - private int length; - - private int offset; - - private final PulseAudioSystem pulseAudioSystem; - - private final PA.stream_request_cb_t readCallback - = new PA.stream_request_cb_t() - { - public void callback(long s, int nbytes) - { - readCallback(s, nbytes); - } - }; - - private long stream; - - public PulseAudioStream(FormatControl formatControl) - { - super(DataSource.this, formatControl); - - pulseAudioSystem = PulseAudioSystem.getPulseAudioSystem(); - if (pulseAudioSystem == null) - throw new IllegalStateException("pulseAudioSystem"); - - MediaServiceImpl mediaServiceImpl - = NeomediaActivator.getMediaServiceImpl(); - - gainControl - = (mediaServiceImpl == null) - ? null - : (GainControl) mediaServiceImpl.getInputVolumeControl(); - } - - public void read(Buffer buffer) - throws IOException - { - pulseAudioSystem.lockMainloop(); - try - { - if (stream == 0) - throw new IOException("stream"); - - Object data = buffer.getData(); - byte[] bytes; - - if (data instanceof byte[]) - { - bytes = (byte[]) data; - if (bytes.length < fragsize) - { - bytes = new byte[fragsize]; - buffer.setData(bytes); - } - } - else - { - bytes = new byte[fragsize]; - buffer.setData(bytes); - } - - int toRead = fragsize; - int offset = 0; - int length = 0; - - while (toRead > 0) - { - if (corked) - break; - - if (this.length <= 0) - { - pulseAudioSystem.waitMainloop(); - continue; - } - - int toCopy = (toRead < this.length) ? toRead : this.length; - - System.arraycopy( - this.buffer, this.offset, - bytes, offset, - toCopy); - - this.offset += toCopy; - this.length -= toCopy; - if (this.length <= 0) - { - this.offset = 0; - this.length = 0; - } - - toRead -= toCopy; - offset += toCopy; - length += toCopy; - } - - buffer.setFlags(Buffer.FLAG_SYSTEM_TIME); - buffer.setLength(length); - buffer.setOffset(0); - buffer.setTimeStamp(System.nanoTime()); - - if (gainControl != null) - { - if (SOFTWARE_GAIN || (cvolume == 0)) - { - if (length > 0) - { - AbstractVolumeControl.applyGain( - gainControl, - bytes, 0, length); - } - } - else - { - float gainControlLevel = gainControl.getLevel(); - - if (this.gainControlLevel != gainControlLevel) - { - this.gainControlLevel = gainControlLevel; - setStreamVolume(stream, gainControlLevel); - } - } - } - } - finally - { - pulseAudioSystem.unlockMainloop(); - } - } - - private void readCallback(long stream, int length) - { - try - { - int peeked; - - if (corked) - peeked = 0; - else - { - int offset; - - if ((buffer == null) || (buffer.length < length)) - { - buffer = new byte[length]; - this.offset = 0; - this.length = 0; - offset = 0; - } - else - { - offset = this.offset + this.length; - if (offset + length > buffer.length) - { - int overflow = this.length + length - buffer.length; - - if (overflow > 0) - { - if (overflow >= this.length) - { - if (DEBUG && logger.isDebugEnabled()) - { - logger.debug( - "Dropping " - + this.length - + " bytes!"); - } - this.offset = 0; - this.length = 0; - offset = 0; - } - else - { - if (DEBUG && logger.isDebugEnabled()) - { - logger.debug( - "Dropping " - + overflow - + " bytes!"); - } - this.offset += overflow; - this.length -= overflow; - } - } - if (this.length > 0) - { - for (int i = 0; - i < this.length; - i++, this.offset++) - { - buffer[i] = buffer[this.offset]; - } - this.offset = 0; - offset = this.length; - } - } - } - - peeked = PA.stream_peek(stream, buffer, offset); - } - - PA.stream_drop(stream); - this.length += peeked; - } - finally - { - pulseAudioSystem.signalMainloop(false); - } - } - - @SuppressWarnings("unused") - public void connect() - throws IOException - { - pulseAudioSystem.lockMainloop(); - try - { - connectWithMainloopLock(); - } - finally - { - pulseAudioSystem.unlockMainloop(); - } - } - - private void connectWithMainloopLock() - throws IOException - { - if (stream != 0) - return; - - AudioFormat format = (AudioFormat) getFormat(); - int sampleRate = (int) format.getSampleRate(); - int channels = format.getChannels(); - int sampleSizeInBits = format.getSampleSizeInBits(); - - if ((sampleRate == Format.NOT_SPECIFIED) - && (MediaUtils.MAX_AUDIO_SAMPLE_RATE - != Format.NOT_SPECIFIED)) - sampleRate = (int) MediaUtils.MAX_AUDIO_SAMPLE_RATE; - if (channels == Format.NOT_SPECIFIED) - channels = 1; - if (sampleSizeInBits == Format.NOT_SPECIFIED) - sampleSizeInBits = 16; - - long stream = 0; - Throwable exception = null; - - try - { - stream - = pulseAudioSystem.createStream( - sampleRate, - channels, - getClass().getName(), - PulseAudioSystem.MEDIA_ROLE_PHONE); - this.channels = channels; - } - catch (IllegalStateException ise) - { - exception = ise; - } - catch (RuntimeException re) - { - exception = re; - } - if (exception != null) - { - IOException ioe = new IOException(); - - ioe.initCause(exception); - throw ioe; - } - if (stream == 0) - throw new IOException("stream"); - - try - { - int bytesPerTenMillis - = (sampleRate / 100) * channels * (sampleSizeInBits / 8); - - fragsize = FRAGSIZE_IN_TENS_OF_MILLIS * bytesPerTenMillis; - buffer = new byte[BUFFER_IN_TENS_OF_MILLIS * bytesPerTenMillis]; - - long attr - = PA.buffer_attr_new( - -1, - -1, - -1, - -1, - fragsize); - - if (attr == 0) - throw new IOException("pa_buffer_attr_new"); - - try - { - Runnable stateCallback - = new Runnable() - { - public void run() - { - pulseAudioSystem.signalMainloop(false); - } - }; - - PA.stream_set_state_callback( - stream, - stateCallback); - PA.stream_connect_record( - stream, - getLocatorDev(), - attr, - PA.STREAM_ADJUST_LATENCY - | PA.STREAM_START_CORKED); - - try - { - if (attr != 0) - { - PA.buffer_attr_free(attr); - attr = 0; - } - - int state - = pulseAudioSystem.waitForStreamState( - stream, - PA.STREAM_READY); - - if (state != PA.STREAM_READY) - throw new IOException("stream.state"); - - PA.stream_set_read_callback( - stream, - readCallback); - - if (!SOFTWARE_GAIN && (gainControl != null)) - { - cvolume = PA.cvolume_new(); - - boolean freeCvolume = true; - - try - { - float gainControlLevel = gainControl.getLevel(); - - setStreamVolume(stream, gainControlLevel); - this.gainControlLevel = gainControlLevel; - freeCvolume = false; - } - finally - { - if (freeCvolume) - { - PA.cvolume_free(cvolume); - cvolume = 0; - } - } - } - - this.stream = stream; - } - finally - { - if (this.stream == 0) - PA.stream_disconnect(stream); - } - } - finally - { - if (attr != 0) - PA.buffer_attr_free(attr); - } - } - finally - { - if (this.stream == 0) - PA.stream_unref(stream); - } - } - - private void cork(boolean b) - throws IOException - { - try - { - PulseAudioSystem.corkStream(stream, b); - corked = b; - } - finally - { - pulseAudioSystem.signalMainloop(false); - } - } - - public void disconnect() - throws IOException - { - pulseAudioSystem.lockMainloop(); - try - { - long stream = this.stream; - - if (stream != 0) - { - try - { - stopWithMainloopLock(); - } - finally - { - long cvolume = this.cvolume; - - this.cvolume = 0; - this.stream = 0; - - buffer = null; - corked = true; - fragsize = 0; - length = 0; - offset = 0; - - pulseAudioSystem.signalMainloop(false); - - if (cvolume != 0) - PA.cvolume_free(cvolume); - PA.stream_disconnect(stream); - PA.stream_unref(stream); - } - } - } - finally - { - pulseAudioSystem.unlockMainloop(); - } - } - - private void setStreamVolume(long stream, float level) - { - int volume - = PA.sw_volume_from_linear( - level - * (AbstractVolumeControl.MAX_VOLUME_PERCENT / 100)); - - PA.cvolume_set(cvolume, channels, volume); - - long o - = PA.context_set_source_output_volume( - pulseAudioSystem.getContext(), - PA.stream_get_index(stream), - cvolume, - null); - - if (o != 0) - PA.operation_unref(o); - } - - @Override - public void start() - throws IOException - { - pulseAudioSystem.lockMainloop(); - try - { - if (stream == 0) - connectWithMainloopLock(); - - cork(false); - } - finally - { - pulseAudioSystem.unlockMainloop(); - } - - super.start(); - } - - @Override - public void stop() - throws IOException - { - pulseAudioSystem.lockMainloop(); - try - { - stopWithMainloopLock(); - } - finally - { - pulseAudioSystem.unlockMainloop(); - } - } - - private void stopWithMainloopLock() - throws IOException - { - if (stream != 0) - cork(true); - - super.stop(); - } - } - - /** - * Initializes a new DataSource instance. - */ - public DataSource() - { - } - - @Override - protected AbstractPullBufferStream createStream( - int streamIndex, - FormatControl formatControl) - { - return new PulseAudioStream(formatControl); - } - - protected void doDisconnect() - { - synchronized (getStreamSyncRoot()) - { - Object[] streams = streams(); - - if ((streams != null) && (streams.length != 0)) - { - for (Object stream : streams) - { - if (stream instanceof PulseAudioStream) - { - try - { - ((PulseAudioStream) stream).disconnect(); - } - catch (IOException ioe) - { - // Well, what can we do? - } - } - } - } - } - - super.doDisconnect(); - } - - private String getLocatorDev() - { - MediaLocator locator = getLocator(); - String locatorDev; - - if (locator == null) - locatorDev = null; - else - { - locatorDev = locator.getRemainder(); - if ((locatorDev != null) && (locatorDev.length() <= 0)) - locatorDev = null; - } - return locatorDev; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/quicktime/DataSource.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/quicktime/DataSource.java deleted file mode 100644 index 3497bc5fc..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/quicktime/DataSource.java +++ /dev/null @@ -1,511 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.quicktime; - -import java.awt.*; -import java.io.*; -import java.lang.reflect.*; -import java.util.*; -import java.util.List; // disambiguation - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.control.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; -import net.java.sip.communicator.impl.neomedia.quicktime.*; -import net.java.sip.communicator.util.*; - -/** - * Implements a PushBufferDataSource and CaptureDevice using - * QuickTime/QTKit. - * - * @author Lyubomir Marinov - */ -public class DataSource - extends AbstractVideoPushBufferCaptureDevice -{ - - /** - * The Logger used by the DataSource class and its - * instances for logging output. - */ - private static final Logger logger = Logger.getLogger(DataSource.class); - - /** - * The QTCaptureSession which captures from {@link #device} and - * pushes media data to the PushBufferStreams of this - * PushBufferDataSource. - */ - private QTCaptureSession captureSession; - - /** - * The QTCaptureDevice which represents the media source of this - * DataSource. - */ - private QTCaptureDevice device; - - /** - * The list of Formats to be reported by DataSource - * instances as supported formats. - */ - private static Format[] supportedFormats; - - /** - * Initializes a new DataSource instance. - */ - public DataSource() - { - } - - /** - * Initializes a new DataSource instance from a specific - * MediaLocator. - * - * @param locator the MediaLocator to create the new instance from - */ - public DataSource(MediaLocator locator) - { - super(locator); - } - - /** - * Overrides - * {@link AbstractVideoPushBufferCaptureDevice#createFrameRateControl()} to - * provide a FrameRateControl which gets and sets the frame rate of - * the QTCaptureDecompressedVideoOutput represented by the - * QuickTimeStream made available by this DataSource. - * - * {@inheritDoc} - * @see AbstractVideoPushBufferCaptureDevice#createFrameRateControl() - */ - @Override - protected FrameRateControl createFrameRateControl() - { - return - new FrameRateControlAdapter() - { - /** - * The output frame rate to be managed by this - * FrameRateControl when there is no - * QuickTimeStream to delegate to. - */ - private float frameRate = -1; - - @Override - public float getFrameRate() - { - float frameRate = -1; - boolean frameRateFromQuickTimeStream = false; - - synchronized (getStreamSyncRoot()) - { - Object[] streams = streams(); - - if ((streams != null) && (streams.length != 0)) - { - for (Object stream : streams) - { - QuickTimeStream quickTimeStream - = (QuickTimeStream) stream; - - if (quickTimeStream != null) - { - frameRate = quickTimeStream.getFrameRate(); - frameRateFromQuickTimeStream = true; - if (frameRate != -1) - break; - } - } - } - } - return - frameRateFromQuickTimeStream - ? frameRate - : this.frameRate; - } - - @Override - public float setFrameRate(float frameRate) - { - float setFrameRate = -1; - boolean frameRateFromQuickTimeStream = false; - - synchronized (getStreamSyncRoot()) - { - Object[] streams = streams(); - - if ((streams != null) && (streams.length != 0)) - { - for (Object stream : streams) - { - QuickTimeStream quickTimeStream - = (QuickTimeStream) stream; - - if (quickTimeStream != null) - { - float quickTimeStreamFrameRate - = quickTimeStream.setFrameRate( - frameRate); - - if (quickTimeStreamFrameRate != -1) - { - setFrameRate - = quickTimeStreamFrameRate; - } - frameRateFromQuickTimeStream = true; - } - } - } - } - if (frameRateFromQuickTimeStream) - return setFrameRate; - else - { - this.frameRate = frameRate; - return this.frameRate; - } - } - }; - } - - /** - * Creates a new PushBufferStream which is to be at a specific - * zero-based index in the list of streams of this - * PushBufferDataSource. The Format-related information of - * the new instance is to be abstracted by a specific - * FormatControl. - * - * @param streamIndex the zero-based index of the PushBufferStream - * in the list of streams of this PushBufferDataSource - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - * @return a new PushBufferStream which is to be at the specified - * streamIndex in the list of streams of this - * PushBufferDataSource and which has its Format-related - * information abstracted by the specified formatControl - * @see AbstractPushBufferCaptureDevice#createStream(int, FormatControl) - */ - protected AbstractPushBufferStream createStream( - int streamIndex, - FormatControl formatControl) - { - QuickTimeStream stream = new QuickTimeStream(this, formatControl); - - if (captureSession != null) - try - { - captureSession.addOutput(stream.captureOutput); - } - catch (NSErrorException nseex) - { - logger.error("Failed to addOutput to QTCaptureSession", nseex); - throw new UndeclaredThrowableException(nseex); - } - return stream; - } - - /** - * Opens a connection to the media source specified by the - * MediaLocator of this DataSource. - * - * @throws IOException if anything goes wrong while opening the connection - * to the media source specified by the MediaLocator of this - * DataSource - * @see AbstractPushBufferCaptureDevice#doConnect() - */ - @Override - protected void doConnect() - throws IOException - { - super.doConnect(); - - boolean deviceIsOpened; - - try - { - deviceIsOpened = device.open(); - } - catch (NSErrorException nseex) - { - IOException ioex = new IOException(); - - ioex.initCause(nseex); - throw ioex; - } - if (!deviceIsOpened) - throw new IOException("Failed to open QTCaptureDevice"); - - QTCaptureDeviceInput deviceInput - = QTCaptureDeviceInput.deviceInputWithDevice(device); - - captureSession = new QTCaptureSession(); - try - { - captureSession.addInput(deviceInput); - } - catch (NSErrorException nseex) - { - IOException ioex = new IOException(); - - ioex.initCause(nseex); - throw ioex; - } - - /* - * Add the QTCaptureOutputs represented by the QuickTimeStreams (if any) - * to the QTCaptureSession. - */ - synchronized (getStreamSyncRoot()) - { - Object[] streams = streams(); - - if (streams != null) - for (Object stream : streams) - if (stream != null) - try - { - captureSession - .addOutput( - ((QuickTimeStream) stream).captureOutput); - } - catch (NSErrorException nseex) - { - logger - .error( - "Failed to addOutput to QTCaptureSession", - nseex); - - IOException ioex = new IOException(); - - ioex.initCause(nseex); - throw ioex; - } - } - } - - /** - * Closes the connection to the media source specified by the - * MediaLocator of this DataSource. - * - * @see AbstractPushBufferCaptureDevice#doDisconnect() - */ - @Override - protected void doDisconnect() - { - super.doDisconnect(); - - if (captureSession != null) - { - captureSession.close(); - captureSession = null; - } - device.close(); - } - - /** - * Starts the transfer of media data from this DataSource. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this DataSource - * @see AbstractPushBufferCaptureDevice#doStart() - */ - @Override - protected void doStart() - throws IOException - { - captureSession.startRunning(); - - super.doStart(); - } - - /** - * Stops the transfer of media data from this DataSource. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this DataSource - * @see AbstractPushBufferCaptureDevice#doStop() - */ - @Override - protected void doStop() - throws IOException - { - super.doStop(); - - captureSession.stopRunning(); - } - - /** - * Gets the Formats which are to be reported by a - * FormatControl as supported formats for a - * PushBufferStream at a specific zero-based index in the list of - * streams of this PushBufferDataSource. - * - * @param streamIndex the zero-based index of the PushBufferStream - * for which the specified FormatControl is to report the list of - * supported Formats - * @return an array of Formats to be reported by a - * FormatControl as the supported formats for the - * PushBufferStream at the specified streamIndex in the - * list of streams of this PushBufferDataSource - * @see AbstractPushBufferCaptureDevice#getSupportedFormats(int) - */ - @Override - protected Format[] getSupportedFormats(int streamIndex) - { - return getSupportedFormats(super.getSupportedFormats(streamIndex)); - } - - /** - * Gets a list of Formats which are more specific than given - * Formats with respect to video size. The implementation tries to - * come up with sane video sizes (for example, by looking for codecs which - * accept the encodings of the specified generic Formats and using - * their sizes if any). - * - * @param genericFormats the Formats from which more specific are - * to be derived - * @return a list of Formats which are more specific than the given - * Formats with respect to video size - */ - private static synchronized Format[] getSupportedFormats( - Format[] genericFormats) - { - if ((supportedFormats != null) && (supportedFormats.length > 0)) - return supportedFormats.clone(); - - List specificFormats = new LinkedList(); - - for (Format genericFormat : genericFormats) - { - VideoFormat genericVideoFormat = (VideoFormat) genericFormat; - - if (genericVideoFormat.getSize() == null) - { - @SuppressWarnings("unchecked") - Vector codecs - = PlugInManager - .getPlugInList( - new VideoFormat(genericVideoFormat.getEncoding()), - null, - PlugInManager.CODEC); - - for (String codec : codecs) - { - Format[] supportedInputFormats - = PlugInManager - .getSupportedInputFormats( - codec, - PlugInManager.CODEC); - - for (Format supportedInputFormat : supportedInputFormats) - if (supportedInputFormat instanceof VideoFormat) - { - Dimension size - = ((VideoFormat) supportedInputFormat) - .getSize(); - - if (size != null) - specificFormats - .add( - genericFormat - .intersects( - new VideoFormat( - null, - size, - Format.NOT_SPECIFIED, - null, - Format.NOT_SPECIFIED))); - } - } - } - - specificFormats.add(genericFormat); - } - supportedFormats - = specificFormats.toArray(new Format[specificFormats.size()]); - return supportedFormats.clone(); - } - - /** - * Sets the QTCaptureDevice which represents the media source of - * this DataSource. - * - * @param device the QTCaptureDevice which represents the media - * source of this DataSource - */ - private void setDevice(QTCaptureDevice device) - { - if (this.device != device) - this.device = device; - } - - /** - * Attempts to set the Format to be reported by the - * FormatControl of a PushBufferStream at a specific - * zero-based index in the list of streams of this - * PushBufferDataSource. The PushBufferStream does not - * exist at the time of the attempt to set its Format. - * - * @param streamIndex the zero-based index of the PushBufferStream - * the Format of which is to be set - * @param oldValue the last-known Format for the - * PushBufferStream at the specified streamIndex - * @param newValue the Format which is to be set - * @return the Format to be reported by the FormatControl - * of the PushBufferStream at the specified streamIndex - * in the list of streams of this PushBufferStream or null - * if the attempt to set the Format did not success and any - * last-known Format is to be left in effect - * @see AbstractPushBufferCaptureDevice#setFormat(int, Format, Format) - */ - @Override - protected Format setFormat( - int streamIndex, - Format oldValue, Format newValue) - { - if (newValue instanceof VideoFormat) - { - // This DataSource supports setFormat. - return newValue; - } - else - return super.setFormat(streamIndex, oldValue, newValue); - } - - /** - * Sets the MediaLocator which specifies the media source of this - * DataSource. - * - * @param locator the MediaLocator which specifies the media source - * of this DataSource - * @see javax.media.protocol.DataSource#setLocator(MediaLocator) - */ - @Override - public void setLocator(MediaLocator locator) - { - super.setLocator(locator); - - locator = getLocator(); - - QTCaptureDevice device; - - if ((locator != null) - && DeviceSystem.LOCATOR_PROTOCOL_QUICKTIME.equalsIgnoreCase( - locator.getProtocol())) - { - String deviceUID = locator.getRemainder(); - - device = QTCaptureDevice.deviceWithUniqueID(deviceUID); - } - else - device = null; - setDevice(device); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/quicktime/QuickTimeStream.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/quicktime/QuickTimeStream.java deleted file mode 100644 index cb1f7eac0..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/quicktime/QuickTimeStream.java +++ /dev/null @@ -1,786 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.quicktime; - -import java.awt.Dimension; // disambiguation -import java.io.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; -import net.java.sip.communicator.impl.neomedia.quicktime.*; - -/** - * Implements a PushBufferStream using QuickTime/QTKit. - * - * @author Lyubomir Marinov - */ -public class QuickTimeStream - extends AbstractPushBufferStream -{ - - /** - * The indicator which determines whether {@link #captureOutput} - * automatically drops late frames. If false, we have to drop them - * ourselves because QuickTime/QTKit will buffer them all and the video will - * be late. - */ - private final boolean automaticallyDropsLateVideoFrames; - - /** - * The pool of ByteBuffers this instances is using to transfer the - * media data captured by {@link #captureOutput} out of this instance - * through the Buffers specified in its {@link #read(Buffer)}. - */ - private final ByteBufferPool byteBufferPool = new ByteBufferPool(); - - /** - * The QTCaptureOutput represented by this SourceStream. - */ - final QTCaptureDecompressedVideoOutput captureOutput - = new QTCaptureDecompressedVideoOutput(); - - /** - * The VideoFormat which has been successfully set on - * {@link #captureOutput}. - */ - private VideoFormat captureOutputFormat; - - /** - * The captured media data to be returned in {@link #read(Buffer)}. - */ - private ByteBuffer data; - - /** - * The Format of {@link #data} if known. If possible, determined by - * the CVPixelBuffer video frame from which data is - * acquired. - */ - private Format dataFormat; - - /** - * The Object which synchronizes the access to the - * {@link #data}-related fields of this instance. - */ - private final Object dataSyncRoot = new Object(); - - /** - * The time stamp in nanoseconds of {@link #data}. - */ - private long dataTimeStamp; - - /** - * The last-known Format of the media data made available by this - * PushBufferStream. - */ - private Format format; - - /** - * The captured media data to become the value of {@link #data} as soon as - * the latter becomes is consumed. Thus prepares this - * QuickTimeStream to provide the latest available frame and not - * wait for QuickTime/QTKit to capture a new one. - */ - private ByteBuffer nextData; - - /** - * The Format of {@link #nextData} if known. - */ - private Format nextDataFormat; - - /** - * The time stamp in nanoseconds of {@link #nextData}. - */ - private long nextDataTimeStamp; - - /** - * The Thread which is to call - * {@link BufferTransferHandler#transferData(PushBufferStream)} for this - * QuickTimeStream so that the call is not made in QuickTime/QTKit - * and we can drop late frames when - * {@link #automaticallyDropsLateVideoFrames} is false. - */ - private Thread transferDataThread; - - /** - * Initializes a new QuickTimeStream instance which is to have its - * Format-related information abstracted by a specific - * FormatControl. - * - * @param dataSource the DataSource which is creating the new - * instance so that it becomes one of its streams - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - */ - QuickTimeStream(DataSource dataSource, FormatControl formatControl) - { - super(dataSource, formatControl); - - if (formatControl != null) - { - Format format = formatControl.getFormat(); - - if (format != null) - setCaptureOutputFormat(format); - } - - automaticallyDropsLateVideoFrames - = captureOutput.setAutomaticallyDropsLateVideoFrames(true); - captureOutput.setDelegate( - new QTCaptureDecompressedVideoOutput.Delegate() - { - - /** - * Notifies this Delegate that the - * QTCaptureOutput to which it is set has output a - * specific CVImageBuffer representing a video - * frame with a specific QTSampleBuffer. - * - * @param videoFrame the CVImageBuffer which - * represents the output video frame - * @param sampleBuffer the QTSampleBuffer which - * represents additional details about the output video - * samples - */ - public void outputVideoFrameWithSampleBuffer( - CVImageBuffer videoFrame, - QTSampleBuffer sampleBuffer) - { - captureOutputDidOutputVideoFrameWithSampleBuffer( - captureOutput, - videoFrame, - sampleBuffer); - } - }); - - FrameRateControl frameRateControl - = (FrameRateControl) - dataSource.getControl(FrameRateControl.class.getName()); - - if (frameRateControl != null) - { - float frameRate = frameRateControl.getFrameRate(); - - if (frameRate > 0) - setFrameRate(frameRate); - } - } - - /** - * Notifies this instance that its QTCaptureOutput has output a - * specific CVImageBuffer representing a video frame with a - * specific QTSampleBuffer. - * - * @param captureOutput the QTCaptureOutput which has output a - * video frame - * @param videoFrame the CVImageBuffer which represents the output - * video frame - * @param sampleBuffer the QTSampleBuffer which represents - * additional details about the output video samples - */ - private void captureOutputDidOutputVideoFrameWithSampleBuffer( - QTCaptureOutput captureOutput, - CVImageBuffer videoFrame, - QTSampleBuffer sampleBuffer) - { - CVPixelBuffer pixelBuffer = (CVPixelBuffer) videoFrame; - boolean transferData; - Format videoFrameFormat = getVideoFrameFormat(pixelBuffer); - - synchronized (dataSyncRoot) - { - if (!automaticallyDropsLateVideoFrames && (data != null)) - { - if (nextData != null) - { - byteBufferPool.returnFreeBuffer(nextData); - nextData = null; - } - - nextData - = byteBufferPool.getFreeBuffer(pixelBuffer.getByteCount()); - if (nextData != null) - { - nextData.setLength( - pixelBuffer.getBytes( - nextData.ptr, - nextData.capacity)); - nextDataTimeStamp = System.nanoTime(); - if (nextDataFormat == null) - nextDataFormat = videoFrameFormat; - } - return; - } - - if (data != null) - { - byteBufferPool.returnFreeBuffer(data); - data = null; - } - - data = byteBufferPool.getFreeBuffer(pixelBuffer.getByteCount()); - if (data != null) - { - data.setLength(pixelBuffer.getBytes(data.ptr, data.capacity)); - dataTimeStamp = System.nanoTime(); - if (dataFormat == null) - dataFormat = videoFrameFormat; - } - if (nextData != null) - { - byteBufferPool.returnFreeBuffer(nextData); - nextData = null; - } - - if (automaticallyDropsLateVideoFrames) - transferData = (data != null); - else - { - transferData = false; - dataSyncRoot.notifyAll(); - } - } - - if (transferData) - { - BufferTransferHandler transferHandler = this.transferHandler; - - if (transferHandler != null) - transferHandler.transferData(this); - } - } - - /** - * Releases the resources used by this instance throughout its existence and - * makes it available for garbage collection. This instance is considered - * unusable after closing. - * - * @see AbstractPushBufferStream#close() - */ - @Override - public void close() - { - super.close(); - - captureOutput.setDelegate(null); - - byteBufferPool.close(); - } - - /** - * Gets the Format of this PushBufferStream as directly - * known by it. - * - * @return the Format of this PushBufferStream as directly - * known by it or null if this PushBufferStream does not - * directly know its Format and it relies on the - * PushBufferDataSource which created it to report its - * Format - */ - @Override - protected Format doGetFormat() - { - Format format; - - if (this.format == null) - { - format = getCaptureOutputFormat(); - if (format == null) - format = super.doGetFormat(); - else - { - VideoFormat videoFormat = (VideoFormat) format; - - if (videoFormat.getSize() != null) - this.format = format; - else - { - Dimension defaultSize - = NeomediaActivator - .getMediaServiceImpl() - .getDeviceConfiguration() - .getVideoSize(); - - format - = videoFormat.intersects( - new VideoFormat( - null, - new Dimension( - defaultSize.width, - defaultSize.height), - Format.NOT_SPECIFIED, - Format.byteArray, - Format.NOT_SPECIFIED)); - } - } - } - else - format = this.format; - return format; - } - - /** - * Gets the Format of the media data made available by this - * PushBufferStream as indicated by {@link #captureOutput}. - * - * @return the Format of the media data made available by this - * PushBufferStream as indicated by {@link #captureOutput} - */ - private Format getCaptureOutputFormat() - { - NSDictionary pixelBufferAttributes - = captureOutput.pixelBufferAttributes(); - - if (pixelBufferAttributes != null) - { - int pixelFormatType - = pixelBufferAttributes - .intForKey( - CVPixelBufferAttributeKey - .kCVPixelBufferPixelFormatTypeKey); - int width - = pixelBufferAttributes - .intForKey( - CVPixelBufferAttributeKey.kCVPixelBufferWidthKey); - int height - = pixelBufferAttributes - .intForKey( - CVPixelBufferAttributeKey.kCVPixelBufferHeightKey); - - switch (pixelFormatType) - { - case CVPixelFormatType.kCVPixelFormatType_32ARGB: - if (captureOutputFormat instanceof AVFrameFormat) - return - new AVFrameFormat( - ((width == 0) && (height == 0) - ? null - : new Dimension(width, height)), - Format.NOT_SPECIFIED, - FFmpeg.PIX_FMT_ARGB, - CVPixelFormatType.kCVPixelFormatType_32ARGB); - else - return - new RGBFormat( - ((width == 0) && (height == 0) - ? null - : new Dimension(width, height)), - Format.NOT_SPECIFIED, - Format.byteArray, - Format.NOT_SPECIFIED, - 32, - 2, 3, 4); - case CVPixelFormatType.kCVPixelFormatType_420YpCbCr8Planar: - if ((width == 0) && (height == 0)) - { - if (captureOutputFormat instanceof AVFrameFormat) - return - new AVFrameFormat( - FFmpeg.PIX_FMT_YUV420P, - CVPixelFormatType - .kCVPixelFormatType_420YpCbCr8Planar); - else - return new YUVFormat(YUVFormat.YUV_420); - } - else if (captureOutputFormat instanceof AVFrameFormat) - { - return - new AVFrameFormat( - new Dimension(width, height), - Format.NOT_SPECIFIED, - FFmpeg.PIX_FMT_YUV420P, - CVPixelFormatType. - kCVPixelFormatType_420YpCbCr8Planar); - } - else - { - int strideY = width; - int strideUV = strideY / 2; - int offsetY = 0; - int offsetU = strideY * height; - int offsetV = offsetU + strideUV * height / 2; - - return - new YUVFormat( - new Dimension(width, height), - Format.NOT_SPECIFIED, - Format.byteArray, - Format.NOT_SPECIFIED, - YUVFormat.YUV_420, - strideY, strideUV, - offsetY, offsetU, offsetV); - } - } - } - return null; - } - - /** - * Gets the output frame rate of the - * QTCaptureDecompressedVideoOutput represented by this - * QuickTimeStream. - * - * @return the output frame rate of the - * QTCaptureDecompressedVideoOutput represented by this - * QuickTimeStream - */ - public float getFrameRate() - { - return (float) (1.0d / captureOutput.minimumVideoFrameInterval()); - } - - /** - * Gets the Format of the media data made available by this - * PushBufferStream as indicated by a specific - * CVPixelBuffer. - * - * @param videoFrame the CVPixelBuffer which provides details about - * the Format of the media data made available by this - * PushBufferStream - * @return the Format of the media data made available by this - * PushBufferStream as indicated by the specified - * CVPixelBuffer - */ - private Format getVideoFrameFormat(CVPixelBuffer videoFrame) - { - Format format = getFormat(); - Dimension size = ((VideoFormat) format).getSize(); - - if ((size == null) || ((size.width == 0) && (size.height == 0))) - format - = format - .intersects( - new VideoFormat( - null, - new Dimension( - videoFrame.getWidth(), - videoFrame.getHeight()), - Format.NOT_SPECIFIED, - Format.byteArray, - Format.NOT_SPECIFIED)); - return format; - } - - /** - * Reads media data from this PushBufferStream into a specific - * Buffer without blocking. - * - * @param buffer the Buffer in which media data is to be read from - * this PushBufferStream - * @throws IOException if anything goes wrong while reading media data from - * this PushBufferStream into the specified buffer - */ - public void read(Buffer buffer) - throws IOException - { - synchronized (dataSyncRoot) - { - if (data == null) - { - buffer.setLength(0); - return; - } - - if (dataFormat != null) - buffer.setFormat(dataFormat); - - Format bufferFormat = buffer.getFormat(); - - if (bufferFormat == null) - { - bufferFormat = getFormat(); - if (bufferFormat != null) - buffer.setFormat(bufferFormat); - } - if (bufferFormat instanceof AVFrameFormat) - { - FinalizableAVFrame.read( - buffer, - bufferFormat, - data, - byteBufferPool); - } - else - { - Object bufferData = buffer.getData(); - byte[] bufferByteData; - int dataLength = data.getLength(); - - if (bufferData instanceof byte[]) - { - bufferByteData = (byte[]) bufferData; - if (bufferByteData.length < dataLength) - bufferByteData = null; - } - else - bufferByteData = null; - if (bufferByteData == null) - { - bufferByteData = new byte[dataLength]; - buffer.setData(bufferByteData); - } - CVPixelBuffer.memcpy(bufferByteData, 0, dataLength, data.ptr); - - buffer.setLength(dataLength); - buffer.setOffset(0); - - byteBufferPool.returnFreeBuffer(data); - } - - buffer.setFlags(Buffer.FLAG_LIVE_DATA | Buffer.FLAG_SYSTEM_TIME); - buffer.setTimeStamp(dataTimeStamp); - - data = null; - if (!automaticallyDropsLateVideoFrames) - dataSyncRoot.notifyAll(); - } - } - - /** - * Calls {@link BufferTransferHandler#transferData(PushBufferStream)} from - * inside {@link #transferDataThread} so that the call is not made in - * QuickTime/QTKit and we can drop late frames in the meantime. - */ - private void runInTransferDataThread() - { - boolean transferData = false; - - while (Thread.currentThread().equals(transferDataThread)) - { - if (transferData) - { - BufferTransferHandler transferHandler = this.transferHandler; - - if (transferHandler != null) - transferHandler.transferData(this); - - synchronized (dataSyncRoot) - { - if (data != null) - { - byteBufferPool.returnFreeBuffer(data); - data = null; - } - - data = nextData; - dataTimeStamp = nextDataTimeStamp; - if (dataFormat == null) - dataFormat = nextDataFormat; - nextData = null; - } - } - - synchronized (dataSyncRoot) - { - if (data == null) - { - data = nextData; - dataTimeStamp = nextDataTimeStamp; - if (dataFormat == null) - dataFormat = nextDataFormat; - nextData = null; - } - if (data == null) - { - boolean interrupted = false; - - try - { - dataSyncRoot.wait(); - } - catch (InterruptedException iex) - { - interrupted = true; - } - if (interrupted) - Thread.currentThread().interrupt(); - - transferData = (data != null); - } - else - transferData = true; - } - } - } - - /** - * Sets the Format of the media data made available by this - * PushBufferStream to {@link #captureOutput}. - * - * @param format the Format of the media data made available by - * this PushBufferStream to be set to {@link #captureOutput} - */ - private void setCaptureOutputFormat(Format format) - { - VideoFormat videoFormat = (VideoFormat) format; - Dimension size = videoFormat.getSize(); - int width; - int height; - - /* - * FIXME Mac OS X Leopard does not seem to report the size of the - * QTCaptureDevice in its formatDescriptions early in its creation. - * The workaround presented here is to just force a specific size. - */ - if (size == null) - { - Dimension defaultSize - = NeomediaActivator - .getMediaServiceImpl() - .getDeviceConfiguration() - .getVideoSize(); - - width = defaultSize.width; - height = defaultSize.height; - } - else - { - width = size.width; - height = size.height; - } - - NSMutableDictionary pixelBufferAttributes = null; - - if ((width > 0) && (height > 0)) - { - if (pixelBufferAttributes == null) - pixelBufferAttributes = new NSMutableDictionary(); - pixelBufferAttributes.setIntForKey( - width, - CVPixelBufferAttributeKey.kCVPixelBufferWidthKey); - pixelBufferAttributes.setIntForKey( - height, - CVPixelBufferAttributeKey.kCVPixelBufferHeightKey); - } - - String encoding; - - if (format instanceof AVFrameFormat) - { - int pixFmt = ((AVFrameFormat) format).getPixFmt(); - - if (pixFmt == FFmpeg.PIX_FMT_YUV420P) - encoding = VideoFormat.YUV; - else if (pixFmt == FFmpeg.PIX_FMT_ARGB) - encoding = VideoFormat.RGB; - else - encoding = null; - } - else if (format.isSameEncoding(VideoFormat.RGB)) - encoding = VideoFormat.RGB; - else if (format.isSameEncoding(VideoFormat.YUV)) - encoding = VideoFormat.YUV; - else - encoding = null; - - if (VideoFormat.RGB.equalsIgnoreCase(encoding)) - { - if (pixelBufferAttributes == null) - pixelBufferAttributes = new NSMutableDictionary(); - pixelBufferAttributes.setIntForKey( - CVPixelFormatType.kCVPixelFormatType_32ARGB, - CVPixelBufferAttributeKey.kCVPixelBufferPixelFormatTypeKey); - } - else if (VideoFormat.YUV.equalsIgnoreCase(encoding)) - { - if (pixelBufferAttributes == null) - pixelBufferAttributes = new NSMutableDictionary(); - pixelBufferAttributes.setIntForKey( - CVPixelFormatType.kCVPixelFormatType_420YpCbCr8Planar, - CVPixelBufferAttributeKey.kCVPixelBufferPixelFormatTypeKey); - } - else - throw new IllegalArgumentException("format"); - - if (pixelBufferAttributes != null) - { - captureOutput.setPixelBufferAttributes(pixelBufferAttributes); - captureOutputFormat = videoFormat; - } - } - - /** - * Sets the output frame rate of the - * QTCaptureDecompressedVideoOutput represented by this - * QuickTimeStream. - * - * @param frameRate the output frame rate to be set on the - * QTCaptureDecompressedVideoOutput represented by this - * QuickTimeStream - * @return the output frame rate of the - * QTCaptureDecompressedVideoOutput represented by this - * QuickTimeStream - */ - public float setFrameRate(float frameRate) - { - captureOutput.setMinimumVideoFrameInterval(1.0d / frameRate); - return getFrameRate(); - } - - /** - * Starts the transfer of media data from this PushBufferStream. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this PushBufferStream - */ - @Override - public void start() - throws IOException - { - if (!automaticallyDropsLateVideoFrames) - { - transferDataThread - = new Thread(getClass().getSimpleName()) - { - @Override - public void run() - { - runInTransferDataThread(); - } - }; - transferDataThread.start(); - } - } - - /** - * Stops the transfer of media data from this PushBufferStream. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this PushBufferStream - */ - @Override - public void stop() - throws IOException - { - transferDataThread = null; - - synchronized (dataSyncRoot) - { - if (data != null) - { - byteBufferPool.returnFreeBuffer(data); - data = null; - } - dataFormat = null; - if (nextData != null) - { - byteBufferPool.returnFreeBuffer(nextData); - nextData = null; - } - nextDataFormat = null; - - if (!automaticallyDropsLateVideoFrames) - dataSyncRoot.notifyAll(); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/video4linux2/DataSource.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/video4linux2/DataSource.java deleted file mode 100644 index 64e861426..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/video4linux2/DataSource.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.video4linux2; - -import java.io.*; - -import javax.media.*; -import javax.media.control.*; - -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; - -/** - * Implements a PullBufferDataSource and CaptureDevice using - * the Video for Linux Two API Specification. - * - * @author Lyubomir Marinov - */ -public class DataSource - extends AbstractVideoPullBufferCaptureDevice -{ - /** - * The map of Video for Linux Two API Specification pixel formats to FFmpeg - * pixel formats which allows converting between the two. - */ - private static final int[] V4L2_TO_FFMPEG_PIX_FMT - = new int[] - { - Video4Linux2.V4L2_PIX_FMT_UYVY, - FFmpeg.PIX_FMT_UYVY422, - Video4Linux2.V4L2_PIX_FMT_YUV420, - FFmpeg.PIX_FMT_YUV420P, - Video4Linux2.V4L2_PIX_FMT_YUYV, - FFmpeg.PIX_FMT_YUYV422, - Video4Linux2.V4L2_PIX_FMT_MJPEG, - FFmpeg.PIX_FMT_YUVJ422P, - Video4Linux2.V4L2_PIX_FMT_JPEG, - FFmpeg.PIX_FMT_YUVJ422P, - Video4Linux2.V4L2_PIX_FMT_RGB24, - FFmpeg.PIX_FMT_RGB24_1, - Video4Linux2.V4L2_PIX_FMT_BGR24, - FFmpeg.PIX_FMT_BGR24_1, - }; - - /** - * The file descriptor of the opened Video for Linux Two API Specification - * device represented by this DataSource. - */ - private int fd = -1; - - /** - * Initializes a new DataSource instance. - */ - public DataSource() - { - } - - /** - * Initializes a new DataSource instance from a specific - * MediaLocator. - * - * @param locator the MediaLocator to create the new instance from - */ - public DataSource(MediaLocator locator) - { - super(locator); - } - - /** - * Creates a new PullBufferStream which is to be at a specific - * zero-based index in the list of streams of this - * PullBufferDataSource. The Format-related information of - * the new instance is to be abstracted by a specific - * FormatControl. - * - * @param streamIndex the zero-based index of the PullBufferStream - * in the list of streams of this PullBufferDataSource - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - * @return a new PullBufferStream which is to be at the specified - * streamIndex in the list of streams of this - * PullBufferDataSource and which has its Format-related - * information abstracted by the specified formatControl - */ - protected Video4Linux2Stream createStream( - int streamIndex, - FormatControl formatControl) - { - return new Video4Linux2Stream(this, formatControl); - } - - /** - * Opens a connection to the media source specified by the - * MediaLocator of this DataSource. - * - * @throws IOException if anything goes wrong while opening the connection - * to the media source specified by the MediaLocator of this - * DataSource - * @see AbstractPullBufferCaptureDevice#doConnect() - */ - @Override - protected void doConnect() - throws IOException - { - super.doConnect(); - - String deviceName = getDeviceName(); - int fd = Video4Linux2.open(deviceName, Video4Linux2.O_RDWR); - - if (-1 == fd) - throw new IOException("Failed to open " + deviceName); - else - { - boolean close = true; - - try - { - synchronized (getStreamSyncRoot()) - { - for (Object stream : getStreams()) - ((Video4Linux2Stream) stream).setFd(fd); - } - close = false; - } - finally - { - if (close) - { - Video4Linux2.close(fd); - fd = -1; - } - } - this.fd = fd; - } - } - - /** - * Closes the connection to the media source specified by the - * MediaLocator of this DataSource. - */ - protected void doDisconnect() - { - try - { - /* - * Letting the Video4Linux2Stream know that the fd is going to be - * closed is necessary at least because - * AbstractPullBufferStream#close() is not guaranteed. - */ - synchronized (getStreamSyncRoot()) - { - Object[] streams = streams(); - - if (streams != null) - { - for (Object stream : streams) - { - try - { - ((Video4Linux2Stream) stream).setFd(-1); - } - catch (IOException ioex) - { - } - } - } - } - } - finally - { - try - { - super.doDisconnect(); - } - finally - { - Video4Linux2.close(fd); - } - } - } - - /** - * Gets the name of the Video for Linux Two API Specification device which - * represents the media source of this DataSource. - * - * @return the name of the Video for Linux Two API Specification device - * which represents the media source of this DataSource - */ - private String getDeviceName() - { - MediaLocator locator = getLocator(); - - return - ((locator != null) - && DeviceSystem.LOCATOR_PROTOCOL_VIDEO4LINUX2 - .equalsIgnoreCase(locator.getProtocol())) - ? locator.getRemainder() - : null; - } - - /** - * Gets the Video for Linux Two API Specification pixel format matching a - * specific FFmpeg pixel format. - * - * @param v4l2PixFmt the FFmpeg pixel format to get the matching Video for - * Linux Two API Specification pixel format of - * @return the Video for Linux Two API Specification pixel format matching - * the specified FFmpeg format - */ - public static int getFFmpegPixFmt(int v4l2PixFmt) - { - for (int i = 0; i < V4L2_TO_FFMPEG_PIX_FMT.length; i += 2) - if (V4L2_TO_FFMPEG_PIX_FMT[i] == v4l2PixFmt) - return V4L2_TO_FFMPEG_PIX_FMT[i + 1]; - return FFmpeg.PIX_FMT_NONE; - } - - /** - * Gets the FFmpeg pixel format matching a specific Video for Linux Two API - * Specification pixel format. - * - * @param ffmpegPixFmt the Video for Linux Two API Specification pixel format - * to get the matching FFmpeg pixel format of - * @return the FFmpeg pixel format matching the specified Video for Linux - * Two API Specification pixel format - */ - public static int getV4L2PixFmt(int ffmpegPixFmt) - { - for (int i = 0; i < V4L2_TO_FFMPEG_PIX_FMT.length; i += 2) - if (V4L2_TO_FFMPEG_PIX_FMT[i + 1] == ffmpegPixFmt) - return V4L2_TO_FFMPEG_PIX_FMT[i]; - return Video4Linux2.V4L2_PIX_FMT_NONE; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/video4linux2/Video4Linux2.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/video4linux2/Video4Linux2.java deleted file mode 100644 index 068b484f3..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/video4linux2/Video4Linux2.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.video4linux2; - -/** - * Provides the interface to the native Video for Linux Two API Specification - * (http://v4l2spec.bytesex.org/spec/) implementation. - * - * @author Lubomir Marinov - */ -public class Video4Linux2 -{ - public static final int MAP_SHARED = 0x01; - - public static final int O_NONBLOCK = 00004000; - - public static final int O_RDWR = 00000002; - - public static final int PROT_READ = 0x1; - - public static final int PROT_WRITE = 0x2; - - public static final int V4L2_BUF_TYPE_VIDEO_CAPTURE = 1; - - public static final int V4L2_CAP_STREAMING = 0x04000000; - - public static final int V4L2_CAP_VIDEO_CAPTURE = 0x00000001; - - public static final int V4L2_FIELD_NONE = 1; - - public static final int V4L2_MEMORY_MMAP = 1; - - public static final int V4L2_MEMORY_USERPTR = 2; - - public static final int V4L2_PIX_FMT_NONE = 0; - - public static final int V4L2_PIX_FMT_RGB24 - = v4l2_fourcc('R', 'G', 'B', '3'); - - public static final int V4L2_PIX_FMT_BGR24 - = v4l2_fourcc('B', 'G', 'R', '3'); - - public static final int V4L2_PIX_FMT_UYVY - = v4l2_fourcc('U', 'Y', 'V', 'Y'); - - public static final int V4L2_PIX_FMT_VYUY - = v4l2_fourcc('V', 'Y', 'U', 'Y'); - - public static final int V4L2_PIX_FMT_YUV420 - = v4l2_fourcc('Y', 'U', '1', '2'); - - public static final int V4L2_PIX_FMT_YUYV - = v4l2_fourcc('Y', 'U', 'Y', 'V'); - - public static final int V4L2_PIX_FMT_MJPEG - = v4l2_fourcc('M', 'J', 'P', 'G'); - - public static final int V4L2_PIX_FMT_JPEG - = v4l2_fourcc('J', 'P', 'E', 'G'); - - public static final int VIDIOC_DQBUF; - - public static final int VIDIOC_G_FMT; - - public static final int VIDIOC_QBUF; - - public static final int VIDIOC_QUERYBUF; - - public static final int VIDIOC_QUERYCAP; - - public static final int VIDIOC_REQBUFS; - - public static final int VIDIOC_S_FMT; - - public static final int VIDIOC_S_PARM; - - public static final int VIDIOC_STREAMOFF; - - public static final int VIDIOC_STREAMON; - - static - { - System.loadLibrary("jnvideo4linux2"); - - VIDIOC_DQBUF = VIDIOC_DQBUF(); - VIDIOC_G_FMT = VIDIOC_G_FMT(); - VIDIOC_QBUF = VIDIOC_QBUF(); - VIDIOC_QUERYBUF = VIDIOC_QUERYBUF(); - VIDIOC_QUERYCAP = VIDIOC_QUERYCAP(); - VIDIOC_REQBUFS = VIDIOC_REQBUFS(); - VIDIOC_S_FMT = VIDIOC_S_FMT(); - VIDIOC_S_PARM = VIDIOC_S_PARM(); - VIDIOC_STREAMOFF = VIDIOC_STREAMOFF(); - VIDIOC_STREAMON = VIDIOC_STREAMON(); - } - - public static native int close(int fd); - - public static native void free(long ptr); - - public static native int ioctl(int fd, int request, long argp); - - public static native long memcpy(long dest, long src, int n); - - public static native long mmap( - long start, - int length, - int prot, - int flags, - int fd, - long offset); - - public static native int munmap(long start, int length); - - public static native int open(String deviceName, int flags); - - public static native long v4l2_buffer_alloc(int type); - - public static native int v4l2_buffer_getBytesused(long v4l2_buffer); - - public static native int v4l2_buffer_getIndex(long v4l2_buffer); - - public static native int v4l2_buffer_getLength(long v4l2_buffer); - - public static native long v4l2_buffer_getMOffset(long v4l2_buffer); - - public static native void v4l2_buffer_setIndex( - long v4l2_buffer, - int index); - - public static native void v4l2_buffer_setMemory( - long v4l2_buffer, - int memory); - - public static native long v4l2_buf_type_alloc(int type); - - public static native long v4l2_capability_alloc(); - - public static native int v4l2_capability_getCapabilities( - long v4l2_capability); - - public static native String v4l2_capability_getCard( - long v4l2_capability); - - private static int v4l2_fourcc(char a, char b, char c, char d) - { - return - (a & 0xFF) - | ((b & 0xFF) << 8) - | ((c & 0xFF) << 16) - | ((d & 0xFF) << 24); - } - - public static native long v4l2_format_alloc(int type); - - public static native long v4l2_format_getFmtPix(long v4l2_format); - - public static native int v4l2_pix_format_getHeight( - long v4l2_pix_format); - - public static native int v4l2_pix_format_getPixelformat( - long v4l2_pix_format); - - public static native int v4l2_pix_format_getWidth(long v4l2_pix_format); - - public static native void v4l2_pix_format_setBytesperline( - long v4l2_pix_format, - int bytesperline); - - public static native void v4l2_pix_format_setField( - long v4l2_pix_format, - int field); - - public static native void v4l2_pix_format_setPixelformat( - long v4l2_pix_format, - int pixelformat); - - public static native void v4l2_pix_format_setWidthAndHeight( - long v4l2_pix_format, - int width, int height); - - public static native long v4l2_requestbuffers_alloc(int type); - - public static native int v4l2_requestbuffers_getCount( - long v4l2_requestbuffers); - - public static native void v4l2_requestbuffers_setCount( - long v4l2_requestbuffers, - int count); - - public static native void v4l2_requestbuffers_setMemory( - long v4l2_requestbuffers, - int memory); - - public static native long v4l2_streamparm_alloc(int type); - - public static native void v4l2_streamparm_setFps(long v4l2_streamparm, int fps); - - private static native int VIDIOC_DQBUF(); - - private static native int VIDIOC_G_FMT(); - - private static native int VIDIOC_QBUF(); - - private static native int VIDIOC_QUERYBUF(); - - private static native int VIDIOC_QUERYCAP(); - - private static native int VIDIOC_REQBUFS(); - - private static native int VIDIOC_S_FMT(); - - private static native int VIDIOC_S_PARM(); - - private static native int VIDIOC_STREAMOFF(); - - private static native int VIDIOC_STREAMON(); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/video4linux2/Video4Linux2Stream.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/video4linux2/Video4Linux2Stream.java deleted file mode 100644 index f4324bab7..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/video4linux2/Video4Linux2Stream.java +++ /dev/null @@ -1,851 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.video4linux2; - -import java.awt.*; -import java.io.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.codec.video.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.*; - -/** - * Implements a PullBufferStream using the Video for Linux Two API - * Specification. - * - * @author Lyubomir Marinov - */ -public class Video4Linux2Stream - extends AbstractVideoPullBufferStream -{ - /** - * The pool of ByteBuffers this instances is using to transfer the - * media data captured by the Video for Linux Two API Specification device - * out of this instance through the Buffers specified in its - * {@link #read(Buffer)}. - */ - private final ByteBufferPool byteBufferPool = new ByteBufferPool(); - - /** - * The capabilities of the Video for Linux Two API Specification device - * represented by {@link #fd}. - */ - private int capabilities = 0; - - /** - * The file descriptor of the Video for Linux Two API Specification device - * read through this PullBufferStream. - */ - private int fd = -1; - - /** - * The last-known Format of the media data made available by this - * PullBufferStream - */ - private Format format; - - /** - * The lengths in bytes of the buffers in the application's address space - * through which the Video for Linux Two API Specification device provides - * the captured media data to this instance when - * {@link #requestbuffersMemory} is equal to V4L2_MEMORY_MAP. - */ - private int[] mmapLengths; - - /** - * The buffers through which the Video for Linux Two API Specification - * device provides the captured media data to this instance when - * {@link #requestbuffersMemory} is equal to V4L2_MEMORY_MAP. These - * are mapped in the application's address space. - */ - private long[] mmaps; - - /** - * The number of buffers through which the Video for Linux Two API - * Specification device provides the captured media data to this instance - * when {@link #requestbuffersMemory} is equal to V4L2_MEMORY_MMAP. - */ - private int requestbuffersCount = 0; - - /** - * The input method negotiated by this instance with the Video for Linux Two - * API Specification device. - */ - private int requestbuffersMemory = 0; - - /** - * The v4l2_buffer instance via which captured media data is - * fetched from the Video for Linux Two API Specification device to this - * instance in {@link #read(Buffer)}. - */ - private long v4l2_buffer; - - /** - * Native Video for Linux Two pixel format. - */ - private int nativePixelFormat = 0; - - /** - * Tell device to start capture in read() method. - */ - private boolean startInRead = false; - - /** - * AVCodecContext for MJPEG conversion. - */ - private long mjpeg_context = 0; - - /** - * AVFrame that is used in case of JPEG/MJPEG conversion. - */ - private long avframe = 0; - - /** - * Initializes a new Video4Linux2Stream instance which is to have - * its Format-related information abstracted by a specific - * FormatControl. - * - * @param dataSource the DataSource which is creating the new - * instance so that it becomes one of its streams - * @param formatControl the FormatControl which is to abstract the - * Format-related information of the new instance - */ - public Video4Linux2Stream( - DataSource dataSource, - FormatControl formatControl) - { - super(dataSource, formatControl); - - v4l2_buffer - = Video4Linux2.v4l2_buffer_alloc( - Video4Linux2.V4L2_BUF_TYPE_VIDEO_CAPTURE); - if (0 == v4l2_buffer) - throw new OutOfMemoryError("v4l2_buffer_alloc"); - Video4Linux2.v4l2_buffer_setMemory( - v4l2_buffer, - Video4Linux2.V4L2_MEMORY_MMAP); - } - - /** - * Releases the resources used by this instance throughout its existence and - * makes it available for garbage collection. This instance is considered - * unusable after closing. - * - * @see AbstractPullBufferStream#close() - */ - @Override - public void close() - { - super.close(); - - if (v4l2_buffer != 0) - { - Video4Linux2.free(v4l2_buffer); - v4l2_buffer = 0; - } - } - - /** - * Gets the Format of this PullBufferStream as directly - * known by it. - * - * @return the Format of this PullBufferStream as directly - * known by it or null if this PullBufferStream does not - * directly know its Format and it relies on the - * PullBufferDataSource which created it to report its - * Format - * @see AbstractPullBufferStream#doGetFormat() - */ - @Override - protected Format doGetFormat() - { - Format format; - - if (this.format == null) - { - format = getFdFormat(); - if (format == null) - format = super.doGetFormat(); - else - { - VideoFormat videoFormat = (VideoFormat) format; - - if (videoFormat.getSize() != null) - this.format = format; - } - } - else - format = this.format; - return format; - } - - /** - * Reads media data from this PullBufferStream into a specific - * Buffer with blocking. - * - * @param buffer the Buffer in which media data is to be read from - * this PullBufferStream - * @throws IOException if anything goes wrong while reading media data from - * this PullBufferStream into the specified buffer - * @see AbstractVideoPullBufferStream#doRead(Buffer) - */ - protected void doRead(Buffer buffer) - throws IOException - { - Format format = buffer.getFormat(); - - if (!(format instanceof AVFrameFormat)) - format = null; - if (format == null) - { - format = getFormat(); - if (format != null) - buffer.setFormat(format); - } - - if(startInRead) - { - startInRead = false; - - long v4l2_buf_type - = Video4Linux2.v4l2_buf_type_alloc( - Video4Linux2.V4L2_BUF_TYPE_VIDEO_CAPTURE); - - if (0 == v4l2_buf_type) - throw new OutOfMemoryError("v4l2_buf_type_alloc"); - try - { - if (Video4Linux2.ioctl(fd, Video4Linux2.VIDIOC_STREAMON, - v4l2_buf_type) == -1) - { - throw new IOException("ioctl: request= VIDIOC_STREAMON"); - } - } - finally - { - Video4Linux2.free(v4l2_buf_type); - } - } - - if (Video4Linux2.ioctl(fd, Video4Linux2.VIDIOC_DQBUF, v4l2_buffer) - == -1) - throw new IOException("ioctl: request= VIDIOC_DQBUF"); - - long timeStamp = System.nanoTime(); - - try - { - ByteBuffer data = null; - int index = Video4Linux2.v4l2_buffer_getIndex(v4l2_buffer); - long mmap = mmaps[index]; - int bytesused = Video4Linux2.v4l2_buffer_getBytesused(v4l2_buffer); - - if(nativePixelFormat == Video4Linux2.V4L2_PIX_FMT_MJPEG || - nativePixelFormat == Video4Linux2.V4L2_PIX_FMT_JPEG) - { - /* initialize FFmpeg's MJPEG decoder if not already done */ - if(mjpeg_context == 0) - { - long avcodec = FFmpeg.avcodec_find_decoder( - FFmpeg.CODEC_ID_MJPEG); - - mjpeg_context = FFmpeg.avcodec_alloc_context(); - FFmpeg.avcodeccontext_set_workaround_bugs(mjpeg_context, - FFmpeg.FF_BUG_AUTODETECT); - - if (FFmpeg.avcodec_open(mjpeg_context, avcodec) < 0) - { - throw new RuntimeException("" + - "Could not open codec CODEC_ID_MJPEG"); - } - - avframe = FFmpeg.avcodec_alloc_frame(); - } - - if(FFmpeg.avcodec_decode_video(mjpeg_context, avframe, mmap, - bytesused) != -1) - { - Object out = buffer.getData(); - - if (!(out instanceof AVFrame) || - (((AVFrame) out).getPtr() != avframe)) - { - buffer.setData(new AVFrame(avframe)); - } - } - } - else - { - data = byteBufferPool.getFreeBuffer(bytesused); - - if (data != null) - { - Video4Linux2.memcpy(data.ptr, mmap, bytesused); - } - data.setLength(bytesused); - FinalizableAVFrame.read(buffer, format, data, byteBufferPool); - } - } - finally - { - if (Video4Linux2.ioctl(fd, Video4Linux2.VIDIOC_QBUF, v4l2_buffer) - == -1) - throw new IOException("ioctl: request= VIDIOC_QBUF"); - } - - buffer.setFlags(Buffer.FLAG_LIVE_DATA | Buffer.FLAG_SYSTEM_TIME); - buffer.setTimeStamp(timeStamp); - } - - /** - * Gets the Format of the media data captured by the Video for - * Linux Two API Specification device represented by the fd of this - * instance. - * - * @return the Format of the media data captured by the Video for - * Linux Two API Specification device represented by the fd of this - * instance - */ - private Format getFdFormat() - { - Format format = null; - - if (-1 != fd) - { - long v4l2_format - = Video4Linux2.v4l2_format_alloc( - Video4Linux2.V4L2_BUF_TYPE_VIDEO_CAPTURE); - - if (v4l2_format == 0) - throw new OutOfMemoryError("v4l2_format_alloc"); - else - { - try - { - if (Video4Linux2.ioctl( - fd, - Video4Linux2.VIDIOC_G_FMT, - v4l2_format) - != -1) - { - long fmtPix - = Video4Linux2.v4l2_format_getFmtPix(v4l2_format); - int pixelformat - = Video4Linux2.v4l2_pix_format_getPixelformat( - fmtPix); - int ffmpegPixFmt - = DataSource.getFFmpegPixFmt(pixelformat); - - if (FFmpeg.PIX_FMT_NONE != ffmpegPixFmt) - { - int width - = Video4Linux2.v4l2_pix_format_getWidth(fmtPix); - int height - = Video4Linux2.v4l2_pix_format_getHeight( - fmtPix); - - format - = new AVFrameFormat( - new Dimension(width, height), - Format.NOT_SPECIFIED, - ffmpegPixFmt, - pixelformat); - } - } - } - finally - { - Video4Linux2.free(v4l2_format); - } - } - } - return format; - } - - /** - * Unmaps the buffers through which the Video for Linux Two API - * Specification device provides the captured media data to this instance - * when {@link #requestbuffersMemory} is equal to V4L2_MEMORY_MMAP - * i.e. breaks the buffers' mappings between the driver's and the - * application's address spaces. - */ - private void munmap() - { - try - { - if (mmaps != null) - { - for (int i = 0; i < mmaps.length; i++) - { - long mmap = mmaps[i]; - - if (mmap != 0) - { - Video4Linux2.munmap(mmap, mmapLengths[i]); - mmaps[i] = 0; - mmapLengths[i] = 0; - } - } - } - } - finally - { - mmaps = null; - mmapLengths = null; - } - } - - /** - * Negotiates the input method with the Video for Linux Two API - * Specification device represented by the fd of this instance. - * - * @throws IOException if anything goes wrong while negotiating the input - * method with the Video for Linux Two API Specification device represented - * by the fd of this instance - */ - private void negotiateFdInputMethod() - throws IOException - { - long v4l2_capability = Video4Linux2.v4l2_capability_alloc(); - - if (0 == v4l2_capability) - throw new OutOfMemoryError("v4l2_capability_alloc"); - try - { - if (Video4Linux2.ioctl( - fd, - Video4Linux2.VIDIOC_QUERYCAP, - v4l2_capability) - == -1) - throw new IOException("ioctl: request= VIDIOC_QUERYCAP"); - capabilities - = Video4Linux2.v4l2_capability_getCapabilities(v4l2_capability); - } - finally - { - Video4Linux2.free(v4l2_capability); - } - if ((capabilities & Video4Linux2.V4L2_CAP_STREAMING) - != Video4Linux2.V4L2_CAP_STREAMING) - throw new IOException("Non-streaming V4L2 device not supported."); - - long v4l2_requestbuffers - = Video4Linux2.v4l2_requestbuffers_alloc( - Video4Linux2.V4L2_BUF_TYPE_VIDEO_CAPTURE); - - if (0 == v4l2_requestbuffers) - throw new OutOfMemoryError("v4l2_requestbuffers_alloc"); - try - { - requestbuffersMemory = Video4Linux2.V4L2_MEMORY_MMAP; - Video4Linux2.v4l2_requestbuffers_setMemory( - v4l2_requestbuffers, - requestbuffersMemory); - Video4Linux2.v4l2_requestbuffers_setCount(v4l2_requestbuffers, 2); - if (Video4Linux2.ioctl( - fd, - Video4Linux2.VIDIOC_REQBUFS, - v4l2_requestbuffers) - == -1) - { - throw - new IOException( - "ioctl: request= VIDIOC_REQBUFS, memory= " - + requestbuffersMemory); - } - requestbuffersCount - = Video4Linux2.v4l2_requestbuffers_getCount( - v4l2_requestbuffers); - } - finally - { - Video4Linux2.free(v4l2_requestbuffers); - } - if (requestbuffersCount < 1) - throw new IOException("Insufficient V4L2 device memory."); - - - long v4l2_buffer - = Video4Linux2.v4l2_buffer_alloc( - Video4Linux2.V4L2_BUF_TYPE_VIDEO_CAPTURE); - - if (0 == v4l2_buffer) - throw new OutOfMemoryError("v4l2_buffer_alloc"); - - try - { - Video4Linux2.v4l2_buffer_setMemory( - v4l2_buffer, - Video4Linux2.V4L2_MEMORY_MMAP); - - mmaps = new long[requestbuffersCount]; - mmapLengths = new int[requestbuffersCount]; - - boolean munmap = true; - - try - { - for (int i = 0; i < requestbuffersCount; i++) - { - Video4Linux2.v4l2_buffer_setIndex(v4l2_buffer, i); - if (Video4Linux2.ioctl( - fd, - Video4Linux2.VIDIOC_QUERYBUF, - v4l2_buffer) - == -1) - { - throw - new IOException("ioctl: request= VIDIOC_QUERYBUF"); - } - - int length - = Video4Linux2.v4l2_buffer_getLength(v4l2_buffer); - long offset - = Video4Linux2.v4l2_buffer_getMOffset(v4l2_buffer); - long mmap - = Video4Linux2.mmap( - 0, - length, - Video4Linux2.PROT_READ - | Video4Linux2.PROT_WRITE, - Video4Linux2.MAP_SHARED, - fd, - offset); - - if (-1 == mmap) - throw new IOException("mmap"); - mmaps[i] = mmap; - mmapLengths[i] = length; - } - munmap = false; - } - finally - { - if (munmap) - munmap(); - } - } - finally - { - Video4Linux2.free(v4l2_buffer); - } - } - - /** - * Sets the file descriptor of the Video for Linux Two API Specification - * device which is to be read through this PullBufferStream. - * - * @param fd the file descriptor of the Video for Linux Two API - * Specification device which is to be read through this - * PullBufferStream - * @throws IOException if anything goes wrong while setting the file - * descriptor of the Video for Linux Two API Specification device which is - * to be read through this PullBufferStream - */ - void setFd(int fd) - throws IOException - { - if (this.fd != fd) - { - if (this.fd != -1) - { - try - { - stop(); - } - catch (IOException ioex) - { - } - munmap(); - } - - /* - * Before a Video for Linux Two API Specification device can be - * read, an attempt to set its format must be made and its cropping - * must be reset. We can only learn about the format to be set from - * formatControl. But since this AbstractPullBufferStream exists - * already, formatControl will ask it about its format. So pretend - * that there is no device prior to asking formatControl about the - * format in order to get the format that has been set by the user. - */ - this.fd = -1; - this.capabilities = 0; - this.requestbuffersMemory = 0; - this.requestbuffersCount = 0; - - if (fd != -1) - { - Format format = getFormat(); - - this.fd = fd; - if (format != null) - setFdFormat(format); - setFdCropToDefault(); - negotiateFdInputMethod(); - } - } - } - - /** - * Sets the crop of the Video for Linux Two API Specification device - * represented by the fd of this instance to its default value so - * that this PullBufferStream reads media data without cropping. - */ - private void setFdCropToDefault() - { - // TODO Auto-generated method stub - } - - /** - * Sets the Format in which the Video for Linux Two API - * Specification device represented by the fd of this instance is - * to capture media data. - * - * @param format the Format of the media data to be captured by the - * Video for Linux Two API Specification device represented by the - * fd of this instance - * @throws IOException if anything goes wrong while setting the - * Format of the media data to be captured by the Video for Linux - * Two API Specification device represented by the fd of this - * instance - */ - private void setFdFormat(Format format) - throws IOException - { - int pixelformat = 0; - - if (format instanceof AVFrameFormat) - { - pixelformat = ((AVFrameFormat) format).getDevicePixFmt(); - nativePixelFormat = pixelformat; - } - if (Video4Linux2.V4L2_PIX_FMT_NONE == pixelformat) - throw new IOException("Unsupported format " + format); - - long v4l2_format - = Video4Linux2.v4l2_format_alloc( - Video4Linux2.V4L2_BUF_TYPE_VIDEO_CAPTURE); - - if (v4l2_format == 0) - throw new OutOfMemoryError("v4l2_format_alloc"); - try - { - if (Video4Linux2.ioctl(fd, Video4Linux2.VIDIOC_G_FMT, v4l2_format) - == -1) - throw new IOException("ioctl: request= VIDIO_G_FMT"); - - VideoFormat videoFormat = (VideoFormat) format; - Dimension size = videoFormat.getSize(); - long fmtPix = Video4Linux2.v4l2_format_getFmtPix(v4l2_format); - int width = Video4Linux2.v4l2_pix_format_getWidth(fmtPix); - int height = Video4Linux2.v4l2_pix_format_getHeight(fmtPix); - boolean setFdFormat = false; - - if (size == null) - { - // if there is no size in the format, respect settings - size = NeomediaActivator - .getMediaServiceImpl() - .getDeviceConfiguration() - .getVideoSize(); - } - - if ((size != null) - && ((size.width != width) || (size.height != height))) - { - Video4Linux2.v4l2_pix_format_setWidthAndHeight( - fmtPix, - size.width, size.height); - setFdFormat = true; - } - if (Video4Linux2.v4l2_pix_format_getPixelformat(v4l2_format) - != pixelformat) - { - Video4Linux2.v4l2_pix_format_setPixelformat( - fmtPix, - pixelformat); - - setFdFormat = true; - } - - if (setFdFormat) - setFdFormat(v4l2_format, fmtPix, size, pixelformat); - } - finally - { - Video4Linux2.free(v4l2_format); - } - } - - /** - * Sets the Format in which the Video for Linux Two API - * Specification device represented by the fd of this instance is - * to capture media data. - * - * @param v4l2_format native format to set on the Video for Linux Two API - * Specification device - * @param fmtPix native pixel format of the device - * @param size size to set on the device - * @param pixelformat requested pixel format - * @throws IOException if anything goes wrong while setting the - * native format of the media data to be captured by the Video for Linux - * Two API Specification device represented by the fd of this - * instance - */ - private void setFdFormat( - long v4l2_format, - long fmtPix, - Dimension size, - int pixelformat) - throws IOException - { - Video4Linux2.v4l2_pix_format_setField( - fmtPix, - Video4Linux2.V4L2_FIELD_NONE); - Video4Linux2.v4l2_pix_format_setBytesperline(fmtPix, 0); - - if (Video4Linux2.ioctl( - fd, - Video4Linux2.VIDIOC_S_FMT, - v4l2_format) - == -1) - { - throw - new IOException( - "ioctl: request= VIDIOC_S_FMT" - + ((size == null) - ? "" - : (", width= " - + size.width - + ", height= " - + size.height)) - + ", pixelformat= " - + pixelformat); - } - else if (Video4Linux2.v4l2_pix_format_getPixelformat(fmtPix) - != pixelformat) - { - throw - new IOException( - "Failed to change the format of the V4L2 device to " - + pixelformat); - } - } - - /** - * Starts the transfer of media data from this PullBufferStream. - * - * @throws IOException if anything goes wrong while starting the transfer of - * media data from this PullBufferStream - * @see AbstractPullBufferStream#start() - */ - @Override - public void start() - throws IOException - { - super.start(); - - long v4l2_buffer - = Video4Linux2.v4l2_buffer_alloc( - Video4Linux2.V4L2_BUF_TYPE_VIDEO_CAPTURE); - - if (0 == v4l2_buffer) - throw new OutOfMemoryError("v4l2_buffer_alloc"); - try - { - Video4Linux2.v4l2_buffer_setMemory( - v4l2_buffer, - Video4Linux2.V4L2_MEMORY_MMAP); - for (int i = 0; i < requestbuffersCount; i++) - { - Video4Linux2.v4l2_buffer_setIndex(v4l2_buffer, i); - if (Video4Linux2.ioctl( - fd, - Video4Linux2.VIDIOC_QBUF, - v4l2_buffer) - == -1) - { - throw - new IOException( - "ioctl: request= VIDIOC_QBUF, index= " + i); - } - } - } - finally - { - Video4Linux2.free(v4l2_buffer); - } - - /* we will start capture in read() method (i.e do the VIDIOC_STREAMON - * ioctl) because for some couple of fps/resolution the captured image - * will be weird (shift, not a JPEG for JPEG/MJPEG format, ...) - * if it is done here. Maybe it is due because sometime JMF do the - * sequence start/stop/start too quickly... - */ - startInRead = true; - } - - /** - * Stops the transfer of media data from this PullBufferStream. - * - * @throws IOException if anything goes wrong while stopping the transfer of - * media data from this PullBufferStream - * @see AbstractPullBufferStream#stop() - */ - @Override - public void stop() - throws IOException - { - try - { - long v4l2_buf_type - = Video4Linux2.v4l2_buf_type_alloc( - Video4Linux2.V4L2_BUF_TYPE_VIDEO_CAPTURE); - - if (0 == v4l2_buf_type) - throw new OutOfMemoryError("v4l2_buf_type_alloc"); - try - { - if (Video4Linux2.ioctl( - fd, - Video4Linux2.VIDIOC_STREAMOFF, - v4l2_buf_type) - == -1) - { - throw new IOException("ioctl: request= VIDIOC_STREAMOFF"); - } - } - finally - { - Video4Linux2.free(v4l2_buf_type); - } - } - finally - { - super.stop(); - - if(mjpeg_context > 0) - { - FFmpeg.avcodec_close(mjpeg_context); - FFmpeg.av_free(mjpeg_context); - } - mjpeg_context = 0; - - if(avframe > 0) - { - FFmpeg.av_free(avframe); - } - avframe = 0; - - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/AbstractRenderer.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/AbstractRenderer.java deleted file mode 100644 index 6223945e7..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/AbstractRenderer.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.renderer; - -import javax.media.*; - -import net.java.sip.communicator.impl.neomedia.control.*; - -/** - * Provides an abstract base implementation of Renderer in order to - * facilitate extenders - * - * @author Lyubomir Marinov - * - * @param the type of Format of the media data processed - * as input by AbstractRenderer - */ -public abstract class AbstractRenderer - extends ControlsAdapter - implements Renderer -{ - /** - * The Format of the media data processed as input by this - * Renderer. - */ - protected InputFormatT inputFormat; - - /** - * Resets the state of this PlugIn. - */ - public void reset() - { - // TODO Auto-generated method stub - } - - /** - * Sets the Format of the media data to be rendered by this - * Renderer. - * - * @param format the Format of the media data to be rendered by - * this Renderer - * @return null if the specified format is not compatible - * with this Renderer; otherwise, the Format which has - * been successfully set - */ - @SuppressWarnings("unchecked") - public Format setInputFormat(Format format) - { - Format matchingFormat = null; - - for (Format supportedInputFormat : getSupportedInputFormats()) - { - if (supportedInputFormat.matches(format)) - { - matchingFormat = supportedInputFormat.intersects(format); - break; - } - } - if (matchingFormat == null) - return null; - - inputFormat = (InputFormatT) matchingFormat; - return inputFormat; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/audio/PortAudioRenderer.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/audio/PortAudioRenderer.java deleted file mode 100644 index a2236cb12..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/audio/PortAudioRenderer.java +++ /dev/null @@ -1,686 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.renderer.audio; - -import java.util.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.portaudio.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.renderer.*; -import net.java.sip.communicator.impl.neomedia.portaudio.*; -import net.java.sip.communicator.util.*; - -/** - * Implements an audio Renderer which uses PortAudio. - * - * @author Damian Minkov - * @author Lyubomir Marinov - */ -public class PortAudioRenderer - extends AbstractRenderer -{ - /** - * The Logger used by the PortAudioRenderer class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(PortAudioRenderer.class); - - /** - * The constant which represents an empty array with - * Format element type. Explicitly defined in order to - * reduce unnecessary allocations. - */ - private static final Format[] EMPTY_SUPPORTED_INPUT_FORMATS - = new Format[0]; - - /** - * The human-readable name of the PortAudioRenderer JMF plug-in. - */ - private static final String PLUGIN_NAME = "PortAudio Renderer"; - - /** - * The list of JMF Formats of audio data which - * PortAudioRenderer instances are capable of rendering. - */ - private static final Format[] SUPPORTED_INPUT_FORMATS; - - /** - * The list of the sample rates supported by PortAudioRenderer as - * input. - */ - private static final double[] SUPPORTED_INPUT_SAMPLE_RATES - = new double[] { 8000, 11025, 16000, 22050, 32000, 44100, 48000 }; - - static - { - int count = SUPPORTED_INPUT_SAMPLE_RATES.length; - - SUPPORTED_INPUT_FORMATS = new Format[count]; - for (int i = 0; i < count; i++) - { - SUPPORTED_INPUT_FORMATS[i] - = new AudioFormat( - AudioFormat.LINEAR, - SUPPORTED_INPUT_SAMPLE_RATES[i], - 16 /* sampleSizeInBits */, - Format.NOT_SPECIFIED /* channels */, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED /* frameSizeInBits */, - Format.NOT_SPECIFIED /* frameRate */, - Format.byteArray); - } - } - - /** - * The audio samples left unwritten by a previous call to - * {@link #process(Buffer)}. As {@link #bytesPerBuffer} number of - * bytes are always written, the number of the unwritten audio samples is - * always less than that. - */ - private byte[] bufferLeft; - - /** - * The number of bytes in {@link #bufferLeft} representing unwritten audio - * samples. - */ - private int bufferLeftLength = 0; - - /** - * The number of bytes to write to the native PortAudio stream represented - * by this instance with a single invocation. Based on - * {@link #framesPerBuffer}. - */ - private int bytesPerBuffer; - - /** - * The number of frames to write to the native PortAudio stream represented - * by this instance with a single invocation. - */ - private int framesPerBuffer; - - /** - * The MediaLocator which specifies the device index of the - * PortAudio device used by this instance for rendering. - */ - private MediaLocator locator; - - private long outputParameters = 0; - - /** - * The indicator which determines whether this Renderer is started. - */ - private boolean started = false; - - /** - * The output PortAudio stream represented by this instance. - */ - private long stream = 0; - - /** - * The indicator which determines whether {@link #stream} is busy and should - * not, for example, be closed. - */ - private boolean streamIsBusy = false; - - /** - * Array of supported input formats. - */ - private Format[] supportedInputFormats; - - /** - * The GainControl through which volume/gain of rendered media is - * controlled. - */ - private final GainControl gainControl; - - /** - * Initializes a new PortAudioRenderer instance. - */ - public PortAudioRenderer() - { - this(true); - } - - /** - * Initializes a new PortAudioRenderer instance. - * - * @param enableVolumeControl true to enable volume control; - * false, otherwise - */ - public PortAudioRenderer(boolean enableVolumeControl) - { - if (enableVolumeControl) - { - /* - * XXX The Renderer implementations are probed for their - * supportedInputFormats during the initialization of - * MediaServiceImpl so the latter may not be available at this time. - * Which is not much of a problem given than the GainControl is of - * no interest during the probing of the supportedInputFormats. - */ - MediaServiceImpl mediaServiceImpl - = NeomediaActivator.getMediaServiceImpl(); - - gainControl - = (mediaServiceImpl == null) - ? null - : (GainControl) mediaServiceImpl.getOutputVolumeControl(); - } - else - gainControl = null; - } - - /** - * Closes this PlugIn. - */ - public synchronized void close() - { - try - { - stop(); - } - finally - { - if (stream != 0) - { - try - { - PortAudio.Pa_CloseStream(stream); - stream = 0; - } - catch (PortAudioException paex) - { - logger.error("Failed to close PortAudio stream.", paex); - } - } - if ((stream == 0) && (outputParameters != 0)) - { - PortAudio.PaStreamParameters_free(outputParameters); - outputParameters = 0; - } - } - } - - /** - * Implements {@link javax.media.Controls#getControls()}. Gets the controls - * available for the owner of this instance. The current implementation - * returns an empty array because it has no available controls. - * - * @return an array of Objects which represent the controls - * available for the owner of this instance - */ - public Object[] getControls() - { - return new Object[] { gainControl }; - } - - /** - * Gets the MediaLocator which specifies the device index of the - * PortAudio device used by this instance for rendering. - * - * @return the MediaLocator which specifies the device index of the - * PortAudio device used by this instance for rendering - */ - public MediaLocator getLocator() - { - MediaLocator locator = this.locator; - - if (locator == null) - { - AudioSystem portAudioSystem - = AudioSystem.getAudioSystem( - AudioSystem.LOCATOR_PROTOCOL_PORTAUDIO); - - if (portAudioSystem != null) - { - CaptureDeviceInfo playbackDevice - = portAudioSystem.getPlaybackDevice(); - - if (playbackDevice != null) - locator = playbackDevice.getLocator(); - } - } - return locator; - } - - /** - * Gets the descriptive/human-readable name of this JMF plug-in. - * - * @return the descriptive/human-readable name of this JMF plug-in - */ - public String getName() - { - return PLUGIN_NAME; - } - - /** - * Gets the list of JMF Formats of audio data which this - * Renderer is capable of rendering. - * - * @return an array of JMF Formats of audio data which this - * Renderer is capable of rendering - */ - public Format[] getSupportedInputFormats() - { - if (supportedInputFormats == null) - { - MediaLocator locator = getLocator(); - int deviceIndex; - - if ((locator == null) - || ((deviceIndex = DataSource.getDeviceIndex(locator)) - == PortAudio.paNoDevice)) - supportedInputFormats = SUPPORTED_INPUT_FORMATS; - else - { - long deviceInfo = PortAudio.Pa_GetDeviceInfo(deviceIndex); - - if (deviceInfo == 0) - supportedInputFormats = SUPPORTED_INPUT_FORMATS; - else - { - int minOutputChannels = 1; - /* - * The maximum output channels may be a lot and checking all - * of them will take a lot of time. Besides, we currently - * support at most 2. - */ - int maxOutputChannels - = Math.min( - PortAudio.PaDeviceInfo_getMaxOutputChannels( - deviceInfo), - 2); - List supportedInputFormats - = new ArrayList(SUPPORTED_INPUT_FORMATS.length); - - for (Format supportedInputFormat : SUPPORTED_INPUT_FORMATS) - { - getSupportedInputFormats( - supportedInputFormat, - deviceIndex, - minOutputChannels, - maxOutputChannels, - supportedInputFormats); - } - this.supportedInputFormats - = supportedInputFormats.isEmpty() - ? EMPTY_SUPPORTED_INPUT_FORMATS - : supportedInputFormats.toArray( - EMPTY_SUPPORTED_INPUT_FORMATS); - } - } - } - return - (supportedInputFormats.length == 0) - ? EMPTY_SUPPORTED_INPUT_FORMATS - : supportedInputFormats.clone(); - } - - private void getSupportedInputFormats( - Format format, - int deviceIndex, - int minOutputChannels, int maxOutputChannels, - List supportedInputFormats) - { - AudioFormat audioFormat = (AudioFormat) format; - int sampleSizeInBits = audioFormat.getSampleSizeInBits(); - long sampleFormat = PortAudio.getPaSampleFormat(sampleSizeInBits); - double sampleRate = audioFormat.getSampleRate(); - - for (int channels = minOutputChannels; - channels <= maxOutputChannels; - channels++) - { - long outputParameters - = PortAudio.PaStreamParameters_new( - deviceIndex, - channels, - sampleFormat, - PortAudio.LATENCY_UNSPECIFIED); - - if (outputParameters != 0) - { - try - { - if (PortAudio.Pa_IsFormatSupported( - 0, - outputParameters, - sampleRate)) - { - supportedInputFormats.add( - new AudioFormat( - audioFormat.getEncoding(), - sampleRate, - sampleSizeInBits, - channels, - audioFormat.getEndian(), - audioFormat.getSigned(), - Format.NOT_SPECIFIED /* frameSizeInBits */, - Format.NOT_SPECIFIED /* frameRate */, - audioFormat.getDataType())); - } - } - finally - { - PortAudio.PaStreamParameters_free(outputParameters); - } - } - } - } - - /** - * Opens the PortAudio device and output stream represented by this instance - * which are to be used to render audio. - * - * @throws ResourceUnavailableException if the PortAudio device or output - * stream cannot be created or opened - */ - public synchronized void open() - throws ResourceUnavailableException - { - try - { - doOpen(); - } - catch (Throwable t) - { - /* - * Log the problem because FMJ may swallow it and thus make - * debugging harder than necessary. - */ - if (logger.isDebugEnabled()) - logger.debug("Failed to open PortAudioRenderer", t); - - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - else if (t instanceof ResourceUnavailableException) - throw (ResourceUnavailableException) t; - else - { - ResourceUnavailableException rue - = new ResourceUnavailableException(); - - rue.initCause(t); - throw rue; - } - } - } - - /** - * Opens the PortAudio device and output stream represented by this instance - * which are to be used to render audio. - * - * @throws ResourceUnavailableException if the PortAudio device or output - * stream cannot be created or opened - */ - private void doOpen() - throws ResourceUnavailableException - { - if (stream == 0) - { - MediaLocator locator = getLocator(); - - if (locator == null) - throw new ResourceUnavailableException("locator not set"); - - int deviceIndex = DataSource.getDeviceIndex(locator); - AudioFormat inputFormat = this.inputFormat; - - if (inputFormat == null) - throw new ResourceUnavailableException("inputFormat not set"); - - int channels = inputFormat.getChannels(); - - if (channels == Format.NOT_SPECIFIED) - channels = 1; - - long sampleFormat - = PortAudio.getPaSampleFormat( - inputFormat.getSampleSizeInBits()); - double sampleRate = inputFormat.getSampleRate(); - - framesPerBuffer - = (int) - ((sampleRate * PortAudio.DEFAULT_MILLIS_PER_BUFFER) - / (channels * 1000)); - - try - { - outputParameters - = PortAudio.PaStreamParameters_new( - deviceIndex, - channels, - sampleFormat, - PortAudio.getSuggestedLatency()); - - stream - = PortAudio.Pa_OpenStream( - 0 /* inputParameters */, - outputParameters, - sampleRate, - framesPerBuffer, - PortAudio.STREAM_FLAGS_CLIP_OFF - | PortAudio.STREAM_FLAGS_DITHER_OFF, - null /* streamCallback */); - } - catch (PortAudioException paex) - { - throw new ResourceUnavailableException(paex.getMessage()); - } - finally - { - if ((stream == 0) && (outputParameters != 0)) - { - PortAudio.PaStreamParameters_free(outputParameters); - outputParameters = 0; - } - } - if (stream == 0) - throw new ResourceUnavailableException("Pa_OpenStream"); - - bytesPerBuffer - = PortAudio.Pa_GetSampleSize(sampleFormat) - * channels - * framesPerBuffer; - } - } - - /** - * Renders the audio data contained in a specific Buffer onto the - * PortAudio device represented by this Renderer. - * - * @param buffer the Buffer which contains the audio data to be - * rendered - * @return BUFFER_PROCESSED_OK if the specified buffer has - * been successfully processed - */ - public int process(Buffer buffer) - { - synchronized (this) - { - if (!started || (stream == 0)) - return BUFFER_PROCESSED_OK; - else - streamIsBusy = true; - } - try - { - process( - (byte[]) buffer.getData(), - buffer.getOffset(), - buffer.getLength()); - } - catch (PortAudioException paex) - { - logger.error("Failed to process Buffer.", paex); - } - finally - { - synchronized (this) - { - streamIsBusy = false; - notifyAll(); - } - } - return BUFFER_PROCESSED_OK; - } - - private void process(byte[] buffer, int offset, int length) - throws PortAudioException - { - - /* - * If there are audio samples left unwritten from a previous write, - * prepend them to the specified buffer. If it's possible to write them - * now, do it. - */ - if ((bufferLeft != null) && (bufferLeftLength > 0)) - { - int numberOfBytesInBufferLeftToBytesPerBuffer - = bytesPerBuffer - bufferLeftLength; - int numberOfBytesToCopyToBufferLeft - = (numberOfBytesInBufferLeftToBytesPerBuffer < length) - ? numberOfBytesInBufferLeftToBytesPerBuffer - : length; - - System - .arraycopy( - buffer, - offset, - bufferLeft, - bufferLeftLength, - numberOfBytesToCopyToBufferLeft); - offset += numberOfBytesToCopyToBufferLeft; - length -= numberOfBytesToCopyToBufferLeft; - bufferLeftLength += numberOfBytesToCopyToBufferLeft; - - if (bufferLeftLength == bytesPerBuffer) - { - PortAudio.Pa_WriteStream(stream, bufferLeft, framesPerBuffer); - bufferLeftLength = 0; - } - } - - // Write the audio samples from the specified buffer. - int numberOfWrites = length / bytesPerBuffer; - - if (numberOfWrites > 0) - { - // if we have some volume setting apply them - if (gainControl != null) - { - AbstractVolumeControl.applyGain( - gainControl, - buffer, offset, length); - } - - PortAudio.Pa_WriteStream( - stream, - buffer, offset, framesPerBuffer, - numberOfWrites); - - int bytesWritten = numberOfWrites * bytesPerBuffer; - - offset += bytesWritten; - length -= bytesWritten; - } - - // If anything was left unwritten, remember it for next time. - if (length > 0) - { - if (bufferLeft == null) - bufferLeft = new byte[bytesPerBuffer]; - System.arraycopy(buffer, offset, bufferLeft, 0, length); - bufferLeftLength = length; - } - } - - /** - * Sets the MediaLocator which specifies the device index of the - * PortAudio device to be used by this instance for rendering. - * - * @param locator a MediaLocator which specifies the device index - * of the PortAudio device to be used by this instance for rendering - */ - public void setLocator(MediaLocator locator) - { - if (this.locator == null) - { - if (locator == null) - return; - } - else if (this.locator.equals(locator)) - return; - - this.locator = locator; - supportedInputFormats = null; - } - - /** - * Starts the rendering process. Any audio data available in the internal - * resources associated with this PortAudioRenderer will begin - * being rendered. - */ - public synchronized void start() - { - if (!started && (stream != 0)) - { - try - { - PortAudio.Pa_StartStream(stream); - started = true; - } - catch (PortAudioException paex) - { - logger.error("Failed to start PortAudio stream.", paex); - } - } - } - - /** - * Stops the rendering process. - */ - public synchronized void stop() - { - boolean interrupted = false; - - while (streamIsBusy) - { - try - { - wait(); - } - catch (InterruptedException iex) - { - interrupted = true; - } - } - if (interrupted) - Thread.currentThread().interrupt(); - - if (started && (stream != 0)) - { - try - { - PortAudio.Pa_StopStream(stream); - started = false; - - bufferLeft = null; - } - catch (PortAudioException paex) - { - logger.error("Failed to close PortAudio stream.", paex); - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/audio/PulseAudioRenderer.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/audio/PulseAudioRenderer.java deleted file mode 100644 index a7b972062..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/audio/PulseAudioRenderer.java +++ /dev/null @@ -1,543 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.renderer.audio; - -import java.io.*; -import java.lang.reflect.*; - -import javax.media.*; -import javax.media.format.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.renderer.*; -import net.java.sip.communicator.impl.neomedia.pulseaudio.*; - -public class PulseAudioRenderer - extends AbstractRenderer -{ - /** - * The human-readable PlugIn name of the - * PulseAudioRenderer instances. - */ - private static final String PLUGIN_NAME = "PulseAudio Renderer"; - - private static final boolean SOFTWARE_GAIN = false; - - private static final Format[] SUPPORTED_INPUT_FORMATS - = new Format[] - { - new AudioFormat( - AudioFormat.LINEAR, - Format.NOT_SPECIFIED /* sampleRate */, - 16, - Format.NOT_SPECIFIED /* channels */, - AudioFormat.LITTLE_ENDIAN, - AudioFormat.SIGNED, - Format.NOT_SPECIFIED /* frameSizeInBits */, - Format.NOT_SPECIFIED /* frameRate */, - Format.byteArray) - }; - - private int channels; - - private boolean corked = true; - - private long cvolume; - - private final GainControl gainControl; - - private float gainControlLevel; - - private MediaLocator locator; - - private final String mediaRole; - - private final PulseAudioSystem pulseAudioSystem; - - private long stream; - - private final PA.stream_request_cb_t writeCallback - = new PA.stream_request_cb_t() - { - public void callback(long s, int nbytes) - { - pulseAudioSystem.signalMainloop(false); - } - }; - - /** - * Initializes a new PulseAudioRenderer instance. - */ - public PulseAudioRenderer() - { - this(null); - } - - public PulseAudioRenderer(String mediaRole) - { - pulseAudioSystem = PulseAudioSystem.getPulseAudioSystem(); - if (pulseAudioSystem == null) - throw new IllegalStateException("pulseAudioSystem"); - - this.mediaRole - = (mediaRole == null) - ? PulseAudioSystem.MEDIA_ROLE_PHONE - : mediaRole; - - if (PulseAudioSystem.MEDIA_ROLE_PHONE.equals(this.mediaRole)) - { - /* - * XXX The Renderer implementations are probed for their - * supportedInputFormats during the initialization of - * MediaServiceImpl so the latter may not be available at this time. - * Which is not much of a problem given than the GainControl is of - * no interest during the probing of the supportedInputFormats. - */ - MediaServiceImpl mediaServiceImpl - = NeomediaActivator.getMediaServiceImpl(); - - gainControl - = (mediaServiceImpl == null) - ? null - : (GainControl) mediaServiceImpl.getOutputVolumeControl(); - } - else - gainControl = null; - } - - public void close() - { - pulseAudioSystem.lockMainloop(); - try - { - long stream = this.stream; - - if (stream != 0) - { - try - { - stopWithMainloopLock(); - } - finally - { - long cvolume = this.cvolume; - - this.cvolume = 0; - this.stream = 0; - - corked = true; - - pulseAudioSystem.signalMainloop(false); - - if (cvolume != 0) - PA.cvolume_free(cvolume); - PA.stream_disconnect(stream); - PA.stream_unref(stream); - } - } - } - finally - { - pulseAudioSystem.unlockMainloop(); - } - } - - private void cork(boolean b) - { - try - { - PulseAudioSystem.corkStream(stream, b); - corked = b; - } - catch (IOException ioe) - { - throw new UndeclaredThrowableException(ioe); - } - finally - { - pulseAudioSystem.signalMainloop(false); - } - } - - public MediaLocator getLocator() - { - MediaLocator locator = this.locator; - - if (locator == null) - { - CaptureDeviceInfo playbackDevice - = pulseAudioSystem.getPlaybackDevice(); - - if (playbackDevice != null) - locator = playbackDevice.getLocator(); - } - return locator; - } - - private String getLocatorDev() - { - MediaLocator locator = getLocator(); - String locatorDev; - - if (locator == null) - locatorDev = null; - else - { - locatorDev = locator.getRemainder(); - if ((locatorDev != null) && (locatorDev.length() <= 0)) - locatorDev = null; - } - return locatorDev; - } - - public String getName() - { - return PLUGIN_NAME; - } - - public Format[] getSupportedInputFormats() - { - return SUPPORTED_INPUT_FORMATS.clone(); - } - - public void open() - throws ResourceUnavailableException - { - pulseAudioSystem.lockMainloop(); - try - { - openWithMainloopLock(); - } - finally - { - pulseAudioSystem.unlockMainloop(); - } - } - - private void openWithMainloopLock() - throws ResourceUnavailableException - { - if (stream != 0) - return; - - AudioFormat format = this.inputFormat; - int sampleRate = (int) format.getSampleRate(); - int channels = format.getChannels(); - int sampleSizeInBits = format.getSampleSizeInBits(); - - if ((sampleRate == Format.NOT_SPECIFIED) - && (MediaUtils.MAX_AUDIO_SAMPLE_RATE - != Format.NOT_SPECIFIED)) - sampleRate = (int) MediaUtils.MAX_AUDIO_SAMPLE_RATE; - if (channels == Format.NOT_SPECIFIED) - channels = 1; - if (sampleSizeInBits == Format.NOT_SPECIFIED) - sampleSizeInBits = 16; - - long stream = 0; - Throwable exception = null; - - try - { - stream - = pulseAudioSystem.createStream( - sampleRate, - channels, - getClass().getName(), - mediaRole); - this.channels = channels; - } - catch (IllegalStateException ise) - { - exception = ise; - } - catch (RuntimeException re) - { - exception = re; - } - if (exception != null) - { - ResourceUnavailableException rue - = new ResourceUnavailableException(); - - rue.initCause(exception); - throw rue; - } - if (stream == 0) - throw new ResourceUnavailableException("stream"); - - try - { - long attr - = PA.buffer_attr_new( - -1, - 2 /* millis / 10 */ - * (sampleRate / 100) - * channels - * (sampleSizeInBits / 8), - -1, - -1, - -1); - - if (attr == 0) - throw new ResourceUnavailableException("pa_buffer_attr_new"); - - try - { - Runnable stateCallback - = new Runnable() - { - public void run() - { - pulseAudioSystem.signalMainloop(false); - } - }; - - PA.stream_set_state_callback( - stream, - stateCallback); - PA.stream_connect_playback( - stream, - getLocatorDev(), - attr, - PA.STREAM_ADJUST_LATENCY - | PA.STREAM_START_CORKED, - 0, - 0); - - try - { - if (attr != 0) - { - PA.buffer_attr_free(attr); - attr = 0; - } - - int state - = pulseAudioSystem.waitForStreamState( - stream, - PA.STREAM_READY); - - if (state != PA.STREAM_READY) - throw new ResourceUnavailableException("stream.state"); - - PA.stream_set_write_callback( - stream, - writeCallback); - - if (!SOFTWARE_GAIN && (gainControl != null)) - { - cvolume = PA.cvolume_new(); - - boolean freeCvolume = true; - - try - { - float gainControlLevel = gainControl.getLevel(); - - setStreamVolume(stream, gainControlLevel); - this.gainControlLevel = gainControlLevel; - freeCvolume = false; - } - finally - { - if (freeCvolume) - { - PA.cvolume_free(cvolume); - cvolume = 0; - } - } - } - - this.stream = stream; - } - finally - { - if (this.stream == 0) - PA.stream_disconnect(stream); - } - } - finally - { - if (attr != 0) - PA.buffer_attr_free(attr); - } - } - finally - { - if (this.stream == 0) - PA.stream_unref(stream); - } - } - - public int process(Buffer buffer) - { - if (buffer.isDiscard()) - return BUFFER_PROCESSED_OK; - if (buffer.getLength() <= 0) - return BUFFER_PROCESSED_OK; - - int ret; - - pulseAudioSystem.lockMainloop(); - try - { - ret = processWithMainloopLock(buffer); - } - finally - { - pulseAudioSystem.unlockMainloop(); - } - if ((ret != BUFFER_PROCESSED_FAILED) && (buffer.getLength() > 0)) - ret |= INPUT_BUFFER_NOT_CONSUMED; - - return ret; - } - - private int processWithMainloopLock(Buffer buffer) - { - if ((stream == 0) || corked) - return BUFFER_PROCESSED_FAILED; - - int writableSize = PA.stream_writable_size(stream); - int ret; - - if (writableSize <= 0) - { - pulseAudioSystem.waitMainloop(); - ret = BUFFER_PROCESSED_OK; - } - else - { - byte[] data = (byte[]) buffer.getData(); - int offset = buffer.getOffset(); - int length = buffer.getLength(); - - if (length < writableSize) - writableSize = length; - - if (gainControl != null) - { - if (SOFTWARE_GAIN || (cvolume == 0)) - { - if (length > 0) - { - AbstractVolumeControl.applyGain( - gainControl, - data, offset, writableSize); - } - } - else - { - float gainControlLevel = gainControl.getLevel(); - - if (this.gainControlLevel != gainControlLevel) - { - this.gainControlLevel = gainControlLevel; - setStreamVolume(stream, gainControlLevel); - } - } - } - - int writtenSize - = PA.stream_write( - stream, - data, offset, writableSize, - null, - 0, - PA.SEEK_RELATIVE); - - if (writtenSize < 0) - ret = BUFFER_PROCESSED_FAILED; - else - { - ret = BUFFER_PROCESSED_OK; - buffer.setLength(length - writtenSize); - buffer.setOffset(offset + writtenSize); - } - } - - return ret; - } - - public void setLocator(MediaLocator locator) - { - if (this.locator == null) - { - if (locator == null) - return; - } - else if (this.locator.equals(locator)) - return; - - this.locator = locator; - } - - private void setStreamVolume(long stream, float level) - { - int volume - = PA.sw_volume_from_linear( - level * (AbstractVolumeControl.MAX_VOLUME_PERCENT / 100)); - - PA.cvolume_set(cvolume, channels, volume); - - long o - = PA.context_set_sink_input_volume( - pulseAudioSystem.getContext(), - PA.stream_get_index(stream), - cvolume, - null); - - if (o != 0) - PA.operation_unref(o); - } - - public void start() - { - pulseAudioSystem.lockMainloop(); - try - { - if (stream == 0) - { - try - { - openWithMainloopLock(); - } - catch (ResourceUnavailableException rue) - { - throw new UndeclaredThrowableException(rue); - } - } - - cork(false); - } - finally - { - pulseAudioSystem.unlockMainloop(); - } - } - - public void stop() - { - pulseAudioSystem.lockMainloop(); - try - { - stopWithMainloopLock(); - } - finally - { - pulseAudioSystem.unlockMainloop(); - } - } - - private void stopWithMainloopLock() - { - if (stream != 0) - cork(true); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRenderer.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRenderer.java deleted file mode 100644 index 05aeab814..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRenderer.java +++ /dev/null @@ -1,640 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.renderer.video; - -import java.awt.*; -import java.lang.reflect.*; - -import javax.media.*; -import javax.media.format.*; -import javax.media.renderer.*; -import javax.swing.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.jmfext.media.renderer.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.util.*; - -/** - * Implements a VideoRenderer which uses JAWT to perform native - * painting in an AWT or Swing Component. - * - * @author Lyubomir Marinov - */ -public class JAWTRenderer - extends AbstractRenderer - implements VideoRenderer -{ - /** - * The Logger used by the JAWTRenderer class and its - * instances for logging output. - */ - private static final Logger logger = Logger.getLogger(JAWTRenderer.class); - - /** - * The human-readable PlugIn name of the JAWTRenderer - * instances. - */ - private static final String PLUGIN_NAME = "JAWT Renderer"; - - /** - * The array of supported input formats. - */ - private static final Format[] SUPPORTED_INPUT_FORMATS - = new Format[] - { - OSUtils.IS_LINUX - ? new YUVFormat( - null /* size */, - Format.NOT_SPECIFIED /* maxDataLength */, - Format.intArray, - Format.NOT_SPECIFIED /* frameRate */, - YUVFormat.YUV_420, - Format.NOT_SPECIFIED /* strideY */, - Format.NOT_SPECIFIED /* strideUV */, - Format.NOT_SPECIFIED /* offsetY */, - Format.NOT_SPECIFIED /* offsetU */, - Format.NOT_SPECIFIED /* offsetV */) - : new RGBFormat( - null, - Format.NOT_SPECIFIED, - Format.intArray, - Format.NOT_SPECIFIED, - 32, - 0x00FF0000, 0x0000FF00, 0x000000FF) - }; - - /** - * The indicator which determines whether CALayer-based painting is - * to be performed by JAWTRenderer on Mac OS X. - */ - private static final boolean USE_MACOSX_CALAYERS; - - static - { - System.loadLibrary("jnawtrenderer"); - - /* - * XXX The native JAWTRenderer implementation on Mac OS X which paints - * in a CALayer-like fashion has been determined through testing to not - * work as expected on MacBookPro8. Unfortunately, the cause of the - * problem has not been determined. As a workaround, fall back to the - * alternative implementation (currently used on the other supported - * operating systems) on the problematic model. - */ - if (OSUtils.IS_MAC) - { - ConfigurationService cfg - = NeomediaActivator.getConfigurationService(); - - if ((cfg == null) - || cfg.getBoolean( - JAWTRenderer.class.getName() - + ".USE_MACOSX_CALAYERS", - false)) - { - String hwModel = sysctlbyname("hw.model"); - - USE_MACOSX_CALAYERS - = (hwModel == null) - || !(hwModel.startsWith("MacBookPro8") - || hwModel.startsWith("MacBookAir4")); - } - else - USE_MACOSX_CALAYERS = false; - } - else - { - // CALayer-like painting is currently only supported on Mac OS X. - USE_MACOSX_CALAYERS = false; - } - } - - /** - * The AWT Component into which this VideoRenderer draws. - */ - private Component component; - - /** - * The handle to the native counterpart of this JAWTRenderer. - */ - private long handle = 0; - - /** - * The last known height of the input processed by this - * JAWTRenderer. - */ - private int inputHeight = 0; - - /** - * The last known width of the input processed by this - * JAWTRenderer. - */ - private int inputWidth = 0; - - /** - * Initializes a new JAWTRenderer instance. - */ - public JAWTRenderer() - { - } - - static native void addNotifyLightweightComponent( - long handle, Component component, - long parentHandle); - - /** - * Closes this PlugIn and releases the resources it has retained - * during its execution. No more data will be accepted by this - * PlugIn afterwards. A closed PlugIn can be reinstated by - * calling open again. - */ - public synchronized void close() - { - if (handle != 0) - { - try - { - /* - * It may or may not be necessary to ensure that #removeNotify() - * is delivered to the native counterpart of this JAWTRenderer. - * Anyway, do so for the sake of completeness. - */ - /* - * Unfortunately, doing so in the synchronized block leads to a - * deadlock. - */ -// if (JComponent.isLightweightComponent(component)) -// { -// Container parent = component.getParent(); -// -// if (parent != null) -// parent.remove(component); -// } - } - finally - { - close(handle, component); - handle = 0; - } - } - } - - /** - * Closes the native counterpart of a JAWTRenderer specified by its - * handle as returned by {@link #open(Component)} and rendering into a - * specific AWT Component. Releases the resources which the - * specified native counterpart has retained during its execution and its - * handle is considered to be invalid afterwards. - * - * @param handle the handle to the native counterpart of a - * JAWTRenderer as returned by {@link #open(Component)} which is to - * be closed - * @param component the AWT Component into which the - * JAWTRenderer and its native counterpart are drawing. The - * platform-specific info of component is not guaranteed to be - * valid. - */ - static native void close(long handle, Component component); - - /** - * Gets the region in the component of this VideoRenderer where the - * video is rendered. - * - * @return the region in the component of this VideoRenderer where - * the video is rendered; null if the entire component is used - */ - public Rectangle getBounds() - { - // TODO Auto-generated method stub - return null; - } - - /** - * Gets the AWT Component into which this VideoRenderer - * draws. - * - * @return the AWT Component into which this VideoRenderer - * draws - */ - public synchronized Component getComponent() - { - if (component == null) - { - StringBuilder componentClassName = new StringBuilder(); - - componentClassName.append(JAWTRenderer.class.getName()); - if (USE_MACOSX_CALAYERS && OSUtils.IS_MAC) - componentClassName.append("Swing"); - else if (OSUtils.IS_ANDROID) - componentClassName.append("Android"); - componentClassName.append("VideoComponent"); - - Class componentClass; - - try - { - componentClass = Class.forName(componentClassName.toString()); - } - catch (ClassNotFoundException cnfe) - { - throw new RuntimeException(cnfe); - } - - Constructor componentConstructor; - - try - { - componentConstructor - = componentClass.getConstructor(JAWTRenderer.class); - } - catch (NoSuchMethodException nsme) - { - throw new RuntimeException(nsme); - } - try - { - component = (Component) componentConstructor.newInstance(this); - } - catch (IllegalAccessException iae) - { - throw new RuntimeException(iae); - } - catch (InstantiationException ie) - { - throw new RuntimeException(ie); - } - catch (InvocationTargetException ite) - { - throw new RuntimeException(ite); - } - } - return component; - } - - /** - * Gets the handle to the native counterpart of this JAWTRenderer. - * - * @return the handle to the native counterpart of this - * JAWTRenderer - */ - long getHandle() - { - return handle; - } - - /** - * Gets the Object which synchronizes the access to the handle to - * the native counterpart of this JAWTRenderer. - * - * @return the Object which synchronizes the access to the handle - * to the native counterpart of this JAWTRenderer - */ - Object getHandleLock() - { - return this; - } - - /** - * Gets the human-readable name of this PlugIn. - * - * @return the human-readable name of this PlugIn - */ - public String getName() - { - return PLUGIN_NAME; - } - - /** - * Gets the list of input Formats supported by this - * Renderer. - * - * @return an array of Format elements which represent the input - * Formats supported by this Renderer - */ - public Format[] getSupportedInputFormats() - { - return SUPPORTED_INPUT_FORMATS.clone(); - } - - /** - * Opens this PlugIn and acquires the resources that it needs to - * operate. The input format of this Renderer has to be set before - * open is called. Buffers should not be passed into this - * PlugIn without first calling open. - * - * @throws ResourceUnavailableException if there is a problem during opening - */ - public void open() - throws ResourceUnavailableException - { - boolean addNotify; - final Component component; - - synchronized (this) - { - if (handle == 0) - { - /* - * If this JAWTRenderer gets opened after its visual/video - * Component has been created, send addNotify to the Component - * once this JAWTRenderer gets opened so that the Component may - * use the handle if it needs to. - */ - addNotify - = (this.component != null) - && (this.component.getParent() != null); - component = getComponent(); - - handle = open(component); - if (handle == 0) - { - throw new ResourceUnavailableException( - "Failed to open the native counterpart of JAWTRenderer"); - } - } - else - { - addNotify = false; - component = null; - } - } - /* - * The #addNotify() invocation, if any, should happen outside the - * synchronized block in order to avoid a deadlock. - */ - if (addNotify) - { - SwingUtilities.invokeLater( - new Runnable() - { - public void run() - { - component.addNotify(); - } - }); - } - } - - /** - * Opens a handle to a native counterpart of a JAWTRenderer which - * is to draw into a specific AWT Component. - * - * @param component the AWT Component into which a - * JAWTRenderer and the native counterpart to be opened are to - * draw. The platform-specific info of component is not guaranteed - * to be valid. - * @return a handle to a native counterpart of a JAWTRenderer which - * is to draw into the specified AWT Component - * @throws ResourceUnavailableException if there is a problem during opening - */ - static native long open(Component component) - throws ResourceUnavailableException; - - /** - * Paints a specific Component which is the AWT Component - * of a JAWTRenderer specified by the handle to its native - * counterpart. - * - * @param handle the handle to the native counterpart of a - * JAWTRenderer which is to draw into the specified AWT - * Component - * @param component the AWT Component into which the - * JAWTRenderer and its native counterpart specified by - * handle are to draw. The platform-specific info of - * component is guaranteed to be valid only during the execution of - * paint. - * @param g the Graphics context into which the drawing is to be - * performed - * @return true if the native counterpart of a - * JAWTRenderer wants to continue receiving the paint - * calls on the AWT Component; otherwise, false. For example, after - * the native counterpart has been able to acquire the native handle of the - * AWT Component, it may be able to determine when the native - * handle needs painting without waiting for AWT to call paint on - * the Component. In such a scenario, the native counterpart may - * indicate with false that it does not need further paint - * deliveries. - */ - static native boolean paint( - long handle, Component component, Graphics g); - - static native boolean paintLightweightComponent( - long handle, Component component, Graphics g); - - /** - * Processes the data provided in a specific Buffer and renders it - * to the output device represented by this Renderer. - * - * @param buffer a Buffer containing the data to be processed and - * rendered - * @return BUFFER_PROCESSED_OK if the processing is successful; - * otherwise, the other possible return codes defined in the PlugIn - * interface - */ - public synchronized int process(Buffer buffer) - { - if (buffer.isDiscard()) - return BUFFER_PROCESSED_OK; - - int bufferLength = buffer.getLength(); - - if (bufferLength == 0) - return BUFFER_PROCESSED_OK; - - Format bufferFormat = buffer.getFormat(); - - if ((bufferFormat != null) - && (bufferFormat != this.inputFormat) - && !bufferFormat.equals(this.inputFormat)) - { - if (setInputFormat(bufferFormat) == null) - return BUFFER_PROCESSED_FAILED; - } - - if (handle == 0) - return BUFFER_PROCESSED_FAILED; - else - { - Dimension size = null; - - if (bufferFormat != null) - size = ((VideoFormat) bufferFormat).getSize(); - if (size == null) - { - size = this.inputFormat.getSize(); - if (size == null) - return BUFFER_PROCESSED_FAILED; - } - - Component component = getComponent(); - boolean repaint = false; - - repaint - = process( - handle, - component, - (int[]) buffer.getData(), buffer.getOffset(), bufferLength, - size.width, size.height); - - if (repaint) - component.repaint(); - return BUFFER_PROCESSED_OK; - } - } - - /** - * Processes the data provided in a specific int array with a - * specific offset and length and renders it to the output device - * represented by a JAWTRenderer specified by the handle to it - * native counterpart. - * - * @param handle the handle to the native counterpart of a - * JAWTRenderer to process the specified data and render it - * @param component the AWT component into which the specified - * JAWTRenderer and its native counterpart draw - * @param data an int array which contains the data to be processed - * and rendered - * @param offset the index in data at which the data to be - * processed and rendered starts - * @param length the number of elements in data starting at - * offset which represent the data to be processed and rendered - * @param width the width of the video frame in data - * @param height the height of the video frame in data - * @return true if data has been successfully processed - */ - static native boolean process( - long handle, - Component component, - int[] data, int offset, int length, - int width, int height); - - static native void processLightweightComponentEvent( - long handle, - int x, int y, int width, int height); - - static native void removeNotifyLightweightComponent( - long handle, Component component); - - /** - * Sets the region in the component of this VideoRenderer where the - * video is to be rendered. - * - * @param bounds the region in the component of this VideoRenderer - * where the video is to be rendered; null if the entire component - * is to be used - */ - public void setBounds(Rectangle bounds) - { - // TODO Auto-generated method stub - } - - /** - * Sets the AWT Component into which this VideoRenderer is - * to draw. JAWTRenderer cannot draw into any other AWT - * Component but its own so it always returns false. - * - * @param component the AWT Component into which this - * VideoRenderer is to draw - * @return true if this VideoRenderer accepted the - * specified component as the AWT Component into which it - * is to draw; false, otherwise - */ - public boolean setComponent(Component component) - { - // We cannot draw into any other AWT Component but our own. - return false; - } - - /** - * Sets the Format of the input to be processed by this - * Renderer. - * - * @param format the Format to be set as the Format of the - * input to be processed by this Renderer - * @return the Format of the input to be processed by this - * Renderer if the specified format is supported or - * null if the specified format is not supported by this - * Renderer. Typically, it is the supported input Format - * which most closely matches the specified Format. - */ - @Override - public Format setInputFormat(Format format) - { - super.setInputFormat(format); - - /* - * Know the width and height of the input because we'll be depicting it - * and we may want, for example, to report it as the preferred size of - * our AWT Component. - */ - Dimension inputSize = inputFormat.getSize(); - - if (inputSize != null) - { - inputWidth = inputSize.width; - inputHeight = inputSize.height; - } - - /* - * Reflect the width and height of the input onto the preferredSize of - * our AWT Component (if necessary). - */ - if ((inputWidth > 0) && (inputHeight > 0)) - { - Component component = getComponent(); - Dimension preferredSize = component.getPreferredSize(); - - /* - * Apart from the simplest of cases in which the component has no - * preferredSize, it is also necessary to reflect the width and - * height of the input onto the preferredSize when the ratio of the - * input is different than the ratio of the preferredSize. - */ - if ((preferredSize == null) - || (preferredSize.width < 1) - || (preferredSize.height < 1) - || (preferredSize.width * inputHeight - != preferredSize.height * inputWidth)) - { - component.setPreferredSize( - new Dimension(inputWidth, inputHeight)); - } - - /* - * If the component does not have a size, it looks strange given - * that we know a preferredSize for it. - */ - Dimension size = component.getSize(); - - if ((size.width < 1) || (size.height < 1)) - { - preferredSize = component.getPreferredSize(); - component.setSize(preferredSize.width, preferredSize.height); - } - } - - return inputFormat; - } - - /** - * Starts the rendering process. Begins rendering any data available in the - * internal buffers of this Renderer. - */ - public void start() - { - } - - /** - * Stops the rendering process. - */ - public void stop() - { - } - - private static native String sysctlbyname(String name); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRendererSwingVideoComponent.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRendererSwingVideoComponent.java deleted file mode 100644 index fd2d74f3c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRendererSwingVideoComponent.java +++ /dev/null @@ -1,908 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.renderer.video; - -import java.awt.*; -import java.awt.event.*; -import java.awt.image.*; -import java.util.*; -import java.util.List; // disambiguation - -import javax.media.*; -import javax.swing.*; - -import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.swing.*; - -/** - * Implements a Swing Component in which JAWTRenderer paints. - * - * @author Lyubomir Marinov - */ -public class JAWTRendererSwingVideoComponent - extends JPanel -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * The Logger used by the JAWTRendererSwingVideoComponent - * class and its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(JAWTRendererSwingVideoComponent.class); - - /** - * The SwingVideoComponentCanvas in which this - * SwingVideoComponent is painted according to the last call to - * {@link #addNotify()}. - */ - private SwingVideoComponentCanvas canvas; - - /** - * The Container which is the last-known parent of this - * SwingVideoComponent. - */ - private Container parent; - - /** - * The ComponentListener which is to be or is listening to - * ComponentEvents fired by {@link #parent}. - */ - private final ComponentListener parentComponentListener - = new ComponentAdapter() - { - @Override - public void componentResized(ComponentEvent e) - { - /* - * It is necessary to call - * #procesLightweightComponentEvent() when the parent gets - * resized only if the native counterpart of this - * SwingVideoComponent expects bounds in a coordinate system - * which changes with respect to the bounds of this - * SwingVideoComponent when the parent gets resized. - */ - //processLightweightComponentEvent(); - } - }; - - /** - * The JAWTRenderer which paints in this - * JAWTRendererSwingVideoComponent. - */ - private final JAWTRenderer renderer; - - /** - * The indicator which determines whether the native counterpart of this - * JAWTRenderer wants paint calls on its Swing - * Component to be delivered. - * - * @see JAWTRendererVideoComponent#wantsPaint - */ - private boolean wantsPaint = true; - - /** - * Constructor. - * - * @param renderer JAWTRenderer instance - */ - public JAWTRendererSwingVideoComponent(JAWTRenderer renderer) - { - if (VideoContainer.DEFAULT_BACKGROUND_COLOR != null) - setBackground(VideoContainer.DEFAULT_BACKGROUND_COLOR); - - this.renderer = renderer; - } - - @Override - public void addNotify() - { - /* - * Since JAWTRenderer#open() may be performing the call, it may be - * wrong about this SwingVideoComponent having a parent. - */ - Container parent = getParent(); - - if (parent == null) - return; - - super.addNotify(); - - wantsPaint = true; - - synchronized (renderer.getHandleLock()) - { - long handle = renderer.getHandle(); - - if (handle != 0) - { - SwingVideoComponentCanvas canvas = findCanvas(); - - if (canvas == null) - { - JAWTRenderer.addNotifyLightweightComponent( - handle, this, - 0); - } - else - { - long canvasHandle; - - synchronized (canvas.getHandleLock()) - { - canvasHandle = canvas.getHandle(); - JAWTRenderer.addNotifyLightweightComponent( - handle, this, - canvasHandle); - } - if ((canvasHandle != 0) && (this.canvas != canvas)) - { - this.canvas = canvas; - } - } - - /* - * Emulate a ComponentEvent so that, for example, the native - * counterpart of this Component gets its bounds up to date. - */ - processLightweightComponentEvent(); - } - } - - if (this.parent != parent) - { - this.parent = parent; - this.parent.addComponentListener(parentComponentListener); - } - } - - /** - * Creates a new AWT Component in which - * SwingVideoComponents can be rendered. - * @return new AWT Component in which SwingVideoComponents - * can be rendered - */ - public Component createCanvas() - { - return new SwingVideoComponentCanvas(renderer); - } - - /** - * Finds a SwingVideoComponentCanvas in which this - * SwingVideoComponent can be painted. - * - * @return a SwingVideoComponentCanvas in which this - * SwingVideoComponent can be painted if any; otherwise, - * null - */ - private SwingVideoComponentCanvas findCanvas() - { - Container parent = getParent(); - - if (parent != null) - for (Component component : parent.getComponents()) - if (component instanceof SwingVideoComponentCanvas) - return (SwingVideoComponentCanvas) component; - return null; - } - - /** - * Gets the SwingVideoComponentCanvas in which this - * SwingVideoComponent is being painted. - * - * @return the SwingVideoComponentCanvas in which this - * SwingVideoComponent is being painted if any; otherwise, - * null - */ - SwingVideoComponentCanvas getCanvas() - { - return canvas; - } - - @Override - public void paint(Graphics g) - { - synchronized (renderer.getHandleLock()) - { - long handle = renderer.getHandle(); - - if (wantsPaint && (handle != 0)) - { - wantsPaint - = JAWTRenderer.paintLightweightComponent( - handle, - this, - g); - } - } - } - - @Override - protected void processComponentEvent(ComponentEvent e) - { - super.processComponentEvent(e); - - if (equals(e.getComponent())) - { - switch(e.getID()) - { - case ComponentEvent.COMPONENT_MOVED: - case ComponentEvent.COMPONENT_RESIZED: - processLightweightComponentEvent(); - break; - } - } - } - - /** - * Notifies this SwingVideoComponent that a - * ComponentEvent related to it has occurred. - */ - private void processLightweightComponentEvent() - { - Rectangle bounds = getBounds(); - - if (bounds != null) - { - synchronized (renderer.getHandleLock()) - { - long handle = renderer.getHandle(); - - if (handle != 0) - { - JAWTRenderer.processLightweightComponentEvent( - handle, - bounds.x, - bounds.y, - bounds.width, - bounds.height); - } - } - } - } - - @Override - public void removeNotify() - { - if (parent != null) - { - parent.removeComponentListener(parentComponentListener); - parent = null; - } - - synchronized (renderer.getHandleLock()) - { - long handle = renderer.getHandle(); - - if (handle != 0) - { - if (canvas != null) - { - synchronized (canvas.getHandleLock()) - { - JAWTRenderer.removeNotifyLightweightComponent( - handle, this); - } - canvas = null; - } - else - { - JAWTRenderer.removeNotifyLightweightComponent( - handle, this); - } - } - } - - /* - * In case the associated JAWTRenderer has said that it does not - * want paint events/notifications, ask it again next time because - * the native handle of this Canvas may be recreated. - */ - wantsPaint = true; - - super.removeNotify(); - } - - @Override - public void repaint() - { - super.repaint(); - - /* - * Since SwingVideoComponent is to be painted in a - * SwingVideoComponentCanvas, the latter should repaint when the - * former does. - */ - Component canvas = getCanvas(); - - if (canvas != null) - canvas.repaint(); - } - - @Override - public void setBounds(int x, int y, int width, int height) - { - super.setBounds(x, y, width, height); - - /* - * Calling #setBounds(int, int, int, int) does not seem to cause - * this SwingVideoComponent to process a ComponentEvent so force it - * because it is really necessary to deliver the up-to-date bounds - * to the native counterpart. - */ - processLightweightComponentEvent(); - } - - @Override - public void setLocation(int x, int y) - { - super.setLocation(x, y); - - processLightweightComponentEvent(); - } - - /** - * Represents a Component which is neither a - * AWTVideoComponent nor a SwingVideoComponent but which - * is to be painted by a SwingVideoComponentCanvas anyway. - */ - private static class NonVideoComponent - { - /** - * The BufferedImage into which {@link #component} is to be - * painted so that it can be processed and then rendered by - * {@link #handle}. - */ - private BufferedImage bufferedImage; - - /** - * The Component represented by this NonVideoComponent - * instance. - */ - public final Component component; - - /** - * The handle of the native JAWTRenderer which paints this - * NonVideoComponent. - */ - private long handle; - - /** - * The height in pixels of {@link #bufferedImage} and {@link #rgb}. - */ - private int height; - - /** - * The pixels of {@link #bufferedImage} to be processed by - * {@link #handle}. - */ - private int[] rgb; - - /** - * The width in pixels of {@link #bufferedImage} and {@link #rgb}. - */ - private int width; - - /** - * Initializes a new NonVideoComponent instance which is to - * paint a specific Component in the context of a parent - * JAWTRenderer. - * - * @param component the Component to be painted - * @param parentHandle the handle of the native JAWTRenderer in - * the context of which component is to be painted - */ - public NonVideoComponent(Component component, long parentHandle) - { - this.component = component; - - try - { - handle = JAWTRenderer.open(this.component); - if (handle != 0) - { - JAWTRenderer.addNotifyLightweightComponent( - handle, this.component, - parentHandle); - } - } - catch (ResourceUnavailableException rue) - { - logger.error( - "Failed to JAWTRenderer.open for NonVideoComponent", - rue); - } - } - - /** - * Releases the resources of this NonVideoComponent and - * prepares it to be garbage collected. - */ - public void dispose() - { - if (handle != 0) - { - JAWTRenderer.removeNotifyLightweightComponent( - handle, component); - JAWTRenderer.close(handle, component); - handle = 0; - } - } - - /** - * Paints the Component associated with this - * NonVideoComponent instance. - */ - public void paint() - { - if (handle != 0) - { - /* - * Make sure the location, the size and the visibility known to - * the associated native JAWTRenderer are in sync with these of - * the component. - */ - Rectangle bounds = component.getBounds(); - - if (!component.isVisible()) - { - bounds.height = 0; - bounds.width = 0; - } - JAWTRenderer.processLightweightComponentEvent( - handle, - bounds.x, bounds.y, bounds.width, bounds.height); - - /* - * If the component is not visible, the native JAWTRenderer - * already knows that it is not to be rendered. - */ - if ((bounds.height < 1) || (bounds.width < 1)) - return; - - /* - * Paint the component and tell the native JAWTRenderer about - * the latest painting. - */ - if ((height != bounds.height) || (width != bounds.width)) - { - rgb = new int[bounds.width * bounds.height]; - bufferedImage - = new BufferedImage( - bounds.width, bounds.height, - BufferedImage.TYPE_INT_ARGB); - height = bounds.height; - width = bounds.width; - } - if ((bufferedImage != null) && (rgb != null)) - { - Graphics g = bufferedImage.createGraphics(); - boolean process = false; - - try - { - component.paint(g); - process = true; - } - finally - { - g.dispose(); - } - if (process) - { - bufferedImage.getRGB( - 0, 0, width, height, - rgb, 0, width); - JAWTRenderer.process( - handle, component, - rgb, 0, rgb.length, - width, height); - } - } - } - } - } - - /** - * Implements an AWT Component in which - * SwingVideoComponents can be rendered. - */ - private static class SwingVideoComponentCanvas - extends JAWTRendererVideoComponent - { - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * The handle to the native JAWTRenderer which does the actual - * painting of this SwingVideoComponentCanvas. - */ - private long handle; - - /** - * The Component to which this - * SwingVideoComponentCanvas has dispatched a - * {@link MouseEvent#MOUSE_PRESSED}. - */ - private Component mousePressedComponent; - - /** - * The NoVideoComponents painted by this - * SwingVideoComponentCanvas. - */ - private final List nonVideoComponents - = new LinkedList(); - - /** - * The Container which is the last-known parent of this - * SwingVideoComponentCanvas. - */ - private Container parent; - - /** - * The ContainerListener which listens to {@link #parent}. - */ - private final ContainerListener parentContainerListener - = new ContainerListener() - { - public void componentAdded(ContainerEvent e) - { - Component c = e.getChild(); - - if (!(c instanceof JAWTRendererVideoComponent) - && !(c instanceof JAWTRendererSwingVideoComponent)) - { - nonVideoComponentAdded(c); - } - } - - public void componentRemoved(ContainerEvent e) - { - Component c = e.getChild(); - - if (mousePressedComponent == c) - mousePressedComponent = null; - - if (!(c instanceof JAWTRendererVideoComponent) - && !(c instanceof JAWTRendererSwingVideoComponent)) - { - nonVideoComponentRemoved(c); - } - else if (SwingVideoComponentCanvas.this.equals(c)) - removeAllNonVideoComponents(); - } - }; - - /** - * Initializes a new SwingVideoComponentCanvas instance. - * - * @param renderer - */ - public SwingVideoComponentCanvas(JAWTRenderer renderer) - { - super(renderer); - - enableEvents( - AWTEvent.MOUSE_EVENT_MASK - | AWTEvent.MOUSE_MOTION_EVENT_MASK); - } - - @Override - public void addNotify() - { - super.addNotify(); - - synchronized (getHandleLock()) - { - if (getHandle() == 0) - { - try - { - this.handle = JAWTRenderer.open(this); - } - catch (ResourceUnavailableException rue) - { - throw new RuntimeException(rue); - } - if (getHandle() == 0) - { - throw new RuntimeException( - "JAWTRenderer#open(Component)"); - } - } - } - - Container parent = getParent(); - - if ((parent != null) && (this.parent != parent)) - { - this.parent = parent; - this.parent.addContainerListener(parentContainerListener); - } - } - - @Override - public boolean contains(int x, int y) - { - /* - * Act as a "glass pane" i.e. be transparent with respect to points - * and pretend they are in whatever is underneath. - */ - return false; - } - - /** - * Dispatches MouseEvents to whatever is underneath this - * SwingVideoComponentCanvas because it only renders - * Components i.e. it is like a "glass pane". - */ - private boolean dispatchMouseEvent(MouseEvent e) - { - Component srcc = e.getComponent(); - - if (srcc != null) - { - int id = e.getID(); - Component dstc = null; - - /* - * After a MOUSE_PRESSED, this SwingVideoComponentCanvas will - * continue to receive, for example, MouseMotionEvents even - * when the point has moved out of it. Emulate the same behavior - * for the Components this SwingVideoComponentCanvas dispatches - * events to since it is transparent in this respect. - */ - if (MouseEvent.MOUSE_PRESSED == id) - mousePressedComponent = null; - else if (mousePressedComponent != null) - { - dstc = mousePressedComponent; - if ((MouseEvent.MOUSE_CLICKED == id) - || (MouseEvent.MOUSE_RELEASED == id)) - mousePressedComponent = null; - } - - if (dstc == null) - { - Container parent = getParent(); - - if (parent != null) - { - Point parentPoint - = SwingUtilities.convertPoint( - srcc, - e.getPoint(), - parent); - - dstc = getComponentAt(parent, parentPoint); - } - } - - if (dstc != null) - { - if (MouseEvent.MOUSE_PRESSED == id) - mousePressedComponent = dstc; - dstc.dispatchEvent( - SwingUtilities.convertMouseEvent( - srcc, - e, - dstc)); - return true; - } - } - return false; - } - - /** - * Determines the Component which is a child of a specific - * Container which contains a specific Point. Since - * SwingVideoComponentCanvas is like a "glass pane", it never - * contains the specified point. - * - * @param parent the Container which contains the - * Components which may contain the specified point - * @param point the point in the coordinate system of parent - * which is to be determined which Component contains it - * @return the Component which is a child of the specified - * Container and contains the specified Point or - * null if there is no such Component - */ - private Component getComponentAt(Container parent, Point point) - { - Component[] components = parent.getComponents(); - - for (int componentIndex = components.length - 1; - componentIndex >= 0; - componentIndex--) - { - Component component = components[componentIndex]; - - if (!equals(component) - && component.isVisible() - && component.contains( - SwingUtilities.convertPoint( - parent, - point, - component))) - { - return component; - } - } - return null; - } - - /* Overrides JAWTRendererVideoComponent#getHandle(). */ - @Override - protected long getHandle() - { - return handle; - } - - /* Overrides JAWTRendererVideoComponent#getHandleLock(). */ - @Override - protected Object getHandleLock() - { - return this; - } - - /** - * Notifies this SwingVideoComponentCanvas that a - * Component which is neither an AWTVideoComponent nor - * a SwingVideoComponent has been added to {@link #parent}. - * - * @param c the component which has been added - */ - private void nonVideoComponentAdded(Component c) - { - synchronized (getHandleLock()) - { - synchronized (nonVideoComponents) - { - for (NonVideoComponent nonVideoComponent - : nonVideoComponents) - { - if (nonVideoComponent.component.equals(c)) - return; - } - - nonVideoComponents.add( - new NonVideoComponent(c, getHandle())); - } - } - } - - /** - * Notifies this SwingVideoComponentCanvas that a - * Component which is neither an AWTVideoComponent nor - * a SwingVideoComponent has been removed from {@link #parent}. - * - * @param c the component which has been removed - */ - private void nonVideoComponentRemoved(Component c) - { - synchronized (nonVideoComponents) - { - Iterator nonVideoComponentIter - = nonVideoComponents.iterator(); - - while (nonVideoComponentIter.hasNext()) - { - NonVideoComponent nonVideoComponent - = nonVideoComponentIter.next(); - - if (nonVideoComponent.component.equals(c)) - { - nonVideoComponentIter.remove(); - nonVideoComponent.dispose(); - break; - } - } - } - } - - @Override - public void paint(Graphics g) - { - try - { - synchronized (nonVideoComponents) - { - for (NonVideoComponent nonVideoComponent - : nonVideoComponents) - nonVideoComponent.paint(); - } - } - finally - { - super.paint(g); - } - } - - @Override - protected void processMouseEvent(MouseEvent e) - { - /* - * Act as a "glass pane" i.e. be transparent with respect to - * MouseEvents and dispatch them to whatever is underneath. - */ - if (!dispatchMouseEvent(e)) - super.processMouseEvent(e); - } - - @Override - protected void processMouseMotionEvent(MouseEvent e) - { - /* - * Act as a "glass pane" i.e. be transparent with respect to - * MouseEvents and dispatch them to whatever is underneath. - */ - if (!dispatchMouseEvent(e)) - super.processMouseMotionEvent(e); - } - - /** - * Removes all NonVideoComponents from this - * SwingVideoComponentCanvas so that their associated - * Components are no longer painted by the represented native - * JAWTRenderer. - */ - private void removeAllNonVideoComponents() - { - synchronized (nonVideoComponents) - { - Iterator nonVideoComponentIter - = nonVideoComponents.iterator(); - - while (nonVideoComponentIter.hasNext()) - { - NonVideoComponent nonVideoComponent - = nonVideoComponentIter.next(); - - nonVideoComponentIter.remove(); - nonVideoComponent.dispose(); - } - } - } - - @Override - public void removeNotify() - { - mousePressedComponent = null; - - if (parent != null) - { - parent.removeContainerListener(parentContainerListener); - removeAllNonVideoComponents(); - parent = null; - } - - synchronized (getHandleLock()) - { - long handle = getHandle(); - - if (handle != 0) - { - try - { - JAWTRenderer.close(handle, this); - } - finally - { - this.handle = 0; - } - } - } - - super.removeNotify(); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRendererVideoComponent.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRendererVideoComponent.java deleted file mode 100644 index 61841946f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRendererVideoComponent.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.jmfext.media.renderer.video; - -import java.awt.*; - -import net.java.sip.communicator.util.swing.*; - -/** - * Implements an AWT Component in which JAWTRenderer paints. - * - * @author Lyubomir Marinov - */ -public class JAWTRendererVideoComponent - extends Canvas -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * The JAWTRenderer which paints in this - * JAWTRendererVideoComponent. - */ - protected final JAWTRenderer renderer; - - /** - * The indicator which determines whether the native counterpart of this - * JAWTRenderer wants paint calls on its AWT - * Component to be delivered. For example, after the native - * counterpart has been able to acquire the native handle of the AWT - * Component, it may be able to determine when the native - * handle needs painting without waiting for AWT to call paint - * on the Component. In such a scenario, the native counterpart - * may indicate with false that it does not need further - * paint deliveries. - */ - private boolean wantsPaint = true; - - /** - * Initializes a new JAWTRendererVideoComponent instance. - * - * @param renderer - */ - public JAWTRendererVideoComponent(JAWTRenderer renderer) - { - if (VideoContainer.DEFAULT_BACKGROUND_COLOR != null) - setBackground(VideoContainer.DEFAULT_BACKGROUND_COLOR); - - this.renderer = renderer; - } - - @Override - public void addNotify() - { - super.addNotify(); - - wantsPaint = true; - } - - /** - * Gets the handle of the native counterpart of the - * JAWTRenderer which paints in this - * AWTVideoComponent. - * - * @return the handle of the native counterpart of the - * JAWTRenderer which paints in this AWTVideoComponent - */ - protected long getHandle() - { - return renderer.getHandle(); - } - - /** - * Gets the synchronization lock which protects the access to the - * handle property of this AWTVideoComponent. - * - * @return the synchronization lock which protects the access to the - * handle property of this AWTVideoComponent - */ - protected Object getHandleLock() - { - return renderer.getHandleLock(); - } - - @Override - public void paint(Graphics g) - { - if (wantsPaint) - { - synchronized (getHandleLock()) - { - long handle; - - if ((handle = getHandle()) != 0) - wantsPaint = JAWTRenderer.paint(handle, this, g); - } - } - } - - @Override - public void removeNotify() - { - /* - * In case the associated JAWTRenderer has said that it does not - * want paint events/notifications, ask it again next time because - * the native handle of this Canvas may be recreated. - */ - wantsPaint = true; - - super.removeNotify(); - } - - @Override - public void update(Graphics g) - { - synchronized (getHandleLock()) - { - if (!wantsPaint || (getHandle() == 0)) - { - super.update(g); - return; - } - } - - /* - * Skip the filling with the background color because it causes - * flickering. - */ - paint(g); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/neomedia.manifest.mf b/src/net/java/sip/communicator/impl/neomedia/neomedia.manifest.mf index 061e16e0d..a7979b859 100644 --- a/src/net/java/sip/communicator/impl/neomedia/neomedia.manifest.mf +++ b/src/net/java/sip/communicator/impl/neomedia/neomedia.manifest.mf @@ -4,18 +4,16 @@ Bundle-Description: A bundle that offers Media capture and presentation capabili Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes -Import-Package: org.bouncycastle.crypto, - org.bouncycastle.crypto.digests, - org.bouncycastle.crypto.engines, - org.bouncycastle.crypto.macs, - org.bouncycastle.crypto.params, - org.bouncycastle.crypto.prng, - org.ice4j.socket, - org.json, - org.osgi.framework, - org.w3c.dom, - org.xml.sax, +Import-Package: apple.awt, + ch.imvs.sdes4j, + ch.imvs.sdes4j.srtp, + gnu.java.zrtp, + gnu.java.zrtp.packets, + gnu.java.zrtp.utils, + gnu.java.zrtp.zidfile, javax.imageio, + javax.media, + javax.media.protocol, javax.sound.sampled, javax.swing, javax.swing.border, @@ -26,33 +24,45 @@ Import-Package: org.bouncycastle.crypto, javax.xml.transform, javax.xml.transform.dom, javax.xml.transform.stream, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.fileaccess, net.java.sip.communicator.service.gui, - net.java.sip.communicator.service.packetlogging, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.resources, - net.java.sip.communicator.service.version, net.java.sip.communicator.util, net.java.sip.communicator.util.event, net.java.sip.communicator.util.swing, + org.bouncycastle.crypto, + org.bouncycastle.crypto.digests, + org.bouncycastle.crypto.engines, + org.bouncycastle.crypto.macs, + org.bouncycastle.crypto.params, + org.bouncycastle.crypto.prng, + org.ice4j.socket, + org.jitsi.impl.neomedia, + org.jitsi.impl.neomedia.codec, + org.jitsi.impl.neomedia.codec.video.h264, + org.jitsi.impl.neomedia.device, + org.jitsi.impl.neomedia.format, + org.jitsi.service.audionotifier, + org.jitsi.service.configuration, + org.jitsi.service.fileaccess, + org.jitsi.service.libjitsi, + org.jitsi.service.neomedia, + org.jitsi.service.neomedia.control, + org.jitsi.service.neomedia.device, + org.jitsi.service.neomedia.event, + org.jitsi.service.neomedia.format, + org.jitsi.service.packetlogging, + org.jitsi.service.resources, + org.jitsi.service.version, + org.jitsi.util, + org.jitsi.util.swing, + org.json, + org.osgi.framework, + org.w3c.dom, + org.xml.sax, quicktime, quicktime.qd, quicktime.std.image, quicktime.std.sg, - quicktime.util, - gnu.java.zrtp, - gnu.java.zrtp.packets, - gnu.java.zrtp.utils, - gnu.java.zrtp.zidfile, - apple.awt, - ch.imvs.sdes4j, - ch.imvs.sdes4j.srtp -Export-Package: net.java.sip.communicator.service.audionotifier, - net.java.sip.communicator.service.neomedia, - net.java.sip.communicator.service.neomedia.control, - net.java.sip.communicator.service.neomedia.device, - net.java.sip.communicator.service.neomedia.event, - net.java.sip.communicator.service.neomedia.format, - net.java.sip.communicator.service.neomedia.imgstreaming + quicktime.util diff --git a/src/net/java/sip/communicator/impl/neomedia/notify/AudioNotifierServiceImpl.java b/src/net/java/sip/communicator/impl/neomedia/notify/AudioNotifierServiceImpl.java deleted file mode 100644 index f2c1f6a1a..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/notify/AudioNotifierServiceImpl.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.notify; - -import java.beans.*; -import java.net.*; -import java.util.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.device.*; -import net.java.sip.communicator.service.audionotifier.*; -import net.java.sip.communicator.service.resources.*; - -/** - * The implementation of the AudioNotifierService. - * - * @author Yana Stamcheva - */ -public class AudioNotifierServiceImpl - implements AudioNotifierService, - PropertyChangeListener -{ - /** - * Map of differents audio clips. - */ - private static final Map audioClips = - new HashMap(); - - /** - * If the sound is currently disabled. - */ - private boolean isMute; - - /** - * Device config to look for notify device. - */ - private final DeviceConfiguration deviceConfiguration; - - /** - * Creates audio notify service. - * @param deviceConfiguration the device configuration. - */ - public AudioNotifierServiceImpl(DeviceConfiguration deviceConfiguration) - { - this.deviceConfiguration = deviceConfiguration; - - deviceConfiguration.addPropertyChangeListener(this); - } - - /** - * Creates an SCAudioClip from the given URI and adds it to the list of - * available audio-s. - * - * @param uri the path where the audio file could be found - * @return a newly created SCAudioClip from uri - */ - public SCAudioClipImpl createAudio(String uri) - { - SCAudioClipImpl audioClip; - - synchronized (audioClips) - { - if(audioClips.containsKey(uri)) - { - audioClip = audioClips.get(uri); - } - else - { - ResourceManagementService resources - = NeomediaActivator.getResources(); - URL url - = (resources == null) - ? null - : resources.getSoundURLForPath(uri); - - if (url == null) - { - // Not found by the class loader. Perhaps it's a local file. - try - { - url = new URL(uri); - } - catch (MalformedURLException e) - { - //logger.error("The given uri could not be parsed.", e); - return null; - } - } - - try - { - AudioSystem audioSystem - = getDeviceConfiguration().getAudioSystem(); - - if (audioSystem == null) - audioClip = new JavaSoundClipImpl(url, this); - else if (NoneAudioSystem.LOCATOR_PROTOCOL.equalsIgnoreCase( - audioSystem.getLocatorProtocol())) - audioClip = null; - else - { - audioClip - = new AudioSystemClipImpl(url, this, audioSystem); - } - } - catch (Throwable t) - { - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - // Cannot create audio to play - return null; - } - - audioClips.put(uri, audioClip); - } - } - - return audioClip; - } - - /** - * Removes the given audio from the list of available audio clips. - * - * @param audioClip the audio to destroy - */ - public void destroyAudio(SCAudioClip audioClip) - { - synchronized (audioClips) - { - audioClips.remove(audioClip); - } - } - - /** - * Enables or disables the sound in the application. If FALSE, we try to - * restore all looping sounds if any. - * - * @param isMute when TRUE disables the sound, otherwise enables the sound. - */ - public void setMute(boolean isMute) - { - this.isMute = isMute; - - for (SCAudioClipImpl audioClip : audioClips.values()) - { - if (isMute) - { - audioClip.internalStop(); - } - else if (audioClip.isLooping()) - { - audioClip.playInLoop(audioClip.getLoopInterval()); - } - } - } - - /** - * Returns TRUE if the sound is currently disabled, FALSE otherwise. - * @return TRUE if the sound is currently disabled, FALSE otherwise - */ - public boolean isMute() - { - return isMute; - } - - /** - * The device configuration. - * - * @return the deviceConfiguration - */ - public DeviceConfiguration getDeviceConfiguration() - { - return deviceConfiguration; - } - - /** - * Listens for changes in notify device - * @param event the event that notify device has changed. - */ - public void propertyChange(PropertyChangeEvent event) - { - if (DeviceConfiguration.AUDIO_NOTIFY_DEVICE.equals( - event.getPropertyName())) - { - audioClips.clear(); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/notify/AudioSystemClipImpl.java b/src/net/java/sip/communicator/impl/neomedia/notify/AudioSystemClipImpl.java deleted file mode 100644 index e0fbabee0..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/notify/AudioSystemClipImpl.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.notify; - -import java.io.*; -import java.net.*; - -import javax.media.*; -import javax.sound.sampled.*; - -import net.java.sip.communicator.impl.neomedia.codec.audio.speex.*; -import net.java.sip.communicator.util.*; - -/** - * Implementation of SCAudioClip using PortAudio. - * - * @author Damyian Minkov - * @author Lubomir Marinov - */ -public class AudioSystemClipImpl - extends SCAudioClipImpl -{ - /** - * The Logger used by the AudioSystemClipImpl class and - * its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(AudioSystemClipImpl.class); - - private final AudioNotifierServiceImpl audioNotifier; - - private final net.java.sip.communicator.impl.neomedia.device.AudioSystem - audioSystem; - - private boolean started = false; - - private final Object syncObject = new Object(); - - private final URL url; - - /** - * Creates the audio clip and initializes the listener used from the - * loop timer. - * - * @param url the URL pointing to the audio file - * @param audioNotifier the audio notify service - * @throws IOException cannot audio clip with supplied URL. - */ - public AudioSystemClipImpl( - URL url, - AudioNotifierServiceImpl audioNotifier, - net.java.sip.communicator.impl.neomedia.device.AudioSystem - audioSystem) - throws IOException - { - this.url = url; - this.audioNotifier = audioNotifier; - this.audioSystem = audioSystem; - } - - /** - * Plays this audio. - */ - public void play() - { - if ((url != null) && !audioNotifier.isMute()) - { - started = true; - new Thread() - { - @Override - public void run() - { - runInPlayThread(); - } - }.start(); - } - } - - /** - * Plays this audio in loop. - * - * @param interval the loop interval - */ - public void playInLoop(int interval) - { - setLoopInterval(interval); - setIsLooping(true); - - play(); - } - - /** - * Stops this audio. - */ - public void stop() - { - internalStop(); - setIsLooping(false); - } - - /** - * Stops this audio without setting the isLooping property in the case of - * a looping audio. The AudioNotifier uses this method to stop the audio - * when setMute(true) is invoked. This allows us to restore all looping - * audios when the sound is restored by calling setMute(false). - */ - public void internalStop() - { - synchronized (syncObject) - { - if (url != null && started) - { - started = false; - syncObject.notifyAll(); - } - } - } - - /** - * Runs in a separate thread to perform the actual playback of the audio - * stream pointed to by {@link #url} looping as necessary. - */ - private void runInPlayThread() - { - Buffer buffer = new Buffer(); - byte[] bufferData = new byte[1024]; - // don't enable volume control for notifications - Renderer renderer = audioSystem.createRenderer(false); - - buffer.setData(bufferData); - while (started) - { - try - { - if (!runOnceInPlayThread(renderer, buffer, bufferData)) - break; - } - finally - { - try - { - renderer.stop(); - } - finally - { - renderer.close(); - } - } - - if(isLooping()) - { - synchronized(syncObject) - { - if (started) - { - try - { - syncObject.wait(getLoopInterval()); - } - catch (InterruptedException e) - { - } - } - } - } - else - break; - } - } - - /** - * Runs in a separate thread to perform the actual playback of the audio - * stream pointed to by {@link #url} once using a specific - * PortAudioRenderer and giving it the audio data for processing - * through a specific JMF Buffer. - * - * @param renderer the PortAudioRenderer which is to render the - * audio data read from the audio stream pointed to by {@link #url} - * @param buffer the JMF Buffer through which the audio data to be - * rendered is to be given to renderer - * @param bufferData the value of the data property of - * buffer explicitly specified for performance reasons so that it - * doesn't have to be read and cast during every iteration of the playback - * loop - * @return true if the playback was successful and it is to be - * carried out again in accord with the looping property value of - * this SCAudioClipImpl; otherwise, false - */ - private boolean runOnceInPlayThread( - Renderer renderer, - Buffer buffer, - byte[] bufferData) - { - AudioInputStream audioStream = null; - - try - { - audioStream = AudioSystem.getAudioInputStream(url); - } - catch (IOException ioex) - { - logger.error("Failed to get audio stream " + url, ioex); - } - catch (UnsupportedAudioFileException uafex) - { - logger.error("Unsupported format of audio stream " + url, uafex); - } - if (audioStream == null) - return false; - - Codec resampler = null; - - try - { - AudioFormat audioStreamFormat = audioStream.getFormat(); - Format rendererFormat - = new javax.media.format.AudioFormat( - javax.media.format.AudioFormat.LINEAR, - audioStreamFormat.getSampleRate(), - audioStreamFormat.getSampleSizeInBits(), - audioStreamFormat.getChannels()); - Format resamplerFormat = null; - - if (renderer.setInputFormat(rendererFormat) == null) - { - /* - * Try to negotiate a resampling of the audioStreamFormat to one - * of the formats supported by the renderer. - */ - resampler = new SpeexResampler(); - resamplerFormat = rendererFormat; - resampler.setInputFormat(resamplerFormat); - - Format[] supportedResamplerFormats - = resampler.getSupportedOutputFormats(resamplerFormat); - - for (Format supportedRendererFormat - : renderer.getSupportedInputFormats()) - { - for (Format supportedResamplerFormat - : supportedResamplerFormats) - { - if (supportedRendererFormat.matches( - supportedResamplerFormat)) - { - rendererFormat = supportedRendererFormat; - resampler.setOutputFormat(rendererFormat); - renderer.setInputFormat(rendererFormat); - break; - } - } - } - } - - Buffer rendererBuffer = buffer; - Buffer resamplerBuffer; - - rendererBuffer.setFormat(rendererFormat); - if (resampler == null) - resamplerBuffer = null; - else - { - resamplerBuffer = new Buffer(); - bufferData = new byte[bufferData.length]; - resamplerBuffer.setData(bufferData); - resamplerBuffer.setFormat(resamplerFormat); - - resampler.open(); - } - - try - { - renderer.open(); - renderer.start(); - - int bufferLength; - - while(started - && ((bufferLength = audioStream.read(bufferData)) - != -1)) - { - if (resampler == null) - { - rendererBuffer.setLength(bufferLength); - rendererBuffer.setOffset(0); - } - else - { - resamplerBuffer.setLength(bufferLength); - resamplerBuffer.setOffset(0); - rendererBuffer.setLength(0); - rendererBuffer.setOffset(0); - resampler.process(resamplerBuffer, rendererBuffer); - } - while ((renderer.process(rendererBuffer) - & Renderer.INPUT_BUFFER_NOT_CONSUMED) - == Renderer.INPUT_BUFFER_NOT_CONSUMED); - } - } - catch (IOException ioex) - { - logger.error("Failed to read from audio stream " + url, ioex); - return false; - } - catch (ResourceUnavailableException ruex) - { - logger.error("Failed to open PortAudioRenderer.", ruex); - return false; - } - } - catch (ResourceUnavailableException ruex) - { - if (resampler != null) - { - logger.error("Failed to open SpeexResampler.", ruex); - return false; - } - } - finally - { - try - { - audioStream.close(); - } - catch (IOException ioex) - { - /* - * The audio stream failed to close but it doesn't mean the URL - * will fail to open again so ignore the exception. - */ - } - - if (resampler != null) - resampler.close(); - } - return true; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/notify/JavaSoundClipImpl.java b/src/net/java/sip/communicator/impl/neomedia/notify/JavaSoundClipImpl.java deleted file mode 100644 index 3fcd93553..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/notify/JavaSoundClipImpl.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.notify; - -import java.applet.*; -import java.awt.event.*; -import java.io.*; -import java.lang.reflect.*; -import java.net.*; -import java.security.*; - -import javax.swing.*; - -import net.java.sip.communicator.service.audionotifier.*; - -/** - * Implementation of SCAudioClip. - * - * @author Yana Stamcheva - */ -public class JavaSoundClipImpl - extends SCAudioClipImpl - implements ActionListener - -{ - private static Constructor acConstructor = null; - - private final Timer playAudioTimer = new Timer(1000, null); - - private final AudioClip audioClip; - - private final AudioNotifierService audioNotifier; - - /** - * Creates the audio clip and initialize the listener used from the - * loop timer. - * - * @param url the url pointing to the audio file - * @param audioNotifier the audio notify service - * @throws IOException cannot audio clip with supplied url. - */ - public JavaSoundClipImpl(URL url, AudioNotifierService audioNotifier) - throws IOException - { - this.audioClip = createAppletAudioClip(url.openStream()); - this.audioNotifier = audioNotifier; - - this.playAudioTimer.addActionListener(this); - } - - /** - * Plays this audio. - */ - public void play() - { - if ((audioClip != null) && !audioNotifier.isMute()) - audioClip.play(); - } - - /** - * Plays this audio in loop. - * - * @param interval the loop interval - */ - public void playInLoop(int interval) - { - if(!audioNotifier.isMute()) - { - if(interval == 0) - audioClip.loop(); - else - { - //first play the audio and then start the timer and wait - audioClip.play(); - playAudioTimer.setDelay(interval); - playAudioTimer.setRepeats(true); - - playAudioTimer.start(); - } - } - - setLoopInterval(interval); - setIsLooping(true); - } - - /** - * Stops this audio. - */ - public void stop() - { - if (audioClip != null) - audioClip.stop(); - - if (isLooping()) - { - playAudioTimer.stop(); - setIsLooping(false); - } - } - - /** - * Stops this audio without setting the isLooping property in the case of - * a looping audio. The AudioNotifier uses this method to stop the audio - * when setMute(true) is invoked. This allows us to restore all looping - * audios when the sound is restored by calling setMute(false). - */ - public void internalStop() - { - if (audioClip != null) - audioClip.stop(); - - if (isLooping()) - playAudioTimer.stop(); - } - - /** - * Creates an AppletAudioClip. - * - * @param inputstream the audio input stream - * @throws IOException - */ - private static AudioClip createAppletAudioClip(InputStream inputstream) - throws IOException - { - if (acConstructor == null) - { - try - { - acConstructor - = AccessController.doPrivileged( - new PrivilegedExceptionAction>() - { - public Constructor run() - throws ClassNotFoundException, - NoSuchMethodException, - SecurityException - { - return createAcConstructor(); - } - }); - } - catch (PrivilegedActionException paex) - { - throw - new IOException( - "Failed to get AudioClip constructor: " - + paex.getException()); - } - } - - try - { - return acConstructor.newInstance(inputstream); - } - catch (Exception ex) - { - throw new IOException("Failed to construct the AudioClip: " + ex); - } - } - - @SuppressWarnings("unchecked") - private static Constructor createAcConstructor() - throws ClassNotFoundException, - NoSuchMethodException, - SecurityException - { - Class class1; - try - { - class1 - = Class.forName( - "com.sun.media.sound.JavaSoundAudioClip", - true, - ClassLoader.getSystemClassLoader()); - } - catch (ClassNotFoundException cnfex) - { - class1 - = Class.forName("sun.audio.SunAudioClip", true, null); - } - return - (Constructor) class1.getConstructor(InputStream.class); - } - - /** - * Plays an audio clip. Used in the playAudioTimer to play an audio in loop. - * @param e the event. - */ - public void actionPerformed(ActionEvent e) - { - if (audioClip != null) - { - audioClip.stop(); - audioClip.play(); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/notify/SCAudioClipImpl.java b/src/net/java/sip/communicator/impl/neomedia/notify/SCAudioClipImpl.java deleted file mode 100644 index f13d909cc..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/notify/SCAudioClipImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.notify; - -import net.java.sip.communicator.service.audionotifier.*; - -/** - * Common properties impl for SCAudioClip. - * - * @author Damian Minkov - */ -public abstract class SCAudioClipImpl - implements SCAudioClip -{ - private boolean isLooping; - - private int loopInterval; - - private boolean isInvalid; - - /** - * Returns TRUE if this audio is invalid, FALSE otherwise. - * - * @return TRUE if this audio is invalid, FALSE otherwise - */ - public boolean isInvalid() - { - return isInvalid; - } - - /** - * Marks this audio as invalid or not. - * - * @param isInvalid TRUE to mark this audio as invalid, FALSE otherwise - */ - public void setInvalid(boolean isInvalid) - { - this.setIsInvalid(isInvalid); - } - - /** - * Returns TRUE if this audio is currently playing in loop, FALSE otherwise. - * @return TRUE if this audio is currently playing in loop, FALSE otherwise. - */ - public boolean isLooping() - { - return isLooping; - } - - /** - * Returns the loop interval if this audio is looping. - * @return the loop interval if this audio is looping - */ - public int getLoopInterval() - { - return loopInterval; - } - - /** - * @param isLooping the isLooping to set - */ - public void setIsLooping(boolean isLooping) - { - this.isLooping = isLooping; - } - - /** - * @param loopInterval the loopInterval to set - */ - public void setLoopInterval(int loopInterval) - { - this.loopInterval = loopInterval; - } - - /** - * @param isInvalid the isInvalid to set - */ - public void setIsInvalid(boolean isInvalid) - { - this.isInvalid = isInvalid; - } - - /** - * Stops this audio without setting the isLooping property in the case of - * a looping audio. The AudioNotifier uses this method to stop the audio - * when setMute(true) is invoked. This allows us to restore all looping - * audios when the sound is restored by calling setMute(false). - */ - public abstract void internalStop(); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudio.java b/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudio.java deleted file mode 100644 index b76edaa46..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudio.java +++ /dev/null @@ -1,806 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.portaudio; - -import java.io.*; -import java.lang.reflect.*; -import java.nio.charset.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.util.*; - -/** - * Provides the interface to the native PortAudio library. - * - * @author Lyubomir Marinov - * @author Damian Minkov - * @author Sebastien Vincent - */ -public final class PortAudio -{ - /** - * The Logger used by the PortAudio class for logging - * output. - */ - private static final Logger logger = Logger.getLogger(PortAudio.class); - - static - { - System.loadLibrary("jnportaudio"); - - try - { - Pa_Initialize(); - } - catch (PortAudioException paex) - { - throw new UndeclaredThrowableException(paex); - } - } - - /** - * The number of milliseconds to be read from or written to a native - * PortAudio stream in a single transfer of data. - */ - public static final int DEFAULT_MILLIS_PER_BUFFER = 20; - - /** - * The default value for the sample rate of the input and the output - * PortAudio streams with which they are to be opened if no other specific - * sample rate is specified to the PortAudio DataSource or - * PortAudioRenderer that they represent. - */ - public static final double DEFAULT_SAMPLE_RATE = 44100; - - private static Runnable devicesChangedCallback; - - /** - * Can be passed as the framesPerBuffer parameter to - * Pa_OpenStream() or Pa_OpenDefaultStream() to indicate - * that the stream callback will accept buffers of any size. - */ - public static final long FRAMES_PER_BUFFER_UNSPECIFIED = 0; - - /** - * Used when creating new stream parameters for suggested latency to use - * high input/output value. - */ - public static final double LATENCY_HIGH = -1d; - - /** - * Used when creating new stream parameters for suggested latency to use low - * input/default value. - */ - public static final double LATENCY_LOW = -2d; - - /** - * Used when creating new stream parameters for suggested latency to use - * default value. - */ - public static final double LATENCY_UNSPECIFIED = 0d; - - /** - * PortAudio "no device" constant. - */ - public static final int paNoDevice = -1; - - /** - * The name of the double property which determines the suggested - * latency to be used when opening PortAudio streams. - */ - private static final String PROP_SUGGESTED_LATENCY - = "net.java.sip.communicator.impl.neomedia.portaudio.suggestedLatency"; - - /** - * A type used to specify one or more sample formats. The standard format - * paFloat32. - */ - public static final long SAMPLE_FORMAT_FLOAT32 = 0x00000001; - - /** - * A type used to specify one or more sample formats. The standard format - * paInt8. - */ - public static final long SAMPLE_FORMAT_INT8 = 0x00000010; - - /** - * A type used to specify one or more sample formats. The standard format - * paInt16. - */ - public static final long SAMPLE_FORMAT_INT16 = 0x00000008; - - /** - * A type used to specify one or more sample formats. The standard format - * paInt24. - */ - public static final long SAMPLE_FORMAT_INT24 = 0x00000004; - - /** - * A type used to specify one or more sample formats. The standard format - * paInt32. - */ - public static final long SAMPLE_FORMAT_INT32 = 0x00000002; - - /** - * A type used to specify one or more sample formats. The standard format - * paUInt8. - */ - public static final long SAMPLE_FORMAT_UINT8 = 0x00000020; - - /** Disables default clipping of out of range samples. */ - public static final long STREAM_FLAGS_CLIP_OFF = 0x00000001; - - /** Disables default dithering. */ - public static final long STREAM_FLAGS_DITHER_OFF = 0x00000002; - - /** - * Flag requests that where possible a full duplex stream will not discard - * overflowed input samples without calling the stream callback. This flag - * is only valid for full duplex callback streams and only when used in - * combination with the paFramesPerBufferUnspecified (0) - * framesPerBuffer parameter. Using this flag incorrectly results in a - * paInvalidFlag error being returned from Pa_OpenStream - * and Pa_OpenDefaultStream. - */ - public static final long STREAM_FLAGS_NEVER_DROP_INPUT = 0x00000004; - - /** - * Flags used to control the behavior of a stream. They are passed as - * parameters to Pa_OpenStream or Pa_OpenDefaultStream. - */ - public static final long STREAM_FLAGS_NO_FLAG = 0; - - /** A mask specifying the platform specific bits. */ - public static final long STREAM_FLAGS_PLATFORM_SPECIFIC_FLAGS = 0xFFFF0000; - - /** - * Call the stream callback to fill initial output buffers, rather than the - * default behavior of priming the buffers with zeros (silence). This flag - * has no effect for input-only and blocking read/write streams. - */ - public static final long - STREAM_FLAGS_PRIME_OUTPUT_BUFFERS_USING_STREAM_CALLBACK - = 0x00000008; - - /** - * Unchanging unique identifiers for each supported host API. This type - * is used in the PaHostApiInfo structure. The values are guaranteed to be - * unique and to never change, thus allowing code to be written that - * conditionally uses host API specific extensions. - */ - public static enum PaHostApiTypeId - { - undefined(-1), /* Used only outside pa for undefined PaHostApiTypeId */ - paInDevelopment(0),/* use while developing support for a new host API */ - paDirectSound(1), - paMME(2), - paASIO(3), - paSoundManager(4), - paCoreAudio(5), - paOSS(7), - paALSA(8), - paAL(9), - paBeOS(10), - paWDMKS(11), - paJACK(12), - paWASAPI(13), - paAudioScienceHPI(14); - - int value; - private PaHostApiTypeId(int value) - { - this.value = value; - } - - /** - * Returns PaHostApiTypeId by its type unique value. - * - * @param value the value. - * @return the corresponding PaHostApiTypeId. - */ - public static PaHostApiTypeId valueOf(int value) - { - for(PaHostApiTypeId ha : values()) - { - if(ha.value == value) - return ha; - } - - return valueOf(value); - } - } - - private static native void free(long ptr); - - /** - * Gets the native PaSampleFormat with a specific size in bits. - * - * @param sampleSizeInBits the size in bits of the native - * PaSampleFormat to get - * @return the native PaSampleFormat with the specified size in - * bits - */ - public static long getPaSampleFormat(int sampleSizeInBits) - { - switch (sampleSizeInBits) - { - case 8: - return PortAudio.SAMPLE_FORMAT_INT8; - case 24: - return PortAudio.SAMPLE_FORMAT_INT24; - case 32: - return PortAudio.SAMPLE_FORMAT_INT32; - default: - return PortAudio.SAMPLE_FORMAT_INT16; - } - } - - /** - * Gets the suggested latency to be used when opening PortAudio streams. - * - * @return the suggested latency to be used when opening PortAudio streams - */ - public static double getSuggestedLatency() - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - - if (cfg != null) - { - String suggestedLatencyString - = cfg.getString(PROP_SUGGESTED_LATENCY); - - if (suggestedLatencyString != null) - { - try - { - double suggestedLatency - = Double.parseDouble(suggestedLatencyString); - - if (suggestedLatency != LATENCY_UNSPECIFIED) - return suggestedLatency; - } - catch (NumberFormatException nfe) - { - logger.error( - "Failed to parse configuration property " - + PROP_SUGGESTED_LATENCY - + " value as a double", - nfe); - } - } - } - - if (OSUtils.IS_MAC || OSUtils.IS_LINUX) - return LATENCY_HIGH; - else if (OSUtils.IS_WINDOWS) - return 0.1d; - else - return LATENCY_UNSPECIFIED; - } - - /** - * Terminates audio processing immediately without waiting for pending - * buffers to complete. - * - * @param stream the steam pointer. - * @throws PortAudioException - */ - public static native void Pa_AbortStream(long stream) - throws PortAudioException; - - /** - * Closes an audio stream. If the audio stream is active it discards any - * pending buffers as if Pa_AbortStream() had been called. - * - * @param stream the steam pointer. - * @throws PortAudioException - */ - public static native void Pa_CloseStream(long stream) - throws PortAudioException; - - /** - * Retrieve the index of the default input device. - * - * @return The default input device index for the default host API, or - * paNoDevice if no default input device is available or an error - * was encountered. - */ - public static native int Pa_GetDefaultInputDevice(); - - /** - * Retrieve the index of the default output device. - * - * @return The default input device index for the default host API, or - * paNoDevice if no default input device is available or an error - * was encountered. - */ - public static native int Pa_GetDefaultOutputDevice(); - - /** - * Retrieve the number of available devices. The number of available devices - * may be zero. - * - * @return the number of devices. - * @throws PortAudioException - */ - public static native int Pa_GetDeviceCount() - throws PortAudioException; - - /** - * Retrieve a pointer to a PaDeviceInfo structure containing information - * about the specified device. - * - * @param deviceIndex the device index - * @return pointer to device info structure. - */ - public static native long Pa_GetDeviceInfo(int deviceIndex); - - /** - * Retrieve a pointer to a structure containing information about a specific - * host Api. - * - * @param hostApiIndex host api index. - * @return A pointer to an immutable PaHostApiInfo structure describing a - * specific host API. - */ - public static native long Pa_GetHostApiInfo(int hostApiIndex); - - /** - * Retrieve the size of a given sample format in bytes. - * - * @param format the format. - * @return The size in bytes of a single sample in the specified format, or - * paSampleFormatNotSupported if the format is not supported. - */ - public static native int Pa_GetSampleSize(long format); - - /** - * Retrieve the number of frames that can be read from the stream without - * waiting. - * - * @param stream pointer to the stream. - * @return returns a non-negative value representing the maximum number of - * frames that can be read from the stream without blocking or busy waiting - * or, a PaErrorCode (which are always negative) if PortAudio is - * not initialized or an error is encountered. - */ - public static native long Pa_GetStreamReadAvailable(long stream); - - /** - * Retrieve the number of frames that can be written to the stream - * without waiting. - * @param stream pointer to the stream. - * @return returns a non-negative value representing the maximum number - * of frames that can be written to the stream without blocking - * or busy waiting or, a PaErrorCode (which are always negative) - * if PortAudio is not initialized or an error is encountered. - */ - public static native long Pa_GetStreamWriteAvailable(long stream); - - /** - * Initializes the native PortAudio library. - * - * @throws PortAudioException - */ - private static native void Pa_Initialize() - throws PortAudioException; - - /** - * Determine whether it would be possible to open a stream - * with the specified parameters. - * @param inputParameters A structure that describes the - * input parameters used to open a stream. - * @param outputParameters A structure that describes the output - * parameters used to open a stream. - * @param sampleRate The required sampleRate. - * @return returns 0 if the format is supported, and an error code - * indicating why the format is not supported otherwise. - * The constant paFormatIsSupported is provided to compare - * with the return value for success. - */ - public static native boolean Pa_IsFormatSupported( - long inputParameters, - long outputParameters, - double sampleRate); - - /** - * Opens a stream for either input, output or both. - * @param inputParameters the input params or 0 if absent. - * @param outputParameters the ouput params or 0 if absent. - * @param sampleRate The desired sampleRate. - * @param framesPerBuffer The number of frames passed to the stream - * callback function, or the preferred block granularity for - * a blocking read/write stream - * @param streamFlags Flags which modify the - * behaviour of the streaming process. - * @param streamCallback A pointer to a client supplied function that is - * responsible for processing and filling input and output buffers. - * If this parameter is NULL the stream will be opened in - * 'blocking read/write' mode. - * @return pointer to the opened stream. - * @throws PortAudioException - */ - public static native long Pa_OpenStream( - long inputParameters, - long outputParameters, - double sampleRate, - long framesPerBuffer, - long streamFlags, - PortAudioStreamCallback streamCallback) - throws PortAudioException; - - /** - * Read samples from an input stream. The function doesn't return until - * the entire buffer has been filled - this may involve waiting for - * the operating system to supply the data. - * @param stream pointer to the stream. - * @param buffer a buffer of sample frames. - * @param frames The number of frames to be read into buffer. - * @throws PortAudioException - */ - public static native void Pa_ReadStream( - long stream, byte[] buffer, long frames) - throws PortAudioException; - - /** - * Commences audio processing. - * @param stream pointer to the stream - * @throws PortAudioException - */ - public static native void Pa_StartStream(long stream) - throws PortAudioException; - - /** - * Terminates audio processing. It waits until all pending audio buffers - * have been played before it returns. - * @param stream pointer to the stream - * @throws PortAudioException - */ - public static native void Pa_StopStream(long stream) - throws PortAudioException; - - public static void Pa_UpdateAvailableDeviceList() - { - updateAvailableDeviceList(); - } - - /** - * Write samples to an output stream. This function doesn't return until - * the entire buffer has been consumed - this may involve waiting for the - * operating system to consume the data. - * @param stream pointer to the stream - * @param buffer A buffer of sample frames. - * @param frames The number of frames to be written from buffer. - * @throws PortAudioException - */ - public static void Pa_WriteStream(long stream, byte[] buffer, long frames) - throws PortAudioException - { - Pa_WriteStream(stream, buffer, 0, frames, 1); - } - - /** - * Writes samples to an output stream. Does not return until the specified - * samples have been consumed - this may involve waiting for the operating - * system to consume the data. - *

- * Provides better efficiency than achieved through multiple consecutive - * calls to {@link #Pa_WriteStream(long, byte[], long)} with one and the - * same buffer because the JNI access to the bytes of the buffer which is - * likely to copy the whole buffer is only performed once. - *

- * - * @param stream the pointer to the PortAudio stream to write the samples to - * @param buffer the buffer containing the samples to be written - * @param offset the byte offset in buffer at which the samples to - * be written start - * @param frames the number of frames from buffer starting at - * offset are to be written with a single write - * @param numberOfWrites the number of writes each writing frames - * number of frames to be performed - * @throws PortAudioException if anything goes wrong while writing - */ - public static native void Pa_WriteStream( - long stream, - byte[] buffer, - int offset, - long frames, - int numberOfWrites) - throws PortAudioException; - - /** - * Gets the human-readable name of the PaDeviceInfo specified by a - * pointer to it. - * - * @param deviceInfo the pointer to the PaDeviceInfo to get the - * human-readable name of - * @return the human-readable name of the PaDeviceInfo pointed to - * by deviceInfo - */ - public static String PaDeviceInfo_getName(long deviceInfo) - { - byte[] nameBytes = PaDeviceInfo_getNameBytes(deviceInfo); - Charset defaultCharset = Charset.defaultCharset(); - String charsetName - = (defaultCharset == null) ? "UTF-8" : defaultCharset.name(); - - try - { - return new String(nameBytes, charsetName); - } - catch (UnsupportedEncodingException ueex) - { - return new String(nameBytes); - } - } - - /** - * Returns defaultHighInputLatency for the device. - * @param deviceInfo device info pointer. - * @return defaultHighInputLatency for the device. - */ - public static native double PaDeviceInfo_getDefaultHighInputLatency( - long deviceInfo); - - /** - * Returns defaultHighOutputLatency for the device. - * @param deviceInfo device info pointer. - * @return defaultHighOutputLatency for the device. - */ - public static native double PaDeviceInfo_getDefaultHighOutputLatency( - long deviceInfo); - - /** - * Returns defaultLowInputLatency for the device. - * @param deviceInfo device info pointer. - * @return defaultLowInputLatency for the device. - */ - public static native double PaDeviceInfo_getDefaultLowInputLatency( - long deviceInfo); - - /** - * Returns defaultLowOutputLatency for the device. - * @param deviceInfo device info pointer. - * @return defaultLowOutputLatency for the device. - */ - public static native double PaDeviceInfo_getDefaultLowOutputLatency( - long deviceInfo); - - /** - * The default samplerate for the deviec. - * @param deviceInfo device info pointer. - * @return the default sameple rate for the device. - */ - public static native double PaDeviceInfo_getDefaultSampleRate( - long deviceInfo); - - /** - * The host api of the device. - * @param deviceInfo device info pointer. - * @return The host api of the device. - */ - public static native int PaDeviceInfo_getHostApi(long deviceInfo); - - /** - * Maximum input channels for the device. - * @param deviceInfo device info pointer. - * @return Maximum input channels for the device. - */ - public static native int PaDeviceInfo_getMaxInputChannels(long deviceInfo); - - /** - * Maximum output channels for the device. - * @param deviceInfo device info pointer. - * @return Maximum output channels for the device. - */ - public static native int PaDeviceInfo_getMaxOutputChannels(long deviceInfo); - - /** - * Gets the name as a byte array of the PortAudio device specified - * by the pointer to its PaDeviceInfo instance. - * - * @param deviceInfo the pointer to the PaDeviceInfo instance to - * get the name of - * @return the name as a byte array of the PortAudio device - * specified by the PaDeviceInfo instance pointed to by - * deviceInfo - */ - private static native byte[] PaDeviceInfo_getNameBytes(long deviceInfo); - - /** - * The default input device for this host API. - * @param hostApiInfo pointer to host api info structure. - * @return The default input device for this host API. - */ - public static native int PaHostApiInfo_getDefaultInputDevice( - long hostApiInfo); - - /** - * The default output device for this host API. - * @param hostApiInfo pointer to host api info structure. - * @return The default output device for this host API. - */ - public static native int PaHostApiInfo_getDefaultOutputDevice( - long hostApiInfo); - - /** - * The number of devices belonging to this host API. - * @param hostApiInfo pointer to host api info structure. - * @return The number of devices belonging to this host API. - */ - public static native int PaHostApiInfo_getDeviceCount(long hostApiInfo); - - /** - * Gets the human-readable name of the PaHostApiInfo specified by a - * pointer to it. - * - * @param hostApiInfo the pointer to the PaHostApiInfo to get the - * human-readable name of - * @return the human-readable name of the PaHostApiInfo pointed to - * by hostApiInfo - * @deprecated Presumes that the name of PaHostApiInfo is - * encoded in modified UTF-8 - */ - @Deprecated - public static native String PaHostApiInfo_getName(long hostApiInfo); - - /** - * The well known unique identifier of this host API. - * @param hostApiInfo pointer to host api info structure. - * @return The well known unique identifier of this host API. - * Enumerator: - * paInDevelopment - * paDirectSound - * paMME - * paASIO - * paSoundManager - * paCoreAudio - * paOSS - * paALSA - * paAL - * paBeOS - * paWDMKS - * paJACK - * paWASAPI - * paAudioScienceHPI - */ - public static native int PaHostApiInfo_getType(long hostApiInfo); - - /** - * Free StreamParameters resources specified by a pointer to it. - * - * @param streamParameters the pointer to the PaStreamParameters - * to free - */ - public static void PaStreamParameters_free(long streamParameters) - { - try - { - free(streamParameters); - return; - } - catch (UnsatisfiedLinkError ulerr) - { - /* - * Ignore it because we'll try to fallback to another - * implementation. - */ - logger.warn( - "The JNI library jnportaudio is out-of-date and needs to be" - + " recompiled.", - ulerr); - } - /* - * FFmpeg on Windows seems to be compiled with --enable-memalign-hack so - * av_free(void *) isn't the same as free(void *) and thus is not a - * suitable/safe fallback. - */ - if (OSUtils.IS_LINUX || OSUtils.IS_MAC) - { - try - { - FFmpeg.av_free(streamParameters); - } - catch (NoClassDefFoundError ncdferr) - { - // We'll warn bellow, don't fail. - } - catch (UnsatisfiedLinkError ulerr) - { - // We'll warn bellow, don't fail. - } - return; - } - logger.warn("Leaking a PaStreamParameters instance."); - } - - /** - * Creates parameters used for opening streams. - * @param deviceIndex the device. - * @param channelCount the channels to be used. - * @param sampleFormat the sample format. - * @param suggestedLatency the suggested latency in milliseconds: - * LATENCY_UNSPECIFIED - - * use default(default high input/output latency) - * LATENCY_HIGH - use default high input/output latency - * LATENCY_LOW - use default low input/output latency - * ... - any other value in milliseconds (e.g. 0.1 is acceptable) - * @return pointer to the params used for Pa_OpenStream. - */ - public static native long PaStreamParameters_new( - int deviceIndex, - int channelCount, - long sampleFormat, - double suggestedLatency); - - /** - * Sets the indicator which determines whether a specific (input) PortAudio - * stream is to have denoise performed on the audio data it provides. - * - * @param stream the (input) PortAudio stream for which denoise is to be - * enabled or disabled - * @param denoise true if denoise is to be performed on the audio - * data provided by stream; otherwise, false - */ - public static native void setDenoise(long stream, boolean denoise); - - /** - * Sets the number of milliseconds of echo to be canceled in the audio data - * provided by a specific (input) PortAudio stream. - * - * @param stream the (input) PortAudio stream for which the number of - * milliseconds of echo to be canceled is to be set - * @param echoFilterLengthInMillis the number of milliseconds of echo to be - * canceled in the audio data provided by stream - */ - public static native void setEchoFilterLengthInMillis( - long stream, - long echoFilterLengthInMillis); - - /** - * Updates available device lists in PortAudio. - */ - private static native void updateAvailableDeviceList(); - - /** - * Implements a (legacy) callback which gets called by the native PortAudio - * counterpart to notify the Java counterpart that the list of PortAudio - * devices has changed. - */ - public static void deviceChanged() - { - devicesChangedCallback(); - } - - /** - * Implements a callback which gets called by the native PortAudio - * counterpart to notify the Java counterpart that the list of PortAudio - * devices has changed. - */ - public static void devicesChangedCallback() - { - Runnable devicesChangedCallback = PortAudio.devicesChangedCallback; - - if (devicesChangedCallback != null) - devicesChangedCallback.run(); - } - - public static void setDevicesChangedCallback( - Runnable devicesChangedCallback) - { - PortAudio.devicesChangedCallback = devicesChangedCallback; - } - - /** - * Prevents the initialization of PortAudio instances. - */ - private PortAudio() - { - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudioException.java b/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudioException.java deleted file mode 100644 index 95f4046da..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudioException.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.portaudio; - -/** - * @author Lubomir Marinov - */ -public class PortAudioException - extends Exception -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * Constructs a PortAudioException with message as - * description. - * @param message description of the exception - */ - public PortAudioException(String message) - { - super(message); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudioStreamCallback.java b/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudioStreamCallback.java deleted file mode 100644 index 4dfcceebb..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudioStreamCallback.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.portaudio; - -import java.nio.*; - -/** - * @author Lubomir Marinov - */ -public interface PortAudioStreamCallback -{ - /** - * "Abort" resut code. - */ - public static final int RESULT_ABORT = 2; - - /** - * "Complete" resut code. - */ - public static final int RESULT_COMPLETE = 1; - - /** - * "Continue" resut code. - */ - public static final int RESULT_CONTINUE = 0; - - /** - * Callback. - * - * @param input input ByteBuffer - * @param output output ByteBuffer - * @return - */ - public int callback(ByteBuffer input, ByteBuffer output); - - /** - * Finished callback. - */ - public void finishedCallback(); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/BufferStreamAdapter.java b/src/net/java/sip/communicator/impl/neomedia/protocol/BufferStreamAdapter.java deleted file mode 100644 index 2f14ee7a7..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/BufferStreamAdapter.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import java.io.*; - -import javax.media.*; -import javax.media.protocol.*; - -/** - * Represents a base class for adapters of SourceStreams, usually - * ones reading data in arrays of bytes and not in Buffers, to - * SourceStreams reading data in Buffers. An example - * use is creating a PushBufferStream representation of a PushSourceStream. - * - * @param the very type of SourceStream to be adapted by a - * BufferStreamAdapter - * @author Lubomir Marinov - */ -public abstract class BufferStreamAdapter - implements SourceStream -{ - - /** - * The Format of this stream to be reported through the output - * Buffer this instance reads data into. - */ - private final Format format; - - /** - * The SourceStream being adapted by this instance. - */ - protected final T stream; - - /** - * Initializes a new BufferStreamAdapter which is to adapt a - * specific SourceStream into a SourceStream with - * a specific Format. - * - * @param stream the SourceStream to be adapted - * @param format the specific Format of the SourceStream - */ - public BufferStreamAdapter(T stream, Format format) - { - this.stream = stream; - this.format = format; - } - - /** - * Implements SourceStream#endOfStream(). Delegates to the wrapped - * SourceStream. - * - * @return true if the stream is finished, false otherwise - */ - public boolean endOfStream() - { - return stream.endOfStream(); - } - - /** - * Implements SourceStream#getContentDescriptor(). Delegates to the wrapped - * SourceStream. - * - * @return the ContentDescriptor of the stream - */ - public ContentDescriptor getContentDescriptor() - { - return stream.getContentDescriptor(); - } - - /** - * Implements SourceStream#getContentLength(). Delegates to the wrapped - * SourceStream. - * - * @return content length - */ - public long getContentLength() - { - return stream.getContentLength(); - } - - /** - * Implements Controls#getControl(String). Delegates to the wrapped - * SourceStream. - * - * @param controlType a String value naming the type of the control - * of this instance to be retrieved - * @return an Object which represents the control of this instance - * with the specified type - */ - public Object getControl(String controlType) - { - return stream.getControl(controlType); - } - - /** - * Implements Controls#getControls(). Delegates to the wrapped SourceStream. - * - * @return array of JMF Control objects - */ - public Object[] getControls() - { - return stream.getControls(); - } - - /** - * Gets the Format of the data this stream provides. - * - * @return the Format of the data this stream provides - */ - public Format getFormat() - { - return format; - } - - /** - * Gets the SourceStream wrapped by this instance. - * - * @return the SourceStream wrapped by this instance - */ - public T getStream() - { - return stream; - } - - /** - * Reads byte data from this stream into a specific Buffer - * which is to use a specific array of bytes for its data. - * - * @param buffer the Buffer to read byte data into from this - * instance - * @param bytes the array of bytes to read data into from this - * instance and to be set as the data of the specified - * buffer - * @throws IOException if I/O related errors occurred during read operation - */ - protected void read(Buffer buffer, byte[] bytes) - throws IOException - { - int offset = 0; - int numberOfBytesRead = read(bytes, offset, bytes.length); - - if (numberOfBytesRead > -1) - { - buffer.setData(bytes); - buffer.setOffset(offset); - buffer.setLength(numberOfBytesRead); - - Format format = getFormat(); - - if (format != null) - buffer.setFormat(format); - } - } - - /** - * Reads byte data from this stream into a specific array of - * bytes starting the storing at a specific offset and reading - * at most a specific number of bytes. - * - * @param buffer the array of bytes into which the data read - * from this stream is to be written - * @param offset the offset in the specified buffer at which - * writing data read from this stream should start - * @param length the maximum number of bytes to be written into the - * specified buffer - * @return the number of bytes read from this stream and written into the - * specified buffer - * @throws IOException if I/O related errors occurred during read operation - */ - protected abstract int read(byte[] buffer, int offset, int length) - throws IOException; -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/CachingPushBufferStream.java b/src/net/java/sip/communicator/impl/neomedia/protocol/CachingPushBufferStream.java deleted file mode 100644 index 4101e610f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/CachingPushBufferStream.java +++ /dev/null @@ -1,777 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import java.io.*; -import java.util.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; -import javax.media.protocol.*; - -/** - * Enables reading from a PushBufferStream a certain maximum number - * of data units (e.g. bytes, shorts, ints) even if the - * PushBufferStream itself pushes a larger number of data units. - *

- * An example use of this functionality is pacing a - * PushBufferStream which pushes more data units in a single step - * than a CaptureDevice. When these two undergo audio mixing, the - * different numbers of per-push data units will cause the - * PushBufferStream "play" itself faster than the - * CaptureDevice. - *

- * - * @author Lyubomir Marinov - */ -public class CachingPushBufferStream - implements PushBufferStream -{ - - /** - * The default length in milliseconds of the buffering to be performed by - * CachePushBufferStreams. - */ - public static final long DEFAULT_BUFFER_LENGTH = 20; - - /** - * The maximum number of Buffers to be cached in a - * CachingPushBufferStream. Generally, defined to a relatively - * large value which allows large buffering and yet tries to prevent - * OutOfMemoryError. - */ - private static final int MAX_CACHE_SIZE = 1024; - - /** - * The BufferControl of this PushBufferStream which allows - * the adjustment of the size of the buffering it performs. - */ - private BufferControl bufferControl; - - /** - * The Object which synchronizes the access to - * {@link #bufferControl}. - */ - private final Object bufferControlSyncRoot = new Object(); - - /** - * The list of Buffers in which this instance stores the data it - * reads from the wrapped PushBufferStream and from which it reads - * in chunks later on when its {@link #read(Buffer)} method is called. - */ - private final List cache = new LinkedList(); - - /** - * The length of the media in milliseconds currently available in - * {@link #cache}. - */ - private long cacheLengthInMillis = 0; - - /** - * The last IOException this stream has received from the - * #read(Buffer) method of the wrapped stream and to be thrown - * by this stream on the earliest call of its #read(Buffer) - * method. - */ - private IOException readException; - - /** - * The PushBufferStream being paced by this instance with - * respect to the maximum number of data units it provides in a single push. - */ - private final PushBufferStream stream; - - /** - * The BufferTransferHandler set on {@link #stream}. - */ - private BufferTransferHandler transferHandler; - - /** - * Initializes a new CachingPushBufferStream instance which is - * to pace the number of per-push data units a specific - * PushBufferStream provides. - * - * @param stream the PushBufferStream to be paced with respect to - * the number of per-push data units it provides - */ - public CachingPushBufferStream(PushBufferStream stream) - { - this.stream = stream; - } - - /** - * Determines whether adding a new Buffer to {@link #cache} is - * acceptable given the maximum size of the cache and the length of - * the media currently available in it. - * - * @return true if adding a new Buffer to cache - * is acceptable; otherwise, false which means that the reading - * from the wrapped PushBufferStream should be blocked until - * true is returned - */ - private boolean canWriteInCache() - { - synchronized (cache) - { - int cacheSize = cache.size(); - - /* - * Obviously, if there's nothing in the cache, we desperately want - * something to be written into it. - */ - if (cacheSize < 1) - return true; - /* - * For the sake of not running out of memory, don't let the sky be - * the limit. - */ - if (cacheSize >= MAX_CACHE_SIZE) - return false; - - long bufferLength = getBufferLength(); - - /* - * There is no bufferLength specified by a BufferControl so don't - * buffer anything. - */ - if (bufferLength < 1) - return false; - /* - * Having Buffers in the cache and yet not having their length in - * milliseconds is weird so don't buffer anything. - */ - if (cacheLengthInMillis < 1) - return false; - /* - * Of course, if the media in the cache hasn't reached the specified - * buffer length, write more to the cache. - */ - return (cacheLengthInMillis < bufferLength); - } - } - - /** - * Implements {@link SourceStream#endOfStream()}. Delegates to the wrapped - * PushBufferStream when the cache of this instance is fully read; - * otherwise, returns false. - * - * @return true if this PushBufferStream has reached the - * end of the content it makes available; otherwise, false - */ - public boolean endOfStream() - { - /* - * TODO If the cache is still not exhausted, don't report the end of - * this stream even if the wrapped stream has reached its end. - */ - return stream.endOfStream(); - } - - /** - * Gets the BufferControl of this PushBufferStream which - * allows the adjustment of the size of the buffering it performs. If it - * does not exist yet, it is created. - * - * @return the BufferControl of this PushBufferStream - * which allows the adjustment of the size of the buffering it performs - */ - private BufferControl getBufferControl() - { - synchronized (bufferControlSyncRoot) - { - if (bufferControl == null) - bufferControl = new BufferControlImpl(); - return bufferControl; - } - } - - /** - * Gets the length in milliseconds of the buffering performed by this - * PushBufferStream. - * - * @return the length in milliseconds of the buffering performed by this - * PushBufferStream if such a value has been set; otherwise, - * {@link BufferControl#DEFAULT_VALUE} - */ - private long getBufferLength() - { - synchronized (bufferControlSyncRoot) - { - return - (bufferControl == null) - ? BufferControl.DEFAULT_VALUE - : bufferControl.getBufferLength(); - } - } - - /** - * Implements {@link SourceStream#getContentDescriptor()}. Delegates to the - * wrapped PushBufferStream. - * - * @return a ContentDescriptor which describes the type of the - * content made available by the wrapped PushBufferStream - */ - public ContentDescriptor getContentDescriptor() - { - return stream.getContentDescriptor(); - } - - /** - * Implements {@link SourceStream#getContentLength()}. Delegates to the - * wrapped PushBufferStream. - * - * @return the length of the content made available by the wrapped - * PushBufferStream - */ - public long getContentLength() - { - return stream.getContentLength(); - } - - /** - * Implements {@link javax.media.Controls#getControl(String)}. Delegates to - * the wrapped PushBufferStream and gives access to the - * BufferControl of this instance if such a controlType is - * specified and the wrapped PushBufferStream does not have such a - * control available. - * - * @param controlType a String value which names the type of the - * control of the wrapped PushBufferStream to be retrieved - * @return an Object which represents the control of the wrapped - * PushBufferStream with the specified type if such a control is - * available; otherwise, null - */ - public Object getControl(String controlType) - { - Object control = stream.getControl(controlType); - - if ((control == null) - && BufferControl.class.getName().equals(controlType)) - control = getBufferControl(); - return control; - } - - /** - * Implements {@link javax.media.Controls#getControls()}. Delegates to the - * wrapped PushBufferStream and adds the BufferControl of - * this instance if the wrapped PushBufferStream does not have a - * control of such type available. - * - * @return an array of Objects which represent the control - * available for the wrapped PushBufferStream - */ - public Object[] getControls() - { - Object[] controls = stream.getControls(); - - if (controls == null) - { - BufferControl bufferControl = getBufferControl(); - - if (bufferControl != null) - controls = new Object[] { bufferControl }; - } - else - { - boolean bufferControlExists = false; - - for (Object control : controls) - if (control instanceof BufferControl) - { - bufferControlExists = true; - break; - } - if (!bufferControlExists) - { - BufferControl bufferControl = getBufferControl(); - - if (bufferControl != null) - { - Object[] newControls = new Object[controls.length + 1]; - - newControls[0] = bufferControl; - System.arraycopy( - controls, 0, - newControls, 1, - controls.length); - } - } - } - return controls; - } - - /** - * Implements {@link PushBufferStream#getFormat()}. Delegates to the wrapped - * PushBufferStream. - * - * @return the Format of the media data available for reading in - * this PushBufferStream - */ - public Format getFormat() - { - return stream.getFormat(); - } - - /** - * Gets the length in milliseconds of the media in a specific - * Buffer (often referred to as duration). - * - * @param buffer the Buffer which contains media the length in - * milliseconds of which is to be calculated - * @return the length in milliseconds of the media in buffer if - * there actually is media in buffer and its length in milliseconds - * can be calculated; otherwise, 0 - */ - private long getLengthInMillis(Buffer buffer) - { - int length = buffer.getLength(); - - if (length < 1) - return 0; - - Format format = buffer.getFormat(); - - if (format == null) - { - format = getFormat(); - if (format == null) - return 0; - } - if (!(format instanceof AudioFormat)) - return 0; - - AudioFormat audioFormat = (AudioFormat) format; - long duration = audioFormat.computeDuration(length); - - return (duration < 1) ? 0 : (duration / 1000000); - } - - /** - * Gets the PushBufferStream wrapped by this instance. - * - * @return the PushBufferStream wrapped by this instance - */ - public PushBufferStream getStream() - { - return stream; - } - - /** - * Implements {@link PushBufferStream#read(Buffer)}. If an - * IOException has been thrown by the wrapped stream when data was - * last read from it, re-throws it. If there has been no such exception, - * reads from the cache of this instance. - * - * @param buffer the Buffer to receive the read media data - * @throws IOException if the wrapped stream has thrown such an exception - * when data was last read from it - */ - public void read(Buffer buffer) - throws IOException - { - synchronized (cache) - { - if (readException != null) - { - IOException ex = new IOException(); - - ex.initCause(readException); - readException = null; - throw ex; - } - - buffer.setLength(0); - if (!cache.isEmpty()) - { - int bufferOffset = buffer.getOffset(); - - while (!cache.isEmpty()) - { - Buffer cacheBuffer = cache.get(0); - int nextBufferOffset - = read(cacheBuffer, buffer, bufferOffset); - - if ((cacheBuffer.getLength() <= 0) - || (cacheBuffer.getData() == null)) - cache.remove(0); - if (nextBufferOffset < 0) - break; - else - bufferOffset = nextBufferOffset; - } - - cacheLengthInMillis -= getLengthInMillis(buffer); - if (cacheLengthInMillis < 0) - cacheLengthInMillis = 0; - - if (canWriteInCache()) - cache.notify(); - } - } - } - - /** - * Reads data from a specific input Buffer (if such data is - * available) and writes the read data into a specific output - * Buffer. The input Buffer will be modified to reflect - * the number of read data units. If the output Buffer has - * allocated an array for storing the read data and the type of this array - * matches that of the input Buffer, it will be used and thus the - * output Buffer may control the maximum number of data units to be - * read into it. - * - * @param input the Buffer to read data from - * @param output the Buffer into which to write the data read - * from the specified input - * @param outputOffset the offset in output at which the data read - * from input is to be written - * @return the offset in output at which a next round of writing is - * to continue; -1 if no more writing in output is to be - * performed and output is to be returned to the caller - * @throws IOException if reading from input into output - * fails including if either of the formats of input and - * output are not supported - */ - private int read(Buffer input, Buffer output, int outputOffset) - throws IOException - { - Object outputData = output.getData(); - - if (outputData != null) - { - Object inputData = input.getData(); - - if (inputData == null) - { - output.setFormat(input.getFormat()); - /* - * There was nothing to read so continue reading and - * concatenating. - */ - return outputOffset; - } - - Class dataType = outputData.getClass(); - - if (inputData.getClass().equals(dataType) - && dataType.equals(byte[].class)) - { - int inputOffset = input.getOffset(); - int inputLength = input.getLength(); - byte[] outputBytes = (byte[]) outputData; - int outputLength - = outputBytes.length - outputOffset; - - // Where is it supposed to be written? - if (outputLength < 1) - return -1; - - if (inputLength < outputLength) - outputLength = inputLength; - System.arraycopy( - (byte[]) inputData, - inputOffset, - outputBytes, - outputOffset, - outputLength); - - output.setData(outputBytes); - output.setLength(output.getLength() + outputLength); - - /* - * If we're currently continuing a concatenation, the parameters - * of the first read from input are left as the parameters of - * output. Mostly done at least for timeStamp. - */ - if (output.getOffset() == outputOffset) - { - output.setFormat(input.getFormat()); - - output.setDiscard(input.isDiscard()); - output.setEOM(input.isEOM()); - output.setFlags(input.getFlags()); - output.setHeader(input.getHeader()); - output.setSequenceNumber(input.getSequenceNumber()); - output.setTimeStamp(input.getTimeStamp()); - - /* - * It's possible that we've split the input into multiple - * outputs so the output duration may be different than the - * input duration. An alternative to Buffer.TIME_UNKNOWN is - * possibly the calculation of the output duration as the - * input duration multiplied by the ratio between the - * current output length and the initial input length. - */ - output.setDuration(Buffer.TIME_UNKNOWN); - } - - input.setLength(inputLength - outputLength); - input.setOffset(inputOffset + outputLength); - // Continue reading and concatenating. - return (outputOffset + outputLength); - } - } - - /* - * If we were supposed to continue a concatenation and we discovered - * that it could not be continued, flush whatever has already been - * written to the caller. - */ - if (output.getOffset() == outputOffset) - { - output.copy(input); - - int outputLength = output.getLength(); - - input.setLength(input.getLength() - outputLength); - input.setOffset(input.getOffset() + outputLength); - } - /* - * We didn't know how to concatenate the media so return it to the - * caller. - */ - return -1; - } - - /** - * Implements - * {@link PushBufferStream#setTransferHandler(BufferTransferHandler)}. - * Delegates to the wrapped PushBufferStream but wraps the specified - * BufferTransferHandler in order to intercept the calls to - * {@link BufferTransferHandler#transferData(PushBufferStream)} and read - * data from the wrapped PushBufferStream into the cache during the - * calls in question. - * - * @param transferHandler the BufferTransferHandler to be notified - * by this PushBufferStream when media data is available for - * reading - */ - public void setTransferHandler(BufferTransferHandler transferHandler) - { - synchronized (cache) - { - BufferTransferHandler substituteTransferHandler - = (transferHandler == null) - ? null - : new StreamSubstituteBufferTransferHandler( - transferHandler, - stream, - this) - { - @Override - public void transferData(PushBufferStream stream) - { - if (CachingPushBufferStream.this.stream - == stream) - { - CachingPushBufferStream.this.transferData( - this); - } - - super.transferData(stream); - } - }; - - stream.setTransferHandler(substituteTransferHandler); - this.transferHandler = substituteTransferHandler; - cache.notifyAll(); - } - } - - /** - * Reads data from the wrapped/input PushBufferStream into the - * cache of this stream if the cache accepts it. If the cache does not - * accept a new read, blocks the calling thread until the cache accepts a - * new read and data is read from the wrapped PushBufferStream into - * the cache. - * - * @param transferHandler the BufferTransferHandler which has been - * notified - */ - protected void transferData(BufferTransferHandler transferHandler) - { - synchronized (cache) - { - boolean interrupted = false; - - while (true) - { - if (this.transferHandler != transferHandler) - return; - if (canWriteInCache()) - break; - try - { - cache.wait(); - } - catch (InterruptedException iex) - { - interrupted = true; - } - } - if (interrupted) - Thread.currentThread().interrupt(); - - Buffer buffer = new Buffer(); - - try - { - stream.read(buffer); - readException = null; - } - catch (IOException ioex) - { - readException = ioex; - } - cache.add(buffer); - cacheLengthInMillis += getLengthInMillis(buffer); - } - } - - /** - * Implements a BufferControl which enables the adjustment of the - * length of the buffering performed by a CachingPushBufferStream. - */ - private static class BufferControlImpl - implements BufferControl - { - - /** - * The length of the buffering to be performed by the owner of this - * instance. - */ - private long bufferLength = DEFAULT_VALUE; - - /** - * The indicator which determines whether threshold calculations are - * enabled. - * - * @see BufferControl#setEnabledThreshold(boolean) - */ - private boolean enabledThreshold; - - /** - * The minimum threshold in milliseconds for the buffering performed by - * the owner of this instance. - * - * @see BufferControl#getMinimumThreshold() - */ - private long minimumThreshold = DEFAULT_VALUE; - - /** - * Implements {@link BufferControl#getBufferLength()}. Gets the length - * in milliseconds of the buffering performed by the owner of this - * instance. - * - * @return the length in milliseconds of the buffering performed by the - * owner of this instance; {@link BufferControl#DEFAULT_VALUE} if it is - * up to the owner of this instance to decide the length in milliseconds - * of the buffering to perform if any - */ - public long getBufferLength() - { - return bufferLength; - } - - /** - * Implements {@link Control#getControlComponent()}. Gets the UI - * Component representing this instance and exported by the - * owner of this instance. Returns null. - * - * @return the UI Component representing this instance and - * exported by the owner of this instance if such a Component - * is available; otherwise, null - */ - public java.awt.Component getControlComponent() - { - return null; - } - - /** - * Implements {@link BufferControl#getEnabledThreshold()}. Gets the - * indicator which determines whether threshold calculations are - * enabled. - * - * @return true if threshold calculations are enabled; - * otherwise, false - */ - public boolean getEnabledThreshold() - { - return enabledThreshold; - } - - /** - * Implements {@link BufferControl#getMinimumThreshold()}. Gets the - * minimum threshold in milliseconds for the buffering performed by the - * owner of this instance. - * - * @return the minimum threshold in milliseconds for the buffering - * performed by the owner of this instance - */ - public long getMinimumThreshold() - { - return minimumThreshold; - } - - /** - * Implements {@link BufferControl#setBufferLength(long)}. Sets the - * length in milliseconds of the buffering to be performed by the owner - * of this instance and returns the value actually in effect after - * attempting to set it to the specified value. - * - * @param bufferLength the length in milliseconds of the buffering to be - * performed by the owner of this instance - * @return the length in milliseconds of the buffering performed by the - * owner of this instance that is actually in effect after the attempt - * to set it to the specified bufferLength - */ - public long setBufferLength(long bufferLength) - { - if ((bufferLength == DEFAULT_VALUE) || (bufferLength > 0)) - this.bufferLength = bufferLength; - // Returns the current value as specified by the javadoc. - return getBufferLength(); - } - - /** - * Implements {@link BufferControl#setEnabledThreshold(boolean)}. Sets - * the indicator which determines whether threshold calculations are - * enabled. - * - * @param enabledThreshold true if threshold calculations are - * to be enabled; otherwise, false - */ - public void setEnabledThreshold(boolean enabledThreshold) - { - this.enabledThreshold = enabledThreshold; - } - - /** - * Implements {@link BufferControl#setMinimumThreshold(long)}. Sets the - * minimum threshold in milliseconds for the buffering to be performed - * by the owner of this instance and returns the value actually in - * effect after attempting to set it to the specified value. - * - * @param minimumThreshold the minimum threshold in milliseconds for the - * buffering to be performed by the owner of this instance - * @return the minimum threshold in milliseconds for the buffering - * performed by the owner of this instance that is actually in effect - * after the attempt to set it to the specified - * minimumThreshold - */ - public long setMinimumThreshold(long minimumThreshold) - { - /* - * The minimumThreshold property is not supported in any way at the - * time of this writing so returns the current value as specified by - * the javadoc. - */ - return getMinimumThreshold(); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/CaptureDeviceDelegatePullBufferDataSource.java b/src/net/java/sip/communicator/impl/neomedia/protocol/CaptureDeviceDelegatePullBufferDataSource.java deleted file mode 100644 index 9ef72671d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/CaptureDeviceDelegatePullBufferDataSource.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import java.io.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.control.*; - -/** - * Represents a PullBufferDataSource which is also a - * CaptureDevice through delegation to a specific - * CaptureDevice. - * - * @author Damian Minkov - * @author Lubomir Marinov - */ -public class CaptureDeviceDelegatePullBufferDataSource - extends PullBufferDataSource - implements CaptureDevice -{ - /** - * The CaptureDevice this instance delegates to in order to - * implement its CaptureDevice functionality. - */ - protected final CaptureDevice captureDevice; - - /** - * The constant which represents an empty array with - * PullBufferStream element type. Explicitly defined in order to - * reduce unnecessary allocations. - */ - protected static final PullBufferStream[] EMPTY_STREAMS - = new PullBufferStream[0]; - - /** - * Initializes a new CaptureDeviceDelegatePullBufferDataSource - * instance which delegates to a specific CaptureDevice in order to - * implement its CaptureDevice functionality. - * - * @param captureDevice the CaptureDevice the new instance is to - * delegate to in order to provide its CaptureDevice functionality - */ - public CaptureDeviceDelegatePullBufferDataSource( - CaptureDevice captureDevice) - { - this.captureDevice = captureDevice; - } - - /** - * Implements {@link PullBufferDataSource#getStreams()}. Delegates to the - * wrapped CaptureDevice if it implements - * PullBufferDataSource; otherwise, returns an empty array with - * PullBufferStream element type. - * - * @return an array of PullBufferStreams as returned by the wrapped - * CaptureDevice if it implements PullBufferDataSource; - * otherwise, an empty array with PullBufferStream element type - */ - @Override - public PullBufferStream[] getStreams() - { - if (captureDevice instanceof PullBufferDataSource) - return ((PullBufferDataSource) captureDevice).getStreams(); - return EMPTY_STREAMS; - } - - /** - * Implements {@link DataSource#getContentType()}. Delegates to the wrapped - * CaptureDevice if it implements DataSource; otherwise, - * returns {@link ContentDescriptor#CONTENT_UNKNOWN}. - * - * @return a String value which describes the content type of the - * wrapped CaptureDevice if it implements DataSource; - * otherwise, ContentDescriptor#CONTENT_UNKNOWN - */ - @Override - public String getContentType() - { - if (captureDevice instanceof DataSource) - return ((DataSource) captureDevice).getContentType(); - return ContentDescriptor.CONTENT_UNKNOWN; - } - - /** - * Implements {@link CaptureDevice#connect()}. Delegates to the wrapped - * CaptureDevice if available; otherwise, does nothing. - * - * @throws IOException if the wrapped CaptureDevice throws such an - * exception - */ - @Override - public void connect() - throws IOException - { - if (captureDevice != null) - captureDevice.connect(); - } - - /** - * Implements {@link CaptureDevice#disconnect()}. Delegates to the wrapped - * CaptureDevice if available; otherwise, does nothing. - */ - @Override - public void disconnect() - { - if (captureDevice != null) - captureDevice.disconnect(); - } - - /** - * Implements {@link CaptureDevice#start()}. Delegates to the wrapped - * CaptureDevice if available; otherwise, does nothing. - * - * @throws IOException if the wrapped CaptureDevice throws such an - * exception - */ - @Override - public void start() - throws IOException - { - if (captureDevice != null) - captureDevice.start(); - } - - /** - * Implements {@link CaptureDevice#start()}. Delegates to the wrapped - * CaptureDevice if available; otherwise, does nothing. - * - * @throws IOException if the wrapped CaptureDevice throws such an - * exception - */ - @Override - public void stop() - throws IOException - { - if (captureDevice != null) - captureDevice.stop(); - } - - /** - * Implements {@link DataSource#getControl(String)}. Delegates to the - * wrapped CaptureDevice if it implements DataSource; - * otherwise, returns null. - * - * @param controlType a String value which names the type of the - * control to be retrieved - * @return an Object which represents the control of the requested - * controlType of the wrapped CaptureDevice if it - * implements DataSource; otherwise, null - */ - @Override - public Object getControl(String controlType) - { - if (captureDevice instanceof DataSource) - return ((DataSource) captureDevice).getControl(controlType); - return null; - } - - /** - * Implements {@link DataSource#getControls()}. Delegates to the wrapped - * CaptureDevice if it implements DataSource; otherwise, - * returns an empty array with Object element type. - * - * @return the array of controls for the wrapped CaptureDevice if - * it implements DataSource; otherwise, an empty array with - * Object element type - */ - @Override - public Object[] getControls() - { - if (captureDevice instanceof DataSource) - return ((DataSource) captureDevice).getControls(); - return ControlsAdapter.EMPTY_CONTROLS; - } - - /** - * Implements {@link DataSource#getDuration()}. Delegates to the wrapped - * CaptureDevice if it implements DataSource; otherwise, - * returns {@link DataSource#DURATION_UNKNOWN}. - * - * @return the duration of the wrapped CaptureDevice as returned by - * its implementation of DataSource if any; otherwise, returns - * DataSource#DURATION_UNKNOWN - */ - @Override - public Time getDuration() - { - if (captureDevice instanceof DataSource) - return ((DataSource) captureDevice).getDuration(); - return DataSource.DURATION_UNKNOWN; - } - - /** - * Implements {@link CaptureDevice#getFormatControls()}. Delegates to the - * wrapped CaptureDevice if available; otherwise, returns an empty - * array with FormatControl element type. - * - * @return the array of FormatControls of the wrapped - * CaptureDevice if available; otherwise, an empty array with - * FormatControl element type - */ - public FormatControl[] getFormatControls() - { - return - (captureDevice != null) - ? captureDevice.getFormatControls() - : new FormatControl[0]; - } - - - /** - * Implements {@link CaptureDevice#getCaptureDeviceInfo()}. Delegates to the - * wrapped CaptureDevice if available; otherwise, returns - * null. - * - * @return the CaptureDeviceInfo of the wrapped - * CaptureDevice if available; otherwise, null - */ - public CaptureDeviceInfo getCaptureDeviceInfo() - { - return - (captureDevice != null) - ? captureDevice.getCaptureDeviceInfo() - : null; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/CaptureDeviceDelegatePushBufferDataSource.java b/src/net/java/sip/communicator/impl/neomedia/protocol/CaptureDeviceDelegatePushBufferDataSource.java deleted file mode 100644 index 73edab69d..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/CaptureDeviceDelegatePushBufferDataSource.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import java.io.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.control.*; - -/** - * Represents a PushBufferDataSource which is also a - * CaptureDevice through delegation to a specific - * CaptureDevice. - * - * @author Lubomir Marinov - */ -public class CaptureDeviceDelegatePushBufferDataSource - extends PushBufferDataSource - implements CaptureDevice -{ - - /** - * The constant which represents an empty array with - * PushBufferStream element type. Explicitly defined in order to - * reduce unnecessary allocations. - */ - protected static final PushBufferStream[] EMPTY_STREAMS - = new PushBufferStream[0]; - - /** - * The CaptureDevice this instance delegates to in order to - * implement its CaptureDevice functionality. - */ - protected final CaptureDevice captureDevice; - - /** - * Initializes a new CaptureDeviceDelegatePushBufferDataSource - * instance which delegates to a specific CaptureDevice in order to - * implement its CaptureDevice functionality. - * - * @param captureDevice the CaptureDevice the new instance is to - * delegate to in order to provide its CaptureDevice functionality - */ - public CaptureDeviceDelegatePushBufferDataSource( - CaptureDevice captureDevice) - { - this.captureDevice = captureDevice; - } - - /** - * Implements {@link CaptureDevice#connect()}. Delegates to the wrapped - * CaptureDevice if available; otherwise, does nothing. - * - * @throws IOException if the wrapped CaptureDevice throws such an - * exception - */ - public void connect() - throws IOException - { - if (captureDevice != null) - captureDevice.connect(); - } - - /** - * Implements {@link CaptureDevice#disconnect()}. Delegates to the wrapped - * CaptureDevice if available; otherwise, does nothing. - */ - public void disconnect() - { - if (captureDevice != null) - captureDevice.disconnect(); - } - - /** - * Implements {@link CaptureDevice#getCaptureDeviceInfo()}. Delegates to the - * wrapped CaptureDevice if available; otherwise, returns - * null. - * - * @return the CaptureDeviceInfo of the wrapped - * CaptureDevice if available; otherwise, null - */ - public CaptureDeviceInfo getCaptureDeviceInfo() - { - return - (captureDevice != null) - ? captureDevice.getCaptureDeviceInfo() - : null; - } - - /** - * Implements {@link DataSource#getContentType()}. Delegates to the wrapped - * CaptureDevice if it implements DataSource; otherwise, - * returns {@link ContentDescriptor#CONTENT_UNKNOWN}. - * - * @return a String value which describes the content type of the - * wrapped CaptureDevice if it implements DataSource; - * otherwise, ContentDescriptor#CONTENT_UNKNOWN - */ - public String getContentType() - { - if (captureDevice instanceof DataSource) - return ((DataSource) captureDevice).getContentType(); - return ContentDescriptor.CONTENT_UNKNOWN; - } - - /** - * Implements {@link DataSource#getControl(String)}. Delegates to the - * wrapped CaptureDevice if it implements DataSource; - * otherwise, returns null. - * - * @param controlType a String value which names the type of the - * control to be retrieved - * @return an Object which represents the control of the requested - * controlType of the wrapped CaptureDevice if it - * implements DataSource; otherwise, null - */ - public Object getControl(String controlType) - { - if (captureDevice instanceof DataSource) - return ((DataSource) captureDevice).getControl(controlType); - return null; - } - - /** - * Implements {@link DataSource#getControls()}. Delegates to the wrapped - * CaptureDevice if it implements DataSource; otherwise, - * returns an empty array with Object element type. - * - * @return the array of controls for the wrapped CaptureDevice if - * it implements DataSource; otherwise, an empty array with - * Object element type - */ - public Object[] getControls() - { - if (captureDevice instanceof DataSource) - return ((DataSource) captureDevice).getControls(); - return ControlsAdapter.EMPTY_CONTROLS; - } - - /** - * Implements {@link DataSource#getDuration()}. Delegates to the wrapped - * CaptureDevice if it implements DataSource; otherwise, - * returns {@link DataSource#DURATION_UNKNOWN}. - * - * @return the duration of the wrapped CaptureDevice as returned by - * its implementation of DataSource if any; otherwise, returns - * DataSource#DURATION_UNKNOWN - */ - public Time getDuration() - { - if (captureDevice instanceof DataSource) - return ((DataSource) captureDevice).getDuration(); - return DataSource.DURATION_UNKNOWN; - } - - /** - * Implements {@link CaptureDevice#getFormatControls()}. Delegates to the - * wrapped CaptureDevice if available; otherwise, returns an empty - * array with FormatControl element type. - * - * @return the array of FormatControls of the wrapped - * CaptureDevice if available; otherwise, an empty array with - * FormatControl element type - */ - public FormatControl[] getFormatControls() - { - return - (captureDevice != null) - ? captureDevice.getFormatControls() - : new FormatControl[0]; - } - - /** - * Implements {@link PushBufferDataSource#getStreams()}. Delegates to the - * wrapped CaptureDevice if it implements - * PushBufferDataSource; otherwise, returns an empty array with - * PushBufferStream element type. - * - * @return an array of PushBufferStreams as returned by the wrapped - * CaptureDevice if it implements PushBufferDataSource; - * otherwise, an empty array with PushBufferStream element type - */ - public PushBufferStream[] getStreams() - { - if (captureDevice instanceof PushBufferDataSource) - return ((PushBufferDataSource) captureDevice).getStreams(); - return EMPTY_STREAMS; - } - - /** - * Implements {@link CaptureDevice#start()}. Delegates to the wrapped - * CaptureDevice if available; otherwise, does nothing. - * - * @throws IOException if the wrapped CaptureDevice throws such an - * exception - */ - public void start() - throws IOException - { - if (captureDevice != null) - captureDevice.start(); - } - - /** - * Implements {@link CaptureDevice#stop()}. Delegates to the wrapped - * CaptureDevice if available; otherwise, does nothing. - * - * @throws IOException if the wrapped CaptureDevice throws such an - * exception - */ - public void stop() - throws IOException - { - if (captureDevice != null) - captureDevice.stop(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/InbandDTMFDataSource.java b/src/net/java/sip/communicator/impl/neomedia/protocol/InbandDTMFDataSource.java deleted file mode 100644 index ae0f08cb1..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/InbandDTMFDataSource.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * All datasources that support inband DTMF functionalities implement - * InbandDTMFDataSource. - * - * @author Vincent Lucas - */ -public interface InbandDTMFDataSource -{ - /** - * Adds a new inband DTMF tone to send. - * - * @param tone the DTMF tone to send. - */ - public void addDTMF(DTMFInbandTone tone); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/MuteDataSource.java b/src/net/java/sip/communicator/impl/neomedia/protocol/MuteDataSource.java deleted file mode 100644 index 787d1253c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/MuteDataSource.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -/** - * All datasources that support muting functionality implement - * MuteDataSource. - * - * @author Damian Minkov - */ -public interface MuteDataSource -{ - /** - * Determines whether this DataSource is mute. - * - * @return true if this DataSource is mute; otherwise, - * false - */ - public boolean isMute(); - - /** - * Sets the mute state of this DataSource. - * - * @param mute true to mute this DataSource; otherwise, - * false - */ - public void setMute(boolean mute); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/PullBufferDataSourceDelegate.java b/src/net/java/sip/communicator/impl/neomedia/protocol/PullBufferDataSourceDelegate.java deleted file mode 100644 index 8b0ee68e4..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/PullBufferDataSourceDelegate.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import java.io.*; - -import javax.media.*; -import javax.media.protocol.*; - -/** - * Implements most of PullBufferDataSource for a particular - * DataSource and requires extenders to only implement - * {@link PullBufferDataSource#getStreams()}. Intended to allow easier - * overriding of the streams returned by a DataSource. - * - * @param the very type of DataSource to be wrapped in a - * PullBufferDataSourceDelegate - * - * @author Damian Minkov - */ -public abstract class PullBufferDataSourceDelegate - extends CaptureDeviceDelegatePullBufferDataSource -{ - /** - * The wrapped DataSource this instance delegates to. - */ - protected final T dataSource; - - /** - * Initializes a new PullBufferDataSourceDelegate which is to - * delegate to a specific DataSource. - * - * @param dataSource the DataSource the new instance is to delegate - * to - */ - public PullBufferDataSourceDelegate(T dataSource) - { - super( - (dataSource instanceof CaptureDevice) - ? (CaptureDevice) dataSource - : null); - - if (dataSource == null) - throw new NullPointerException("dataSource"); - - this.dataSource = dataSource; - } - - /** - * Implements {@link DataSource#connect()}. Delegates to the wrapped - * DataSource. Overrides - * {@link CaptureDeviceDelegatePullBufferDataSource#connect()} because the - * wrapped DataSource may not be a CaptureDevice yet it - * still needs to be connected. - * - * @throws IOException if the wrapped DataSource throws such an - * exception - */ - @Override - public void connect() - throws IOException - { - dataSource.connect(); - } - - /** - * Implements {@link DataSource#disconnect()}. Delegates to the wrapped - * DataSource. Overrides - * {@link CaptureDeviceDelegatePullBufferDataSource#disconnect()} because - * the wrapped DataSource may not be a CaptureDevice yet - * it still needs to be disconnected. - */ - @Override - public void disconnect() - { - dataSource.disconnect(); - } - - /** - * Implements {@link DataSource#getContentType()}. Delegates to the wrapped - * DataSource. Overrides - * {@link CaptureDeviceDelegatePullBufferDataSource#getContentType()} - * because the wrapped DataSource may not be a - * CaptureDevice yet it still needs to report the content type. - * - * @return a String value which describes the content type of the - * wrapped DataSource - */ - @Override - public String getContentType() - { - return dataSource.getContentType(); - } - - /** - * Implements {@link DataSource#getLocator()}. Delegates to the wrapped - * DataSource. - * - * @return a MediaLocator value which describes the locator of the - * wrapped DataSource - */ - @Override - public MediaLocator getLocator() - { - return dataSource.getLocator(); - } - - /** - * Implements {@link DataSource#getControl(String)}. Delegates to the - * wrapped DataSource. Overrides - * {@link CaptureDeviceDelegatePullBufferDataSource#getControl(String)} - * because the wrapped DataSource may not be a - * CaptureDevice yet it still needs to give access to the control. - * - * @param controlType a String value which names the type of the - * control to be retrieved - * @return an Object which represents the control of the requested - * controlType of the wrapped DataSource - */ - @Override - public Object getControl(String controlType) - { - return dataSource.getControl(controlType); - } - - /** - * Implements {@link DataSource#getControls()}. Delegates to the wrapped - * PullBufferDataSource. Overrides - * {@link CaptureDeviceDelegatePullBufferDataSource#getControls()} because - * the wrapped DataSource may not be a CaptureDevice yet - * it still needs to give access to the controls. - * - * @return an array of Objects which represent the controls of the - * wrapped DataSource - */ - @Override - public Object[] getControls() - { - return dataSource.getControls(); - } - - /** - * Gets the DataSource wrapped by this instance. - * - * @return the DataSource wrapped by this instance - */ - public T getDataSource() - { - return dataSource; - } - - /** - * Implements {@link DataSource#getDuration()}. Delegates to the wrapped - * DataSource. Overrides - * {@link CaptureDeviceDelegatePullBufferDataSource#getDuration()} because - * the wrapped DataSource may not be a CaptureDevice yet - * it still needs to report the duration. - * - * @return the duration of the wrapped DataSource - */ - @Override - public Time getDuration() - { - return dataSource.getDuration(); - } - - /** - * Gets the PullBufferStreams through which this - * PullBufferDataSource gives access to its media data. - * - * @return an array of PullBufferStreams through which this - * PullBufferDataSource gives access to its media data - */ - @Override - public abstract PullBufferStream[] getStreams(); - - /** - * Implements {@link DataSource#start()}. Delegates to the wrapped - * DataSource. Overrides - * {@link CaptureDeviceDelegatePullBufferDataSource#start()} because the - * wrapped DataSource may not be a CaptureDevice yet it - * still needs to be started. - * - * @throws IOException if the wrapped DataSource throws such an - * exception - */ - @Override - public void start() - throws IOException - { - dataSource.start(); - } - - /** - * Implements {@link DataSource#stop()}. Delegates to the wrapped - * DataSource. Overrides - * {@link CaptureDeviceDelegatePullBufferDataSource#stop()} because the - * wrapped DataSource may not be a CaptureDevice yet it - * still needs to be stopped. - * - * @throws IOException if the wrapped DataSource throws such an - * exception - */ - @Override - public void stop() - throws IOException - { - dataSource.stop(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/PullBufferStreamAdapter.java b/src/net/java/sip/communicator/impl/neomedia/protocol/PullBufferStreamAdapter.java deleted file mode 100644 index f204e7401..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/PullBufferStreamAdapter.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import java.io.*; - -import javax.media.*; -import javax.media.format.*; -import javax.media.protocol.*; - -/** - * Represents a PullBufferStream which reads its data from a - * specific PullSourceStream. - * - * @author Lubomir Marinov - */ -public class PullBufferStreamAdapter - extends BufferStreamAdapter - implements PullBufferStream -{ - - /** - * Initializes a new PullBufferStreamAdapter instance which - * reads its data from a specific PullSourceStream with a - * specific Format - * - * @param stream the PullSourceStream the new instance is to - * read its data from - * @param format the Format of the specified input - * stream and of the new instance - */ - public PullBufferStreamAdapter(PullSourceStream stream, Format format) - { - super(stream, format); - } - - /** - * Gets the frame size measured in bytes defined by a specific - * Format. - * - * @param format the Format to determine the frame size in - * bytes of - * @return the frame size measured in bytes defined by the specified - * Format - */ - private static int getFrameSizeInBytes(Format format) - { - AudioFormat audioFormat = (AudioFormat) format; - int frameSizeInBits = audioFormat.getFrameSizeInBits(); - - if (frameSizeInBits <= 0) - return - (audioFormat.getSampleSizeInBits() / 8) - * audioFormat.getChannels(); - return (frameSizeInBits <= 8) ? 1 : (frameSizeInBits / 8); - } - - /** - * Implements PullBufferStream#read(Buffer). Delegates to the wrapped - * PullSourceStream by either allocating a new byte[] buffer or using the - * existing one in the specified Buffer. - * - * @param buffer Buffer to read - * @throws IOException if I/O errors occurred during read operation - */ - public void read(Buffer buffer) - throws IOException - { - Object data = buffer.getData(); - byte[] bytes = null; - - if (data != null) - { - if (data instanceof byte[]) - bytes = (byte[]) data; - else if (data instanceof short[]) - { - short[] shorts = (short[]) data; - - bytes = new byte[2 * shorts.length]; - } - else if (data instanceof int[]) - { - int[] ints = (int[]) data; - - bytes = new byte[4 * ints.length]; - } - } - if (bytes == null) - { - int frameSizeInBytes = getFrameSizeInBytes(getFormat()); - - bytes - = new byte[ - 1024 * ((frameSizeInBytes <= 0) ? 4 : frameSizeInBytes)]; - } - - read(buffer, bytes); - } - - /** - * Implements BufferStreamAdapter#read(byte[], int, int). Delegates to the - * wrapped PullSourceStream. - * - * @param buffer byte array to read - * @param offset to start reading - * @param length length to read - * @return number of bytes read - * @throws IOException if I/O related errors occurred during read operation - */ - protected int read(byte[] buffer, int offset, int length) - throws IOException - { - return stream.read(buffer, offset, length); - } - - /** - * Implements PullBufferStream#willReadBlock(). Delegates to the wrapped - * PullSourceStream. - * - * @return true if this stream will block on read operation, false otherwise - */ - public boolean willReadBlock() - { - return stream.willReadBlock(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/PushBufferDataSourceAdapter.java b/src/net/java/sip/communicator/impl/neomedia/protocol/PushBufferDataSourceAdapter.java deleted file mode 100644 index 8fa2c8664..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/PushBufferDataSourceAdapter.java +++ /dev/null @@ -1,573 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import java.io.*; -import java.util.*; - -import javax.media.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.util.*; - -/** - * Implements PushBufferDataSource for a specific - * PullBufferDataSource. - * - * @author Lubomir Marinov - */ -public class PushBufferDataSourceAdapter - extends PushBufferDataSourceDelegate -{ - - /** - * The Logger used by the PushBufferDataSourceAdapter - * class and its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(PushBufferDataSourceAdapter.class); - - /** - * The indicator which determines whether the - * PushBufferStreamAdapater instances should wait for their - * {@link PushBufferStreamAdapter#streamReadThread}s to exit before their - * {@link PushBufferStreamAdapter#stop()} returns. - */ - private static final boolean STRICT_STOP = false; - - /** - * The indicator which determines whether {@link #start()} has been called - * on this DataSource without a subsequent call to {@link #stop()}. - */ - private boolean started = false; - - /** - * The PushBufferStreams through which this - * PushBufferDataSource gives access to its media data. - */ - private final List streams - = new ArrayList(); - - /** - * Initializes a new PushBufferDataSourceAdapter which is to - * implement PushBufferDataSource capabilities for a specific - * PullBufferDataSource. - * - * @param dataSource the PullBufferDataSource the new instance is - * to implement PushBufferDataSource capabilities for - */ - public PushBufferDataSourceAdapter(PullBufferDataSource dataSource) - { - super(dataSource); - } - - /** - * Implements {@link DataSource#disconnect()}. Disposes of the - * PushBufferStreamAdapters which wrap the - * PullBufferStreams of the PullBufferDataSource wrapped - * by this instance. - */ - @Override - public void disconnect() - { - synchronized (streams) - { - Iterator streamIter = streams.iterator(); - - while (streamIter.hasNext()) - { - PushBufferStreamAdapter stream = streamIter.next(); - - streamIter.remove(); - stream.close(); - } - } - - super.disconnect(); - } - - /** - * Implements {@link DataSource#start()}. Starts the wrapped - * PullBufferDataSource and the pushing from the - * PushBufferStreamAdapters which wrap the - * PullBufferStreams of the PullBufferDataSource wrapped - * by this instance. - * - * @throws IOException if anything wrong happens while starting the wrapped - * PullBufferDataSource or the pushing from the - * PushBufferStreamAdapters which wrap the - * PullBufferStreams of the PullBufferDataSource wrapped - * by this instance - */ - @Override - public void start() - throws IOException - { - super.start(); - - synchronized (streams) - { - started = true; - - for (PushBufferStreamAdapter stream : streams) - stream.start(); - } - } - - /** - * Implements {@link DataSource#start()}. Stops the wrapped - * PullBufferDataSource and the pushing from the - * PushBufferStreamAdapters which wrap the - * PullBufferStreams of the PullBufferDataSource wrapped - * by this instance. - * - * @throws IOException if anything wrong happens while stopping the wrapped - * PullBufferDataSource or the pushing from the - * PushBufferStreamAdapters which wrap the - * PullBufferStreams of the PullBufferDataSource wrapped - * by this instance - */ - @Override - public void stop() - throws IOException - { - synchronized (streams) - { - started = false; - - for (PushBufferStreamAdapter stream : streams) - stream.stop(); - } - - super.stop(); - } - - /** - * Implements {@link PushBufferDataSource#getStreams()}. Gets the - * PushBufferStreams through which this - * PushBufferDataSource gives access to its media data. - * - * @return an array of PushBufferStreams through which this - * PushBufferDataSource gives access to its media data - */ - public PushBufferStream[] getStreams() - { - synchronized (streams) - { - PullBufferStream[] dataSourceStreams = dataSource.getStreams(); - int dataSourceStreamCount; - - /* - * I don't know whether dataSource returns a copy of its internal - * storage so I'm not sure if it's safe to modify dataSourceStreams. - */ - if (dataSourceStreams != null) - { - dataSourceStreams = dataSourceStreams.clone(); - dataSourceStreamCount = dataSourceStreams.length; - } - else - dataSourceStreamCount = 0; - - /* - * Dispose of the PushBufferStreamAdapters which adapt - * PullBufferStreams which are no longer returned by dataSource. - */ - Iterator streamIter = streams.iterator(); - - while (streamIter.hasNext()) - { - PushBufferStreamAdapter streamAdapter = streamIter.next(); - PullBufferStream stream = streamAdapter.stream; - boolean removeStream = true; - - for (int dataSourceStreamIndex = 0; - dataSourceStreamIndex < dataSourceStreamCount; - dataSourceStreamIndex++) - if (stream == dataSourceStreams[dataSourceStreamIndex]) - { - removeStream = false; - dataSourceStreams[dataSourceStreamIndex] = null; - break; - } - if (removeStream) - { - streamIter.remove(); - streamAdapter.close(); - } - } - - /* - * Create PushBufferStreamAdapters for the PullBufferStreams - * returned by dataSource which are not adapted yet. - */ - for (int dataSourceStreamIndex = 0; - dataSourceStreamIndex < dataSourceStreamCount; - dataSourceStreamIndex++) - { - PullBufferStream dataSourceStream - = dataSourceStreams[dataSourceStreamIndex]; - - if (dataSourceStream != null) - { - PushBufferStreamAdapter stream - = new PushBufferStreamAdapter(dataSourceStream); - - streams.add(stream); - if (started) - stream.start(); - } - } - - return streams.toArray(EMPTY_STREAMS); - } - } - - /** - * Implements PushBufferStream for a specific - * PullBufferStream. - */ - private static class PushBufferStreamAdapter - implements PushBufferStream - { - - /** - * The Buffer which contains the media data read by this - * instance from {@link #stream} and to be returned by this - * implementation of {@link PushBufferStream#read(Buffer)} by copying. - */ - private final Buffer buffer = new Buffer(); - - /** - * The indicator which determines whether {@link #buffer} contains media - * data read by this instance from {@link #stream} and not returned by - * this implementation of {@link PushBufferStream#read(Buffer)} yet. - */ - private boolean bufferIsWritten = false; - - /** - * The indicator which determined whether {@link #start()} has been - * called without a subsequent call to {@link #stop()}. - */ - private boolean started = false; - - /** - * The PullBufferStream to which this instance provides - * PushBufferStream capabilities. - */ - public final PullBufferStream stream; - - /** - * The IOException, if any, which has been thrown by the last - * call to {@link PullBufferStream#read(Buffer)} on {@link #stream} and - * which still hasn't been rethrown by this implementation of - * {@link PushBufferStream#read(Buffer)}. - */ - private IOException streamReadException; - - /** - * The Thread which currently reads media data from - * {@link #stream} into {@link #buffer}. - */ - private Thread streamReadThread; - - /** - * The Object which synchronizes the access to - * {@link #streamReadThread}-related members. - */ - private final Object streamReadThreadSyncRoot = new Object(); - - /** - * The BufferTransferHandler through which this - * PushBufferStream notifies its user that media data is - * available for reading. - */ - private BufferTransferHandler transferHandler; - - /** - * Initializes a new PushBufferStreamAdapter instance which is - * to implement PushBufferStream for a specific - * PullBufferStream. - * - * @param stream the PullBufferStream the new instance is to - * implement PushBufferStream for - */ - public PushBufferStreamAdapter(PullBufferStream stream) - { - if (stream == null) - throw new NullPointerException("stream"); - - this.stream = stream; - } - - /** - * Disposes of this PushBufferStreamAdapter. Afterwards, this - * instance is not guaranteed to be operation and considered to be - * available for garbage collection. - */ - void close() - { - stop(); - } - - /** - * Implements {@link SourceStream#endOfStream()}. Delegates to the - * wrapped PullBufferStream. - * - * @return true if the wrapped PullBufferStream has - * reached the end of the media data; otherwise, false - */ - public boolean endOfStream() - { - return stream.endOfStream(); - } - - /** - * Implements {@link SourceStream#getContentDescriptor()}. Delegates to - * the wrapped PullBufferStream. - * - * @return the ContentDescriptor of the wrapped - * PullBufferStream which describes the type of the media data - * it gives access to - */ - public ContentDescriptor getContentDescriptor() - { - return stream.getContentDescriptor(); - } - - /** - * Implements {@link SourceStream#getContentLength()}. Delegates to the - * wrapped PullBufferStream. - * - * @return the length of the content the wrapped - * PullBufferStream gives access to - */ - public long getContentLength() - { - return stream.getContentLength(); - } - - /** - * Implements {@link javax.media.Controls#getControl(String)}. Delegates - * to the wrapped PullBufferStream. - * - * @param controlType a String value which specifies the type - * of the control of the wrapped PullBufferStream to be - * retrieved - * @return an Object which represents the control of the - * wrapped PushBufferStream of the requested type if the - * wrapped PushBufferStream has such a control; null - * if the wrapped PushBufferStream does not have a control of - * the specified type - */ - public Object getControl(String controlType) - { - return stream.getControl(controlType); - } - - /** - * Implements {@link javax.media.Controls#getControls()}. Delegates to - * the wrapped PushBufferStream. - * - * @return an array of Objects which represent the controls - * available for the wrapped PushBufferStream - */ - public Object[] getControls() - { - return stream.getControls(); - } - - /** - * Implements {@link PushBufferStream#getFormat()}. Delegates to the - * wrapped PullBufferStream. - * - * @return the Format of the wrapped PullBufferStream - */ - public Format getFormat() - { - return stream.getFormat(); - } - - /** - * Implements {@link PushBufferStream#read(Buffer)}. - * - * @param buffer a Buffer in which media data is to be written - * by this PushBufferDataSource - * @throws IOException if anything wrong happens while reading media - * data from this PushBufferDataSource into the specified - * buffer - */ - public void read(Buffer buffer) - throws IOException - { - synchronized (this.buffer) - { - /* - * If stream has throw an exception during its last read, - * rethrow it as an exception of this stream. - */ - if (streamReadException != null) - { - IOException ie = new IOException(); - - ie.initCause(streamReadException); - streamReadException = null; - throw ie; - } - else if (bufferIsWritten) - { - buffer.copy(this.buffer); - bufferIsWritten = false; - } - else - buffer.setLength(0); - } - } - - /** - * Executes an iteration of {@link #streamReadThread} i.e. reads media - * data from {@link #stream} into {@link #buffer} and invokes - * {@link BufferTransferHandler#transferData(PushBufferStream)} on - * {@link #transferHandler} if any. - */ - private void runInStreamReadThread() - { - boolean bufferIsWritten; - - synchronized (buffer) - { - try - { - stream.read(buffer); - this.bufferIsWritten = !buffer.isDiscard(); - streamReadException = null; - } - catch (IOException ie) - { - this.bufferIsWritten = false; - streamReadException = ie; - } - bufferIsWritten = this.bufferIsWritten; - } - - if (bufferIsWritten) - { - BufferTransferHandler transferHandler = this.transferHandler; - - if (transferHandler != null) - transferHandler.transferData(this); - } - } - - /** - * Implements - * {@link PushBufferStream#setTransferHandler(BufferTransferHandler)}. - * Sets the means through which this PushBufferStream is to - * notify its user that media data is available for reading. - * - * @param transferHandler the BufferTransferHandler through - * which PushBufferStream is to notify its user that media data - * is available for reading - */ - public void setTransferHandler(BufferTransferHandler transferHandler) - { - if (this.transferHandler != transferHandler) - this.transferHandler = transferHandler; - } - - /** - * Starts the reading of media data of this - * PushBufferStreamAdapter from the wrapped - * PullBufferStream. - */ - void start() - { - synchronized (streamReadThreadSyncRoot) - { - PushBufferStreamAdapter.this.started = true; - - if (streamReadThread == null) - { - streamReadThread = new Thread() - { - @Override - public void run() - { - try - { - while (true) - { - synchronized (streamReadThreadSyncRoot) - { - if (!PushBufferStreamAdapter.this.started) - break; - if (streamReadThread - != Thread.currentThread()) - break; - } - runInStreamReadThread(); - } - } - finally - { - synchronized (streamReadThreadSyncRoot) - { - if (streamReadThread - == Thread.currentThread()) - { - streamReadThread = null; - streamReadThreadSyncRoot.notifyAll(); - } - } - } - } - }; - streamReadThread.setDaemon(true); - streamReadThread.start(); - } - } - } - - /** - * Stops the reading of media data of this - * PushBufferStreamAdapter from the wrapped - * PullBufferStream. - */ - void stop() - { - synchronized (streamReadThreadSyncRoot) - { - started = false; - if (STRICT_STOP) - { - boolean interrupted = false; - - while (streamReadThread != null) - try - { - streamReadThreadSyncRoot.wait(); - } - catch (InterruptedException iex) - { - logger - .info( - getClass().getSimpleName() - + " interrupted while waiting for" - + " PullBufferStream read thread" - + " to stop.", - iex); - interrupted = true; - } - if (interrupted) - Thread.currentThread().interrupt(); - } - else - streamReadThread = null; - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/PushBufferDataSourceDelegate.java b/src/net/java/sip/communicator/impl/neomedia/protocol/PushBufferDataSourceDelegate.java deleted file mode 100644 index cf0eb6cf8..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/PushBufferDataSourceDelegate.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import java.io.*; - -import javax.media.*; -import javax.media.protocol.*; - -/** - * Implements most of PushBufferDataSource for a particular - * DataSource and requires extenders to only implement - * {@link PushBufferDataSource#getStreams()}. Intended to allow easier - * overriding of the streams returned by a DataSource. - * - * @param the very type of DataSource to be wrapped in a - * PushBufferDataSourceDelegate - * @author Lubomir Marinov - */ -public abstract class PushBufferDataSourceDelegate - extends CaptureDeviceDelegatePushBufferDataSource -{ - - /** - * The wrapped DataSource this instance delegates to. - */ - protected final T dataSource; - - /** - * Initializes a new PushBufferDataSourceDelegate which is to - * delegate to a specific DataSource. - * - * @param dataSource the DataSource the new instance is to delegate - * to - */ - public PushBufferDataSourceDelegate(T dataSource) - { - super( - (dataSource instanceof CaptureDevice) - ? (CaptureDevice) dataSource - : null); - - if (dataSource == null) - throw new NullPointerException("dataSource"); - - this.dataSource = dataSource; - } - - /** - * Implements {@link DataSource#connect()}. Delegates to the wrapped - * DataSource. Overrides - * {@link CaptureDeviceDelegatePushBufferDataSource#connect()} because the - * wrapped DataSource may not be a CaptureDevice yet it - * still needs to be connected. - * - * @throws IOException if the wrapped DataSource throws such an - * exception - */ - @Override - public void connect() - throws IOException - { - dataSource.connect(); - } - - /** - * Implements {@link DataSource#disconnect()}. Delegates to the wrapped - * DataSource. Overrides - * {@link CaptureDeviceDelegatePushBufferDataSource#disconnect()} because - * the wrapped DataSource may not be a CaptureDevice yet - * it still needs to be disconnected. - */ - @Override - public void disconnect() - { - dataSource.disconnect(); - } - - /** - * Implements {@link DataSource#getContentType()}. Delegates to the wrapped - * DataSource. Overrides - * {@link CaptureDeviceDelegatePushBufferDataSource#getContentType()} - * because the wrapped DataSource may not be a - * CaptureDevice yet it still needs to report the content type. - * - * @return a String value which describes the content type of the - * wrapped DataSource - */ - @Override - public String getContentType() - { - return dataSource.getContentType(); - } - - /** - * Implements {@link DataSource#getLocator()}. Delegates to the wrapped - * DataSource. - * - * @return a MediaLocator value which describes the locator of the - * wrapped DataSource - */ - @Override - public MediaLocator getLocator() - { - return dataSource.getLocator(); - } - - /** - * Implements {@link DataSource#getControl(String)}. Delegates to the - * wrapped DataSource. Overrides - * {@link CaptureDeviceDelegatePushBufferDataSource#getControl(String)} - * because the wrapped DataSource may not be a - * CaptureDevice yet it still needs to give access to the control. - * - * @param controlType a String value which names the type of the - * control to be retrieved - * @return an Object which represents the control of the requested - * controlType of the wrapped DataSource - */ - @Override - public Object getControl(String controlType) - { - return dataSource.getControl(controlType); - } - - /** - * Implements {@link DataSource#getControls()}. Delegates to the wrapped - * PushBufferDataSource. Overrides - * {@link CaptureDeviceDelegatePushBufferDataSource#getControls()} because - * the wrapped DataSource may not be a CaptureDevice yet - * it still needs to give access to the controls. - * - * @return an array of Objects which represent the controls of the - * wrapped DataSource - */ - @Override - public Object[] getControls() - { - return dataSource.getControls(); - } - - /** - * Gets the DataSource wrapped by this instance. - * - * @return the DataSource wrapped by this instance - */ - public T getDataSource() - { - return dataSource; - } - - /** - * Implements {@link DataSource#getDuration()}. Delegates to the wrapped - * DataSource. Overrides - * {@link CaptureDeviceDelegatePushBufferDataSource#getDuration()} because - * the wrapped DataSource may not be a CaptureDevice yet - * it still needs to report the duration. - * - * @return the duration of the wrapped DataSource - */ - @Override - public Time getDuration() - { - return dataSource.getDuration(); - } - - /** - * Gets the PushBufferStreams through which this - * PushBufferDataSource gives access to its media data. - * - * @return an array of PushBufferStreams through which this - * PushBufferDataSource gives access to its media data - */ - @Override - public abstract PushBufferStream[] getStreams(); - - /** - * Implements {@link DataSource#start()}. Delegates to the wrapped - * DataSource. Overrides - * {@link CaptureDeviceDelegatePushBufferDataSource#start()} because the - * wrapped DataSource may not be a CaptureDevice yet it - * still needs to be started. - * - * @throws IOException if the wrapped DataSource throws such an - * exception - */ - @Override - public void start() - throws IOException - { - dataSource.start(); - } - - /** - * Implements {@link DataSource#stop()}. Delegates to the wrapped - * DataSource. Overrides - * {@link CaptureDeviceDelegatePushBufferDataSource#stop()} because the - * wrapped DataSource may not be a CaptureDevice yet it - * still needs to be stopped. - * - * @throws IOException if the wrapped DataSource throws such an - * exception - */ - @Override - public void stop() - throws IOException - { - dataSource.stop(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/PushBufferStreamAdapter.java b/src/net/java/sip/communicator/impl/neomedia/protocol/PushBufferStreamAdapter.java deleted file mode 100644 index fbdc2dadf..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/PushBufferStreamAdapter.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import java.io.*; - -import javax.media.*; -import javax.media.protocol.*; - -/** - * Represents a PushBufferStream which reads its data from a - * specific PushSourceStream. - * - * @author Lubomir Marinov - */ -public class PushBufferStreamAdapter - extends BufferStreamAdapter - implements PushBufferStream -{ - - /** - * Initializes a new PushBufferStreamAdapter instance which - * reads its data from a specific PushSourceStream with a - * specific Format - * - * @param stream the PushSourceStream the new instance is to - * read its data from - * @param format the Format of the specified input - * stream and of the new instance - */ - public PushBufferStreamAdapter(PushSourceStream stream, Format format) - { - super(stream, format); - } - - /** - * Implements PushBufferStream#read(Buffer). Delegates to the wrapped - * PushSourceStream by allocating a new byte[] buffer of size equal to - * PushSourceStream#getMinimumTransferSize(). - * - * @param buffer the Buffer to read - * @throws IOException if I/O related errors occurred during read operation - */ - public void read(Buffer buffer) - throws IOException - { - read(buffer, new byte[stream.getMinimumTransferSize()]); - } - - /** - * Implements BufferStreamAdapter#read(byte[], int, int). Delegates to the - * wrapped PushSourceStream. - * - * @param buffer byte array to read - * @param offset offset to start reading - * @param length length to read - * @return number of bytes read - * @throws IOException if I/O related errors occurred during read operation - */ - protected int read(byte[] buffer, int offset, int length) - throws IOException - { - return stream.read(buffer, offset, length); - } - - /** - * Implements PushBufferStream#setTransferHandler(BufferTransferHandler). - * Delegates to the wrapped PushSourceStream by translating the specified - * BufferTransferHandler to a SourceTransferHandler. - * - * @param transferHandler a BufferTransferHandler to set - */ - public void setTransferHandler(final BufferTransferHandler transferHandler) - { - stream.setTransferHandler(new SourceTransferHandler() - { - public void transferData(PushSourceStream stream) { - transferHandler.transferData(PushBufferStreamAdapter.this); - } - }); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/RewritablePullBufferDataSource.java b/src/net/java/sip/communicator/impl/neomedia/protocol/RewritablePullBufferDataSource.java deleted file mode 100644 index a5ac6cf81..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/RewritablePullBufferDataSource.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import java.io.*; -import java.util.*; - -import javax.media.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * Implements a PullBufferDataSource wrapper which provides mute - * support for the wrapped instance. - *

- * Because the class wouldn't work for our use case without it, - * CaptureDevice is implemented and is being delegated to the wrapped - * DataSource (if it supports the interface in question). - *

- * - * @author Damian Minkov - * @author Lubomir Marinov - */ -public class RewritablePullBufferDataSource - extends PullBufferDataSourceDelegate - implements MuteDataSource, - InbandDTMFDataSource -{ - /** - * The indicator which determines whether this DataSource is mute. - */ - private boolean mute; - - /** - * The tones to send via inband DTMF, if not empty. - */ - private LinkedList tones = new LinkedList(); - - /** - * Initializes a new RewritablePullBufferDataSource instance which - * is to provide mute support for a specific PullBufferDataSource. - * - * @param dataSource the PullBufferDataSource the new instance is - * to provide mute support for - */ - public RewritablePullBufferDataSource(PullBufferDataSource dataSource) - { - super(dataSource); - } - - /** - * Sets the mute state of this DataSource. - * - * @param mute true to mute this DataSource; otherwise, - * false - */ - public void setMute(boolean mute) - { - this.mute = mute; - } - - /** - * Determines whether this DataSource is mute. - * - * @return true if this DataSource is mute; otherwise, - * false - */ - public boolean isMute() - { - return mute; - } - - /** - * Adds a new inband DTMF tone to send. - * - * @param tone the DTMF tone to send. - */ - public void addDTMF(DTMFInbandTone tone) - { - this.tones.add(tone); - } - - /** - * Determines whether this DataSource sends a DTMF tone. - * - * @return true if this DataSource is sending a DTMF tone; - * otherwise, false. - */ - public boolean isSendingDTMF() - { - return !this.tones.isEmpty(); - } - - /** - * Get wrapped DataSource. - * - * @return wrapped DataSource - */ - public PullBufferDataSource getWrappedDataSource() - { - return dataSource; - } - - /** - * Implements {@link PullBufferDataSource#getStreams()}. Wraps the streams - * of the wrapped PullBufferDataSource into - * MutePullBufferStream instances in order to provide mute support - * to them. - * - * @return an array of PullBufferStream instances with enabled mute - * support - */ - public PullBufferStream[] getStreams() - { - PullBufferStream[] streams = dataSource.getStreams(); - - if (streams != null) - for (int streamIndex = 0; streamIndex < streams.length; streamIndex++) - streams[streamIndex] = - new MutePullBufferStream(streams[streamIndex]); - return streams; - } - - /** - * Implements a PullBufferStream wrapper which provides mute - * support for the wrapped instance. - */ - private class MutePullBufferStream - extends SourceStreamDelegate - implements PullBufferStream - { - - /** - * Initializes a new MutePullBufferStream instance which is to - * provide mute support for a specific PullBufferStream. - * - * @param stream the PullBufferStream the new instance is to - * provide mute support for - */ - private MutePullBufferStream(PullBufferStream stream) - { - super(stream); - } - - /** - * Implements {@link PullBufferStream#getFormat()}. Delegates to the - * wrapped PullBufferStream. - * - * @return the Format of the wrapped PullBufferStream - */ - public Format getFormat() - { - return stream.getFormat(); - } - - /** - * Implements PullBufferStream#read(Buffer). If this instance is muted - * (through its owning RewritablePullBufferDataSource), overwrites the - * data read from the wrapped PullBufferStream with silence data. - * @param buffer which data will be filled. @throws IOException Thrown - * if an error occurs while reading. - */ - public void read(Buffer buffer) - throws IOException - { - stream.read(buffer); - - if (isSendingDTMF()) - { - RewritablePushBufferDataSource.sendDTMF(buffer, tones.poll()); - } - else if (isMute()) - { - RewritablePushBufferDataSource.mute(buffer); - } - } - - /** - * Implements PullBufferStream#willReadBlock(). Delegates to the wrapped - * PullSourceStream. - * @return true if read would block; otherwise returns - * false. - */ - public boolean willReadBlock() - { - return stream.willReadBlock(); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/RewritablePushBufferDataSource.java b/src/net/java/sip/communicator/impl/neomedia/protocol/RewritablePushBufferDataSource.java deleted file mode 100644 index a78d31d32..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/RewritablePushBufferDataSource.java +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import java.io.*; -import java.nio.ByteBuffer; // disambiguation. -import java.nio.ByteOrder; // disambiguation. -import java.nio.IntBuffer; // disambiguation. -import java.util.*; - -import javax.media.*; -import javax.media.format.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * Implements a PushBufferDataSource wrapper which provides mute - * support for the wrapped instance. - *

- * Because the class wouldn't work for our use case without it, - * CaptureDevice is implemented and is being delegated to the wrapped - * DataSource (if it supports the interface in question). - *

- * - * @author Lyubomir Marinov - */ -public class RewritablePushBufferDataSource - extends PushBufferDataSourceDelegate - implements MuteDataSource, - InbandDTMFDataSource -{ - - /** - * The indicator which determines whether this DataSource is mute. - */ - private boolean mute; - - /** - * The tones to send via inband DTMF, if not empty. - */ - private LinkedList tones = new LinkedList(); - - /** - * Initializes a new RewritablePushBufferDataSource instance which - * is to provide mute support for a specific PushBufferDataSource. - * - * @param dataSource the PushBufferDataSource the new instance is - * to provide mute support for - */ - public RewritablePushBufferDataSource(PushBufferDataSource dataSource) - { - super(dataSource); - } - - /** - * Implements {@link PushBufferDataSource#getStreams()}. Wraps the streams - * of the wrapped PushBufferDataSource into - * MutePushBufferStream instances in order to provide mute support - * to them. - * - * @return an array of PushBufferStream instances with enabled mute - * support - */ - public PushBufferStream[] getStreams() - { - PushBufferStream[] streams = dataSource.getStreams(); - - if (streams != null) - { - for (int streamIndex = 0; - streamIndex < streams.length; - streamIndex++) - { - PushBufferStream stream = streams[streamIndex]; - - if (stream != null) - streams[streamIndex] = new MutePushBufferStream(stream); - } - } - return streams; - } - - /** - * Determines whether this DataSource is mute. - * - * @return true if this DataSource is mute; otherwise, - * false - */ - public synchronized boolean isMute() - { - return mute; - } - - /** - * Replaces the media data contained in a specific Buffer with a - * compatible representation of silence. - * - * @param buffer the Buffer the data contained in which is to be - * replaced with silence - */ - public static void mute(Buffer buffer) - { - Object data = buffer.getData(); - - if (data != null) - { - Class dataClass = data.getClass(); - final int fromIndex = buffer.getOffset(); - final int toIndex = fromIndex + buffer.getLength(); - - if (Format.byteArray.equals(dataClass)) - Arrays.fill((byte[]) data, fromIndex, toIndex, (byte) 0); - else if (Format.intArray.equals(dataClass)) - Arrays.fill((int[]) data, fromIndex, toIndex, 0); - else if (Format.shortArray.equals(dataClass)) - Arrays.fill((short[]) data, fromIndex, toIndex, (short) 0); - - buffer.setData(data); - } - } - - /** - * Sets the mute state of this DataSource. - * - * @param mute true to mute this DataSource; otherwise, - * false - */ - public synchronized void setMute(boolean mute) - { - this.mute = mute; - } - - /** - * Adds a new inband DTMF tone to send. - * - * @param tone the DTMF tone to send. - */ - public void addDTMF(DTMFInbandTone tone) - { - this.tones.add(tone); - } - - /** - * Determines whether this DataSource sends a DTMF tone. - * - * @return true if this DataSource is sending a DTMF tone; - * otherwise, false. - */ - public boolean isSendingDTMF() - { - return !this.tones.isEmpty(); - } - - /** - * Replaces the media data contained in a specific Buffer with an - * inband DTMF tone signal. - * - * @param buffer the Buffer the data contained in which is to be - * replaced with the DTMF tone - * @param tone the DMFTTone to send via inband DTMF signal. - */ - public static void sendDTMF( - Buffer buffer, - DTMFInbandTone tone) - { - Object data = buffer.getData(); - - // Send the inband DTMF tone only if the buffer contains audio data. - if (data != null && (buffer.getFormat() instanceof AudioFormat)) - { - Class dataClass = data.getClass(); - int fromIndex = buffer.getOffset(); - - AudioFormat audioFormat = (AudioFormat) buffer.getFormat(); - double samplingFrequency = audioFormat.getSampleRate(); - int sampleSizeInBits = audioFormat.getSampleSizeInBits(); - - // Generates the inband DTMF signal. - int[] sampleData = tone.getAudioSamples( - samplingFrequency, - sampleSizeInBits); - IntBuffer.wrap(sampleData); - - int toIndex = fromIndex + - sampleData.length * (sampleSizeInBits / 8); - ByteBuffer newData = ByteBuffer.allocate(toIndex); - - // Prepares newData to be endian compliant with original buffer - // data. - if(audioFormat.getEndian() == AudioFormat.BIG_ENDIAN) - { - newData.order(ByteOrder.BIG_ENDIAN); - } - else - { - newData.order(ByteOrder.LITTLE_ENDIAN); - } - - // Keeps data unchanged if storeed before the original buffer offset - // index. - // Takes care of original data array type (byte, short or int). - if (Format.byteArray.equals(dataClass)) - { - newData.put(((byte[]) data), 0, fromIndex); - } - else if (Format.shortArray.equals(dataClass)) - { - for(int i = 0; i < fromIndex; ++i) - { - newData.putShort(((short[]) data)[i]); - } - } - else if (Format.intArray.equals(dataClass)) - { - for(int i = 0; i < fromIndex; ++i) - { - newData.putInt(((int[]) data)[i]); - } - } - - // Copies inband DTMF singal into newData. - // Takes care of audio format encryption data type (byte, short or - // int). - switch (sampleSizeInBits) - { - case 8: - for(int i = 0; i < sampleData.length; ++i) - { - newData.put(((byte) sampleData[i])); - } - break; - case 16: - for(int i = 0; i < sampleData.length; ++i) - { - newData.putShort(((short) sampleData[i])); - } - break; - case 32: - for(int i = 0; i < sampleData.length; ++i) - { - newData.putInt(sampleData[i]); - } - break; - } - - // Copies newData up to date into the original buffer. - // Takes care of original data array type (byte, short or int). - if (Format.byteArray.equals(dataClass)) - { - buffer.setData(newData.array()); - } - else if (Format.shortArray.equals(dataClass)) - { - buffer.setData(newData.asShortBuffer().array()); - } - else if (Format.intArray.equals(dataClass)) - { - buffer.setData(newData.asIntBuffer().array()); - } - - // Updates the buffer length. - buffer.setLength(toIndex - fromIndex); - } - } - - /** - * Implements a PushBufferStream wrapper which provides mute - * support for the wrapped instance. - */ - private class MutePushBufferStream - extends SourceStreamDelegate - implements PushBufferStream - { - - /** - * Initializes a new MutePushBufferStream instance which is to - * provide mute support to a specific PushBufferStream. - * - * @param stream the PushBufferStream the new instance is to - * provide mute support to - */ - public MutePushBufferStream(PushBufferStream stream) - { - super(stream); - } - - /** - * Implements {@link PushBufferStream#getFormat()}. Delegates to the - * wrapped PushBufferStream. - * - * @return the Format of the wrapped PushBufferStream - */ - public Format getFormat() - { - return stream.getFormat(); - } - - /** - * Implements {@link PushBufferStream#read(Buffer)}. If this instance is - * muted (through its owning RewritablePushBufferDataSource), - * overwrites the data read from the wrapped PushBufferStream - * with silence data. - * - * @param buffer a Buffer in which the read data is to be - * returned to the caller - * @throws IOException if reading from the wrapped - * PushBufferStream fails - */ - public void read(Buffer buffer) - throws IOException - { - stream.read(buffer); - - if (isSendingDTMF()) - { - sendDTMF(buffer, tones.poll()); - } - else if (isMute()) - { - mute(buffer); - } - } - - /** - * Implements - * {@link PushBufferStream#setTransferHandler(BufferTransferHandler)}. - * Sets up the hiding of the wrapped PushBufferStream from the - * specified transferHandler and thus gives this - * MutePushBufferStream full control when the - * transferHandler in question starts calling to the stream - * given to it in - * BufferTransferHandler#transferData(PushBufferStream). - * - * @param transferHandler a BufferTransferHandler to be - * notified by this instance when data is available for reading from it - */ - public void setTransferHandler(BufferTransferHandler transferHandler) - { - stream.setTransferHandler( - (transferHandler == null) - ? null - : new StreamSubstituteBufferTransferHandler( - transferHandler, - stream, - this)); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/SourceStreamDelegate.java b/src/net/java/sip/communicator/impl/neomedia/protocol/SourceStreamDelegate.java deleted file mode 100644 index add34a47b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/SourceStreamDelegate.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import javax.media.protocol.*; - -/** - * Implements a SourceStream which wraps a specific - * SourceStream. - * - * @param the very type of the SourceStream wrapped by - * SourceStreamDelegate - * - * @author Lyubomir Marinov - */ -public class SourceStreamDelegate - implements SourceStream -{ - - /** - * The SourceStreamDelegate wrapped by this instance. - */ - protected final T stream; - - /** - * Initializes a new SourceStreamDelegate instance which is to - * wrap a specific SourceStream. - * - * @param stream the SourceStream the new instance is to - * wrap - */ - public SourceStreamDelegate(T stream) - { - this.stream = stream; - } - - /** - * Implements {@link SourceStream#endOfStream()}. Delegates to the wrapped - * SourceStream. - * - * @return true if the wrapped SourceStream has reached - * the end the content it makes available - */ - public boolean endOfStream() - { - return stream.endOfStream(); - } - - /** - * Implements {@link SourceStream#getContentDescriptor()}. Delegates to the - * wrapped SourceStream. - * - * @return a ContentDescriptor which describes the content made - * available by the wrapped SourceStream - */ - public ContentDescriptor getContentDescriptor() - { - return stream.getContentDescriptor(); - } - - /** - * Implements {@link SourceStream#getContentLength()}. Delegates to the - * wrapped SourceStream. - * - * @return the length of the content made available by the wrapped - * SourceStream - */ - public long getContentLength() - { - return stream.getContentLength(); - } - - /** - * Implements {@link Controls#getControl(String)}. Delegates to the wrapped - * SourceStream. - * - * @param controlType a String value which specifies the type of - * the control to be retrieved - * @return an Object which represents the control of the wrapped - * SourceStream of the specified type if such a control is - * available; otherwise, null - */ - public Object getControl(String controlType) - { - return stream.getControl(controlType); - } - - /** - * Implements {@link Controls#getControls()}. Delegates to the wrapped - * SourceStream. - * - * @return an array of Objects which represent the controls - * available for the wrapped SourceStream - */ - public Object[] getControls() - { - return stream.getControls(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/StreamSubstituteBufferTransferHandler.java b/src/net/java/sip/communicator/impl/neomedia/protocol/StreamSubstituteBufferTransferHandler.java deleted file mode 100644 index 5757a1529..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/StreamSubstituteBufferTransferHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import javax.media.protocol.*; - -/** - * Implements a BufferTransferHandler wrapper which doesn't - * expose a PushBufferStream but rather a specific substitute in order - * to give full control to the {@link PushBufferStream#read(javax.media.Buffer)} - * method of the substitute. - *

- * The purpose is achieved in #transferData(PushBufferStream) - * where the method argument stream is ignored and the substitute - * is used instead. - *

- * - * @author Lubomir Marinov - */ -public class StreamSubstituteBufferTransferHandler - implements BufferTransferHandler -{ - - /** - * The PushBufferStream to be overridden for - * transferHandler with the substitute of this - * instance. - */ - private final PushBufferStream stream; - - /** - * The PushBufferStream to override the stream of - * this instance for transferHandler. - */ - private final PushBufferStream substitute; - - /** - * The wrapped BufferTransferHandler which receives the - * actual events from the wrapped PushBufferStream. - */ - private final BufferTransferHandler transferHandler; - - /** - * Initializes a new StreamSubstituteBufferTransferHandler instance - * which is to overwrite the source PushBufferStream of a specific - * BufferTransferHandler. - * - * @param transferHandler the BufferTransferHandler the new - * instance is to overwrite the source PushBufferStream - * of - * @param stream the PushBufferStream to be overridden for the - * specified transferHandler with the specified - * substitute - * @param substitute the PushBufferStream to override the - * specified stream for the specified - * transferHandler - */ - public StreamSubstituteBufferTransferHandler( - BufferTransferHandler transferHandler, - PushBufferStream stream, - PushBufferStream substitute) - { - this.transferHandler = transferHandler; - this.stream = stream; - this.substitute = substitute; - } - - /** - * Implements BufferTransferHandler#transferData(PushBufferStream). Puts in - * place the essence of the StreamSubstituteBufferTransferHandler class - * which is to report to the transferHandler from the same PushBufferStream - * to which it was set so that the substitute can gain full control. - * - * @param stream the PushBufferStream to transfer - */ - public void transferData(PushBufferStream stream) - { - transferHandler.transferData( - (stream == this.stream) ? substitute : stream); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/protocol/TranscodingDataSource.java b/src/net/java/sip/communicator/impl/neomedia/protocol/TranscodingDataSource.java deleted file mode 100644 index db3240a52..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/protocol/TranscodingDataSource.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.protocol; - -import java.io.*; -import java.lang.reflect.*; - -import javax.media.*; -import javax.media.control.*; -import javax.media.format.*; -import javax.media.protocol.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.control.*; - -/** - * Represents a DataSource which transcodes the tracks of a specific - * input DataSource into a specific output Format. The - * transcoding is attempted only for tracks which actually support it for the - * specified output Format. - * - * @author Lubomir Marinov - */ -public class TranscodingDataSource - extends DataSource -{ - - /** - * The DataSource which has its tracks transcoded by this instance. - */ - private final DataSource inputDataSource; - - /** - * The DataSource which contains the transcoded tracks of - * inputDataSource and which is wrapped by this instance. It is the - * output of transcodingProcessor. - */ - private DataSource outputDataSource; - - /** - * The Format in which the tracks of inputDataSource are - * transcoded. - */ - private final Format outputFormat; - - /** - * The Processor which carries out the actual transcoding of the - * tracks of inputDataSource. - */ - private Processor transcodingProcessor; - - /** - * Initializes a new TranscodingDataSource instance to transcode - * the tracks of a specific DataSource into a specific output - * Format. - * - * @param inputDataSource the DataSource which is to have its - * tracks transcoded in a specific outptu Format - * @param outputFormat the Format in which the new instance is to - * transcode the tracks of inputDataSource - */ - public TranscodingDataSource( - DataSource inputDataSource, - Format outputFormat) - { - super(inputDataSource.getLocator()); - - this.inputDataSource = inputDataSource; - this.outputFormat = outputFormat; - } - - /** - * Implements {@link DataSource#connect()}. Sets up the very transcoding - * process and just does not start it i.e. creates a Processor on - * the inputDataSource, sets outputFormat on its tracks - * (which support a Format compatible with outputFormat) - * and connects to its output DataSource. - * - * @throws IOException if creating the transcoding Processor, - * setting its Format or connecting to it fails - */ - public synchronized void connect() - throws IOException - { - if (outputDataSource != null) - return; - - /* - * Manager#createProcessor(DataSource) requires the specified DataSource - * to be connected. - */ - inputDataSource.connect(); - - Processor processor; - - try - { - processor = Manager.createProcessor(inputDataSource); - } - catch (NoProcessorException npex) - { - IOException ioex = new IOException(); - ioex.initCause(npex); - throw ioex; - } - - ProcessorUtility processorUtility = new ProcessorUtility(); - - if (!processorUtility.waitForState(processor, Processor.Configured)) - throw new IOException("Couldn't configure transcoding processor."); - - TrackControl[] trackControls = processor.getTrackControls(); - - if (trackControls != null) - for (TrackControl trackControl : trackControls) - { - Format trackFormat = trackControl.getFormat(); - - /* - * XXX We only care about AudioFormat here and we assume - * outputFormat is of such type because it is in our current and - * only use case of TranscodingDataSource - */ - if ((trackFormat instanceof AudioFormat) - && !trackFormat.matches(outputFormat)) - { - Format[] supportedTrackFormats - = trackControl.getSupportedFormats(); - - if (supportedTrackFormats != null) - for (Format supportedTrackFormat - : supportedTrackFormats) - if (supportedTrackFormat.matches(outputFormat)) - { - Format intersectionFormat - = supportedTrackFormat.intersects( - outputFormat); - - if (intersectionFormat != null) - { - trackControl.setFormat(intersectionFormat); - break; - } - } - } - } - - if (!processorUtility.waitForState(processor, Processor.Realized)) - throw new IOException("Couldn't realize transcoding processor."); - - DataSource outputDataSource = processor.getDataOutput(); - - outputDataSource.connect(); - - transcodingProcessor = processor; - this.outputDataSource = outputDataSource; - } - - /** - * Implements {@link DataSource#disconnect()}. Stops and undoes the whole - * setup of the very transcoding process i.e. disconnects from the output - * DataSource of the transcodingProcessor and disposes of the - * transcodingProcessor. - */ - public synchronized void disconnect() - { - if (outputDataSource == null) - return; - - try - { - stop(); - } - catch (IOException ioex) - { - throw new UndeclaredThrowableException(ioex); - } - - outputDataSource.disconnect(); - - transcodingProcessor.deallocate(); - transcodingProcessor.close(); - transcodingProcessor = null; - - outputDataSource = null; - } - - /** - * Implements {@link DataSource#getContentType()}. Delegates to the actual - * output of the transcoding. - * - * @return a String value which describes the type of the content - * made available by this DataSource - */ - public synchronized String getContentType() - { - return - (outputDataSource == null) - ? null - : outputDataSource.getContentType(); - } - - /** - * Implements {@link DataSource#getControl(String)}. Delegates to the actual - * output of the transcoding. - * - * @param controlType a String value which names the type of the - * control to be retrieved - * @return an Object which represents the control of this instance - * with the specified type if such a control is available; otherwise, - * null - */ - public synchronized Object getControl(String controlType) - { - /* - * The Javadoc of DataSource#getControl(String) says it's an error to - * call the method without being connected and by that time we should - * have the outputDataSource. - */ - return outputDataSource.getControl(controlType); - } - - /** - * Implements {@link DataSource#getControls()}. Delegates to the actual - * output of the transcoding. - * - * @return an array of Objects which represent the controls - * available for this instance - */ - public synchronized Object[] getControls() - { - return - (outputDataSource == null) - ? ControlsAdapter.EMPTY_CONTROLS - : outputDataSource.getControls(); - } - - /** - * Implements {@link DataSource#getDuration()}. Delegates to the actual - * output of the transcoding. - * - * @return a Time value which describes the duration of the content - * made available by this instance - */ - public synchronized Time getDuration() - { - return - (outputDataSource == null) - ? DURATION_UNKNOWN - : outputDataSource.getDuration(); - } - - /** - * Gets the output streams that this instance provides. Some of them may be - * the result of transcoding the tracks of the input DataSource of - * this instance in the output Format of this instance. - * - * @return an array of SourceStreams which represents the - * collection of output streams that this instance provides - */ - public synchronized SourceStream[] getStreams() - { - if (outputDataSource instanceof PushBufferDataSource) - return ((PushBufferDataSource) outputDataSource).getStreams(); - if (outputDataSource instanceof PullBufferDataSource) - return ((PullBufferDataSource) outputDataSource).getStreams(); - if (outputDataSource instanceof PushDataSource) - return ((PushDataSource) outputDataSource).getStreams(); - if (outputDataSource instanceof PullDataSource) - return ((PullDataSource) outputDataSource).getStreams(); - return new SourceStream[0]; - } - - /** - * Implements {@link DataSource#start()}. Starts the actual transcoding - * process already set up with {@link #connect()}. - * - * @throws IOException if starting the transcoding fails - */ - public synchronized void start() - throws IOException - { - /* - * The Javadoc of DataSource#start() says it's an error to call the - * method without being connected and by that time we should have the - * outputDataSource. - */ - outputDataSource.start(); - transcodingProcessor.start(); - } - - /** - * Implements {@link DataSource#stop()}. Stops the actual transcoding - * process if it has already been set up with {@link #connect()}. - * - * @throws IOException if stopping the transcoding fails - */ - public synchronized void stop() - throws IOException - { - if (outputDataSource != null) - { - transcodingProcessor.stop(); - outputDataSource.stop(); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/pulseaudio/PA.java b/src/net/java/sip/communicator/impl/neomedia/pulseaudio/PA.java deleted file mode 100644 index 9f221c252..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/pulseaudio/PA.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.pulseaudio; - -public final class PA -{ - public interface context_success_cb_t - { - void callback(long c, boolean success); - } - - public interface sink_info_cb_t - { - void callback(long c, long i, int eol); - } - - public interface source_info_cb_t - { - void callback(long c, long i, int eol); - } - - public interface stream_request_cb_t - { - void callback(long s, int nbytes); - } - - public interface stream_success_cb_t - { - void callback(long s, boolean success); - } - - public static final int CONTEXT_AUTHORIZING = 2; - - public static final int CONTEXT_CONNECTING = 1; - - public static final int CONTEXT_FAILED = 5; - - public static final int CONTEXT_NOFAIL = 2; - - public static final int CONTEXT_NOFLAGS = 0; - - public static final int CONTEXT_READY = 4; - - public static final int CONTEXT_SETTING_NAME = 3; - - public static final int CONTEXT_TERMINATED = 6; - - public static final int CONTEXT_UNCONNECTED = 0; - - public static final int ENCODING_ANY = 0; - - public static final int ENCODING_INVALID = -1; - - public static final int ENCODING_PCM = 1; - - public static final int INVALID_INDEX = -1; - - public static final int OPERATION_CANCELLED = 2; - - public static final int OPERATION_DONE = 1; - - public static final int OPERATION_RUNNING = 0; - - public static final String PROP_APPLICATION_NAME = "application.name"; - - public static final String PROP_APPLICATION_VERSION = "application.version"; - - public static final String PROP_FORMAT_CHANNELS = "format.channels"; - - public static final String PROP_FORMAT_RATE = "format.rate"; - - public static final String PROP_MEDIA_NAME = "media.name"; - - public static final String PROP_MEDIA_ROLE = "media.role"; - - public static final int SAMPLE_S16LE = 3; - - public static final int SEEK_RELATIVE = 0; - - public static final int STREAM_ADJUST_LATENCY = 0x2000; - - public static final int STREAM_FAILED = 3; - - public static final int STREAM_NOFLAGS = 0x0000; - - public static final int STREAM_READY = 2; - - public static final int STREAM_START_CORKED = 0x0001; - - public static final int STREAM_TERMINATED = 4; - - static - { - System.loadLibrary("jnpulseaudio"); - } - - public static native void buffer_attr_free(long attr); - - public static native long buffer_attr_new( - int maxlength, - int tlength, - int prebuf, - int minreq, - int fragsize); - - public static native int context_connect( - long c, - String server, - int flags, - long api); - - public static native void context_disconnect(long c); - - public static native long context_get_sink_info_list( - long c, - sink_info_cb_t cb); - - public static native long context_get_source_info_list( - long c, - source_info_cb_t cb); - - public static native int context_get_state(long c); - - public static native long context_new_with_proplist( - long mainloop, - String name, - long proplist); - - public static native long context_set_sink_input_volume( - long c, - int idx, - long volume, - context_success_cb_t cb); - - public static native long context_set_source_output_volume( - long c, - int idx, - long volume, - context_success_cb_t cb); - - public static native void context_set_state_callback(long c, Runnable cb); - - public static native void context_unref(long c); - - public static native void cvolume_free(long cv); - - public static native long cvolume_new(); - - public static native long cvolume_set(long cv, int channels, int v); - - public static native int format_info_get_encoding(long f); - - public static native long format_info_get_plist(long f); - - public static native int format_info_get_prop_int(long f, String key); - - public static native String get_library_version(); - - public static native int operation_get_state(long o); - - public static native void operation_unref(long o); - - public static native void proplist_free(long p); - - public static native long proplist_new(); - - public static native int proplist_sets(long p, String key, String value); - - public static native void sample_spec_free(long ss); - - public static native long sample_spec_new( - int format, - int rate, - int channels); - - public static native String sink_info_get_description(long i); - - public static native long[] sink_info_get_formats(long i); - - public static native int sink_info_get_index(long i); - - public static native int sink_info_get_monitor_source(long i); - - public static native String sink_info_get_monitor_source_name(long i); - - public static native String sink_info_get_name(long i); - - public static native int sink_info_get_sample_spec_channels(long i); - - public static native int sink_info_get_sample_spec_format(long i); - - public static native int sink_info_get_sample_spec_rate(long i); - - public static native String source_info_get_description(long i); - - public static native long[] source_info_get_formats(long i); - - public static native int source_info_get_index(long i); - - public static native int source_info_get_monitor_of_sink(long i); - - public static native String source_info_get_name(long i); - - public static native int source_info_get_sample_spec_channels(long i); - - public static native int source_info_get_sample_spec_format(long i); - - public static native int source_info_get_sample_spec_rate(long i); - - public static native int stream_connect_playback( - long s, - String dev, - long attr, - int flags, - long volume, - long syncStream); - - public static native int stream_connect_record( - long s, - String dev, - long attr, - int flags); - - public static native long stream_cork( - long s, - boolean b, - stream_success_cb_t cb); - - public static native int stream_disconnect(long s); - - public static native int stream_drop(long s); - - public static native int stream_get_index(long s); - - public static native int stream_get_state(long s); - - public static native long stream_new_with_proplist( - long c, - String name, - long ss, - long map, - long p); - - public static native int stream_peek(long s, byte[] data, int dataOffset); - - public static native int stream_readable_size(long s); - - public static native void stream_set_read_callback( - long s, - stream_request_cb_t cb); - - public static native void stream_set_state_callback(long s, Runnable cb); - - public static native void stream_set_write_callback( - long s, - stream_request_cb_t cb); - - public static native void stream_unref(long s); - - public static native int stream_writable_size(long s); - - public static native int stream_write( - long s, - byte[] data, - int dataOffset, - int dataLength, - Runnable freeCb, - long offset, - int seek); - - public static native int sw_volume_from_linear(double v); - - public static native void threaded_mainloop_free(long m); - - public static native long threaded_mainloop_get_api(long m); - - public static native void threaded_mainloop_lock(long m); - - public static native long threaded_mainloop_new(); - - public static native void threaded_mainloop_signal( - long m, - boolean waitForAccept); - - public static native int threaded_mainloop_start(long m); - - public static native void threaded_mainloop_stop(long m); - - public static native void threaded_mainloop_unlock(long m); - - public static native void threaded_mainloop_wait(long m); - - /** Prevents the initialization of PA instances. */ - private PA() - { - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/CVImageBuffer.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/CVImageBuffer.java deleted file mode 100644 index 21fb32b31..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/CVImageBuffer.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Represents a CoreVideo CVImageBufferRef. - * - * @author Lyubomir Marinov - */ -public class CVImageBuffer -{ - static - { - System.loadLibrary("jnquicktime"); - } - - /** - * The CoreVideo CVImageBufferRef represented by this instance. - */ - private long ptr; - - /** - * Initializes a new CVImageBuffer instance which is to represent - * a specific CoreVideo CVImageBufferRef. - * - * @param ptr the CoreVideo CVImageBufferRef to be represented by - * the new instance - */ - public CVImageBuffer(long ptr) - { - setPtr(ptr); - } - - /** - * Gets the CoreVideo CVImageBufferRef represented by this - * instance. - * - * @return the CoreVideo CVImageBufferRef represented by this - * instance - */ - protected long getPtr() - { - return ptr; - } - - /** - * Sets the CoreVideo CVImageBufferRef represented by this - * instance. - * - * @param ptr the CoreVideo CVImageBufferRef to be represented by - * this instance - */ - protected void setPtr(long ptr) - { - if (ptr == 0) - throw new IllegalArgumentException("ptr"); - - this.ptr = ptr; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/CVPixelBuffer.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/CVPixelBuffer.java deleted file mode 100644 index ee6fa7cfc..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/CVPixelBuffer.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Represents a CoreVideo CVPixelBufferRef. - * - * @author Lubomir Marinov - */ -public class CVPixelBuffer - extends CVImageBuffer -{ - - /** - * Initializes a new CVPixelBuffer instance which is to represent - * a specific CoreVideo CVPixelBufferRef. - * - * @param ptr the CoreVideo CVPixelBufferRef to be represented by - * the new instance - */ - public CVPixelBuffer(long ptr) - { - super(ptr); - } - - /** - * Gets the number of bytes which represent the pixels of the associated - * CoreVideo CVPixelBufferRef. - * - * @return the number of bytes which represent the pixels of the associated - * CoreVideo CVPixelBufferRef - */ - public int getByteCount() - { - return getByteCount(getPtr()); - } - - /** - * Gets the number of bytes which represent the pixels of a specific - * CoreVideo CVPixelBufferRef. - * - * @param ptr the CVPixelBufferRef to get the number of bytes which - * represent its pixels of - * @return the number of bytes which represent the pixels of the specified - * CoreVideo CVPixelBufferRef - */ - private static native int getByteCount(long ptr); - - /** - * Gets a byte array which represents the pixels of the associated - * CoreVideo CVPixelBufferRef. - * - * @return a byte array which represents the pixels of the - * associated CoreVideo CVPixelBufferRef - */ - public byte[] getBytes() - { - return getBytes(getPtr()); - } - - /** - * Gets a byte array which represents the pixels of a specific - * CoreVideo CVPixelBufferRef. - * - * @param ptr the CVPixelBufferRef to get the pixel bytes of - * @return a byte array which represents the pixels of the - * specified CoreVideo CVPixelBufferRef - */ - private static native byte[] getBytes(long ptr); - - /** - * Gets the bytes which represent the pixels of the associated - * CVPixelBufferRef into a specific native byte buffer with a - * specific capacity. - * - * @param buf the native byte buffer to return the bytes into - * @param bufLength the capacity in bytes of buf - * @return the number of bytes written into buf - */ - public int getBytes(long buf, int bufLength) - { - return getBytes(getPtr(), buf, bufLength); - } - - /** - * Gets the bytes which represent the pixels of a specific - * CVPixelBufferRef into a specific native byte buffer with a - * specific capacity. - * - * @param ptr the CVPixelBufferRef to get the bytes of - * @param buf the native byte buffer to return the bytes into - * @param bufLength the capacity in bytes of buf - * @return the number of bytes written into buf - */ - private static native int getBytes(long ptr, long buf, int bufLength); - - /** - * Gets the height in pixels of this CVPixelBuffer. - * - * @return the height in pixels of this CVPixelBuffer - */ - public int getHeight() - { - return getHeight(getPtr()); - } - - /** - * Gets the height in pixels of a specific CoreVideo - * CVPixelBufferRef. - * - * @param ptr the CoreVideo CVPixelBufferRef to get the height in - * pixels of - * @return the height in pixels of the specified CoreVideo - * CVPixelBufferRef - */ - private static native int getHeight(long ptr); - - /** - * Gets the width in pixels of this CVPixelBuffer. - * - * @return the width in pixels of this CVPixelBuffer - */ - public int getWidth() - { - return getWidth(getPtr()); - } - - /** - * Gets the width in pixels of a specific CoreVideo - * CVPixelBufferRef. - * - * @param ptr the CoreVideo CVPixelBufferRef to get the width in - * pixels of - * @return the width in pixels of the specified CoreVideo - * CVPixelBufferRef - */ - private static native int getWidth(long ptr); - - /** - * Native copy from native pointer src to byte array dst. - * @param dst destination array - * @param dstOffset offset of dst to copy data to - * @param dstLength length of dst - * @param src native pointer source - */ - public static native void memcpy( - byte[] dst, int dstOffset, int dstLength, - long src); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/CVPixelBufferAttributeKey.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/CVPixelBufferAttributeKey.java deleted file mode 100644 index 8ae76e9d6..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/CVPixelBufferAttributeKey.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * @author Lyubomir Marinov - */ -public final class CVPixelBufferAttributeKey -{ - public static final long kCVPixelBufferHeightKey; - - public static final long kCVPixelBufferPixelFormatTypeKey; - - public static final long kCVPixelBufferWidthKey; - - static - { - System.loadLibrary("jnquicktime"); - - kCVPixelBufferHeightKey = kCVPixelBufferHeightKey(); - kCVPixelBufferPixelFormatTypeKey = kCVPixelBufferPixelFormatTypeKey(); - kCVPixelBufferWidthKey = kCVPixelBufferWidthKey(); - } - - /** - * Prevents the initialization of CVPixelBufferAttributeKey - * instances. - */ - private CVPixelBufferAttributeKey() - { - } - - private static native long kCVPixelBufferHeightKey(); - - private static native long kCVPixelBufferPixelFormatTypeKey(); - - private static native long kCVPixelBufferWidthKey(); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/CVPixelFormatType.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/CVPixelFormatType.java deleted file mode 100644 index 11dca5338..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/CVPixelFormatType.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Defines the types of CVPixelBuffers to be output by - * QTCaptureDecompressedVideoOutput. - * - * @author Lubomir Marinov - */ -public final class CVPixelFormatType -{ - - /** 24 bit RGB */ - public static final int kCVPixelFormatType_24RGB = 0x00000018; - - /** 32 bit ARGB */ - public static final int kCVPixelFormatType_32ARGB = 0x00000020; - - /** Planar Component Y'CbCr 8-bit 4:2:0. */ - public static final int kCVPixelFormatType_420YpCbCr8Planar = 0x79343230; - - /** - * Prevents the initialization of CVPixelFormatType instances. - */ - private CVPixelFormatType() - { - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/NSDictionary.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/NSDictionary.java deleted file mode 100644 index 44749f71e..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/NSDictionary.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Represents an Objective-C NSDictionary object. - * - * @author Lubomir Marinov - */ -public class NSDictionary - extends NSObject -{ - - /** - * Initializes a new NSDictionary instance which is to represent a - * specific Objective-C NSDictionary object. - * - * @param ptr the pointer to the Objective-C NSDictionary object to - * be represented by the new instance - */ - public NSDictionary(long ptr) - { - super(ptr); - } - - /** - * Called by the garbage collector to release system resources and perform - * other cleanup. - * - * @see Object#finalize() - */ - @Override - protected void finalize() - { - release(); - } - - public int intForKey(long key) - { - return intForKey(getPtr(), key); - } - - private static native int intForKey(long ptr, long key); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/NSError.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/NSError.java deleted file mode 100644 index bf95f9760..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/NSError.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Represents an Objective-C NSError object. - * - * @author Lubomir Marinov - */ -public class NSError - extends NSObject -{ - /** - * Initializes a new NSError instance which is to represent a - * specific Objective-C NSError object. - * - * @param ptr the pointer to the Objective-C NSError object to be - * represented by the new instance - */ - public NSError(long ptr) - { - super(ptr); - } - - /** - * Called by the garbage collector to release system resources and perform - * other cleanup. - * - * @see Object#finalize() - */ - @Override - protected void finalize() - { - release(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/NSErrorException.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/NSErrorException.java deleted file mode 100644 index 70df5fda2..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/NSErrorException.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Defines an Exception which reports an NSError. - * - * @author Lubomir Marinov - */ -public class NSErrorException - extends Exception -{ - - /** - * The NSError reported by this instance. - */ - private final NSError error; - - /** - * Initializes a new NSErrorException instance which is to report a - * specific Objective-C NSError. - * - * @param errorPtr the pointer to the Objective-C NSError object to - * be reported by the new instance - */ - public NSErrorException(long errorPtr) - { - this(new NSError(errorPtr)); - } - - /** - * Initializes a new NSErrorException instance which is to report a - * specific NSError. - * - * @param error the NSError to be reported by the new instance - */ - public NSErrorException(NSError error) - { - this.error = error; - } - - /** - * Gets the NSError reported by this instance. - * - * @return the NSError reported by this instance - */ - public NSError getError() - { - return error; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/NSMutableDictionary.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/NSMutableDictionary.java deleted file mode 100644 index 73f9bbfe0..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/NSMutableDictionary.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Represents an Objective-C NSMutableDictionary object. - * - * @author Lubomir Marinov - */ -public class NSMutableDictionary - extends NSDictionary -{ - - /** - * Initializes a new NSMutableDictionary instance which is to - * represent a new Objective-C NSMutableDictionary object. - */ - public NSMutableDictionary() - { - this(allocAndInit()); - } - - /** - * Initializes a new NSMutableDictionary instance which is to - * represent a specific Objective-C NSMutableDictionary object. - * - * @param ptr the pointer to the Objective-C NSMutableDictionary - * object to be represented by the new instance - */ - public NSMutableDictionary(long ptr) - { - super(ptr); - } - - private static native long allocAndInit(); - - public void setIntForKey(int value, long key) - { - setIntForKey(getPtr(), value, key); - } - - private static native void setIntForKey(long ptr, int value, long key); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/NSObject.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/NSObject.java deleted file mode 100644 index 9b1631757..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/NSObject.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Represents the root of most Objective-C class hierarchies which which objects - * inherit a basic interface to the runtime system and the ability to behave as - * Objective-C objects. - * - * @author Lyubomir Marinov - */ -public class NSObject -{ - static - { - System.loadLibrary("jnquicktime"); - } - - /** - * The pointer to the Objective-C object represented by this instance. - */ - private long ptr; - - /** - * Initializes a new NSObject instance which is to represent a - * specific Objective-C object. - * - * @param ptr the pointer to the Objective-C object to be represented by the - * new instance - */ - public NSObject(long ptr) - { - setPtr(ptr); - } - - /** - * Gets the pointer to the Objective-C object represented by this instance. - * - * @return the pointer to the Objective-C object represented by this - * instance - */ - protected long getPtr() - { - return ptr; - } - - /** - * Decrements the reference count of the Objective-C object represented by - * this instance. It is sent a dealloc message when its reference - * count reaches 0. - */ - public void release() - { - release(ptr); - } - - /** - * Decrements the reference count of a specific Objective-C object. It is - * sent a dealloc message when its reference count reaches - * 0. - * - * @param ptr the pointer to the Objective-C object to decrement the - * reference count of - */ - static native void release(long ptr); - - /** - * Increments the reference count of the Objective-C object represented by - * this instance. - */ - public void retain() - { - retain(ptr); - } - - /** - * Increments the reference count of a specific Objective-C object. - * - * @param ptr the pointer to be Objective-C object to increment the - * reference count of - */ - static native void retain(long ptr); - - /** - * Sets the pointer to the Objective-C object represented by this instance. - * - * @param ptr the pointer to the Objective-C object to be represented by - * this instance - */ - protected void setPtr(long ptr) - { - if (ptr == 0) - throw new IllegalArgumentException("ptr"); - - this.ptr = ptr; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureDecompressedVideoOutput.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureDecompressedVideoOutput.java deleted file mode 100644 index 06a99a5fc..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureDecompressedVideoOutput.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Represents a QTKit QTCaptureDecompressedVideoOutput object. - * - * @author Lyubomir Marinov - */ -public class QTCaptureDecompressedVideoOutput - extends QTCaptureOutput -{ - - /** - * Initializes a new QTCaptureDecompressedVideoOutput which - * represents a new QTKit QTCaptureDecompressedVideoOutput object. - */ - public QTCaptureDecompressedVideoOutput() - { - this(allocAndInit()); - } - - /** - * Initializes a new QTCaptureDecompressedVideoOutput which is to - * represent a new QTKit QTCaptureDecompressedVideoOutput object. - * - * @param ptr the pointer to the QTKit - * QTCaptureDecompressedVideoOutput object to be represented by the - * new instance - */ - public QTCaptureDecompressedVideoOutput(long ptr) - { - super(ptr); - } - - private static native long allocAndInit(); - - /** - * Called by the garbage collector to release system resources and perform - * other cleanup. - * - * @see Object#finalize() - */ - @Override - protected void finalize() - { - release(); - } - - /** - * Gets the minimum time interval between which this - * QTCaptureDecompressedVideoOutput will output consecutive video - * frames. - * - * @return the minimum time interval between which this - * QTCaptureDecompressedVideoOutput will output consecutive video - * frames. It is equivalent to the inverse of the maximum frame rate. The - * value of 0 indicates an unlimited maximum frame rate. - */ - public double minimumVideoFrameInterval() - { - return minimumVideoFrameInterval(getPtr()); - } - - /** - * Gets the minimum time interval between which a specific - * QTCaptureDecompressedVideoOutput instance will output - * consecutive video frames. - * - * @param ptr a pointer to the QTCaptureDecompressedVideoOutput - * instance to get the minimum time interval between consecutive video frame - * output of - * @return the minimum time interval between which a specific - * QTCaptureDecompressedVideoOutput instance will output - * consecutive video frames. It is equivalent to the inverse of the maximum - * frame rate. The value of 0 indicates an unlimited maximum frame - * rate. - */ - private static native double minimumVideoFrameInterval(long ptr); - - public NSDictionary pixelBufferAttributes() - { - long pixelBufferAttributesPtr = pixelBufferAttributes(getPtr()); - - return - (pixelBufferAttributesPtr == 0) - ? null - : new NSDictionary(pixelBufferAttributesPtr); - } - - private static native long pixelBufferAttributes(long ptr); - - public boolean setAutomaticallyDropsLateVideoFrames( - boolean automaticallyDropsLateVideoFrames) - { - return - setAutomaticallyDropsLateVideoFrames( - getPtr(), - automaticallyDropsLateVideoFrames); - } - - private static native boolean setAutomaticallyDropsLateVideoFrames( - long ptr, - boolean automaticallyDropsLateVideoFrames); - - public void setDelegate(Delegate delegate) - { - setDelegate(getPtr(), delegate); - } - - private static native void setDelegate(long ptr, Delegate delegate); - - /** - * Sets the minimum time interval between which this - * QTCaptureDecompressedVideoOutput is to output consecutive video - * frames. - * - * @param minimumVideoFrameInterval the minimum time interval between which - * this QTCaptureDecompressedVideoOutput is to output consecutive - * video frames. It is equivalent to the inverse of the maximum frame rate. - * The value of 0 indicates an unlimited frame rate. - */ - public void setMinimumVideoFrameInterval(double minimumVideoFrameInterval) - { - setMinimumVideoFrameInterval(getPtr(), minimumVideoFrameInterval); - } - - /** - * Sets the minimum time interval between which a specific - * QTCaptureDecompressedVideoOutput instance is to output - * consecutive video frames. - * - * @param ptr a pointer to the QTCaptureDecompressedVideoOutput - * instance to set the minimum time interval between consecutive video frame - * output on - * @param minimumVideoFrameInterval the minimum time interval between which - * a specific QTCaptureDecompressedVideoOutput instance is to - * output consecutive video frames. It is equivalent to the inverse of the - * maximum frame rate. The value of 0 indicates an unlimited frame - * rate. - */ - private static native void setMinimumVideoFrameInterval( - long ptr, - double minimumVideoFrameInterval); - - public void setPixelBufferAttributes(NSDictionary pixelBufferAttributes) - { - setPixelBufferAttributes(getPtr(), pixelBufferAttributes.getPtr()); - } - - private static native void setPixelBufferAttributes( - long ptr, - long pixelBufferAttributesPtr); - - /** - * Represents the receiver of CVImageBuffer video frames and their - * associated QTSampleBuffers captured by a - * QTCaptureDecompressedVideoOutput. - */ - public static abstract class Delegate - { - private MutableQTSampleBuffer sampleBuffer; - - private MutableCVPixelBuffer videoFrame; - - /** - * Notifies this Delegate that the QTCaptureOutput to - * which it is set has output a specific CVImageBuffer - * representing a video frame with a specific QTSampleBuffer. - * - * @param videoFrame the CVImageBuffer which represents the - * output video frame - * @param sampleBuffer the QTSampleBuffer which represents - * additional details about the output video samples - */ - public abstract void outputVideoFrameWithSampleBuffer( - CVImageBuffer videoFrame, - QTSampleBuffer sampleBuffer); - - void outputVideoFrameWithSampleBuffer( - long videoFramePtr, - long sampleBufferPtr) - { - if (videoFrame == null) - videoFrame = new MutableCVPixelBuffer(videoFramePtr); - else - videoFrame.setPtr(videoFramePtr); - - if (sampleBuffer == null) - sampleBuffer = new MutableQTSampleBuffer(sampleBufferPtr); - else - sampleBuffer.setPtr(sampleBufferPtr); - - outputVideoFrameWithSampleBuffer(videoFrame, sampleBuffer); - } - } - - /** - * Represents a CVPixelBuffer which allows public changing of the - * CoreVideo CVPixelBufferRef it represents. - */ - private static class MutableCVPixelBuffer - extends CVPixelBuffer - { - /** - * Initializes a new MutableCVPixelBuffer which is to represent - * a specific CoreVideo CVPixelBufferRef. - * - * @param ptr the CoreVideo CVPixelBufferRef to be represented - * by the new instance - */ - private MutableCVPixelBuffer(long ptr) - { - super(ptr); - } - - /** - * Sets the CoreVideo CVImageBufferRef represented by this - * instance. - * - * @param ptr the CoreVideo CVImageBufferRef to be represented - * by this instance - * @see CVPixelBuffer#setPtr(long) - */ - @Override - public void setPtr(long ptr) - { - super.setPtr(ptr); - } - } - - /** - * Represents a QTSampleBuffer which allows public changing of the - * QTKit QTSampleBuffer object it represents. - */ - private static class MutableQTSampleBuffer - extends QTSampleBuffer - { - /** - * Initializes a new MutableQTSampleBuffer instance which is to - * represent a specific QTKit QTSampleBuffer object. - * - * @param ptr the pointer to the QTKit QTSampleBuffer object to - * be represented by the new instance - */ - private MutableQTSampleBuffer(long ptr) - { - super(ptr); - } - - /** - * Sets the pointer to the Objective-C object represented by this - * instance. - * - * @param ptr the pointer to the Objective-C object to be represented by - * this instance - * @see QTSampleBuffer#setPtr(long) - */ - @Override - public void setPtr(long ptr) - { - super.setPtr(ptr); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureDevice.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureDevice.java deleted file mode 100644 index cd076fb28..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureDevice.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -import java.util.*; - -/** - * Represents a QTKit capture device which is connected or has been previously - * connected to the user's computer during the lifetime of the application. - * - * @author Lubomir Marinov - */ -public class QTCaptureDevice - extends NSObject -{ - - /** - * The cached QTCaptureDevice instances previously returned by the - * last call to {@link #inputDevicesWithMediaType(QTMediaType)}. - */ - private static final Map> inputDevices - = new HashMap>(); - - /** - * The constant which represents an empty array with - * QTFormatDescription element type. Explicitly defined in order to - * avoid unnecessary allocations. - */ - private static final QTFormatDescription[] NO_FORMAT_DESCRIPTIONS - = new QTFormatDescription[0]; - - /** - * The constant which represents an empty array with - * QTCaptureDevice element type. Explicitly defined in order to - * avoid unnecessary allocations. - */ - private static final QTCaptureDevice[] NO_INPUT_DEVICES - = new QTCaptureDevice[0]; - - /** - * Initializes a new QTCaptureDevice instance which is to represent - * a specific QTKit QTCaptureDevice object. - * - * @param ptr the pointer to the QTKit QTCaptureDevice object which - * is to be represented by the new instance - */ - public QTCaptureDevice(long ptr) - { - super(ptr); - } - - /** - * Releases application control over this device acquired in the - * {@link #open()} method. - */ - public void close() - { - close(getPtr()); - } - - /** - * Releases application control over a specific QTKit - * QTCaptureDevice object acquired in the {@link #open(long)} - * method. - * - * @param ptr the pointer to the QTKit QTCaptureDevice object to - * close - */ - private static native void close(long ptr); - - /** - * Gets the QTCaptureDevice with a specific unique identifier. - * - * @param deviceUID the unique identifier of the QTCaptureDevice to - * be retrieved - * @return the QTCaptureDevice with the specified unique identifier - * if such a QTCaptureDevice exists; otherwise, null - */ - public static QTCaptureDevice deviceWithUniqueID(String deviceUID) - { - QTCaptureDevice[] inputDevices - = inputDevicesWithMediaType(QTMediaType.Video); - QTCaptureDevice deviceWithUniqueID - = deviceWithUniqueID(deviceUID, inputDevices); - - if (deviceWithUniqueID == null) - { - inputDevices = inputDevicesWithMediaType(QTMediaType.Sound); - deviceWithUniqueID = deviceWithUniqueID(deviceUID, inputDevices); - } - return deviceWithUniqueID; - } - - private static QTCaptureDevice deviceWithUniqueID( - String deviceUID, - QTCaptureDevice[] inputDevices) - { - if (inputDevices != null) - for (QTCaptureDevice inputDevice : inputDevices) - if (deviceUID.equals(inputDevice.uniqueID())) - return inputDevice; - return null; - } - - /** - * Called by the garbage collector to release system resources and perform - * other cleanup. - * - * @see Object#finalize() - */ - @Override - protected void finalize() - { - release(); - } - - public QTFormatDescription[] formatDescriptions() - { - long[] formatDescriptionPtrs = formatDescriptions(getPtr()); - QTFormatDescription[] formatDescriptions; - - if (formatDescriptionPtrs == null) - formatDescriptions = NO_FORMAT_DESCRIPTIONS; - else - { - int formatDescriptionCount = formatDescriptionPtrs.length; - - if (formatDescriptionCount == 0) - formatDescriptions = NO_FORMAT_DESCRIPTIONS; - else - { - formatDescriptions - = new QTFormatDescription[formatDescriptionCount]; - for (int i = 0; i < formatDescriptionCount; i++) - formatDescriptions[i] - = new QTFormatDescription(formatDescriptionPtrs[i]); - } - } - return formatDescriptions; - } - - private static native long[] formatDescriptions(long ptr); - - public static QTCaptureDevice[] inputDevicesWithMediaType( - QTMediaType mediaType) - { - long[] inputDevicePtrs = inputDevicesWithMediaType(mediaType.name()); - int inputDeviceCount - = (inputDevicePtrs == null) ? 0 : inputDevicePtrs.length; - QTCaptureDevice[] inputDevicesWithMediaType; - - if (inputDeviceCount == 0) - { - inputDevicesWithMediaType = NO_INPUT_DEVICES; - inputDevices.remove(mediaType); - } - else - { - inputDevicesWithMediaType = new QTCaptureDevice[inputDeviceCount]; - - List cachedInputDevicesWithMediaType - = inputDevices.get(mediaType); - - if (cachedInputDevicesWithMediaType == null) - { - cachedInputDevicesWithMediaType - = new LinkedList(); - inputDevices.put(mediaType, cachedInputDevicesWithMediaType); - } - for (int i = 0; i < inputDeviceCount; i++) - { - long inputDevicePtr = inputDevicePtrs[i]; - QTCaptureDevice inputDevice = null; - - for (QTCaptureDevice cachedInputDevice - : cachedInputDevicesWithMediaType) - if (inputDevicePtr == cachedInputDevice.getPtr()) - { - inputDevice = cachedInputDevice; - break; - } - if (inputDevice == null) - { - inputDevice = new QTCaptureDevice(inputDevicePtr); - cachedInputDevicesWithMediaType.add(inputDevice); - } - else - NSObject.release(inputDevicePtr); - inputDevicesWithMediaType[i] = inputDevice; - } - - Iterator cachedInputDeviceIter - = cachedInputDevicesWithMediaType.iterator(); - - while (cachedInputDeviceIter.hasNext()) - { - long cachedInputDevicePtr - = cachedInputDeviceIter.next().getPtr(); - boolean remove = true; - - for (long inputDevicePtr : inputDevicePtrs) - if (cachedInputDevicePtr == inputDevicePtr) - { - remove = false; - break; - } - if (remove) - cachedInputDeviceIter.remove(); - } - } - return inputDevicesWithMediaType; - } - - private static native long[] inputDevicesWithMediaType(String mediaType); - - /** - * Gets the indicator which determines whether this QTCaptureDevice - * is connected and available to applications. - * - * @return true if this QTCaptureDevice is connected and - * available to applications; otherwise, false - */ - public boolean isConnected() - { - return isConnected(getPtr()); - } - - /** - * Gets the indicator which determines whether a specific QTKit - * QTCaptureDevice object is connected and available to - * applications. - * - * @param ptr the pointer to the QTKit QTCaptureDevice object which - * is to get the indicator for - * @return true if the specified QTKit QTCaptureDevice - * object is connected and available to applications; otherwise, - * false - */ - private static native boolean isConnected(long ptr); - - /** - * Gets the localized human-readable name of this QTCaptureDevice. - * - * @return the localized human-readable name of this - * QTCaptureDevice - */ - public String localizedDisplayName() - { - return localizedDisplayName(getPtr()); - } - - /** - * Gets the localized human-readable name of a specific QTKit - * QTCaptureDevice object. - * - * @param ptr the pointer to the QTKit QTCaptureDevice object to - * get the localized human-readable name of - * @return the localized human-readable name of the specified QTKit - * QTCaptureDevice object - */ - private static native String localizedDisplayName(long ptr); - - /** - * Attempts to give the application control over this - * QTCaptureDevice so that it can be used for capture. - * - * @return true if this device was opened successfully; otherwise, - * false - * @throws NSErrorException if this device was not opened successfully and - * carries an NSError describing why this device could not be - * opened - */ - public boolean open() - throws NSErrorException - { - return open(getPtr()); - } - - /** - * Attempts to give the application control over a specific QTKit - * QTCaptureDevice object so that it can be used for capture. - * - * @param ptr the pointer to the QTKit QTCaptureDevice to be opened - * @return true if the device was opened successfully; otherwise, - * false - * @throws NSErrorException if the device was not opened successfully and - * carries an NSError describing why the device could not be opened - */ - private static native boolean open(long ptr) throws NSErrorException; - - /** - * Gets the unique identifier of this QTCaptureDevice. - * - * @return the unique identifier of this QTCaptureDevice - */ - public String uniqueID() - { - return uniqueID(getPtr()); - } - - /** - * Gets the unique identifier of a specific QTKit QTCaptureDevice - * object. - * - * @param ptr the pointer to the QTKit QTCaptureDevice object to - * get the unique identifier of - * @return the unique identifier of the specified QTKit - * QTCaptureDevice object - */ - private static native String uniqueID(long ptr); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureDeviceInput.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureDeviceInput.java deleted file mode 100644 index 71d432a11..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureDeviceInput.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Represents a QTKit QTCaptureDeviceInput object. - * - * @author Lubomir Marinov - */ -public class QTCaptureDeviceInput - extends QTCaptureInput -{ - - /** - * Initializes a new QTCaptureDeviceInput which is to represent a - * specific QTKit QTCaptureDeviceInput object. - * - * @param ptr the pointer to the QTKit QTCaptureDeviceInput object - * to be represented by the new instance - */ - public QTCaptureDeviceInput(long ptr) - { - super(ptr); - } - - public static QTCaptureDeviceInput deviceInputWithDevice( - QTCaptureDevice device) - throws IllegalArgumentException - { - return new QTCaptureDeviceInput(deviceInputWithDevice(device.getPtr())); - } - - private static native long deviceInputWithDevice(long devicePtr) - throws IllegalArgumentException; - - /** - * Called by the garbage collector to release system resources and perform - * other cleanup. - * - * @see Object#finalize() - */ - @Override - protected void finalize() - { - release(); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureInput.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureInput.java deleted file mode 100644 index 3955cd067..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureInput.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Represents a QTKit QTCaptureInput object. - * - * @author Lubomir Marinov - */ -public class QTCaptureInput - extends NSObject -{ - - /** - * Initializes a new QTCaptureInput instance which is to represent - * a specific QTKit QTCaptureInput object. - * - * @param ptr the pointer to the QTKit QTCaptureInput object to be - * represented by the new instance - */ - public QTCaptureInput(long ptr) - { - super(ptr); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureOutput.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureOutput.java deleted file mode 100644 index 8d405897e..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureOutput.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Represents a QTKit QTCaptureOutput object. - * - * @author Lubomir Marinov - */ -public class QTCaptureOutput - extends NSObject -{ - - /** - * Initializes a new QTCaptureOutput instance which is to represent - * a specific QTKit QTCaptureOutput object. - * - * @param ptr the pointer to the QTKit QTCaptureOutput object to be - * represented by the new instance - */ - public QTCaptureOutput(long ptr) - { - super(ptr); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureSession.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureSession.java deleted file mode 100644 index e3c1a5158..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTCaptureSession.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Represents a QTKit QTCaptureSession object. - * - * @author Lubomir Marinov - */ -public class QTCaptureSession - extends NSObject -{ - private boolean closed = false; - - /** - * Initializes a new QTCaptureSession instance which represents a - * new QTKit QTCaptureSession object. - */ - public QTCaptureSession() - { - this(allocAndInit()); - } - - /** - * Initializes a new QTCaptureSession instance which is to - * represent a specific QTKit QTCaptureSession object. - * - * @param ptr the pointer to the QTKit QTCaptureSession object to - * be represented by the new instance - */ - public QTCaptureSession(long ptr) - { - super(ptr); - } - - public boolean addInput(QTCaptureInput input) - throws NSErrorException - { - return addInput(getPtr(), input.getPtr()); - } - - private static native boolean addInput(long ptr, long inputPtr) - throws NSErrorException; - - public boolean addOutput(QTCaptureOutput output) - throws NSErrorException - { - return addOutput(getPtr(), output.getPtr()); - } - - private static native boolean addOutput(long ptr, long outputPtr) - throws NSErrorException; - - private static native long allocAndInit(); - - /** - * Releases the resources used by this instance throughout its existence and - * makes it available for garbage collection. This instance is considered - * unusable after closing. - */ - public synchronized void close() - { - if (!closed) - { - stopRunning(); - release(); - closed = true; - } - } - - /** - * Called by the garbage collector to release system resources and perform - * other cleanup. - * - * @see Object#finalize() - */ - @Override - protected void finalize() - { - close(); - } - - public void startRunning() - { - startRunning(getPtr()); - } - - private static native void startRunning(long ptr); - - public void stopRunning() - { - stopRunning(getPtr()); - } - - private static native void stopRunning(long ptr); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTFormatDescription.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/QTFormatDescription.java deleted file mode 100644 index 006d0dfc3..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTFormatDescription.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -import java.awt.*; - -/** - * Describes the media format of media samples and of media sources, such as - * devices and capture connections. Includes basic information about the media, - * such as media type and format type (or codec type), as well as extended - * information specific to each media type. - * - * @author Lubomir Marinov - */ -public class QTFormatDescription - extends NSObject -{ - public static final String VideoEncodedPixelsSizeAttribute; - - static - { - VideoEncodedPixelsSizeAttribute = VideoEncodedPixelsSizeAttribute(); - } - - /** - * Initializes a new QTFormatDescription instance which is to - * represent a specific QTKit QTFormatDescription object. - * - * @param ptr the pointer to the QTKit QTFormatDescription object - * which is to be represented by the new instance - */ - public QTFormatDescription(long ptr) - { - super(ptr); - } - - /** - * Called by the garbage collector to release system resources and perform - * other cleanup. - * - * @see Object#finalize() - */ - @Override - protected void finalize() - { - release(); - } - - public Dimension sizeForKey(String key) - { - return sizeForKey(getPtr(), key); - } - - private static native Dimension sizeForKey(long ptr, String key); - - private static native String VideoEncodedPixelsSizeAttribute(); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTMediaType.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/QTMediaType.java deleted file mode 100644 index 3159858ea..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTMediaType.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Enumerates the QTKit media types. - * - * @author Lubomir Marinov - */ -public enum QTMediaType -{ - - /** - * The QTKit type of multiplexed media which may contain audio, video, and - * other data in a single stream. - */ - Muxed, - - /** - * The QTKit type of media which contains only audio frames. - */ - Sound, - - /** - * The QTKit type of media which contains only video frames. - */ - Video -} diff --git a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTSampleBuffer.java b/src/net/java/sip/communicator/impl/neomedia/quicktime/QTSampleBuffer.java deleted file mode 100644 index 8c7425ac6..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/quicktime/QTSampleBuffer.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.quicktime; - -/** - * Represents a QuickTime/QTKit QTSampleBuffer object. - * - * @author Lubomir Marinov - */ -public class QTSampleBuffer - extends NSObject -{ - - /** - * Initializes a new QTSampleBuffer which is to represent a - * specific QuickTime/QTKit QTSampleBuffer object. - * - * @param ptr the pointer to the QuickTime/QTKit QTSampleBuffer - * object to be represented by the new instance - */ - public QTSampleBuffer(long ptr) - { - super(ptr); - } - - public byte[] bytesForAllSamples() - { - return bytesForAllSamples(getPtr()); - } - - private static native byte[] bytesForAllSamples(long ptr); - - public QTFormatDescription formatDescription() - { - long formatDescriptionPtr = formatDescription(getPtr()); - - return - (formatDescriptionPtr == 0) - ? null - : new QTFormatDescription(formatDescriptionPtr); - } - - private static native long formatDescription(long ptr); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/ControlTransformInputStream.java b/src/net/java/sip/communicator/impl/neomedia/transform/ControlTransformInputStream.java deleted file mode 100644 index 00ec7c856..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/ControlTransformInputStream.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform; - -import java.io.*; -import java.net.*; -import java.util.*; - -import net.java.sip.communicator.service.neomedia.event.*; - -/** - * Implement control channel (RTCP) for TransformInputStream - * which notify listeners when RTCP feedback messages are received. - * - * @author Bing SU (nova.su@gmail.com) - * @author Lyubomir Marinov - * @author Sebastien Vincent - */ -public class ControlTransformInputStream - extends TransformUDPInputStream -{ - /** - * The list of RTCPFeedbackListener. - */ - private final List listeners - = new LinkedList(); - - /** - * Initializes a new ControlTransformInputStream which is to - * receive packet data from a specific UDP socket. - * - * @param socket the UDP socket the new instance is to receive data from - */ - public ControlTransformInputStream(DatagramSocket socket) - { - super(socket); - } - - /** - * Adds an RTCPFeedbackListener. - * - * @param listener the RTCPFeedbackListener to add - */ - public void addRTCPFeedbackListener(RTCPFeedbackListener listener) - { - if (listener == null) - throw new NullPointerException("listener"); - if(!listeners.contains(listener)) - listeners.add(listener); - } - - /** - * Removes an RTCPFeedbackListener. - * - * @param listener the RTCPFeedbackListener to remove - */ - public void removeRTCPFeedbackListener(RTCPFeedbackListener listener) - { - listeners.remove(listener); - } - - /** - * Copies the content of the most recently received packet into - * inBuffer. - * - * @param inBuffer the byte[] that we'd like to copy the content - * of the packet to. - * @param offset the position where we are supposed to start writing in - * inBuffer. - * @param length the number of bytes available for writing in - * inBuffer. - * - * @return the number of bytes read - * - * @throws IOException if length is less than the size of the - * packet. - */ - public int read(byte[] inBuffer, int offset, int length) - throws IOException - { - if (ioError) - return -1; - - int pktLength = pkt.getLength(); - - if (length < pktLength) - throw new IOException( - "Input buffer not big enough for " + pktLength); - - /* check if RTCP feedback message */ - - /* Feedback message size is minimum 12 bytes: - * Version/Padding/Feedback message type: 1 byte - * Payload type: 1 byte - * Length: 2 bytes - * SSRC of packet sender: 4 bytes - * SSRC of media source: 4 bytes - */ - if ((pktLength >= 12) && !listeners.isEmpty()) - { - byte data[] = pkt.getBuffer(); - int fmt = 0; - int pt = 0; - - /* get FMT field (last 5 bits of first byte) */ - fmt = (data[0] & 0x1F); - pt |= (data[1] & 0xFF); - - RTCPFeedbackEvent evt = new RTCPFeedbackEvent(this, fmt, pt); - - /* notify feedback listeners */ - for(RTCPFeedbackListener l : listeners) - l.feedbackReceived(evt); - } - - System.arraycopy( - pkt.getBuffer(), pkt.getOffset(), - inBuffer, offset, - pktLength); - - return pktLength; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/PacketTransformer.java b/src/net/java/sip/communicator/impl/neomedia/transform/PacketTransformer.java deleted file mode 100755 index dc3abb400..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/PacketTransformer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform; - -import net.java.sip.communicator.impl.neomedia.*; - -/** - * Encapsulate the concept of packet transformation. Given a packet, - * PacketTransformer can either transform it or reverse the - * transformation. - * - * @author Bing SU (nova.su@gmail.com) - */ -public interface PacketTransformer -{ - /** - * Transforms a specific packet. - * - * @param pkt the packet to be transformed - * @return the transformed packet - */ - public RawPacket transform(RawPacket pkt); - - /** - * Reverse-transforms a specific packet (i.e. transforms a transformed - * packet back). - * - * @param pkt the transformed packet to be restored - * @return the restored packet - */ - public RawPacket reverseTransform(RawPacket pkt); - - /** - * Closes this PacketTransformer i.e. releases the resources - * allocated by it and prepares it for garbage collection. - */ - public void close(); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/RTPTransformTCPConnector.java b/src/net/java/sip/communicator/impl/neomedia/transform/RTPTransformTCPConnector.java deleted file mode 100644 index 904732731..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/RTPTransformTCPConnector.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform; - -import java.io.*; - -import javax.media.rtp.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.util.*; - -/** - * TransformConnector implements the RTPConnector interface. RTPConnector - * is originally designed for programmers to abstract the underlying transport - * mechanism for RTP control and data from the RTPManager. However, it provides - * the possibility to modify / transform the RTP and RTCP packets before - * they are sent to network, or after the have been received from the network. - * - * The RTPConnector interface is very powerful. But just to perform packets - * transformation, we do not need all the flexibility. So, we designed this - * TransformConnector, which uses UDP to transfer RTP/RTCP packets just like - * normal RTP stack, and then provides the TransformInputStream interface for - * people to define their own transformation. - * - * With TransformConnector, people can implement RTP/RTCP packets transformation - * and/or manipulation by implementing the TransformEngine interface. - * - * @see TransformEngine - * @see RTPConnector - * @see RTPManager - * - * @author Bing SU (nova.su@gmail.com) - * @author Lubomir Marinov - */ -public class RTPTransformTCPConnector - extends RTPConnectorTCPImpl -{ - /** - * The Logger used by the TransformConnector class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(RTPTransformUDPConnector.class); - - /** - * The customized TransformEngine which contains the concrete - * transform logic. - */ - private TransformEngine engine; - - /** - * Initializes a new TransformConnector which is to use a given - * pair of datagram sockets for RTP and RTCP traffic specified in the form - * of a StreamConnector. - * - * @param connector the pair of datagram sockets for RTP and RTCP traffic - * the new instance is to use - */ - public RTPTransformTCPConnector(StreamConnector connector) - { - super(connector); - } - - /** - * Overrides RTPConnectorImpl#createControlInputStream() to use - * TransformInputStream. - */ - @Override - protected TransformTCPInputStream createControlInputStream() - throws IOException - { - TransformTCPInputStream controlInputStream - = new TransformTCPInputStream(getControlSocket()); - - controlInputStream.setTransformer(getRTCPTransformer()); - return controlInputStream; - } - - /** - * Overrides RTPConnectorImpl#createControlOutputStream() to use - * TransformOutputStream. - */ - @Override - protected TransformTCPOutputStream createControlOutputStream() - throws IOException - { - TransformTCPOutputStream controlOutputStream - = new TransformTCPOutputStream(getControlSocket()); - - controlOutputStream.setTransformer(getRTCPTransformer()); - return controlOutputStream; - } - - /** - * Overrides RTPConnectorImpl#createDataInputStream() to use - * TransformInputStream. - */ - @Override - protected TransformTCPInputStream createDataInputStream() - throws IOException - { - TransformTCPInputStream dataInputStream - = new TransformTCPInputStream(getDataSocket()); - - dataInputStream.setTransformer(getRTPTransformer()); - return dataInputStream; - } - - /** - * Overrides RTPConnectorImpl#createDataOutputStream() to use - * TransformOutputStream. - */ - @Override - protected TransformTCPOutputStream createDataOutputStream() - throws IOException - { - TransformTCPOutputStream dataOutputStream - = new TransformTCPOutputStream(getDataSocket()); - - dataOutputStream.setTransformer(getRTPTransformer()); - return dataOutputStream; - } - - /** - * Gets the customized TransformEngine which contains the concrete - * transform logic. - * - * @return the TransformEngine which contains the concrete - * transform logic - */ - public TransformEngine getEngine() - { - return engine; - } - - /** - * Gets the PacketTransformer specified by the current - * TransformerEngine which is used to transform and - * reverse-transform RTCP packets. - * - * @return the PacketTransformer specified by the current - * TransformEngine which is used to transform and reverse-transform - * RTCP packets if there is currently a TransformEngine and it - * specifies a TransformEngine for RTCP data; otherwise, - * null - */ - private PacketTransformer getRTCPTransformer() - { - TransformEngine engine = getEngine(); - - return (engine == null) ? null : engine.getRTCPTransformer(); - } - - /** - * Gets the PacketTransformer specified by the current - * TransformerEngine which is used to transform and - * reverse-transform RTP packets. - * - * @return the PacketTransformer specified by the current - * TransformEngine which is used to transform and reverse-transform - * RTP packets if there is currently a TransformEngine and it - * specifies a TransformEngine for RTP data; otherwise, - * null - */ - private PacketTransformer getRTPTransformer() - { - TransformEngine engine = getEngine(); - - return (engine == null) ? null : engine.getRTPTransformer(); - } - - /** - * Sets the customized TransformEngine which contains the concrete - * transform logic. - * - * @param engine the TransformEngine which contains the concrete - * transform logic - */ - public void setEngine(TransformEngine engine) - { - if (this.engine != engine) - { - this.engine = engine; - - /* - * Deliver the new PacketTransformers defined by the new - * TransformEngine to the respective streams. - */ - TransformTCPInputStream controlInputStream; - try - { - controlInputStream - = (TransformTCPInputStream) getControlInputStream(false); - } - catch (IOException ioex) - { - logger.error("The impossible happened", ioex); - controlInputStream = null; - } - if (controlInputStream != null) - controlInputStream.setTransformer(getRTCPTransformer()); - TransformTCPOutputStream controlOutputStream; - try - { - controlOutputStream - = (TransformTCPOutputStream) getControlOutputStream(false); - } - catch (IOException ioex) - { - logger.error("The impossible happened", ioex); - controlOutputStream = null; - } - if (controlOutputStream != null) - controlOutputStream.setTransformer(getRTCPTransformer()); - TransformTCPInputStream dataInputStream; - try - { - dataInputStream - = (TransformTCPInputStream) getDataInputStream(false); - } - catch (IOException ioex) - { - logger.error("The impossible happened", ioex); - dataInputStream = null; - } - if (dataInputStream != null) - dataInputStream.setTransformer(getRTPTransformer()); - TransformTCPOutputStream dataOutputStream; - try - { - dataOutputStream - = (TransformTCPOutputStream) getDataOutputStream(false); - } - catch (IOException ioex) - { - logger.error("The impossible happened", ioex); - dataOutputStream = null; - } - if (dataOutputStream != null) - dataOutputStream.setTransformer(getRTPTransformer()); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/RTPTransformUDPConnector.java b/src/net/java/sip/communicator/impl/neomedia/transform/RTPTransformUDPConnector.java deleted file mode 100644 index c70de5ac9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/RTPTransformUDPConnector.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform; - -import java.io.*; - -import javax.media.rtp.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.util.*; - -/** - * TransformConnector implements the RTPConnector interface. RTPConnector - * is originally designed for programmers to abstract the underlying transport - * mechanism for RTP control and data from the RTPManager. However, it provides - * the possibility to modify / transform the RTP and RTCP packets before - * they are sent to network, or after the have been received from the network. - * - * The RTPConnector interface is very powerful. But just to perform packets - * transformation, we do not need all the flexibility. So, we designed this - * TransformConnector, which uses UDP to transfer RTP/RTCP packets just like - * normal RTP stack, and then provides the TransformInputStream interface for - * people to define their own transformation. - * - * With TransformConnector, people can implement RTP/RTCP packets transformation - * and/or manipulation by implementing the TransformEngine interface. - * - * @see TransformEngine - * @see RTPConnector - * @see RTPManager - * - * @author Bing SU (nova.su@gmail.com) - * @author Lubomir Marinov - */ -public class RTPTransformUDPConnector - extends RTPConnectorUDPImpl -{ - /** - * The Logger used by the TransformConnector class and its - * instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(RTPTransformUDPConnector.class); - - /** - * The customized TransformEngine which contains the concrete - * transform logic. - */ - private TransformEngine engine; - - /** - * Initializes a new TransformConnector which is to use a given - * pair of datagram sockets for RTP and RTCP traffic specified in the form - * of a StreamConnector. - * - * @param connector the pair of datagram sockets for RTP and RTCP traffic - * the new instance is to use - */ - public RTPTransformUDPConnector(StreamConnector connector) - { - super(connector); - } - - /** - * Overrides RTPConnectorImpl#createControlInputStream() to use - * TransformInputStream. - */ - @Override - protected TransformUDPInputStream createControlInputStream() - throws IOException - { - TransformUDPInputStream controlInputStream - = new ControlTransformInputStream(getControlSocket()); - - controlInputStream.setTransformer(getRTCPTransformer()); - return controlInputStream; - } - - /** - * Overrides RTPConnectorImpl#createControlOutputStream() to use - * TransformOutputStream. - */ - @Override - protected TransformUDPOutputStream createControlOutputStream() - throws IOException - { - TransformUDPOutputStream controlOutputStream - = new TransformUDPOutputStream(getControlSocket()); - - controlOutputStream.setTransformer(getRTCPTransformer()); - return controlOutputStream; - } - - /** - * Overrides RTPConnectorImpl#createDataInputStream() to use - * TransformInputStream. - */ - @Override - protected TransformUDPInputStream createDataInputStream() - throws IOException - { - TransformUDPInputStream dataInputStream - = new TransformUDPInputStream(getDataSocket()); - - dataInputStream.setTransformer(getRTPTransformer()); - return dataInputStream; - } - - /** - * Overrides RTPConnectorImpl#createDataOutputStream() to use - * TransformOutputStream. - */ - @Override - protected TransformUDPOutputStream createDataOutputStream() - throws IOException - { - TransformUDPOutputStream dataOutputStream - = new TransformUDPOutputStream(getDataSocket()); - - dataOutputStream.setTransformer(getRTPTransformer()); - return dataOutputStream; - } - - /** - * Gets the customized TransformEngine which contains the concrete - * transform logic. - * - * @return the TransformEngine which contains the concrete - * transform logic - */ - public TransformEngine getEngine() - { - return engine; - } - - /** - * Gets the PacketTransformer specified by the current - * TransformerEngine which is used to transform and - * reverse-transform RTCP packets. - * - * @return the PacketTransformer specified by the current - * TransformEngine which is used to transform and reverse-transform - * RTCP packets if there is currently a TransformEngine and it - * specifies a TransformEngine for RTCP data; otherwise, - * null - */ - private PacketTransformer getRTCPTransformer() - { - TransformEngine engine = getEngine(); - - return (engine == null) ? null : engine.getRTCPTransformer(); - } - - /** - * Gets the PacketTransformer specified by the current - * TransformerEngine which is used to transform and - * reverse-transform RTP packets. - * - * @return the PacketTransformer specified by the current - * TransformEngine which is used to transform and reverse-transform - * RTP packets if there is currently a TransformEngine and it - * specifies a TransformEngine for RTP data; otherwise, - * null - */ - private PacketTransformer getRTPTransformer() - { - TransformEngine engine = getEngine(); - - return (engine == null) ? null : engine.getRTPTransformer(); - } - - /** - * Sets the customized TransformEngine which contains the concrete - * transform logic. - * - * @param engine the TransformEngine which contains the concrete - * transform logic - */ - public void setEngine(TransformEngine engine) - { - if (this.engine != engine) - { - this.engine = engine; - - /* - * Deliver the new PacketTransformers defined by the new - * TransformEngine to the respective streams. - */ - TransformUDPInputStream controlInputStream; - try - { - controlInputStream - = (TransformUDPInputStream) getControlInputStream(false); - } - catch (IOException ioex) - { - logger.error("The impossible happened", ioex); - controlInputStream = null; - } - if (controlInputStream != null) - controlInputStream.setTransformer(getRTCPTransformer()); - TransformUDPOutputStream controlOutputStream; - try - { - controlOutputStream - = (TransformUDPOutputStream) getControlOutputStream(false); - } - catch (IOException ioex) - { - logger.error("The impossible happened", ioex); - controlOutputStream = null; - } - if (controlOutputStream != null) - controlOutputStream.setTransformer(getRTCPTransformer()); - TransformUDPInputStream dataInputStream; - try - { - dataInputStream - = (TransformUDPInputStream) getDataInputStream(false); - } - catch (IOException ioex) - { - logger.error("The impossible happened", ioex); - dataInputStream = null; - } - if (dataInputStream != null) - dataInputStream.setTransformer(getRTPTransformer()); - TransformUDPOutputStream dataOutputStream; - try - { - dataOutputStream - = (TransformUDPOutputStream) getDataOutputStream(false); - } - catch (IOException ioex) - { - logger.error("The impossible happened", ioex); - dataOutputStream = null; - } - if (dataOutputStream != null) - dataOutputStream.setTransformer(getRTPTransformer()); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/TransformEngine.java b/src/net/java/sip/communicator/impl/neomedia/transform/TransformEngine.java deleted file mode 100755 index f72aa8de4..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/TransformEngine.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform; - -/** - * Defines how to get PacketTransformers for RTP and RTCP packets. A - * single PacketTransformer can be used for both RTP and RTCP packets - * or there can be two separate PacketTransformers. - * - * @author Bing SU (nova.su@gmail.com) - */ -public interface TransformEngine -{ - /** - * Gets the PacketTransformer for RTP packets. - * - * @return the PacketTransformer for RTP packets - */ - public PacketTransformer getRTPTransformer(); - - /** - * Gets the PacketTransformer for RTCP packets. - * - * @return the PacketTransformer for RTCP packets - */ - public PacketTransformer getRTCPTransformer(); -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/TransformEngineChain.java b/src/net/java/sip/communicator/impl/neomedia/transform/TransformEngineChain.java deleted file mode 100644 index b99315605..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/TransformEngineChain.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform; - -import net.java.sip.communicator.impl.neomedia.*; - -/** - * The engine chain allows using numerous TransformEngines on a single - * stream. - * - * @author Emil Ivov - * @author Lubomir Marinov - */ -public class TransformEngineChain - implements TransformEngine -{ - - /** - * The sequence of TransformEngines whose - * PacketTransformers that this engine chain will be applying to - * RTP and RTCP packets. - */ - private final TransformEngine[] engineChain; - - /** - * The sequence of PacketTransformers that this engine chain will - * be applying to RTP packets. - */ - private final PacketTransformerChain rtpTransformChain; - - /** - * The sequence of PacketTransformers that this engine chain will - * be applying to RTCP packets. - */ - private final PacketTransformerChain rtcpTransformChain; - - /** - * Creates a new TransformEngineChain using the - * engineChain array. Engines will be applied in the order - * specified by the engineChain array for outgoing packets - * and in the reverse order for incoming packets. - * - * @param engineChain an array containing TransformEngines in the - * order that they are to be applied on outgoing packets. - */ - public TransformEngineChain(TransformEngine[] engineChain) - { - this.engineChain = engineChain.clone(); - - rtpTransformChain = new PacketTransformerChain(true); - rtcpTransformChain = new PacketTransformerChain(false); - } - - /** - * Returns the meta PacketTransformer that will be applying - * RTCP transformations from all engines registered in this - * TransformEngineChain. - * - * @return a PacketTransformerChain over all RTP transformers in - * this engine chain. - */ - public PacketTransformer getRTPTransformer() - { - return rtpTransformChain; - } - - /** - * Returns the meta PacketTransformer that will be applying - * RTCP transformations from all engines registered in this - * TransformEngineChain. - * - * @return a PacketTransformerChain over all RTCP transformers in - * this engine chain. - */ - public PacketTransformer getRTCPTransformer() - { - return rtcpTransformChain; - } - - /** - * A PacketTransformerChain is a meta PacketTransformer - * that applies all transformers present in this engine chain. The class - * respects the order of the engine chain for outgoing packets and reverses - * it for incoming packets. - */ - private class PacketTransformerChain - implements PacketTransformer - { - /** - * Indicates whether this transformer will be dealing with RTP or, - * in other words, whether it will transform packets via the RTP - * transformers in this chain rather than the RTCP ones. - */ - private final boolean isRtp; - - /** - * Creates an instance of this packet transformer and prepares it to - * deal with RTP or RTCP according to the isRtp arg. - * - * @param isRtp true if this transformer will be dealing with - * RTP (i.e. will transform packets via the RTP transformers in this - * chain rather than the RTCP ones) and false otherwise. - */ - public PacketTransformerChain(boolean isRtp) - { - this.isRtp = isRtp; - } - - /** - * Close the transformer and underlying transform engines. - * - * Propagate the close to all transformers in chain. - */ - public void close() - { - for (TransformEngine engine : engineChain) - { - PacketTransformer pTransformer - = isRtp - ? engine.getRTPTransformer() - : engine.getRTCPTransformer(); - - //the packet transformer may be null if for example the engine - //only does RTP transformations and this is an RTCP transformer. - if( pTransformer != null) - pTransformer.close(); - } - } - - /** - * Transforms a specific packet. - * - * @param pkt the packet to be transformed - * @return the transformed packet - */ - public RawPacket transform(RawPacket pkt) - { - for (TransformEngine engine : engineChain) - { - PacketTransformer pTransformer - = isRtp - ? engine.getRTPTransformer() - : engine.getRTCPTransformer(); - - //the packet transformer may be null if for example the engine - //only does RTP transformations and this is an RTCP transformer. - if( pTransformer != null) - pkt = pTransformer.transform(pkt); - } - - return pkt; - } - - /** - * Reverse-transforms a specific packet (i.e. transforms a transformed - * packet back). - * - * @param pkt the transformed packet to be restored - * @return the restored packet - */ - public RawPacket reverseTransform(RawPacket pkt) - { - for (int i = engineChain.length - 1 ; i >= 0; i--) - { - TransformEngine engine = engineChain[i]; - PacketTransformer pTransformer - = isRtp - ? engine.getRTPTransformer() - : engine.getRTCPTransformer(); - - //the packet transformer may be null if for example the engine - //only does RTP transformations and this is an RTCP transformer. - if( pTransformer != null) - { - pkt = pTransformer.reverseTransform(pkt); - if (pkt == null) - return null; - } - } - - return pkt; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/TransformTCPInputStream.java b/src/net/java/sip/communicator/impl/neomedia/transform/TransformTCPInputStream.java deleted file mode 100644 index ca23b2288..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/TransformTCPInputStream.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform; - -import java.net.*; - -import net.java.sip.communicator.impl.neomedia.*; - -/** - * Extends RTPConnectorInputStream with transform logic for TCP. - * - * In this implementation, we use TCP sockets to receive RTP/RTCP. We listen on - * the address / port specified by local session address. When one packet is - * received, it is first reverse transformed through PacketTransformer defined - * by user. And then returned as normal RTP/RTCP packets to RTPManager. - * - * @author Bing SU (nova.su@gmail.com) - * @author Lubomir Marinov - */ -public class TransformTCPInputStream - extends RTPConnectorTCPInputStream -{ - /** - * The user defined PacketTransformer which is used to reverse - * transform packets. - */ - private PacketTransformer transformer; - - /** - * Initializes a new TransformInputStream which is to receive - * packet data from a specific TCP socket. - * - * @param socket the UDP socket the new instance is to receive data from - */ - public TransformTCPInputStream(Socket socket) - { - super(socket); - } - - /** - * Creates a new RawPacket from a specific DatagramPacket - * in order to have this instance receive its packet data through its - * {@link #read(byte[], int, int)} method. Reverse-transforms the received - * packet. - * - * @param datagramPacket the DatagramPacket containing the packet - * data - * @return a new RawPacket containing the packet data of the - * specified DatagramPacket or possibly its modification; - * null to ignore the packet data of the specified - * DatagramPacket and not make it available to this instance - * through its {@link #read(byte[], int, int)} method - * @see RTPConnectorInputStream#createRawPacket(DatagramPacket) - */ - @Override - protected RawPacket createRawPacket(DatagramPacket datagramPacket) - { - PacketTransformer transformer = getTransformer(); - RawPacket pkt = super.createRawPacket(datagramPacket); - - return (transformer == null) ? pkt : transformer.reverseTransform(pkt); - } - - /** - * Gets the PacketTransformer which is used to reverse-transform - * packets. - * - * @return the PacketTransformer which is used to reverse-transform - * packets - */ - public PacketTransformer getTransformer() - { - return transformer; - } - - /** - * Sets the PacketTransformer which is to be used to - * reverse-transform packets. - * - * @param transformer the PacketTransformer which is to be used to - * reverse-transform packets - */ - public void setTransformer(PacketTransformer transformer) - { - this.transformer = transformer; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/TransformTCPOutputStream.java b/src/net/java/sip/communicator/impl/neomedia/transform/TransformTCPOutputStream.java deleted file mode 100644 index a59a723d8..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/TransformTCPOutputStream.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform; - -import java.net.*; - -import net.java.sip.communicator.impl.neomedia.*; - -/** - * Extends RTPConnectorOutputStream with transform logic for TCP. - * - * In this implementation, TCP socket is used to send the data out. When a - * normal RTP/RTCP packet is passed down from RTPManager, we first transform - * the packet using user define PacketTransformer and then send it out through - * network to all the stream targets. - * - * @author Bing SU (nova.su@gmail.com) - * @author Lubomir Marinov - */ -public class TransformTCPOutputStream - extends RTPConnectorTCPOutputStream -{ - /** - * The PacketTransformer used to transform RTP/RTCP packets. - */ - private PacketTransformer transformer; - - /** - * Initializes a new TransformOutputStream which is to send packet - * data out through a specific TCP socket. - * - * @param socket the TCP socket used to send packet data out - */ - public TransformTCPOutputStream(Socket socket) - { - super(socket); - } - - /** - * Creates a new RawPacket from a specific byte[] buffer - * in order to have this instance send its packet data through its - * {@link #write(byte[], int, int)} method. Transforms the packet to be - * sent. - * - * @param buffer the packet data to be sent to the targets of this instance - * @param offset the offset of the packet data in buffer - * @param length the length of the packet data in buffer - * @return a new RawPacket containing the packet data of the - * specified byte[] buffer or possibly its modification; - * null to ignore the packet data of the specified byte[] - * buffer and not send it to the targets of this instance through its - * {@link #write(byte[], int, int)} method - * @see RTPConnectorOutputStream#createRawPacket(byte[], int, int) - */ - @Override - protected RawPacket createRawPacket(byte[] buffer, int offset, int length) - { - RawPacket pkt = super.createRawPacket(buffer, offset, length); - PacketTransformer transformer = getTransformer(); - - if (transformer != null) - { - pkt = transformer.transform(pkt); - - /* - * This is for the case when the ZRTP engine stops the media stream - * allowing only ZRTP packets. - */ - // TODO Comment in order to use the GoClear feature. - if ((pkt == null) && (targets.size() > 0)) - throw new NullPointerException("pkt"); - } - return pkt; - } - - /** - * Gets the PacketTransformer which is used to transform packets. - * - * @return the PacketTransformer which is used to transform packets - */ - public PacketTransformer getTransformer() - { - return transformer; - } - - /** - * Sets the PacketTransformer which is to be used to transform - * packets. - * - * @param transformer the PacketTransformer which is to be used to - * transform packets - */ - public void setTransformer(PacketTransformer transformer) - { - this.transformer = transformer; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/TransformUDPInputStream.java b/src/net/java/sip/communicator/impl/neomedia/transform/TransformUDPInputStream.java deleted file mode 100644 index 0e3a89fd8..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/TransformUDPInputStream.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform; - -import java.net.*; - -import net.java.sip.communicator.impl.neomedia.*; - -/** - * Extends RTPConnectorInputStream with transform logic for UDP. - * - * In this implementation, we use UDP sockets to receive RTP/RTCP. We listen on - * the address / port specified by local session address. When one packet is - * received, it is first reverse transformed through PacketTransformer defined - * by user. And then returned as normal RTP/RTCP packets to RTPManager. - * - * @author Bing SU (nova.su@gmail.com) - * @author Lubomir Marinov - */ -public class TransformUDPInputStream - extends RTPConnectorUDPInputStream -{ - /** - * The user defined PacketTransformer which is used to reverse - * transform packets. - */ - private PacketTransformer transformer; - - /** - * Initializes a new TransformInputStream which is to receive - * packet data from a specific UDP socket. - * - * @param socket the UDP socket the new instance is to receive data from - */ - public TransformUDPInputStream(DatagramSocket socket) - { - super(socket); - } - - /** - * Creates a new RawPacket from a specific DatagramPacket - * in order to have this instance receive its packet data through its - * {@link #read(byte[], int, int)} method. Reverse-transforms the received - * packet. - * - * @param datagramPacket the DatagramPacket containing the packet - * data - * @return a new RawPacket containing the packet data of the - * specified DatagramPacket or possibly its modification; - * null to ignore the packet data of the specified - * DatagramPacket and not make it available to this instance - * through its {@link #read(byte[], int, int)} method - * @see RTPConnectorInputStream#createRawPacket(DatagramPacket) - */ - @Override - protected RawPacket createRawPacket(DatagramPacket datagramPacket) - { - PacketTransformer transformer = getTransformer(); - RawPacket pkt = super.createRawPacket(datagramPacket); - - return (transformer == null) ? pkt : transformer.reverseTransform(pkt); - } - - /** - * Gets the PacketTransformer which is used to reverse-transform - * packets. - * - * @return the PacketTransformer which is used to reverse-transform - * packets - */ - public PacketTransformer getTransformer() - { - return transformer; - } - - /** - * Sets the PacketTransformer which is to be used to - * reverse-transform packets. - * - * @param transformer the PacketTransformer which is to be used to - * reverse-transform packets - */ - public void setTransformer(PacketTransformer transformer) - { - this.transformer = transformer; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/TransformUDPOutputStream.java b/src/net/java/sip/communicator/impl/neomedia/transform/TransformUDPOutputStream.java deleted file mode 100644 index 0b5a7fb43..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/TransformUDPOutputStream.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform; - -import java.net.*; - -import net.java.sip.communicator.impl.neomedia.*; - -/** - * Extends RTPConnectorOutputStream with transform logic for UDP. - * - * In this implementation, UDP socket is used to send the data out. When a - * normal RTP/RTCP packet is passed down from RTPManager, we first transform - * the packet using user define PacketTransformer and then send it out through - * network to all the stream targets. - * - * @author Bing SU (nova.su@gmail.com) - * @author Lubomir Marinov - */ -public class TransformUDPOutputStream - extends RTPConnectorUDPOutputStream -{ - /** - * The PacketTransformer used to transform RTP/RTCP packets. - */ - private PacketTransformer transformer; - - /** - * Initializes a new TransformOutputStream which is to send packet - * data out through a specific UDP socket. - * - * @param socket the UDP socket used to send packet data out - */ - public TransformUDPOutputStream(DatagramSocket socket) - { - super(socket); - } - - /** - * Creates a new RawPacket from a specific byte[] buffer - * in order to have this instance send its packet data through its - * {@link #write(byte[], int, int)} method. Transforms the packet to be - * sent. - * - * @param buffer the packet data to be sent to the targets of this instance - * @param offset the offset of the packet data in buffer - * @param length the length of the packet data in buffer - * @return a new RawPacket containing the packet data of the - * specified byte[] buffer or possibly its modification; - * null to ignore the packet data of the specified byte[] - * buffer and not send it to the targets of this instance through its - * {@link #write(byte[], int, int)} method - * @see RTPConnectorOutputStream#createRawPacket(byte[], int, int) - */ - @Override - protected RawPacket createRawPacket(byte[] buffer, int offset, int length) - { - RawPacket pkt = super.createRawPacket(buffer, offset, length); - PacketTransformer transformer = getTransformer(); - - if (transformer != null) - { - pkt = transformer.transform(pkt); - - /* - * This is for the case when the ZRTP engine stops the media stream - * allowing only ZRTP packets. - */ - // TODO Comment in order to use the GoClear feature. - if ((pkt == null) && (targets.size() > 0)) - throw new NullPointerException("pkt"); - } - return pkt; - } - - /** - * Gets the PacketTransformer which is used to transform packets. - * - * @return the PacketTransformer which is used to transform packets - */ - public PacketTransformer getTransformer() - { - return transformer; - } - - /** - * Sets the PacketTransformer which is to be used to transform - * packets. - * - * @param transformer the PacketTransformer which is to be used to - * transform packets - */ - public void setTransformer(PacketTransformer transformer) - { - this.transformer = transformer; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/csrc/CsrcTransformEngine.java b/src/net/java/sip/communicator/impl/neomedia/transform/csrc/CsrcTransformEngine.java deleted file mode 100644 index 42565f1c9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/csrc/CsrcTransformEngine.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.csrc; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.transform.*; -import net.java.sip.communicator.service.neomedia.*; - -/** - * We use this engine to add the list of CSRC identifiers in RTP packets that - * we send to conference participants during calls where we are the mixer. - * - * @author Emil Ivov - */ -public class CsrcTransformEngine - implements TransformEngine, - PacketTransformer -{ - /** - * The MediaStreamImpl that this transform engine was created to - * transform packets for. - */ - private final MediaStreamImpl mediaStream; - - /** - * The number currently assigned to CSRC audio level extensions or - * -1 if no such ID has been set and audio level extensions should - * not be transmitted. - */ - private byte csrcAudioLevelExtID = -1; - - /** - * The buffer that we use to encode the csrc audio level extensions. - */ - private byte[] extensionBuff = null; - - /** - * Indicates the length that we are currently using in the - * extensionBuff buffer. - */ - private int extensionBuffLen = 0; - - /** - * The dispatcher that is delivering audio levels to the media steam. - */ - private CsrcAudioLevelDispatcher csrcLevelDispatcher = null; - - /** - * The direction that we are supposed to handle audio levels in. - */ - private MediaDirection audioLevelDirection = MediaDirection.INACTIVE; - - /** - * Creates an engine instance that will be adding CSRC lists to the - * specified stream. - * - * @param stream that MediaStream whose RTP packets we are going - * to be adding CSRC lists. to - */ - public CsrcTransformEngine(MediaStreamImpl stream) - { - this.mediaStream = stream; - } - - /** - * Closes this PacketTransformer i.e. releases the resources - * allocated by it and prepares it for garbage collection. - */ - public void close() - { - if (csrcLevelDispatcher != null) - csrcLevelDispatcher.stop(); - } - - /** - * Always returns null since this engine does not require any - * RTCP transformations. - * - * @return null since this engine does not require any - * RTCP transformations. - */ - public PacketTransformer getRTCPTransformer() - { - return null; - } - - /** - * Returns a reference to this class since it is performing RTP - * transformations in here. - * - * @return a reference to this instance of the - * CsrcTransformEngine. - */ - public PacketTransformer getRTPTransformer() - { - return this; - } - - /** - * Extracts the list of CSRC identifiers and passes it to the - * MediaStream associated with this engine. Other than that the - * method does not do any transformations since CSRC lists are part of - * RFC 3550 and they shouldn't be disrupting the rest of the application. - * - * @param pkt the RTP RawPacket that we are to extract a CSRC list - * from. - * - * @return the same RawPacket that was received as a parameter - * since we don't need to worry about hiding the CSRC list from the rest - * of the RTP stack. - */ - public RawPacket reverseTransform(RawPacket pkt) - { - if ((csrcAudioLevelExtID > 0) && audioLevelDirection.allowsReceiving()) - { - //extract the audio levels and send them to the dispatcher. - long[] levels = pkt.extractCsrcLevels(csrcAudioLevelExtID); - - if(levels != null) - { - if (csrcLevelDispatcher == null) - { - csrcLevelDispatcher = new CsrcAudioLevelDispatcher(); - new Thread(csrcLevelDispatcher).start(); - } - - csrcLevelDispatcher.addLevels(levels); - } - } - return pkt; - } - - /** - * Extracts the list of CSRC identifiers representing participants currently - * contributing to the media being sent by the MediaStream - * associated with this engine and (unless the list is empty) encodes them - * into the RawPacket. - * - * @param pkt the RTP RawPacket that we need to add a CSRC list to. - * - * @return the updated RawPacket instance containing the list of - * CSRC identifiers. - */ - public synchronized RawPacket transform(RawPacket pkt) - { - // if somebody has modified the packet and added an extension - // don't process it. As ZRTP creates special RTP packets carrying no - // RTP data and those packets are used only by ZRTP we don't use them. - if(pkt.getExtensionBit()) - return pkt; - - long[] csrcList = mediaStream.getLocalContributingSourceIDs(); - - if(csrcList == null || csrcList.length == 0) - { - //nothing to do. - return pkt; - } - - pkt.setCsrcList( csrcList); - - //attach audio levels if we are expected to do so. - if ((this.csrcAudioLevelExtID > 0) - && audioLevelDirection.allowsSending() - && (mediaStream instanceof AudioMediaStreamImpl)) - { - byte[] levelsExt = createLevelExtensionBuffer(csrcList); - - pkt.addExtension(levelsExt, extensionBuffLen); - } - - return pkt; - } - - /** - * Sets the ID that this transformer should be using for audio level - * extensions or disables audio level extensions if extID is - * -1. - * - * @param extID ID that this transformer should be using for audio level - * extensions or -1 if audio level extensions should be disabled - * @param dir the direction that we are expected to hand this extension in. - * - */ - public void setCsrcAudioLevelAudioLevelExtensionID(byte extID, - MediaDirection dir) - { - this.csrcAudioLevelExtID = extID; - this.audioLevelDirection = dir; - } - - /** - * Creates a audio level extension buffer containing the level extension - * header and the audio levels corresponding to (and in the same order as) - * the CSRC IDs in the csrcList - * - * @param csrcList the list of CSRC IDs whose level we'd like the extension - * to contain. - * @return the extension buffer in the form that it should be added to the - * RTP packet. - */ - private byte[] createLevelExtensionBuffer(long[] csrcList) - { - int buffLen = 1 + //CSRC one byte extension hdr - csrcList.length; - - // calculate extension padding - int padLen = 4 - buffLen%4; - - if(padLen == 4) - padLen = 0; - - buffLen += padLen; - - byte[] extensionBuff = getExtensionBuff(buffLen); - - extensionBuff[0] - = (byte)((csrcAudioLevelExtID << 4) | (csrcList.length - 1)); - - int csrcOffset = 1; // initial offset is equal to ext hdr size - - for(long csrc : csrcList) - { - byte level - = (byte) - ((AudioMediaStreamImpl)mediaStream) - .getLastMeasuredAudioLevel(csrc); - - extensionBuff[csrcOffset] = level; - csrcOffset ++; - } - - return extensionBuff; - } - - /** - * Returns a reusable byte array which is guaranteed to have the requested - * ensureCapacity length and sets our internal length keeping - * var. - * - * @param ensureCapacity the minimum length that we need the returned buffer - * to have. - * @return a reusable byte[] array guaranteed to have a length - * equal to or greater than ensureCapacity. - */ - private byte[] getExtensionBuff(int ensureCapacity) - { - if ((extensionBuff == null) || (extensionBuff.length < ensureCapacity)) - extensionBuff = new byte[ensureCapacity]; - - extensionBuffLen = ensureCapacity; - return extensionBuff; - } - - /** - * A simple thread that waits for new levels to be reported from incoming - * RTP packets and then delivers them to the AudioMediaStream - * associated with this engine. The reason we need to do this in a separate - * thread is, of course, the time sensitive nature of incoming RTP packets. - */ - private class CsrcAudioLevelDispatcher - implements Runnable - { - /** Indicates whether this thread is supposed to be running */ - private boolean isRunning = false; - - /** The levels that we last received from the reverseTransform thread*/ - private long[] lastReportedLevels = null; - - /** - * Waits for new levels to be reported via the addLevels() - * method and then delivers them to the AudioMediaStream that - * we are associated with. - */ - public void run() - { - isRunning = true; - - //no point in listening if our stream is not an audio one. - if(!(mediaStream instanceof AudioMediaStreamImpl)) - return; - - long[] temp = null; - - while(isRunning) - { - synchronized(this) - { - if(lastReportedLevels == null) - { - try - { - wait(); - } - catch (InterruptedException ie) {} - } - - temp = lastReportedLevels; - // make lastReportedLevels to null - // so we will wait for the next level on next iteration - lastReportedLevels = null; - } - - if(temp != null) - { - //now notify our listener - if (mediaStream != null) - { - ((AudioMediaStreamImpl)mediaStream) - .fireConferenceAudioLevelEvent(temp); - } - } - } - } - - /** - * A level matrix that we should deliver to our media stream and - * its listeners in a separate thread. - * - * @param levels the levels that we'd like to queue for processing. - */ - public void addLevels(long[] levels) - { - synchronized(this) - { - this.lastReportedLevels = levels; - - notifyAll(); - } - } - - /** - * Causes our run method to exit so that this thread would stop - * handling levels. - */ - public void stop() - { - synchronized(this) - { - this.lastReportedLevels = null; - isRunning = false; - - notifyAll(); - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/dtmf/DtmfRawPacket.java b/src/net/java/sip/communicator/impl/neomedia/transform/dtmf/DtmfRawPacket.java deleted file mode 100644 index 29ae76e72..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/dtmf/DtmfRawPacket.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.dtmf; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.util.*; - -/** - * DtmfRawPacket represent an RTP Packet. - * You create your DtmfRawPacket by calling the constructor. - * You specify the DTMF attributes : code=9, end=false, marker=true ... - * Then you fill the packet using init( ... dtmf attributes ... ); - * - * @author Romain Philibert - * @author Emil Ivov - * @author Damian Minkov - */ -public class DtmfRawPacket - extends RawPacket -{ - /** - * Our class logger. - */ - private static final Logger logger - = Logger.getLogger(DtmfRawPacket.class); - - /** - * The fixed size of a DTMF packet. - */ - public static final int DTMF_PACKET_SIZE = 16; - - /** - * The event code to send. - */ - private int code; - - /** - * Is this an end packet. - */ - private boolean end; - - /** - * The duration of the current packet. - */ - private int duration; - - /** - * Creates a DtmfRawPacket using the specified buffer. - * - * @param buffer the byte array that we should use to store packet - * content - * @param offset the index where we should start using the buffer. - * @param payload the payload that has been negotiated for telephone events - * by our signaling modules. - */ - public DtmfRawPacket(byte[] buffer, int offset, byte payload) - { - super (buffer, offset, DTMF_PACKET_SIZE); - - setPayload(payload); - } - - /** - * Used for incoming DTMF packets, creating DtmfRawPacket - * from RTP one. - * @param pkt the RTP packet. - */ - public DtmfRawPacket(RawPacket pkt) - { - super(pkt.getBuffer(), pkt.getOffset(), pkt.getLength()); - - int at = getHeaderLength(); - - code = readByte(at++); - end = (readByte(at++) & 0x80) != 0; - - duration = ((readByte(at++) & 0xFF) << 8) | (readByte(at++) & 0xFF); - } - - /** - * Initializes DTMF specific values in this packet. - * - * @param code the DTMF code representing the digit. - * @param end the DTMF End flag - * @param marker the RTP Marker flag - * @param duration the DTMF duration - * @param timestamp the RTP timestamp - */ - public void init(int code, - boolean end, - boolean marker, - int duration, - long timestamp) - { - if(logger.isTraceEnabled()) - { - logger.trace("DTMF send on RTP, code : " + code + - " duration = "+duration +" timestamps = "+timestamp + - " Marker = " + marker + " End = " + end); - } - - // Set the payload type and the marker - setMarker(marker); - - // set the Timestamp - setTimestamp(timestamp); - - // Create the RTP data - setDtmfPayload(code, end, duration); - } - - /** - * Initializes the a DTMF raw data using event, E and duration field. - * Event : the digits to transmit (0-15). - * E : End field, used to mark the two last packets. - * R always = 0. - * Volume always = 0. - * Duration : duration increments for each dtmf sending updates, - * stay unchanged at the end for the 3 last packets. - *
-     *  0                   1                   2                   3
-     *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-     *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-     *  |     event     |E R| volume    |          duration             |
-     *  |       ?       |? 0|    0      |              ?                |
-     *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-     * 
- * - * @param code the digit to transmit 0-15 - * @param end boolean used to mark the two last packets - * @param duration int increments for each dtmf sending - * updates, stay unchanged at the end for the 2 last packets. - */ - private void setDtmfPayload(int code, boolean end, int duration) - { - this.code = code; - this.end = end; - this.duration = duration; - - int at = getHeaderLength(); - - writeByte(at++, (byte)code); - writeByte(at++, end ? (byte)0x80 : (byte)0); - writeByte(at++, (byte)(duration >> 8)); - writeByte(at++, (byte)duration); - } - - /** - * The event code of the current packet. - * @return the code - */ - public int getCode() - { - return code; - } - - /** - * Is this an end packet. - * @return the end - */ - public boolean isEnd() - { - return end; - } - - /** - * The duration of the current event. - * @return the duration - */ - public int getDuration() - { - return duration; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/dtmf/DtmfTransformEngine.java b/src/net/java/sip/communicator/impl/neomedia/transform/dtmf/DtmfTransformEngine.java deleted file mode 100644 index 712469a0c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/dtmf/DtmfTransformEngine.java +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.dtmf; - -import javax.media.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.impl.neomedia.transform.*; -import net.java.sip.communicator.service.neomedia.*; - -/** - * The class is responsible for sending DTMF tones in an RTP audio stream as - * described by RFC4733. - * - * @author Emil Ivov - * @author Romain Philibert - * @author Damian Minkov - */ -public class DtmfTransformEngine - implements TransformEngine, - PacketTransformer -{ - - /** - * The AudioMediaStreamImpl that this transform engine was created - * by and that it's going to deliver DTMF packets for. - */ - private final AudioMediaStreamImpl mediaStream; - - /** - * The enumeration contains a set of states that reflect the progress of - */ - private enum ToneTransmissionState - { - /** - * Indicates that this engine is not currently sending DTMF. - */ - IDLE, - - /** - * Indicates that the user has just called the {@link - * #startSending(DTMFRtpTone)} method and we haven't yet sent any of the - * packets corresponding to that particular tone. - */ - SEND_PENDING, - - /** - * Indicates that we are currently in the process of sending a DTMF - * tone, and we have already sent at least one packet. - */ - SENDING, - - /** - * Indicates that the user has requested that DTMF transmission be - * stopped but we haven't acted upon that request yet (i.e. we have yet - * to send a single retransmission) - */ - END_REQUESTED, - - /** - * Indicates that the user has requested that DTMF transmission be - * stopped we have already sent a retransmission of the final packet. - */ - END_SEQUENCE_INITIATED - }; - - /** - * Array of all supported tones. - */ - private static final DTMFRtpTone[] supportedTones = - new DTMFRtpTone[] - {DTMFRtpTone.DTMF_0, DTMFRtpTone.DTMF_1, DTMFRtpTone.DTMF_2, - DTMFRtpTone.DTMF_3, DTMFRtpTone.DTMF_4, DTMFRtpTone.DTMF_5, - DTMFRtpTone.DTMF_6, DTMFRtpTone.DTMF_7, DTMFRtpTone.DTMF_8, - DTMFRtpTone.DTMF_9, DTMFRtpTone.DTMF_A, DTMFRtpTone.DTMF_B, - DTMFRtpTone.DTMF_C, DTMFRtpTone.DTMF_D, DTMFRtpTone.DTMF_SHARP, - DTMFRtpTone.DTMF_STAR}; - - /** - * The dispatcher that is delivering tones to the media steam. - */ - private DTMFDispatcher dtmfDispatcher = null; - - /** - * The status that this engine is currently in. - */ - private ToneTransmissionState toneTransmissionState - = ToneTransmissionState.IDLE; - - /** - * The tone that we are supposed to be currently transmitting. - */ - private DTMFRtpTone currentTone = null; - - /** - * The duration (in timestamp units or in other words ms*8) that we have - * transmitted the current tone for. - */ - private int currentDuration = 0; - - /** - * The current transmitting timestamp. - */ - private long currentTimestamp = 0; - - /** - * We send 3 end packets and this is the counter of remaining packets. - */ - private int remainingsEndPackets = 0; - - /** - * Current duration of every event we send. - */ - private int currentSpacingDuration = Format.NOT_SPECIFIED; - - /** - * Creates an engine instance that will be replacing audio packets - * with DTMF ones upon request. - * - * @param stream the AudioMediaStream whose RTP packets we are - * going to be replacing with DTMF. - */ - public DtmfTransformEngine(AudioMediaStreamImpl stream) - { - this.mediaStream = stream; - } - - /** - * Close the transformer and underlying transform engine. - * - * Nothing to do here. - */ - public void close() - { - } - - /** - * Gets the current duration of every event we send. - * - * @return the current duration of every event we send - */ - private int getCurrentSpacingDuration() - { - if (currentSpacingDuration == Format.NOT_SPECIFIED) - { - // the default is 50 ms. RECOMMENDED in rfc4733. - currentSpacingDuration - = (int) mediaStream.getFormat().getClockRate()/50; - } - return currentSpacingDuration; - } - /** - * Always returns null since this engine does not require any - * RTCP transformations. - * - * @return null since this engine does not require any - * RTCP transformations. - */ - public PacketTransformer getRTCPTransformer() - { - return null; - } - - /** - * Returns a reference to this class since it is performing RTP - * transformations in here. - * - * @return a reference to this instance of the - * DtmfTransformEngine. - */ - public PacketTransformer getRTPTransformer() - { - return this; - } - - /** - * A stub meant to handle incoming DTMF packets. - * - * @param pkt an incoming packet that we need to parse and handle in case - * we determine it to be DTMF. - * - * @return the pkt if it is not a DTMF tone and null - * otherwise since we will be handling the packet ourselves and their's - * no point in feeding it to the application. - */ - public RawPacket reverseTransform(RawPacket pkt) - { - byte currentDtmfPayload = mediaStream.getDynamicRTPPayloadType( - Constants.TELEPHONE_EVENT); - - if(currentDtmfPayload == pkt.getPayloadType()) - { - DtmfRawPacket p = new DtmfRawPacket(pkt); - - if (dtmfDispatcher == null) - { - dtmfDispatcher = new DTMFDispatcher(); - new Thread(dtmfDispatcher).start(); - } - dtmfDispatcher.addTonePacket(p); - - // ignore received dtmf packets - // if jmf receive change in rtp payload stops reception - return null; - } - - return pkt; - } - - /** - * Replaces pkt with a DTMF packet if this engine is in a DTMF - * transmission mode or returns it unchanged otherwise. - * - * @param pkt the audio packet that we may want to replace with a DTMF one. - * - * @return pkt with a DTMF packet if this engine is in a DTMF - * transmission mode or returns it unchanged otherwise. - */ - public RawPacket transform(RawPacket pkt) - { - if (this.toneTransmissionState.equals(ToneTransmissionState.IDLE) - || currentTone == null) - { - return pkt; - } - - byte currentDtmfPayload = mediaStream.getDynamicRTPPayloadType( - Constants.TELEPHONE_EVENT); - - if ( currentDtmfPayload == -1 ) - throw new IllegalStateException("Can't send DTMF when no payload " - +"type has been negotiated for DTMF events."); - - DtmfRawPacket dtmfPkt = new DtmfRawPacket(pkt.getBuffer(), - pkt.getOffset(), currentDtmfPayload); - - long audioPacketTimestamp = dtmfPkt.getTimestamp(); - boolean pktEnd = false; - boolean pktMarker = false; - int pktDuration = 0; - - if(toneTransmissionState == ToneTransmissionState.SEND_PENDING) - { - currentDuration = 0; - currentDuration += getCurrentSpacingDuration(); - pktDuration = currentDuration; - - pktMarker = true; - currentTimestamp = audioPacketTimestamp; - - toneTransmissionState = ToneTransmissionState.SENDING; - } - else if(toneTransmissionState == ToneTransmissionState.SENDING) - { - currentDuration += getCurrentSpacingDuration(); - pktDuration = currentDuration; - // Check for long state event - if (currentDuration > 0xFFFF) - { - // When duration > 0xFFFF we first send a packet with - // duration = 0xFFFF. For the next packet, the duration - // start from begining but the audioPacketTimestamp is set to the - // time when the long duration event occurs. - pktDuration = 0xFFFF; - currentDuration = 0; - currentTimestamp = audioPacketTimestamp; - } - } - else if(toneTransmissionState == ToneTransmissionState.END_REQUESTED) - { - // The first ending packet do have the End flag set. - // But the 2 next will have the End flag set. - // - // The audioPacketTimestamp and the duration field stay unchanged for - // the 3 last packets - currentDuration += getCurrentSpacingDuration(); - pktDuration = currentDuration; - - pktEnd = true; - remainingsEndPackets = 2; - - toneTransmissionState = ToneTransmissionState.END_SEQUENCE_INITIATED; - } - else if(toneTransmissionState == ToneTransmissionState.END_SEQUENCE_INITIATED) - { - pktEnd = true; - pktDuration = currentDuration; - remainingsEndPackets--; - - if(remainingsEndPackets == 0) - toneTransmissionState = ToneTransmissionState.IDLE; - } - - dtmfPkt.init( - currentTone.getCode(), - pktEnd, - pktMarker, - pktDuration, - currentTimestamp); - pkt = dtmfPkt; - - return pkt; - } - - - /** - * DTMF sending stub: this is where we should set the transformer in the - * proper state so that it would start replacing packets with dtmf codes. - * - * @param tone the tone that we'd like to start sending. - */ - public void startSending(DTMFRtpTone tone) - { - if(toneTransmissionState != ToneTransmissionState.IDLE) - throw new IllegalStateException( - "Calling start before stopping previous transmission"); - - currentTone = tone; - toneTransmissionState = ToneTransmissionState.SEND_PENDING; - } - - /** - * Interrupts transmission of a DTMFRtpTone started with the - * startSendingDTMF() method. Has no effect if no tone is currently - * being sent. - * - * @see AudioMediaStream#stopSendingDTMF(DTMFMethod dtmfMethod) - */ - public void stopSendingDTMF() - { - toneTransmissionState = ToneTransmissionState.END_REQUESTED; - } - - /** - * Stops threads that this transform engine is using for even delivery. - */ - public void stop() - { - if(dtmfDispatcher != null) - dtmfDispatcher.stop(); - } - - /** - * A simple thread that waits for new tones to be reported from incoming - * RTP packets and then delivers them to the AudioMediaStream - * associated with this engine. The reason we need to do this in a separate - * thread is of course the time sensitive nature of incoming RTP packets. - */ - private class DTMFDispatcher - implements Runnable - { - /** Indicates whether this thread is supposed to be running */ - private boolean isRunning = false; - - /** The tone that we last received from the reverseTransform thread*/ - private DTMFRtpTone lastReceivedTone = null; - - /** The tone that we last received from the reverseTransform thread*/ - private DTMFRtpTone lastReportedTone = null; - - /** - * Have we received end of the currently started tone. - */ - private boolean toEnd = false; - - /** - * Waits for new tone to be reported via the addTonePacket() - * method and then delivers them to the AudioMediaStream that - * we are associated with. - */ - public void run() - { - isRunning = true; - - DTMFRtpTone temp = null; - - while(isRunning) - { - synchronized(this) - { - if(lastReceivedTone == null) - { - try - { - wait(); - } - catch (InterruptedException ie) {} - } - - temp = lastReceivedTone; - // make lastReportedLevels to null - // so we will wait for the next tone on next iteration - lastReceivedTone = null; - } - - if(temp != null - && ((lastReportedTone == null && !toEnd) - || (lastReportedTone != null && toEnd))) - { - //now notify our listener - if (mediaStream != null) - { - mediaStream.fireDTMFEvent(temp, toEnd); - if(toEnd) - lastReportedTone = null; - else - lastReportedTone = temp; - toEnd = false; - } - } - } - } - - /** - * A packet that we should convert to tone and deliver - * to our media stream and its listeners in a separate thread. - * - * @param p the packet we will convert and deliver. - */ - public void addTonePacket(DtmfRawPacket p) - { - synchronized(this) - { - this.lastReceivedTone = getToneFromPacket(p); - this.toEnd = p.isEnd(); - - notifyAll(); - } - } - - /** - * Causes our run method to exit so that this thread would stop - * handling levels. - */ - public void stop() - { - synchronized(this) - { - this.lastReceivedTone = null; - isRunning = false; - - notifyAll(); - } - } - - /** - * Maps DTMF packet codes to our DTMFRtpTone objects. - * @param p the packet - * @return the corresponding tone. - */ - private DTMFRtpTone getToneFromPacket(DtmfRawPacket p) - { - for (int i = 0; i < supportedTones.length; i++) - { - DTMFRtpTone t = supportedTones[i]; - if(t.getCode() == p.getCode()) - return t; - } - - return null; - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/rtcp/StatisticsEngine.java b/src/net/java/sip/communicator/impl/neomedia/transform/rtcp/StatisticsEngine.java deleted file mode 100644 index f9d02615c..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/rtcp/StatisticsEngine.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.rtcp; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.transform.*; -import net.java.sip.communicator.service.neomedia.format.*; -import net.java.sip.communicator.util.*; -import net.sf.fmj.media.rtp.*; - -/** - * Engine which don't transform packets, just listens for outgoing - * RTCP Packets and logs and stores statistical data for the stream. - * - * @author Damian Minkov - */ -public class StatisticsEngine - implements TransformEngine, - PacketTransformer -{ - /** - * The Logger used by the StatisticsEngine class - * and its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(StatisticsEngine.class); - - /** - * The rtp statistics prefix we use for every log. - * Simplifies parsing and searching for statistics info in log files. - */ - public static final String RTP_STAT_PREFIX = "rtpstat:"; - - /** - * Number of sender reports send. - * Used only for logging and debug purposes. - */ - private long numberOfSenderReports = 0; - - /** - * The minimum inter arrival jitter value we have reported. - */ - private long maxInterArrivalJitter = 0; - - /** - * The minimum inter arrival jitter value we have reported. - */ - private long minInterArrivalJitter = -1; - - /** - * Number of lost packets reported. - */ - private long lost = 0; - - /** - * The stream created us. - */ - private MediaStreamImpl mediaStream; - - /** - * Creates Statistic engine. - * @param stream the stream creating us. - */ - public StatisticsEngine(MediaStreamImpl stream) - { - this.mediaStream = stream; - } - - /** - * Close the transformer and underlying transform engine. - * - * Nothing to do here. - */ - public void close() - { - } - - /** - * Transfers RTCP sender report feedback as new information about the - * download stream for the MediaStreamStats. - * Finds the info needed for statistics in the packet and stores it. - * Then returns the same packet as we are not modifying it. - * - * @param pkt the packet - * @return the packet - */ - public RawPacket transform(RawPacket pkt) - { - try - { - numberOfSenderReports++; - - byte[] data = pkt.getBuffer(); - int offset = pkt.getOffset(); - int length = pkt.getLength(); - - RTCPHeader header = new RTCPHeader( - data, offset, length); - if (header.getPacketType() == RTCPPacket.SR) - { - RTCPSenderReport report = new RTCPSenderReport( - data, offset, length); - - if(report.getFeedbackReports().size() > 0) - { - RTCPFeedback feedback = - (RTCPFeedback)report.getFeedbackReports().get(0); - - this.mediaStream.getMediaStreamStats() - .updateNewSentFeedback(feedback); - - // The rest of this function is only used for logging - // purpose. Thus, it is useless to continue if the - // logger is not at least in INFO mode. - if(!logger.isInfoEnabled()) - return pkt; - - long jitter = feedback.getJitter(); - - if(jitter < getMinInterArrivalJitter() - || getMinInterArrivalJitter() == -1) - minInterArrivalJitter = jitter; - - if(getMaxInterArrivalJitter() < jitter) - maxInterArrivalJitter = jitter; - - lost = feedback.getNumLost(); - - // As sender reports are sent on every 5 seconds, print - // every 4th packet, on every 20 seconds. - if(numberOfSenderReports % 4 != 1) - return pkt; - - StringBuilder buff = new StringBuilder(RTP_STAT_PREFIX); - MediaFormat mediaStreamFormat = mediaStream.getFormat(); - - buff.append("Sending a report for ") - .append(mediaStreamFormat != null - ? mediaStreamFormat.getMediaType() - : "") - .append(" stream SSRC:") - .append(feedback.getSSRC()) - .append(" [packet count:") - .append(report.getSenderPacketCount()) - .append(", bytes:").append(report.getSenderByteCount()) - .append(", interarrival jitter:") - .append(jitter) - .append(", lost packets:").append(feedback.getNumLost()) - .append(", time since previous report:") - .append((int) (feedback.getDLSR() / 65.536)) - .append("ms ]"); - logger.info(buff); - } - } - } - catch(Throwable t) - { - t.printStackTrace(); - } - - return pkt; - } - - /** - * Transfers RTCP sender report feedback as new information about the upload - * stream for the MediaStreamStats. - * Returns the packet as we are listening just for sending packages. - * - * @param pkt the packet without any change. - * @return the packet without any change. - */ - public RawPacket reverseTransform(RawPacket pkt) - { - try - { - byte[] data = pkt.getBuffer(); - int offset = pkt.getOffset(); - int length = pkt.getLength(); - - if(length - offset != 0) - { - RTCPHeader header = new RTCPHeader(data, offset, length); - if (header.getPacketType() == RTCPPacket.SR) - { - RTCPSenderReport report = new RTCPSenderReport( - data, offset, length); - - if(report.getFeedbackReports().size() > 0) - { - RTCPFeedback feedback = - (RTCPFeedback)report.getFeedbackReports().get(0); - - this.mediaStream.getMediaStreamStats() - .updateNewReceivedFeedback(feedback); - } - } - } - } - catch(Throwable t) - { - t.printStackTrace(); - } - return pkt; - } - - /** - * Always returns null since this engine does not require any - * RTP transformations. - * - * @return null since this engine does not require any - * RTP transformations. - */ - public PacketTransformer getRTPTransformer() - { - return null; - } - - /** - * Returns a reference to this class since it is performing RTP - * transformations in here. - * - * @return a reference to this instance of the - * StatisticsEngine. - */ - public PacketTransformer getRTCPTransformer() - { - return this; - } - - /** - * The minimum inter arrival jitter value we have reported. - * @return minimum inter arrival jitter value we have reported. - */ - public long getMaxInterArrivalJitter() - { - return maxInterArrivalJitter; - } - - /** - * The maximum inter arrival jitter value we have reported. - * @return maximum inter arrival jitter value we have reported. - */ - public long getMinInterArrivalJitter() - { - return minInterArrivalJitter; - } - - /** - * Number of lost packets reported. - * @return number of lost packets reported. - */ - public long getLost() - { - return lost; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/sdes/SDesControlImpl.java b/src/net/java/sip/communicator/impl/neomedia/transform/sdes/SDesControlImpl.java deleted file mode 100644 index 8c282e7ea..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/sdes/SDesControlImpl.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.sdes; - -import gnu.java.zrtp.utils.ZrtpFortuna; - -import java.util.*; - -import ch.imvs.sdes4j.srtp.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.transform.*; -import net.java.sip.communicator.impl.neomedia.transform.zrtp.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.event.*; - -/** - * Default implementation of {@link SDesControl} that supports the crypto suites - * of the original RFC4568 and the KDR parameter, but nothing else. - * - * @author Ingo Bauersachs - */ -public class SDesControlImpl - implements SDesControl -{ - /** - * List of enabled crypto suites. - */ - private List enabledCryptoSuites = new ArrayList(3) - { - private static final long serialVersionUID = 0L; - - { - add(SrtpCryptoSuite.AES_CM_128_HMAC_SHA1_80); - add(SrtpCryptoSuite.AES_CM_128_HMAC_SHA1_32); - add(SrtpCryptoSuite.F8_128_HMAC_SHA1_80); - } - }; - - - /** - * List of supported crypto suites. - */ - private final List supportedCryptoSuites = new ArrayList(3) - { - private static final long serialVersionUID = 0L; - - { - add(SrtpCryptoSuite.AES_CM_128_HMAC_SHA1_80); - add(SrtpCryptoSuite.AES_CM_128_HMAC_SHA1_32); - add(SrtpCryptoSuite.F8_128_HMAC_SHA1_80); - } - }; - - private SrtpSDesFactory sdesFactory; - private SrtpCryptoAttribute[] attributes; - private SDesTransformEngine engine; - private SrtpCryptoAttribute selectedInAttribute; - private SrtpCryptoAttribute selectedOutAttribute; - private SrtpListener srtpListener; - - /** - * SDESControl - */ - public SDesControlImpl() - { - sdesFactory = new SrtpSDesFactory(); - Random r = new Random() - { - private static final long serialVersionUID = 0L; - - @Override - public void nextBytes(byte[] bytes) - { - ZrtpFortuna.getInstance().getFortuna().nextBytes(bytes); - } - }; - sdesFactory.setRandomGenerator(r); - } - - public void setEnabledCiphers(Iterable ciphers) - { - enabledCryptoSuites.clear(); - for(String c : ciphers) - enabledCryptoSuites.add(c); - } - - public Iterable getSupportedCryptoSuites() - { - return Collections.unmodifiableList(supportedCryptoSuites); - } - - public void cleanup() - { - if (engine != null) - { - engine.close(); - engine = null; - } - } - - public void setSrtpListener(SrtpListener srtpListener) - { - this.srtpListener = srtpListener; - } - - public SrtpListener getSrtpListener() - { - return srtpListener; - } - - public boolean getSecureCommunicationStatus() - { - return engine != null; - } - - /** - * Not used. - * @param masterSession not used. - */ - public void setMasterSession(boolean masterSession) - {} - - public void start(MediaType type) - { - // in srtp the started and security event is one after another - // in some other security mechanisms (e.g. zrtp) there can be started - // and no security one or security timeout event - srtpListener.securityNegotiationStarted( - type.equals(MediaType.AUDIO) ? - SecurityEventManager.AUDIO_SESSION - : SecurityEventManager.VIDEO_SESSION, - this); - - srtpListener.securityTurnedOn( - type.equals(MediaType.AUDIO) ? - SecurityEventManager.AUDIO_SESSION - : SecurityEventManager.VIDEO_SESSION, - selectedInAttribute.getCryptoSuite().encode(), this); - } - - public void setMultistream(SrtpControl master) - { - } - - public TransformEngine getTransformEngine() - { - if(engine == null) - engine = new SDesTransformEngine(this); - return engine; - } - - public String[] getInitiatorCryptoAttributes() - { - if(attributes == null) - { - attributes = new SrtpCryptoAttribute[enabledCryptoSuites.size()]; - for (int i = 0; i < attributes.length; i++) - { - attributes[i] = - sdesFactory.createCryptoAttribute(i + 1, - enabledCryptoSuites.get(i)); - } - } - String[] result = new String[attributes.length]; - for(int i = 0; i < attributes.length; i++) - result[i] = attributes[i].encode(); - return result; - } - - public String responderSelectAttribute(Iterable peerAttributes) - { - for (String suite : enabledCryptoSuites) - { - for (String ea : peerAttributes) - { - SrtpCryptoAttribute peerCA = SrtpCryptoAttribute.create(ea); - if (suite.equals(peerCA.getCryptoSuite().encode())) - { - selectedInAttribute = peerCA; - selectedOutAttribute = - sdesFactory.createCryptoAttribute(1, suite); - return selectedOutAttribute.encode(); - } - } - } - return null; - } - - public boolean initiatorSelectAttribute(Iterable peerAttributes) - { - for (SrtpCryptoAttribute localCA : attributes) - { - for (String ea : peerAttributes) - { - SrtpCryptoAttribute peerCA = SrtpCryptoAttribute.create(ea); - if (localCA.getCryptoSuite().equals(peerCA.getCryptoSuite())) - { - selectedInAttribute = peerCA; - selectedOutAttribute = localCA; - return true; - } - } - } - return false; - } - - public SrtpCryptoAttribute getInAttribute() - { - return selectedInAttribute; - } - - public SrtpCryptoAttribute getOutAttribute() - { - return selectedOutAttribute; - } - - public void setConnector(AbstractRTPConnector newValue) - { - } - - /** - * Returns true, SDES always requires the secure transport of its keys. - * - * @return true - */ - public boolean requiresSecureSignalingTransport() - { - return true; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/sdes/SDesTransformEngine.java b/src/net/java/sip/communicator/impl/neomedia/transform/sdes/SDesTransformEngine.java deleted file mode 100644 index 0263e64a9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/sdes/SDesTransformEngine.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.sdes; - -import ch.imvs.sdes4j.srtp.*; - -import net.java.sip.communicator.impl.neomedia.transform.srtp.*; - -/** - * PacketTransformer for SDES based SRTP encryption. - * - * @author Ingo Bauersachs - */ -public class SDesTransformEngine - extends AsymmetricSRTPTransformer -{ - /** - * Creates a new instance of this class. - * @param sDesControl The control that supplies the key material. - */ - public SDesTransformEngine(SDesControlImpl sDesControl) - { - super( - getTransformEngine(sDesControl.getOutAttribute()), - getTransformEngine(sDesControl.getInAttribute()) - ); - } - - private static SRTPTransformEngine getTransformEngine( - SrtpCryptoAttribute attribute) - { - if (attribute.getSessionParams() != null - && attribute.getSessionParams().length > 0) - { - throw new IllegalArgumentException( - "session parameters are not supported"); - } - - SrtpCryptoSuite cs = attribute.getCryptoSuite(); - return new SRTPTransformEngine( - getKey(attribute), - getSalt(attribute), - new SRTPPolicy( - getEncryptionCipher(cs), cs.getEncKeyLength() / 8, - getHashAlgorithm(cs), cs.getSrtpAuthKeyLength() / 8, - cs.getSrtpAuthTagLength() / 8, - cs.getSaltKeyLength() / 8 - ), - new SRTPPolicy( - getEncryptionCipher(cs), cs.getEncKeyLength() / 8, - getHashAlgorithm(cs), cs.getSrtcpAuthKeyLength() / 8, - cs.getSrtcpAuthTagLength() / 8, - cs.getSaltKeyLength() / 8 - ) - ); - } - -// /** -// * Get the key derivation parameter or the default from the SDES attribute. -// * @param attribute The negotiated SDES attribute for the stream. -// * @return The KDR parameter or 0 if not present. -// */ -// private static long getKdr(SrtpCryptoAttribute attribute) -// { -// if (attribute.getSessionParams() != null) -// { -// for (SrtpSessionParam param : attribute.getSessionParams()) -// { -// if (param instanceof KdrSessionParam) -// return ((KdrSessionParam) param) -// .getKeyDerivationRateExpanded(); -// } -// } -// return 0; -// } - - private static byte[] getKey(SrtpCryptoAttribute attribute) - { - int length = attribute.getCryptoSuite().getEncKeyLength() / 8; - byte[] key = new byte[length]; - System.arraycopy(attribute.getKeyParams()[0].getKey(), 0, key, 0, - length); - return key; - } - - private static byte[] getSalt(SrtpCryptoAttribute attribute) - { - int keyLength = attribute.getCryptoSuite().getEncKeyLength() / 8; - int saltLength = attribute.getCryptoSuite().getSaltKeyLength() / 8; - byte[] salt = new byte[keyLength]; - System.arraycopy(attribute.getKeyParams()[0].getKey(), keyLength, salt, - 0, saltLength); - return salt; - } - - private static int getEncryptionCipher(SrtpCryptoSuite cs) - { - switch (cs.getEncryptionAlgorithm()) - { - case SrtpCryptoSuite.ENCRYPTION_AES128_CM: - return SRTPPolicy.AESCM_ENCRYPTION; - case SrtpCryptoSuite.ENCRYPTION_AES128_F8: - return SRTPPolicy.AESF8_ENCRYPTION; - default: - throw new IllegalArgumentException("Unsupported cipher"); - } - } - - private static int getHashAlgorithm(SrtpCryptoSuite cs) - { - switch (cs.getHashAlgorithm()) - { - case SrtpCryptoSuite.HASH_HMAC_SHA1: - return SRTPPolicy.HMACSHA1_AUTHENTICATION; - default: - throw new IllegalArgumentException("Unsupported hash"); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/AsymmetricSRTPTransformer.java b/src/net/java/sip/communicator/impl/neomedia/transform/srtp/AsymmetricSRTPTransformer.java deleted file mode 100644 index 507915c11..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/AsymmetricSRTPTransformer.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.srtp; - -import net.java.sip.communicator.impl.neomedia.transform.*; - -/** - * SRTP/SRTCP TransformEngine that uses different keys for forward and reverse - * transformations. - * - * @author Ingo Bauersachs - */ -public class AsymmetricSRTPTransformer - implements TransformEngine -{ - private SRTPTransformEngine forwardEngine; - private SRTPTransformEngine reverseEngine; - - public AsymmetricSRTPTransformer(SRTPTransformEngine forwardEngine, - SRTPTransformEngine reverseEngine) - { - this.forwardEngine = forwardEngine; - this.reverseEngine = reverseEngine; - } - - /** - * Close the transformer engine. - * - * The close functions closes all stored default crypto contexts. This - * deletes key data and forces a cleanup of the crypto contexts. - */ - public void close() - { - if (forwardEngine != null) - forwardEngine.close(); - if (reverseEngine != null) - reverseEngine.close(); - - forwardEngine = null; - reverseEngine = null; - } - /* - * (non-Javadoc) - * - * @see - * net.java.sip.communicator.impl.neomedia.transform.srtp.SRTPTransformEngine - * #getRTCPTransformer() - */ - public PacketTransformer getRTCPTransformer() - { - return new SRTCPTransformer(forwardEngine, reverseEngine); - } - - /* - * (non-Javadoc) - * - * @see - * net.java.sip.communicator.impl.neomedia.transform.srtp.SRTPTransformEngine - * #getRTPTransformer() - */ - public PacketTransformer getRTPTransformer() - { - return new SRTPTransformer(forwardEngine, reverseEngine); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTCPCryptoContext.java b/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTCPCryptoContext.java deleted file mode 100644 index 9edddce6b..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTCPCryptoContext.java +++ /dev/null @@ -1,710 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - * - * - * Some of the code in this class is derived from ccRtp's SRTP implementation, - * which has the following copyright notice: - * - Copyright (C) 2004-2006 the Minisip Team - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package net.java.sip.communicator.impl.neomedia.transform.srtp; - -import java.util.Arrays; - -import net.java.sip.communicator.impl.neomedia.*; - -import org.bouncycastle.crypto.digests.SHA1Digest; -import org.bouncycastle.crypto.macs.*; -import org.bouncycastle.crypto.params.KeyParameter; -import org.bouncycastle.crypto.params.ParametersForSkein; -import org.bouncycastle.crypto.BlockCipher; -import org.bouncycastle.crypto.Mac; - -import org.bouncycastle.crypto.engines.AESFastEngine; -import org.bouncycastle.crypto.engines.TwofishEngine; - - -/** - * SRTPCryptoContext class is the core class of SRTP implementation. - * There can be multiple SRTP sources in one SRTP session. And each SRTP stream - * has a corresponding SRTPCryptoContext object, identified by SSRC. In this - * way, different sources can be protected independently. - * - * SRTPCryptoContext class acts as a manager class and maintains all the - * information used in SRTP transformation. It is responsible for deriving - * encryption keys / salting keys / authentication keys from master keys. And - * it will invoke certain class to encrypt / decrypt (transform / reverse - * transform) RTP packets. It will hold a replay check db and do replay check - * against incoming packets. - * - * Refer to section 3.2 in RFC3711 for detailed description of cryptographic - * context. - * - * Cryptographic related parameters, i.e. encryption mode / authentication mode, - * master encryption key and master salt key are determined outside the scope - * of SRTP implementation. They can be assigned manually, or can be assigned - * automatically using some key management protocol, such as MIKEY (RFC3830) or - * Phil Zimmermann's ZRTP protocol. - * - * @author Bing SU (nova.su@gmail.com) - */ -public class SRTCPCryptoContext -{ - /** - * The replay check windows size - */ - private static final long REPLAY_WINDOW_SIZE = 64; - - /** - * RTCP SSRC of this cryptographic context - */ - private long ssrcCtx; - - /** - * Master key identifier - */ - private byte[] mki; - - /** - * Index received so far - */ - private int receivedIndex = 0; - - /** - * Index sent so far - */ - private int sentIndex = 0; - - /** - * Bit mask for replay check - */ - private long replayWindow; - - /** - * Master encryption key - */ - private byte[] masterKey; - - /** - * Master salting key - */ - private byte[] masterSalt; - - /** - * Derived session encryption key - */ - private byte[] encKey; - - /** - * Derived session authentication key - */ - private byte[] authKey; - - /** - * Derived session salting key - */ - private byte[] saltKey; - - /** - * Encryption / Authentication policy for this session - */ - private final SRTPPolicy policy; - - /** - * The HMAC object we used to do packet authentication - */ - private Mac mac; // used for various HMAC computations - - // The symmetric cipher engines we need here - private BlockCipher cipher = null; - private BlockCipher cipherF8 = null; // used inside F8 mode only - - // implements the counter cipher mode for RTP according to RFC 3711 - private final SRTPCipherCTR cipherCtr = new SRTPCipherCTR(); - - // Here some fields that a allocated here or in constructor. The methods - // use these fields to avoid too many new operations - - private final byte[] tagStore; - private final byte[] ivStore = new byte[16]; - private final byte[] rbStore = new byte[4]; - - // this is some working store, used by some methods to avoid new operations - // the methods must use this only to store some reults for immediate processing - private final byte[] tempStore = new byte[100]; - - /** - * Construct an empty SRTPCryptoContext using ssrc. - * The other parameters are set to default null value. - * - * @param ssrc SSRC of this SRTPCryptoContext - */ - public SRTCPCryptoContext(long ssrcIn) - { - ssrcCtx = ssrcIn; - mki = null; - masterKey = null; - masterSalt = null; - encKey = null; - authKey = null; - saltKey = null; - policy = null; - tagStore = null; - } - - /** - * Construct a normal SRTPCryptoContext based on the given parameters. - * - * @param ssrc - * the RTP SSRC that this SRTP cryptographic context protects. - * @param masterKey - * byte array holding the master key for this SRTP cryptographic - * context. Refer to chapter 3.2.1 of the RFC about the role of - * the master key. - * @param masterSalt - * byte array holding the master salt for this SRTP cryptographic - * context. It is used to computer the initialization vector that - * in turn is input to compute the session key, session - * authentication key and the session salt. - * @param policy - * SRTP policy for this SRTP cryptographic context, defined the - * encryption algorithm, the authentication algorithm, etc - */ - @SuppressWarnings("fallthrough") - public SRTCPCryptoContext(long ssrcIn, - byte[] masterK, byte[] masterS, SRTPPolicy policyIn) - { - ssrcCtx = ssrcIn; - mki = null; - - policy = policyIn; - - masterKey = new byte[policy.getEncKeyLength()]; - System.arraycopy(masterK, 0, masterKey, 0, policy - .getEncKeyLength()); - - masterSalt = new byte[policy.getSaltKeyLength()]; - System.arraycopy(masterS, 0, masterSalt, 0, policy - .getSaltKeyLength()); - - switch (policy.getEncType()) { - case SRTPPolicy.NULL_ENCRYPTION: - encKey = null; - saltKey = null; - break; - - case SRTPPolicy.AESF8_ENCRYPTION: - cipherF8 = new AESFastEngine(); - - case SRTPPolicy.AESCM_ENCRYPTION: - cipher = new AESFastEngine(); - encKey = new byte[this.policy.getEncKeyLength()]; - saltKey = new byte[this.policy.getSaltKeyLength()]; - break; - - case SRTPPolicy.TWOFISHF8_ENCRYPTION: - cipherF8 = new TwofishEngine(); - - case SRTPPolicy.TWOFISH_ENCRYPTION: - cipher = new TwofishEngine(); - encKey = new byte[this.policy.getEncKeyLength()]; - saltKey = new byte[this.policy.getSaltKeyLength()]; - break; - } - - switch (policy.getAuthType()) { - case SRTPPolicy.NULL_AUTHENTICATION: - authKey = null; - tagStore = null; - break; - - case SRTPPolicy.HMACSHA1_AUTHENTICATION: - mac = new HMac(new SHA1Digest()); - authKey = new byte[policy.getAuthKeyLength()]; - tagStore = new byte[mac.getMacSize()]; - break; - - case SRTPPolicy.SKEIN_AUTHENTICATION: - mac = new SkeinMac(); - authKey = new byte[policy.getAuthKeyLength()]; - tagStore = new byte[policy.getAuthTagLength()]; - break; - - default: - tagStore = null; - } - } - - /** - * Close the crypto context. - * - * The close functions deletes key data and performs a cleanup of the - * crypto context. - * - * Clean up key data, maybe this is the second time. However, sometimes - * we cannot know if the CryptoContext was used and the application called - * deriveSrtpKeys(...) tah would have cleaned the key data. - * - */ - public void close() - { - Arrays.fill(masterKey, (byte)0); - Arrays.fill(masterSalt, (byte)0); - } - - /** - * Get the authentication tag length of this SRTP cryptographic context - * - * @return the authentication tag length of this SRTP cryptographic context - */ - public int getAuthTagLength() - { - return policy.getAuthTagLength(); - } - - /** - * Get the MKI length of this SRTP cryptographic context - * - * @return the MKI length of this SRTP cryptographic context - */ - public int getMKILength() - { - if (mki != null) - return mki.length; - return 0; - } - - /** - * Get the SSRC of this SRTP cryptographic context - * - * @return the SSRC of this SRTP cryptographic context - */ - public long getSSRC() - { - return ssrcCtx; - } - - /** - * Transform a RTP packet into a SRTP packet. - * This method is called when a normal RTP packet ready to be sent. - * - * Operations done by the transformation may include: encryption, using - * either Counter Mode encryption, or F8 Mode encryption, adding - * authentication tag, currently HMC SHA1 method. - * - * Both encryption and authentication functionality can be turned off - * as long as the SRTPPolicy used in this SRTPCryptoContext is requires no - * encryption and no authentication. Then the packet will be sent out - * untouched. However this is not encouraged. If no SRTP feature is enabled, - * then we shall not use SRTP TransformConnector. We should use the original - * method (RTPManager managed transportation) instead. - * - * @param pkt the RTP packet that is going to be sent out - */ - public void transformPacket(RawPacket pkt) - { - boolean encrypt = false; - /* Encrypt the packet using Counter Mode encryption */ - if (policy.getEncType() == SRTPPolicy.AESCM_ENCRYPTION || - policy.getEncType() == SRTPPolicy.TWOFISH_ENCRYPTION) - { - processPacketAESCM(pkt, sentIndex); - encrypt = true; - } - - /* Encrypt the packet using F8 Mode encryption */ - else if (policy.getEncType() == SRTPPolicy.AESF8_ENCRYPTION || - policy.getEncType() == SRTPPolicy.TWOFISHF8_ENCRYPTION) - { - processPacketAESF8(pkt, sentIndex); - encrypt = true; - } - int index = 0; - if (encrypt) - index = sentIndex | 0x80000000; - - // Grow packet storage in one step - pkt.grow(4 + policy.getAuthTagLength()); - - // Authenticate the packet - // The authenticate method gets the index via parameter and stores - // it in network order in rbStore variable. - if (policy.getAuthType() != SRTPPolicy.NULL_AUTHENTICATION) - { - authenticatePacket(pkt, index); - pkt.append(rbStore, 4); - pkt.append(tagStore, policy.getAuthTagLength()); - } - sentIndex++; - sentIndex &= ~0x80000000; // clear possible overflow - } - - /** - * Transform a SRTCP packet into a RTCP packet. - * This method is called when a SRTCP packet was received. - * - * Operations done by the this operation include: - * Authentication check, Packet replay check and decryption. - * - * Both encryption and authentication functionality can be turned off - * as long as the SRTPPolicy used in this SRTPCryptoContext requires no - * encryption and no authentication. Then the packet will be sent out - * untouched. However this is not encouraged. If no SRTCP feature is enabled, - * then we shall not use SRTP TransformConnector. We should use the original - * method (RTPManager managed transportation) instead. - * - * @param pkt the received RTCP packet - * @return true if the packet can be accepted - * false if authentication or replay check failed - */ - public boolean reverseTransformPacket(RawPacket pkt) - { - boolean decrypt = false; - int tagLength = policy.getAuthTagLength(); - int indexEflag = pkt.getSRTCPIndex(tagLength); - - if ((indexEflag & 0x80000000) == 0x80000000) - decrypt = true; - - int index = indexEflag & ~0x80000000; - - /* Replay control */ - if (!checkReplay(index)) - { - return false; - } - - /* Authenticate the packet */ - if (policy.getAuthType() != SRTPPolicy.NULL_AUTHENTICATION) - { - // get original authentication data and store in tempStore - pkt.readRegionToBuff(pkt.getLength() - tagLength, tagLength, - tempStore); - - // Shrink packet to remove the authentication tag and index - // because this is part of authenicated data - pkt.shrink(tagLength + 4); - - // compute, then save authentication in tagStore - authenticatePacket(pkt, indexEflag); - - for (int i = 0; i < tagLength; i++) - { - if ((tempStore[i] & 0xff) == (tagStore[i] & 0xff)) - continue; - else - return false; - } - } - - if (decrypt) - { - /* Decrypt the packet using Counter Mode encryption */ - if (policy.getEncType() == SRTPPolicy.AESCM_ENCRYPTION - || policy.getEncType() == SRTPPolicy.TWOFISH_ENCRYPTION) - { - processPacketAESCM(pkt, index); - } - - /* Decrypt the packet using F8 Mode encryption */ - else if (policy.getEncType() == SRTPPolicy.AESF8_ENCRYPTION - || policy.getEncType() == SRTPPolicy.TWOFISHF8_ENCRYPTION) - { - processPacketAESF8(pkt, index); - } - } - update(index); - - return true; - } - - /** - * Perform Counter Mode AES encryption / decryption - * @param pkt the RTP packet to be encrypted / decrypted - */ - public void processPacketAESCM(RawPacket pkt, int index) - { - long ssrc = pkt.getRTCPSSRC(); - - /* Compute the CM IV (refer to chapter 4.1.1 in RFC 3711): - * - * k_s XX XX XX XX XX XX XX XX XX XX XX XX XX XX - * SSRC XX XX XX XX - * index XX XX XX XX - * ------------------------------------------------------XOR - * IV XX XX XX XX XX XX XX XX XX XX XX XX XX XX 00 00 - * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - */ - ivStore[0] = saltKey[0]; - ivStore[1] = saltKey[1]; - ivStore[2] = saltKey[2]; - ivStore[3] = saltKey[3]; - - // The shifts transform the ssrc and index into network order - ivStore[4] = (byte) (((ssrc >> 24) & 0xff) ^ this.saltKey[4]); - ivStore[5] = (byte) (((ssrc >> 16) & 0xff) ^ this.saltKey[5]); - ivStore[6] = (byte) (((ssrc >> 8) & 0xff) ^ this.saltKey[6]); - ivStore[7] = (byte) ((ssrc & 0xff) ^ this.saltKey[7]); - - ivStore[8] = saltKey[8]; - ivStore[9] = saltKey[9]; - - ivStore[10] = (byte) (((index >> 24) & 0xff) ^ this.saltKey[10]); - ivStore[11] = (byte) (((index >> 16) & 0xff) ^ this.saltKey[11]); - ivStore[12] = (byte) (((index >> 8) & 0xff) ^ this.saltKey[12]); - ivStore[13] = (byte) ((index & 0xff) ^ this.saltKey[13]); - - ivStore[14] = ivStore[15] = 0; - - // Encrypted part excludes fixed header (8 bytes) - final int payloadOffset = 8; - final int payloadLength = pkt.getLength() - payloadOffset; - - cipherCtr.process(cipher, pkt.getBuffer(), - pkt.getOffset() + payloadOffset, - payloadLength, ivStore); - } - - /** - * Perform F8 Mode AES encryption / decryption - * - * @param pkt the RTP packet to be encrypted / decrypted - */ - public void processPacketAESF8(RawPacket pkt, int index) - { - // byte[] iv = new byte[16]; - - // 4 bytes of the iv are zero - // the first byte of the RTP header is not used. - ivStore[0] = 0; - ivStore[1] = 0; - ivStore[2] = 0; - ivStore[3] = 0; - - // Need the encryption flag - index = index | 0x80000000; - - // set the index and the encrypt flag in network order into IV - ivStore[4] = (byte) (index >> 24); - ivStore[5] = (byte) (index >> 16); - ivStore[6] = (byte) (index >> 8); - ivStore[7] = (byte) index; - - // The fixed header follows and fills the rest of the IV - System.arraycopy(pkt.getBuffer(), pkt.getOffset(), ivStore, 8, 8); - - // Encrypted part excludes fixed header (8 bytes), index (4 bytes), and - // authentication tag (variable according to policy) - final int payloadOffset = 8; - final int payloadLength - = pkt.getLength() - (4 + policy.getAuthTagLength()); - - SRTPCipherF8.process(cipher, pkt.getBuffer(), - pkt.getOffset() + payloadOffset, - payloadLength, ivStore, cipherF8); - } - - /** - * Authenticate a packet. - * - * Calculated authentication tag is stored in tagStore area. - * - * @param pkt the RTP packet to be authenticated - */ - private void authenticatePacket(RawPacket pkt, int index) - { - mac.update(pkt.getBuffer(), 0, pkt.getLength()); - // byte[] rb = new byte[4]; - rbStore[0] = (byte) (index >> 24); - rbStore[1] = (byte) (index >> 16); - rbStore[2] = (byte) (index >> 8); - rbStore[3] = (byte) index; - mac.update(rbStore, 0, rbStore.length); - mac.doFinal(tagStore, 0); - } - - /** - * Checks if a packet is a replayed on based on its sequence number. - * - * This method supports a 64 packet history relative the the given - * sequence number. - * - * Sequence Number is guaranteed to be real (not faked) through - * authentication. - * - * @param index index number of the SRTCP packet - * @return true if this sequence number indicates the packet is not a - * replayed one, false if not - */ - boolean checkReplay(int index) - { - // compute the index of previously received packet and its - // delta to the new received packet - long delta = index - receivedIndex; - - if (delta > 0) - { - /* Packet not yet received */ - return true; - } - else - { - if (-delta > REPLAY_WINDOW_SIZE) - { - /* Packet too old */ - return false; - } - else - { - if (((this.replayWindow >> (-delta)) & 0x1) != 0) - { - /* Packet already received ! */ - return false; - } - else - { - /* Packet not yet received */ - return true; - } - } - } - } - - /** - * Compute the initialization vector, used later by encryption algorithms, - * based on the label. - * - * @param label label specified for each type of iv - */ - private void computeIv(byte label) - { - for (int i = 0; i < 14; i++) - { - ivStore[i] = masterSalt[i]; - } - ivStore[7] ^= label; - ivStore[14] = ivStore[15] = 0; - } - - /** - * Derives the srtcp session keys from the master key. - * - */ - public void deriveSrtcpKeys() - { - // compute the session encryption key - byte label = 3; - computeIv(label); - - KeyParameter encryptionKey = new KeyParameter(masterKey); - cipher.init(true, encryptionKey); - Arrays.fill(masterKey, (byte)0); - - cipherCtr.getCipherStream(cipher, encKey, policy.getEncKeyLength(), ivStore); - - if (authKey != null) - { - label = 4; - computeIv(label); - cipherCtr.getCipherStream(cipher, authKey, - policy.getAuthKeyLength(), ivStore); - - switch ((policy.getAuthType())) - { - case SRTPPolicy.HMACSHA1_AUTHENTICATION: - KeyParameter key = new KeyParameter(authKey); - mac.init(key); - break; - - case SRTPPolicy.SKEIN_AUTHENTICATION: - // Skein MAC uses number of bits as MAC size, not just bytes - ParametersForSkein pfs = new ParametersForSkein( - new KeyParameter(authKey), - ParametersForSkein.Skein512, tagStore.length * 8); - mac.init(pfs); - break; - } - } - Arrays.fill(authKey, (byte)0); - - // compute the session salt - label = 5; - computeIv(label); - cipherCtr.getCipherStream(cipher, saltKey, policy.getSaltKeyLength(), ivStore); - Arrays.fill(masterSalt, (byte)0); - - // As last step: initialize cipher with derived encryption key. - if (cipherF8 != null) - SRTPCipherF8.deriveForIV(cipherF8, encKey, saltKey); - encryptionKey = new KeyParameter(encKey); - cipher.init(true, encryptionKey); - Arrays.fill(encKey, (byte)0); - } - - - /** - * Update the SRTP packet index. - * - * This method is called after all checks were successful. - * - * @param index index number of the accepted packet - */ - private void update(int index) - { - int delta = receivedIndex - index; - - /* update the replay bit mask */ - if (delta > 0) - { - replayWindow = replayWindow << delta; - replayWindow |= 1; - } - else - { - replayWindow |= ( 1 << delta ); - } - - receivedIndex = index; - } - - /** - * Derive a new SRTPCryptoContext for use with a new SSRC - * - * This method returns a new SRTPCryptoContext initialized with the data of - * this SRTPCryptoContext. Replacing the SSRC, Roll-over-Counter, and the - * key derivation rate the application cab use this SRTPCryptoContext to - * encrypt / decrypt a new stream (Synchronization source) inside one RTP - * session. - * - * Before the application can use this SRTPCryptoContext it must call the - * deriveSrtpKeys method. - * - * @param ssrc - * The SSRC for this context - * @return a new SRTPCryptoContext with all relevant data set. - */ - public SRTCPCryptoContext deriveContext(long ssrc) - { - SRTCPCryptoContext pcc = null; - pcc = new SRTCPCryptoContext(ssrc, masterKey, - masterSalt, policy); - return pcc; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTCPTransformer.java b/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTCPTransformer.java deleted file mode 100644 index 13b7fec48..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTCPTransformer.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.srtp; - -import java.util.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.transform.*; - -/** - * SRTCPTransformer implements PacketTransformer. - * It encapsulate the encryption / decryption logic for SRTCP packets - * - * @author Bing SU (nova.su@gmail.com) - * @author Werner Dittmann <Werner.Dittmann@t-online.de> - */ -public class SRTCPTransformer - implements PacketTransformer -{ - private final SRTPTransformEngine forwardEngine; - private final SRTPTransformEngine reverseEngine; - - /** - * All the known SSRC's corresponding SRTCPCryptoContexts - */ - private final Hashtable contexts; - - /** - * Constructs a SRTCPTransformer object. - * - * @param engine The associated SRTPTransformEngine object for both - * transform directions. - */ - public SRTCPTransformer(SRTPTransformEngine engine) - { - this(engine, engine); - } - - /** - * Constructs a SRTCPTransformer object. - * - * @param forwardEngine The associated SRTPTransformEngine object for - * forward transformations. - * @param reverseEngine The associated SRTPTransformEngine object for - * reverse transformations. - */ - public SRTCPTransformer( - SRTPTransformEngine forwardEngine, - SRTPTransformEngine reverseEngine) - { - this.forwardEngine = forwardEngine; - this.reverseEngine = reverseEngine; - this.contexts = new Hashtable(); - } - - /** - * Closes this SRTCPTransformer and the underlying transform - * engine. It closes all stored crypto contexts. It deletes key data and - * forces a cleanup of the crypto contexts. - */ - public void close() - { - synchronized (contexts) - { - forwardEngine.close(); - if (reverseEngine != forwardEngine) - reverseEngine.close(); - - Iterator> iter - = contexts.entrySet().iterator(); - - while (iter.hasNext()) - { - Map.Entry entry = iter.next(); - SRTCPCryptoContext context = entry.getValue(); - - iter.remove(); - if (context != null) - context.close(); - } - } - } - - private SRTCPCryptoContext getContext( - RawPacket pkt, - SRTPTransformEngine engine) - { - long ssrc = pkt.getRTCPSSRC(); - SRTCPCryptoContext context; - - synchronized (contexts) - { - context = contexts.get(ssrc); - if (context == null) - { - context = engine.getDefaultContextControl(); - if (context != null) - { - context = context.deriveContext(ssrc); - context.deriveSrtcpKeys(); - contexts.put(ssrc, context); - } - } - } - - return context; - } - - /** - * Decrypts a SRTCP packet - * - * @param pkt encrypted SRTCP packet to be decrypted - * @return decrypted SRTCP packet - */ - public RawPacket reverseTransform(RawPacket pkt) - { - SRTCPCryptoContext context = getContext(pkt, reverseEngine); - - return - ((context != null) && context.reverseTransformPacket(pkt)) - ? pkt - : null; - } - - /** - * Encrypts a SRTCP packet - * - * @param pkt plain SRTCP packet to be encrypted - * @return encrypted SRTCP packet - */ - public RawPacket transform(RawPacket pkt) - { - SRTCPCryptoContext context = getContext(pkt, forwardEngine); - - context.transformPacket(pkt); - return pkt; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPCipherCTR.java b/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPCipherCTR.java deleted file mode 100644 index fd75aa9a7..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPCipherCTR.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - * - * Some of the code in this class is derived from ccRtp's SRTP implementation, - * which has the following copyright notice: - * - Copyright (C) 2004-2006 the Minisip Team - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package net.java.sip.communicator.impl.neomedia.transform.srtp; - -import org.bouncycastle.crypto.BlockCipher; - -/** - * SRTPCipherCTR implements SRTP Counter Mode AES Encryption (AES-CM). - * Counter Mode AES Encryption algorithm is defined in RFC3711, section 4.1.1. - * - * Other than Null Cipher, RFC3711 defined two two encryption algorithms: - * Counter Mode AES Encryption and F8 Mode AES encryption. Both encryption - * algorithms are capable to encrypt / decrypt arbitrary length data, and the - * size of packet data is not required to be a multiple of the AES block - * size (128bit). So, no padding is needed. - * - * Please note: these two encryption algorithms are specially defined by SRTP. - * They are not common AES encryption modes, so you will not be able to find a - * replacement implementation in common cryptographic libraries. - * - * As defined by RFC3711: Counter Mode Encryption is mandatory.. - * - * mandatory to impl optional default - * ------------------------------------------------------------------------- - * encryption AES-CM, NULL AES-f8 AES-CM - * message integrity HMAC-SHA1 - HMAC-SHA1 - * key derivation (PRF) AES-CM - AES-CM - * - * We use AESCipher to handle basic AES encryption / decryption. - * - * @author Werner Dittmann (Werner.Dittmann@t-online.de) - * @author Bing SU (nova.su@gmail.com) - */ -public class SRTPCipherCTR -{ - - private final static int BLKLEN = 16; - private final static int MAX_BUFFER_LENGTH = 10*1024; - private final byte[] cipherInBlock = new byte[BLKLEN]; - private final byte[] tmpCipherBlock = new byte[BLKLEN]; - private byte[] streamBuf = new byte[1024]; - - public SRTPCipherCTR() - { - } - - public void process(BlockCipher cipher, byte[] data, int off, int len, - byte[] iv) - { - if (off + len > data.length) - return; - - // if data fits in inter buffer - use it. Otherwise allocate bigger - // buffer store it to use it for later processing - up to a defined - // maximum size. - byte[] cipherStream = null; - if (len > streamBuf.length) - { - cipherStream = new byte[len]; - if (cipherStream.length <= MAX_BUFFER_LENGTH) - { - streamBuf = cipherStream; - } - } - else - { - cipherStream = streamBuf; - } - - getCipherStream(cipher, cipherStream, len, iv); - for (int i = 0; i < len; i++) - data[i + off] ^= cipherStream[i]; - } - - /** - * Computes the cipher stream for AES CM mode. See section 4.1.1 in RFC3711 - * for detailed description. - * - * @param out - * byte array holding the output cipher stream - * @param length - * length of the cipher stream to produce, in bytes - * @param iv - * initialization vector used to generate this cipher stream - */ - public void getCipherStream(BlockCipher aesCipher, byte[] out, int length, - byte[] iv) - { - System.arraycopy(iv, 0, cipherInBlock, 0, 14); - - int ctr; - for (ctr = 0; ctr < length / BLKLEN; ctr++) - { - // compute the cipher stream - cipherInBlock[14] = (byte) ((ctr & 0xFF00) >> 8); - cipherInBlock[15] = (byte) ((ctr & 0x00FF)); - - aesCipher.processBlock(cipherInBlock, 0, out, ctr * BLKLEN); - } - - // Treat the last bytes: - cipherInBlock[14] = (byte) ((ctr & 0xFF00) >> 8); - cipherInBlock[15] = (byte) ((ctr & 0x00FF)); - - aesCipher.processBlock(cipherInBlock, 0, tmpCipherBlock, 0); - System.arraycopy(tmpCipherBlock, 0, out, ctr * BLKLEN, length % BLKLEN); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPCipherF8.java b/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPCipherF8.java deleted file mode 100644 index d72e9a1fc..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPCipherF8.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - * - * Some of the code in this class is derived from ccRtp's SRTP implementation, - * which has the following copyright notice: - * - Copyright (C) 2004-2006 the Minisip Team - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package net.java.sip.communicator.impl.neomedia.transform.srtp; - -import java.util.*; - -import org.bouncycastle.crypto.BlockCipher; -import org.bouncycastle.crypto.params.KeyParameter; - -/** - * SRTPCipherF8 implements SRTP F8 Mode AES Encryption (AES-f8). - * F8 Mode AES Encryption algorithm is defined in RFC3711, section 4.1.2. - * - * Other than Null Cipher, RFC3711 defined two two encryption algorithms: - * Counter Mode AES Encryption and F8 Mode AES encryption. Both encryption - * algorithms are capable to encrypt / decrypt arbitrary length data, and the - * size of packet data is not required to be a multiple of the AES block - * size (128bit). So, no padding is needed. - * - * Please note: these two encryption algorithms are specially defined by SRTP. - * They are not common AES encryption modes, so you will not be able to find a - * replacement implementation in common cryptographic libraries. - * - * As defined by RFC3711: F8 mode encryption is optional. - * - * mandatory to impl optional default - * ------------------------------------------------------------------------- - * encryption AES-CM, NULL AES-f8 AES-CM - * message integrity HMAC-SHA1 - HMAC-SHA1 - * key derivation (PRF) AES-CM - AES-CM - * - * We use AESCipher to handle basic AES encryption / decryption. - * - * @author Bing SU (nova.su@gmail.com) - * @author Werner Dittmann - */ -public class SRTPCipherF8 -{ - /** - * AES block size, just a short name. - */ - private final static int BLKLEN = 16; - - /** - * F8 mode encryption context, see RFC3711 section 4.1.2 for detailed - * description. - */ - class F8Context - { - public byte[] S; - public byte[] ivAccent; - long J; - } - - public static void deriveForIV(BlockCipher f8Cipher, byte[] key, byte[] salt) - { - /* - * Get memory for the special key. This is the key to compute the - * derived IV (IV'). - */ - byte[] saltMask = new byte[key.length]; - byte[] maskedKey = new byte[key.length]; - - /* - * First copy the salt into the mask field, then fill with 0x55 to get a - * full key. - */ - System.arraycopy(salt, 0, saltMask, 0, salt.length); - for (int i = salt.length; i < saltMask.length; ++i) - saltMask[i] = 0x55; - - /* - * XOR the original key with the above created mask to get the special - * key. - */ - for (int i = 0; i < key.length; i++) - maskedKey[i] = (byte) (key[i] ^ saltMask[i]); - - /* - * Prepare the f8Cipher with the special key to compute IV' - */ - KeyParameter encryptionKey = new KeyParameter(maskedKey); - f8Cipher.init(true, encryptionKey); - saltMask = null; - maskedKey = null; - } - - public static void process(BlockCipher cipher, byte[] data, int off, int len, - byte[] iv, BlockCipher f8Cipher) - { - F8Context f8ctx = new SRTPCipherF8().new F8Context(); - - /* - * Get memory for the derived IV (IV') - */ - f8ctx.ivAccent = new byte[BLKLEN]; - - /* - * Use the derived IV encryption setup to encrypt the original IV to produce IV'. - */ - f8Cipher.processBlock(iv, 0, f8ctx.ivAccent, 0); - - f8ctx.J = 0; // initialize the counter - f8ctx.S = new byte[BLKLEN]; // get the key stream buffer - - Arrays.fill(f8ctx.S, (byte) 0); - - int inLen = len; - - while (inLen >= BLKLEN) - { - processBlock(cipher, f8ctx, data, off, data, off, BLKLEN); - inLen -= BLKLEN; - off += BLKLEN; - } - - if (inLen > 0) - { - processBlock(cipher, f8ctx, data, off, data, off, inLen); - } - } - - /** - * Encrypt / Decrypt a block using F8 Mode AES algorithm, read len bytes - * data from in at inOff and write the output into out at outOff - * - * @param f8ctx - * F8 encryption context - * @param in - * byte array holding the data to be processed - * @param inOff - * start offset of the data to be processed inside in array - * @param out - * byte array that will hold the processed data - * @param outOff - * start offset of output data in out - * @param len - * length of the input data - */ - private static void processBlock(BlockCipher cipher, F8Context f8ctx, - byte[] in, int inOff, byte[] out, int outOff, int len) - { - /* - * XOR the previous key stream with IV' - * ( S(-1) xor IV' ) - */ - for (int i = 0; i < BLKLEN; i++) - f8ctx.S[i] ^= f8ctx.ivAccent[i]; - - /* - * Now XOR (S(n-1) xor IV') with the current counter, then increment - * the counter - */ - f8ctx.S[12] ^= f8ctx.J >> 24; - f8ctx.S[13] ^= f8ctx.J >> 16; - f8ctx.S[14] ^= f8ctx.J >> 8; - f8ctx.S[15] ^= f8ctx.J >> 0; - f8ctx.J++; - - /* - * Now compute the new key stream using AES encrypt - */ - cipher.processBlock(f8ctx.S, 0, f8ctx.S, 0); - - /* - * As the last step XOR the plain text with the key stream to produce - * the cipher text. - */ - for (int i = 0; i < len; i++) - out[outOff + i] = (byte) (in[inOff + i] ^ f8ctx.S[i]); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPCryptoContext.java b/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPCryptoContext.java deleted file mode 100644 index ef51ff5a2..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPCryptoContext.java +++ /dev/null @@ -1,837 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - * - * - * Some of the code in this class is derived from ccRtp's SRTP implementation, - * which has the following copyright notice: - * - Copyright (C) 2004-2006 the Minisip Team - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package net.java.sip.communicator.impl.neomedia.transform.srtp; - -import java.util.Arrays; - -import net.java.sip.communicator.impl.neomedia.*; - -import org.bouncycastle.crypto.*; -import org.bouncycastle.crypto.digests.*; -import org.bouncycastle.crypto.engines.*; -import org.bouncycastle.crypto.macs.*; -import org.bouncycastle.crypto.params.*; - -/** - * SRTPCryptoContext class is the core class of SRTP implementation. - * There can be multiple SRTP sources in one SRTP session. And each SRTP stream - * has a corresponding SRTPCryptoContext object, identified by SSRC. In this - * way, different sources can be protected independently. - * - * SRTPCryptoContext class acts as a manager class and maintains all the - * information used in SRTP transformation. It is responsible for deriving - * encryption keys / salting keys / authentication keys from master keys. And - * it will invoke certain class to encrypt / decrypt (transform / reverse - * transform) RTP packets. It will hold a replay check db and do replay check - * against incoming packets. - * - * Refer to section 3.2 in RFC3711 for detailed description of cryptographic - * context. - * - * Cryptographic related parameters, i.e. encryption mode / authentication mode, - * master encryption key and master salt key are determined outside the scope - * of SRTP implementation. They can be assigned manually, or can be assigned - * automatically using some key management protocol, such as MIKEY (RFC3830), - * SDES (RFC4568) or Phil Zimmermann's ZRTP protocol (RFC6189). - * - * @author Bing SU (nova.su@gmail.com) - */ -public class SRTPCryptoContext -{ - /** - * The replay check windows size - */ - private static final long REPLAY_WINDOW_SIZE = 64; - - /** - * RTP SSRC of this cryptographic context - */ - private long ssrcCtx; - - /** - * Master key identifier - */ - private byte[] mki; - - /** - * Roll-Over-Counter, see RFC3711 section 3.2.1 for detailed description - */ - private int roc; - - /** - * Roll-Over-Counter guessed from packet - */ - private int guessedROC; - - /** - * RTP sequence number of the packet current processing - */ - private int seqNum; - - /** - * Whether we have the sequence number of current packet - */ - private boolean seqNumSet; - - /** - * Key Derivation Rate, used to derive session keys from master keys - */ - private long keyDerivationRate; - - /** - * Bit mask for replay check - */ - private long replayWindow; - - /** - * Master encryption key - */ - private byte[] masterKey; - - /** - * Master salting key - */ - private byte[] masterSalt; - - /** - * Derived session encryption key - */ - private byte[] encKey; - - /** - * Derived session authentication key - */ - private byte[] authKey; - - /** - * Derived session salting key - */ - private byte[] saltKey; - - /** - * Encryption / Authentication policy for this session - */ - private final SRTPPolicy policy; - - /** - * The HMAC object we used to do packet authentication - */ - private Mac mac; // used for various HMAC computations - - /** - * The symmetric cipher engines we need here - */ - private BlockCipher cipher = null; - - /** - * Used inside F8 mode only - */ - private BlockCipher cipherF8 = null; - - /** - * implements the counter cipher mode for RTP according to RFC 3711 - */ - private final SRTPCipherCTR cipherCtr = new SRTPCipherCTR(); - - /** - * Temp store. - */ - private final byte[] tagStore; - - /** - * Temp store. - */ - private final byte[] ivStore = new byte[16]; - - /** - * Temp store. - */ - private final byte[] rbStore = new byte[4]; - - /** - * this is a working store, used by some methods to avoid new operations - * the methods must use this only to store results for immediate processing - */ - private final byte[] tempStore = new byte[100]; - - /** - * Construct an empty SRTPCryptoContext using ssrc. - * The other parameters are set to default null value. - * - * @param ssrcIn SSRC of this SRTPCryptoContext - */ - public SRTPCryptoContext(long ssrcIn) - { - ssrcCtx = ssrcIn; - mki = null; - roc = 0; - guessedROC = 0; - seqNum = 0; - keyDerivationRate = 0; - masterKey = null; - masterSalt = null; - encKey = null; - authKey = null; - saltKey = null; - seqNumSet = false; - policy = null; - tagStore = null; - } - - /** - * Construct a normal SRTPCryptoContext based on the given parameters. - * - * @param ssrcIn - * the RTP SSRC that this SRTP cryptographic context protects. - * @param rocIn - * the initial Roll-Over-Counter according to RFC 3711. These are - * the upper 32 bit of the overall 48 bit SRTP packet index. - * Refer to chapter 3.2.1 of the RFC. - * @param kdr - * the key derivation rate defines when to recompute the SRTP - * session keys. Refer to chapter 4.3.1 in the RFC. - * @param masterK - * byte array holding the master key for this SRTP cryptographic - * context. Refer to chapter 3.2.1 of the RFC about the role of - * the master key. - * @param masterS - * byte array holding the master salt for this SRTP cryptographic - * context. It is used to computer the initialization vector that - * in turn is input to compute the session key, session - * authentication key and the session salt. - * @param policyIn - * SRTP policy for this SRTP cryptographic context, defined the - * encryption algorithm, the authentication algorithm, etc - */ - @SuppressWarnings("fallthrough") - public SRTPCryptoContext(long ssrcIn, int rocIn, long kdr, - byte[] masterK, byte[] masterS, SRTPPolicy policyIn) - { - ssrcCtx = ssrcIn; - mki = null; - roc = rocIn; - guessedROC = 0; - seqNum = 0; - keyDerivationRate = kdr; - seqNumSet = false; - - policy = policyIn; - - masterKey = new byte[policy.getEncKeyLength()]; - System.arraycopy(masterK, 0, masterKey, 0, policy - .getEncKeyLength()); - - masterSalt = new byte[policy.getSaltKeyLength()]; - System.arraycopy(masterS, 0, masterSalt, 0, policy - .getSaltKeyLength()); - - mac = new HMac(new SHA1Digest()); - - switch (policy.getEncType()) - { - case SRTPPolicy.NULL_ENCRYPTION: - encKey = null; - saltKey = null; - break; - - case SRTPPolicy.AESF8_ENCRYPTION: - cipherF8 = new AESFastEngine(); - //$FALL-THROUGH$ - - case SRTPPolicy.AESCM_ENCRYPTION: - cipher = new AESFastEngine(); - encKey = new byte[policy.getEncKeyLength()]; - saltKey = new byte[policy.getSaltKeyLength()]; - break; - - case SRTPPolicy.TWOFISHF8_ENCRYPTION: - cipherF8 = new TwofishEngine(); - - case SRTPPolicy.TWOFISH_ENCRYPTION: - cipher = new TwofishEngine(); - encKey = new byte[this.policy.getEncKeyLength()]; - saltKey = new byte[this.policy.getSaltKeyLength()]; - break; - } - - switch (policy.getAuthType()) - { - case SRTPPolicy.NULL_AUTHENTICATION: - authKey = null; - tagStore = null; - break; - - case SRTPPolicy.HMACSHA1_AUTHENTICATION: - mac = new HMac(new SHA1Digest()); - authKey = new byte[policy.getAuthKeyLength()]; - tagStore = new byte[mac.getMacSize()]; - break; - - case SRTPPolicy.SKEIN_AUTHENTICATION: - mac = new SkeinMac(); - authKey = new byte[policy.getAuthKeyLength()]; - tagStore = new byte[policy.getAuthTagLength()]; - break; - - default: - tagStore = null; - } - } - - /** - * Close the crypto context. - * - * The close functions deletes key data and performs a cleanup of the - * crypto context. - * - * Clean up key data, maybe this is the second time however, sometimes - * we cannot know if the CryptoCOntext was used and the application called - * deriveSrtpKeys(...) . - * - */ - public void close() - { - Arrays.fill(masterKey, (byte)0); - Arrays.fill(masterSalt, (byte)0); - } - - /** - * Get the authentication tag length of this SRTP cryptographic context - * - * @return the authentication tag length of this SRTP cryptographic context - */ - public int getAuthTagLength() - { - return policy.getAuthTagLength(); - } - - /** - * Get the MKI length of this SRTP cryptographic context - * - * @return the MKI length of this SRTP cryptographic context - */ - public int getMKILength() - { - if (mki != null) - { - return mki.length; - } - else - { - return 0; - } - } - - /** - * Get the SSRC of this SRTP cryptographic context - * - * @return the SSRC of this SRTP cryptographic context - */ - public long getSSRC() - { - return ssrcCtx; - } - - /** - * Get the Roll-Over-Counter of this SRTP cryptographic context - * - * @return the Roll-Over-Counter of this SRTP cryptographic context - */ - public int getROC() - { - return roc; - } - - /** - * Set the Roll-Over-Counter of this SRTP cryptographic context - * - * @param rocIn the Roll-Over-Counter of this SRTP cryptographic context - */ - public void setROC(int rocIn) - { - roc = rocIn; - } - - /** - * Transform a RTP packet into a SRTP packet. - * This method is called when a normal RTP packet ready to be sent. - * - * Operations done by the transformation may include: encryption, using - * either Counter Mode encryption, or F8 Mode encryption, adding - * authentication tag, currently HMC SHA1 method. - * - * Both encryption and authentication functionality can be turned off - * as long as the SRTPPolicy used in this SRTPCryptoContext is requires no - * encryption and no authentication. Then the packet will be sent out - * untouched. However this is not encouraged. If no SRTP feature is enabled, - * then we shall not use SRTP TransformConnector. We should use the original - * method (RTPManager managed transportation) instead. - * - * @param pkt the RTP packet that is going to be sent out - */ - public void transformPacket(RawPacket pkt) - { - /* Encrypt the packet using Counter Mode encryption */ - if (policy.getEncType() == SRTPPolicy.AESCM_ENCRYPTION || - policy.getEncType() == SRTPPolicy.TWOFISH_ENCRYPTION) - { - processPacketAESCM(pkt); - } - else if (policy.getEncType() == SRTPPolicy.AESF8_ENCRYPTION || - policy.getEncType() == SRTPPolicy.TWOFISHF8_ENCRYPTION) - { - /* Encrypt the packet using F8 Mode encryption */ - processPacketAESF8(pkt); - } - - /* Authenticate the packet */ - if (policy.getAuthType() != SRTPPolicy.NULL_AUTHENTICATION) - { - authenticatePacketHMCSHA1(pkt, roc); - pkt.append(tagStore, policy.getAuthTagLength()); - } - - /* Update the ROC if necessary */ - int seqNo = pkt.getSequenceNumber(); - if (seqNo == 0xFFFF) - { - roc++; - } - } - - /** - * Transform a SRTP packet into a RTP packet. - * This method is called when a SRTP packet is received. - * - * Operations done by the this operation include: - * Authentication check, Packet replay check and decryption. - * - * Both encryption and authentication functionality can be turned off - * as long as the SRTPPolicy used in this SRTPCryptoContext is requires no - * encryption and no authentication. Then the packet will be sent out - * untouched. However this is not encouraged. If no SRTP feature is enabled, - * then we shall not use SRTP TransformConnector. We should use the original - * method (RTPManager managed transportation) instead. - * - * @param pkt the RTP packet that is just received - * @return true if the packet can be accepted - * false if the packet failed authentication or failed replay check - */ - public boolean reverseTransformPacket(RawPacket pkt) - { - int seqNo = pkt.getSequenceNumber(); - - if (!seqNumSet) - { - seqNumSet = true; - seqNum = seqNo; - } - // Guess the SRTP index (48 bit), see rFC 3711, 3.3.1 - // Stores the guessed roc in this.guessedROC - long guessedIndex = guessIndex(seqNo); - - /* Replay control */ - if (!checkReplay(seqNo, guessedIndex)) - { - return false; - } - /* Authenticate the packet */ - if (policy.getAuthType() != SRTPPolicy.NULL_AUTHENTICATION) - { - int tagLength = policy.getAuthTagLength(); - - // get original authentication and store in tempStore - pkt.readRegionToBuff(pkt.getLength() - tagLength, - tagLength, tempStore); - - pkt.shrink(tagLength); - - // save computed authentication in tagStore - authenticatePacketHMCSHA1(pkt, guessedROC); - - for (int i = 0; i < tagLength; i++) - { - if ((tempStore[i]&0xff) == (tagStore[i]&0xff)) - continue; - else - { - return false; - } - } - } - - /* Decrypt the packet using Counter Mode encryption*/ - if (policy.getEncType() == SRTPPolicy.AESCM_ENCRYPTION || - policy.getEncType() == SRTPPolicy.TWOFISH_ENCRYPTION) - { - processPacketAESCM(pkt); - } - - /* Decrypt the packet using F8 Mode encryption*/ - else if (policy.getEncType() == SRTPPolicy.AESF8_ENCRYPTION || - policy.getEncType() == SRTPPolicy.TWOFISHF8_ENCRYPTION) - { - processPacketAESF8(pkt); - } - - update(seqNo, guessedIndex); - - return true; - } - - /** - * Perform Counter Mode AES encryption / decryption - * @param pkt the RTP packet to be encrypted / decrypted - */ - public void processPacketAESCM(RawPacket pkt) - { - long ssrc = pkt.getSSRC(); - int seqNo = pkt.getSequenceNumber(); - long index = ((long) this.roc << 16) | seqNo; - - // byte[] iv = new byte[16]; - ivStore[0] = saltKey[0]; - ivStore[1] = saltKey[1]; - ivStore[2] = saltKey[2]; - ivStore[3] = saltKey[3]; - - int i; - for (i = 4; i < 8; i++) - { - ivStore[i] = (byte) - ( - (0xFF & (ssrc >> ((7 - i) * 8))) - ^ - this.saltKey[i] - ); - } - - for (i = 8; i < 14; i++) - { - ivStore[i] = (byte) - ( - (0xFF & (byte) (index >> ((13 - i) * 8))) - ^ - this.saltKey[i] - ); - } - - ivStore[14] = ivStore[15] = 0; - - final int payloadOffset = pkt.getHeaderLength(); - final int payloadLength = pkt.getPayloadLength(); - - cipherCtr.process(cipher, pkt.getBuffer(), pkt.getOffset() + - payloadOffset, payloadLength, ivStore); - } - - /** - * Perform F8 Mode AES encryption / decryption - * - * @param pkt the RTP packet to be encrypted / decrypted - */ - public void processPacketAESF8(RawPacket pkt) - { - // byte[] iv = new byte[16]; - - // 11 bytes of the RTP header are the 11 bytes of the iv - // the first byte of the RTP header is not used. - System.arraycopy(pkt.getBuffer(), pkt.getOffset(), ivStore, 0, 12); - ivStore[0] = 0; - - // set the ROC in network order into IV - ivStore[12] = (byte) (this.roc >> 24); - ivStore[13] = (byte) (this.roc >> 16); - ivStore[14] = (byte) (this.roc >> 8); - ivStore[15] = (byte) this.roc; - - final int payloadOffset = pkt.getHeaderLength(); - final int payloadLength = pkt.getPayloadLength(); - - SRTPCipherF8.process(cipher, pkt.getBuffer(), pkt.getOffset() + payloadOffset, - payloadLength, ivStore, cipherF8); - } - - /** - * Authenticate a packet. - * Calculated authentication tag is returned. - * - * @param pkt the RTP packet to be authenticated - * @param rocIn Roll-Over-Counter - */ - private void authenticatePacketHMCSHA1(RawPacket pkt, int rocIn) - { - mac.update(pkt.getBuffer(), pkt.getOffset(), pkt.getLength()); - // byte[] rb = new byte[4]; - rbStore[0] = (byte) (rocIn >> 24); - rbStore[1] = (byte) (rocIn >> 16); - rbStore[2] = (byte) (rocIn >> 8); - rbStore[3] = (byte) rocIn; - mac.update(rbStore, 0, rbStore.length); - mac.doFinal(tagStore, 0); - } - - /** - * Checks if a packet is a replayed on based on its sequence number. - * - * This method supports a 64 packet history relative the the given - * sequence number. - * - * Sequence Number is guaranteed to be real (not faked) through - * authentication. - * - * @param seqNo sequence number of the packet - * @param guessedIndex guessed roc - * @return true if this sequence number indicates the packet is not a - * replayed one, false if not - */ - boolean checkReplay(int seqNo, long guessedIndex) - { - // compute the index of previously received packet and its - // delta to the new received packet - long localIndex = (((long) this.roc) << 16) | this.seqNum; - long delta = guessedIndex - localIndex; - - if (delta > 0) - { - /* Packet not yet received */ - return true; - } - else - { - if (-delta > REPLAY_WINDOW_SIZE) { - /* Packet too old */ - return false; - } - else - { - if (((this.replayWindow >> (-delta)) & 0x1) != 0) - { - /* Packet already received ! */ - return false; - } - else - { - /* Packet not yet received */ - return true; - } - } - } - } - - /** - * Compute the initialization vector, used later by encryption algorithms, - * based on the lable, the packet index, key derivation rate and master - * salt key. - * - * @param label label specified for each type of iv - * @param index 48bit RTP packet index - */ - private void computeIv(long label, long index) - { - long key_id; - - if (keyDerivationRate == 0) - { - key_id = label << 48; - } - else - { - key_id = ((label << 48) | (index / keyDerivationRate)); - } - for (int i = 0; i < 7; i++) - { - ivStore[i] = masterSalt[i]; - } - for (int i = 7; i < 14; i++) - { - ivStore[i] = (byte) - ( - (byte) (0xFF & (key_id >> (8 * (13 - i)))) - ^ - masterSalt[i] - ); - } - ivStore[14] = ivStore[15] = 0; - } - - /** - * Derives the srtp session keys from the master key - * - * @param index - * the 48 bit SRTP packet index - */ - public void deriveSrtpKeys(long index) - { - // compute the session encryption key - long label = 0; - computeIv(label, index); - - KeyParameter encryptionKey = new KeyParameter(masterKey); - cipher.init(true, encryptionKey); - Arrays.fill(masterKey, (byte)0); - - cipherCtr.getCipherStream(cipher, encKey, policy.getEncKeyLength(), ivStore); - - // compute the session authentication key - if (authKey != null) - { - label = 0x01; - computeIv(label, index); - cipherCtr.getCipherStream(cipher, authKey, - policy.getAuthKeyLength(), ivStore); - - switch ((policy.getAuthType())) - { - case SRTPPolicy.HMACSHA1_AUTHENTICATION: - KeyParameter key = new KeyParameter(authKey); - mac.init(key); - break; - - case SRTPPolicy.SKEIN_AUTHENTICATION: - // Skein MAC uses number of bits as MAC size, not just bytes - ParametersForSkein pfs = new ParametersForSkein( - new KeyParameter(authKey), - ParametersForSkein.Skein512, tagStore.length*8); - mac.init(pfs); - break; - } - } - Arrays.fill(authKey, (byte)0); - - // compute the session salt - label = 0x02; - computeIv(label, index); - cipherCtr.getCipherStream(cipher, saltKey, policy.getSaltKeyLength(), ivStore); - Arrays.fill(masterSalt, (byte)0); - - // As last step: initialize cipher with derived encryption key. - if (cipherF8 != null) - SRTPCipherF8.deriveForIV(cipherF8, encKey, saltKey); - encryptionKey = new KeyParameter(encKey); - cipher.init(true, encryptionKey); - Arrays.fill(encKey, (byte)0); - } - - /** - * Compute (guess) the new SRTP index based on the sequence number of a - * received RTP packet. - * - * @param seqNo sequence number of the received RTP packet - * @return the new SRTP packet index - */ - private long guessIndex(int seqNo) - { - if (this.seqNum < 32768) - { - if (seqNo - this.seqNum > 32768) - { - guessedROC = roc - 1; - } - else - { - guessedROC = roc; - } - } - else - { - if (seqNum - 32768 > seqNo) - { - guessedROC = roc + 1; - } - else - { - guessedROC = roc; - } - } - - return ((long) guessedROC) << 16 | seqNo; - } - - /** - * Update the SRTP packet index. - * - * This method is called after all checks were successful. - * See section 3.3.1 in RFC3711 for detailed description. - * - * @param seqNo sequence number of the accepted packet - * @param guessedIndex guessed roc - */ - private void update(int seqNo, long guessedIndex) - { - long delta = guessedIndex - (((long) this.roc) << 16 | this.seqNum); - - /* update the replay bit mask */ - if( delta > 0 ) - { - replayWindow = replayWindow << delta; - replayWindow |= 1; - } - else - { - replayWindow |= ( 1 << delta ); - } - - if (seqNo > seqNum) - { - seqNum = seqNo & 0xffff; - } - if (this.guessedROC > this.roc) - { - roc = guessedROC; - seqNum = seqNo & 0xffff; - } - } - - /** - * Derive a new SRTPCryptoContext for use with a new SSRC - * - * This method returns a new SRTPCryptoContext initialized with the data of - * this SRTPCryptoContext. Replacing the SSRC, Roll-over-Counter, and the - * key derivation rate the application cab use this SRTPCryptoContext to - * encrypt / decrypt a new stream (Synchronization source) inside one RTP - * session. - * - * Before the application can use this SRTPCryptoContext it must call the - * deriveSrtpKeys method. - * - * @param ssrc - * The SSRC for this context - * @param roc - * The Roll-Over-Counter for this context - * @param deriveRate - * The key derivation rate for this context - * @return a new SRTPCryptoContext with all relevant data set. - */ - public SRTPCryptoContext deriveContext(long ssrc, int roc, long deriveRate) - { - SRTPCryptoContext pcc = null; - pcc = new SRTPCryptoContext(ssrc, roc, deriveRate, masterKey, - masterSalt, policy); - return pcc; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPPolicy.java b/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPPolicy.java deleted file mode 100644 index 99d3f2e79..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPPolicy.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.srtp; - -/** - * SRTPPolicy holds the SRTP encryption / authentication policy of a SRTP - * session. - * - * @author Bing SU (nova.su@gmail.com) - */ -public class SRTPPolicy -{ - /** - * Null Cipher, does not change the content of RTP payload - */ - public final static int NULL_ENCRYPTION = 0; - - /** - * Counter Mode AES Cipher, defined in Section 4.1.1, RFC3711 - */ - public final static int AESCM_ENCRYPTION = 1; - - /** - * Counter Mode TwoFish Cipher - */ - public final static int TWOFISH_ENCRYPTION = 3; - - /** - * F8 mode AES Cipher, defined in Section 4.1.2, RFC 3711 - */ - public final static int AESF8_ENCRYPTION = 2; - - /** - * F8 Mode TwoFish Cipher - */ - public final static int TWOFISHF8_ENCRYPTION = 4; - /** - * Null Authentication, no authentication - */ - public final static int NULL_AUTHENTICATION = 0; - - /** - * HAMC SHA1 Authentication, defined in Section 4.2.1, RFC3711 - */ - public final static int HMACSHA1_AUTHENTICATION = 1; - - /** - * Skein Authentication - */ - public final static int SKEIN_AUTHENTICATION = 2; - - /** - * SRTP encryption type - */ - private int encType; - - /** - * SRTP encryption key length - */ - private int encKeyLength; - - /** - * SRTP authentication type - */ - private int authType; - - /** - * SRTP authentication key length - */ - private int authKeyLength; - - /** - * SRTP authentication tag length - */ - private int authTagLength; - - /** - * SRTP salt key length - */ - private int saltKeyLength; - - /** - * Construct a SRTPPolicy object based on given parameters. - * This class acts as a storage class, so all the parameters are passed in - * through this constructor. - * - * @param encType SRTP encryption type - * @param encKeyLength SRTP encryption key length - * @param authType SRTP authentication type - * @param authKeyLength SRTP authentication key length - * @param authTagLength SRTP authentication tag length - * @param saltKeyLength SRTP salt key length - */ - public SRTPPolicy(int encType, - int encKeyLength, - int authType, - int authKeyLength, - int authTagLength, - int saltKeyLength) - { - this.encType = encType; - this.encKeyLength = encKeyLength; - this.authType = authType; - this.authKeyLength = authKeyLength; - this.authTagLength = authTagLength; - this.saltKeyLength = saltKeyLength; - } - - /** - * Get the authentication key length - * - * @return the authentication key length - */ - public int getAuthKeyLength() - { - return this.authKeyLength; - } - - /** - * Set the authentication key length - * - * @param authKeyLength the authentication key length - */ - public void setAuthKeyLength(int authKeyLength) - { - this.authKeyLength = authKeyLength; - } - - /** - * Get the authentication tag length - * - * @return the authentication tag length - */ - public int getAuthTagLength() - { - return this.authTagLength; - } - - /** - * Set the authentication tag length - * - * @param authTagLength the authentication tag length - */ - public void setAuthTagLength(int authTagLength) - { - this.authTagLength = authTagLength; - } - - /** - * Get the authentication type - * - * @return the authentication type - */ - public int getAuthType() - { - return this.authType; - } - - /** - * Set the authentication type - * - * @param authType the authentication type - */ - public void setAuthType(int authType) - { - this.authType = authType; - } - - /** - * Get the encryption key length - * - * @return the encryption key length - */ - public int getEncKeyLength() - { - return this.encKeyLength; - } - - /** - * Set the encryption key length - * - * @param encKeyLength the encryption key length - */ - public void setEncKeyLength(int encKeyLength) - { - this.encKeyLength = encKeyLength; - } - - /** - * Get the encryption type - * - * @return the encryption type - */ - public int getEncType() - { - return this.encType; - } - - /** - * Set the encryption type - * - * @param encType encryption type - */ - public void setEncType(int encType) - { - this.encType = encType; - } - - /** - * Get the salt key length - * - * @return the salt key length - */ - public int getSaltKeyLength() - { - return this.saltKeyLength; - } - - /** - * Set the salt key length - * - * @param keyLength the salt key length - */ - public void setSaltKeyLength(int keyLength) - { - this.saltKeyLength = keyLength; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPTransformEngine.java b/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPTransformEngine.java deleted file mode 100644 index 90fe713ad..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPTransformEngine.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.srtp; - -import net.java.sip.communicator.impl.neomedia.transform.*; - -/** - * SRTPTransformEngine class implements TransformEngine interface. - * It stores important information / objects regarding SRTP processing. - * Through SRTPTransformEngine, we can get the needed PacketTransformer, which - * will be used by abstract TransformConnector classes. - * - * @author Bing SU (nova.su@gmail.com) - * - */ -public class SRTPTransformEngine - implements TransformEngine -{ - /** - * The default SRTPCryptoContext, which will be used to derivate other - * contexts. - */ - private SRTPCryptoContext defaultContext; - - /** - * The default SRTPCryptoContext, which will be used to derive other - * contexts. - */ - private SRTCPCryptoContext defaultContextControl; - - /** - * Construct a SRTPTransformEngine based on given master encryption key, - * master salt key and SRTP/SRTCP policy. - * - * @param masterKey the master encryption key - * @param masterSalt the master salt key - * @param srtpPolicy SRTP policy - * @param srtcpPolicy SRTCP policy - */ - public SRTPTransformEngine(byte[] masterKey, byte[] masterSalt, - SRTPPolicy srtpPolicy, SRTPPolicy srtcpPolicy) - { - - defaultContext = new SRTPCryptoContext(0, 0, 0, - masterKey, - masterSalt, - srtpPolicy); - defaultContextControl = new SRTCPCryptoContext(0, - masterKey, - masterSalt, - srtcpPolicy); - } - - /** - * Close the transformer engine. - * - * The close functions closes all stored default crypto contexts. This - * deletes key data and forces a cleanup of the crypto contexts. - */ - public void close() - { - if (defaultContext != null) - defaultContext.close(); - if (defaultContextControl != null) - defaultContextControl.close(); - - defaultContext = null; - defaultContextControl = null; - } - - /** - * Gets the PacketTransformer for RTCP packets. - * - * @return the PacketTransformer for RTCP packets - */ - public PacketTransformer getRTCPTransformer() - { - return new SRTCPTransformer(this); - } - - /* - * (non-Javadoc) - * @see net.java.sip.communicator.impl.media.transform. - * TransformEngine#getRTPTransformer() - */ - public PacketTransformer getRTPTransformer() - { - return new SRTPTransformer(this); - } - - /** - * Get the default SRTPCryptoContext - * - * @return the default SRTPCryptoContext - */ - public SRTPCryptoContext getDefaultContext() - { - return this.defaultContext; - } - - /** - * Get the default SRTPCryptoContext - * - * @return the default SRTPCryptoContext - */ - public SRTCPCryptoContext getDefaultContextControl() - { - return this.defaultContextControl; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPTransformer.java b/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPTransformer.java deleted file mode 100644 index eddfda8f9..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/srtp/SRTPTransformer.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - * - * Some of the code in this class is derived from ccRtp's SRTP implementation, - * which has the following copyright notice: - * - Copyright (C) 2004-2006 the Minisip Team - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package net.java.sip.communicator.impl.neomedia.transform.srtp; - -import java.util.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.transform.*; - -/** - * SRTPTransformer implements PacketTransformer and provides implementations - * for RTP packet to SRTP packet transformation and SRTP packet to RTP packet - * transformation logic. - * - * It will first find the corresponding SRTPCryptoContext for each packet based - * on their SSRC and then invoke the context object to perform the - * transformation and reverse transformation operation. - * - * @author Bing SU (nova.su@gmail.com) - */ -public class SRTPTransformer - implements PacketTransformer -{ - private final SRTPTransformEngine forwardEngine; - private final SRTPTransformEngine reverseEngine; - - /** - * All the known SSRC's corresponding SRTPCryptoContexts - */ - private final Hashtable contexts; - - /** - * Initializes a new SRTPTransformer instance. - * - * @param engine the SRTPTransformEngine to be used by the new - * instance for both directions - */ - public SRTPTransformer(SRTPTransformEngine engine) - { - this(engine, engine); - } - - /** - * Constructs a SRTPTransformer object. - * - * @param forwardEngine The associated SRTPTransformEngine object for - * forward transformations. - * @param reverseEngine The associated SRTPTransformEngine object for - * reverse transformations. - */ - public SRTPTransformer( - SRTPTransformEngine forwardEngine, - SRTPTransformEngine reverseEngine) - { - this.forwardEngine = forwardEngine; - this.reverseEngine = reverseEngine; - this.contexts = new Hashtable(); - } - - /** - * Closes this SRTPTransformer and the underlying transform - * engines.It closes all stored crypto contexts. It deletes key data and - * forces a cleanup of the crypto contexts. - */ - public void close() - { - synchronized (contexts) - { - forwardEngine.close(); - if (reverseEngine != forwardEngine) - reverseEngine.close(); - - Iterator> iter - = contexts.entrySet().iterator(); - - while (iter.hasNext()) - { - Map.Entry entry = iter.next(); - SRTPCryptoContext context = entry.getValue(); - - iter.remove(); - if (context != null) - context.close(); - } - } - } - - private SRTPCryptoContext getContext( - long ssrc, - SRTPTransformEngine engine, - int deriveSrtpKeysIndex) - { - SRTPCryptoContext context; - - synchronized (contexts) - { - context = contexts.get(ssrc); - if (context == null) - { - context = engine.getDefaultContext(); - if (context != null) - { - context = context.deriveContext(ssrc, 0, 0); - context.deriveSrtpKeys(deriveSrtpKeysIndex); - contexts.put(ssrc, context); - } - } - } - - return context; - } - - /** - * Reverse-transforms a specific packet (i.e. transforms a transformed - * packet back). - * - * @param pkt the transformed packet to be restored - * @return the restored packet - */ - public RawPacket reverseTransform(RawPacket pkt) - { - // only accept RTP version 2 (SNOM phones send weird packages when on - // hold, ignore them with this check (RTP Version must be equal to 2) - if((pkt.readByte(0) & 0xC0) != 0x80) - return null; - - SRTPCryptoContext context - = getContext(pkt.getSSRC(), reverseEngine, pkt.getSequenceNumber()); - - return - ((context != null) && context.reverseTransformPacket(pkt)) - ? pkt - : null; - } - - /** - * Transforms a specific packet. - * - * @param pkt the packet to be transformed - * @return the transformed packet - */ - public RawPacket transform(RawPacket pkt) - { - SRTPCryptoContext context = getContext(pkt.getSSRC(), forwardEngine, 0); - - context.transformPacket(pkt); - return pkt; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/zrtp/SecurityEventManager.java b/src/net/java/sip/communicator/impl/neomedia/transform/zrtp/SecurityEventManager.java deleted file mode 100644 index 71aa2a3d4..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/zrtp/SecurityEventManager.java +++ /dev/null @@ -1,467 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.zrtp; - -import gnu.java.zrtp.*; - -import java.util.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.service.neomedia.event.*; -import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -/** - * The user callback class for ZRTP4J. - * - * This class constructs and sends events to the ZRTP GUI implementation. The - * showMessage() function implements a specific check to start - * associated ZRTP multi-stream sessions. - * - * Coordinate this callback class with the associated GUI implementation class - * - * @see net.java.sip.communicator.impl.gui.main.call.ZrtpSecurityPanel - * - * @author Emanuel Onica - * @author Werner Dittmann - * @author Yana Stamcheva - */ -public class SecurityEventManager extends ZrtpUserCallback -{ - /** - * Our class logger. - */ - private static final Logger logger - = Logger.getLogger(SecurityEventManager.class); - - /** - * A warning String that we display to the user. - */ - public static final String WARNING_NO_RS_MATCH = - getI18NString("impl.media.security.WARNING_NO_RS_MATCH", null); - - /** - * A warning String that we display to the user. - */ - public static final String WARNING_NO_EXPECTED_RS_MATCH = - getI18NString("impl.media.security.WARNING_NO_EXPECTED_RS_MATCH", null); - - /** - * Indicates an audio session type. - */ - public static final int AUDIO_SESSION = - CallPeerSecurityStatusEvent.AUDIO_SESSION; - - /** - * Indicates a video session type. - */ - public static final int VIDEO_SESSION = - CallPeerSecurityStatusEvent.VIDEO_SESSION; - - /** - * The zrtp control that this manager is associated with. - */ - private final ZrtpControlImpl zrtpControl; - - /** - * A callback to the instance that created us. - */ - private SrtpListener securityListener; - - /** - * Is this a ZRTP DH (Master) session? - */ - private boolean isDHSession = false; - - /** - * Type of session - */ - private int sessionType; - - /** - * SAS string. - */ - private String sas; - - /** - * Cipher. - */ - private String cipher; - - /** - * Indicates if the SAS has already been verified in a previous session. - */ - private boolean isSasVerified; - - /** - * The class constructor. - * - * @param zrtpControl that this manager is to be associated with. - */ - public SecurityEventManager(ZrtpControlImpl zrtpControl) - { - this.zrtpControl = zrtpControl; - this.securityListener = zrtpControl.getSrtpListener(); - } - - /** - * Set the type of this session. - * - * @param type the session type. The session type could be either - * AUDIO_SESSION or VIDEO_SESSION. - */ - public void setSessionType(int type) - { - sessionType = type; - } - - /** - * Set the DH session flag. - * - * @param isDHSession the DH session flag. - */ - public void setDHSession(boolean isDHSession) - { - this.isDHSession = isDHSession; - } - - /* - * The following methods implement the ZrtpUserCallback interface - */ - - /** - * Reports the security algorithm that the ZRTP protocol negotiated. - * - * @param cipher the cipher - */ - @Override - public void secureOn(String cipher) - { - if (logger.isDebugEnabled()) - logger.debug(sessionTypeToString(sessionType) - + ": cipher enabled: " + cipher); - - this.cipher = cipher; - } - - /** - * ZRTP computes the SAS string after nearly all the negotiation - * and computations are done internally. - * - * @param sas The string containing the SAS. - * @param isVerified is sas verified. - */ - @Override - public void showSAS(String sas, boolean isVerified) - { - if (logger.isDebugEnabled()) - logger.debug(sessionTypeToString(sessionType) + ": SAS is: " + sas); - - this.sas = sas; - this.isSasVerified = isVerified; - } - - /** - * Show some information to user. - * ZRTP calls this method to display some information to the user. - * Along with the message ZRTP provides a severity indicator that defines: - * Info, Warning, Error, and Alert. - * @param sev severity of the message. - * @param subCode the message code. - */ - @Override - public void showMessage(ZrtpCodes.MessageSeverity sev, - EnumSet subCode) - { - int multiStreams = 0; - - Iterator ii = subCode.iterator(); - Object msgCode = ii.next(); - - String message = null; - String i18nMessage = null; - int severity = 0; - - boolean sendEvent = true; - - if (msgCode instanceof ZrtpCodes.InfoCodes) - { - ZrtpCodes.InfoCodes inf = (ZrtpCodes.InfoCodes) msgCode; - - // Use the following fields if INFORMATION type messages shall be - // shown to the user via SecurityMessageEvent, i.e. if - // sendEvent is set to true - // severity = CallPeerSecurityMessageEvent.INFORMATION; - - // Don't spam user with info messages, only internal processing - // or logging. - sendEvent = false; - - // If the ZRTP Master session (DH mode) signals "security on" - // then start multi-stream sessions. - // Signal SAS to GUI only if this is a DH mode session. - // Multi-stream session don't have own SAS data - if (inf == ZrtpCodes.InfoCodes.InfoSecureStateOn) - { - if (isDHSession) - { - securityListener.securityTurnedOn( - sessionType, cipher, - zrtpControl); - } - else - { - securityListener.securityTurnedOn(sessionType, cipher, - zrtpControl); - } - } - } - else if (msgCode instanceof ZrtpCodes.WarningCodes) - { - // Warning codes usually do not affect encryption or security. Only - // in few cases inform the user and ask to verify SAS. - ZrtpCodes.WarningCodes warn = (ZrtpCodes.WarningCodes) msgCode; - severity = CallPeerSecurityMessageEvent.WARNING; - - if (warn == ZrtpCodes.WarningCodes.WarningNoRSMatch) - { - message = "No retained shared secret available."; - i18nMessage = WARNING_NO_RS_MATCH; - } - else if (warn == ZrtpCodes.WarningCodes.WarningNoExpectedRSMatch) - { - message = "An expected retained shared secret is missing."; - i18nMessage = WARNING_NO_EXPECTED_RS_MATCH; - } - else if (warn == ZrtpCodes.WarningCodes.WarningCRCmismatch) - { - message = "Internal ZRTP packet checksum mismatch."; - i18nMessage = getI18NString( - "impl.media.security.CHECKSUM_MISMATCH", null); - } - else - { - // Other warnings are internal only, no user action required - sendEvent = false; - } - } - else if (msgCode instanceof ZrtpCodes.SevereCodes) - { - ZrtpCodes.SevereCodes severe = (ZrtpCodes.SevereCodes) msgCode; - severity = CallPeerSecurityMessageEvent.SEVERE; - - if (severe == ZrtpCodes.SevereCodes.SevereCannotSend) - { - message = "Failed to send data." - + "Internet data connection or peer is down."; - i18nMessage =getI18NString( - "impl.media.security.DATA_SEND_FAILED", msgCode.toString()); - } - else if (severe == ZrtpCodes.SevereCodes.SevereTooMuchRetries) - { - message = "Too much retries during ZRTP negotiation."; - i18nMessage = getI18NString( - "impl.media.security.RETRY_RATE_EXCEEDED", - msgCode.toString()); - } - else if (severe == ZrtpCodes.SevereCodes.SevereProtocolError) - { - message = "Internal protocol error occured."; - i18nMessage = getI18NString( - "impl.media.security.INTERNAL_PROTOCOL_ERROR", - msgCode.toString()); - } - else - { - message = "General error has occurred."; - i18nMessage = getI18NString( - "impl.media.security.ZRTP_GENERIC_MSG", - msgCode.toString()); - } - } - else if (msgCode instanceof ZrtpCodes.ZrtpErrorCodes) - { - severity = CallPeerSecurityMessageEvent.ERROR; - - message = "Indicates compatibility problems like for example:" - + "unsupported protocol version, unsupported hash type," - + "cypher type, SAS scheme, etc."; - i18nMessage = getI18NString( - "impl.media.security.ZRTP_GENERIC_MSG", - msgCode.toString()); - } - else - { - // Other warnings are internal only, no user action required - sendEvent = false; - } - - if (sendEvent) - securityListener - .securityMessageReceived(message, i18nMessage, severity); - - if (logger.isDebugEnabled()) - logger.debug(sessionTypeToString(sessionType) + ": " - + "ZRTP message: severity: " + sev + ", sub code: " + msgCode - + ", DH session: " + isDHSession + ", multi: " + multiStreams); - } - - /** - * Negotiation has failed. - * - * @param severity of the message. - * @param subCode the message code. - */ - @Override - public void zrtpNegotiationFailed( ZrtpCodes.MessageSeverity severity, - EnumSet subCode) - { - Iterator ii = subCode.iterator(); - Object msgCode = ii.next(); - - if (logger.isDebugEnabled()) - logger.debug(sessionTypeToString(sessionType) - + ": ZRTP key negotiation failed, sub code: " + msgCode); - } - - /** - * Inform user interface that security is not active any more. - */ - @Override - public void secureOff() - { - if (logger.isDebugEnabled()) - logger.debug(sessionTypeToString(sessionType) + ": Security off"); - - securityListener.securityTurnedOff(sessionType); - } - - /** - * The other part does not support zrtp. - */ - @Override - public void zrtpNotSuppOther() - { - if (logger.isDebugEnabled()) - logger.debug(sessionTypeToString(sessionType) - + ": Other party does not support ZRTP key negotiation protocol," - + " no secure calls possible."); - - securityListener.securityTimeout(sessionType); - } - - /** - * Inform the user that ZRTP received "go clear" message from its peer. - */ - @Override - public void confirmGoClear() - { - if (logger.isDebugEnabled()) - logger.debug(sessionTypeToString(sessionType) - + ": GoClear confirmation requested."); - } - - /** - * Converts the sessionType into into a String. - * - * @param sessionType one of the - * CallPeerSecurityStatusEvent.XXX_SESSION fields - * - * @return a String representation of sessionType. - */ - private String sessionTypeToString(int sessionType) - { - switch (sessionType) - { - case AUDIO_SESSION: - return "AUDIO_SESSION"; - case VIDEO_SESSION: - return "VIDEO_SESSION"; - default: - throw new IllegalArgumentException("sessionType"); - } - } - - /** - * Gets the localized message and replace the param. If the param is null - * we ignore it. - * - * @param key the key for the localized message. - * @param param the param to replace. - * @return the i18n message. - */ - private static String getI18NString(String key, String param) - { - ResourceManagementService resources = NeomediaActivator.getResources(); - - if (resources == null) - return null; - else - { - String[] params = (param == null) ? null : new String[] { param }; - - return resources.getI18NString(key, params); - } - } - - /** - * Sets a new receiver of the security callback events. - * @param securityListener An object that receives the security events. - */ - public void setSrtpListener(SrtpListener securityListener) - { - this.securityListener = securityListener; - } - - /** - * Gets the SAS for the current media stream. - * - * @return the four character ZRTP SAS. - */ - public String getSecurityString() - { - return sas; - } - - /** - * Gets the cipher information for the current media stream. - * - * @return the cipher information string. - */ - public String getCipherString() - { - return cipher; - } - - /** - * Gets the status of the SAS verification. - * - * @return true when the SAS has been verified. - */ - public boolean isSecurityVerified() - { - return isSasVerified; - } - - /** - * Indicates that we started the process of securing the the connection. - */ - public void securityNegotiationStarted() - { - // make sure we don't throw any exception - try - { - this.securityListener - .securityNegotiationStarted(sessionType, zrtpControl); - } - catch(Throwable t) - { - logger.error("Error processing security started."); - } - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/zrtp/ZRTCPTransformer.java b/src/net/java/sip/communicator/impl/neomedia/transform/zrtp/ZRTCPTransformer.java deleted file mode 100644 index cb621ec6f..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/zrtp/ZRTCPTransformer.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.zrtp; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.transform.*; - -/** - * PacketTransformer that delegates the forward/reverse transformation of - * packets to different packet transformers. - * - * @author Werner Dittmann - */ -public class ZRTCPTransformer - implements PacketTransformer -{ - /** - * We support different SRTCP contexts for input and output traffic: - * - * Transform() uses the srtcpOut to perform encryption - * reverseTransform() uses srtcpIn to perform decryption - */ - private PacketTransformer srtcpIn = null; - private PacketTransformer srtcpOut = null; - - /** - * Close the transformer engine. - * - * The close functions closes all stored default crypto contexts. This deletes key data - * and forces a cleanup of the crypto contexts. - */ - public void close() - { - if (srtcpOut != null) - { - srtcpOut.close(); - srtcpOut = null; - } - if (srtcpIn != null) - { - srtcpIn.close(); - srtcpIn = null; - } - } - /** - * Encrypt a SRTCP packet - * - * Currently SRTCP packet encryption / decryption is not supported - * So this method does not change the packet content - * - * @param pkt plain SRTCP packet to be encrypted - * @return encrypted SRTCP packet - */ - public RawPacket transform(RawPacket pkt) - { - if (srtcpOut == null) - { - return pkt; - } - return srtcpOut.transform(pkt); - } - - /** - * Decrypt a SRTCP packet - * - * Currently SRTCP packet encryption / decryption is not supported - * So this method does not change the packet content - * - * @param pkt encrypted SRTCP packet to be decrypted - * @return decrypted SRTCP packet - */ - public RawPacket reverseTransform(RawPacket pkt) - { - if (srtcpIn == null) - { - return pkt; - } - return srtcpIn.reverseTransform(pkt); - } - - /** - * @param srtcpIn the srtcpIn to set - */ - public void setSrtcpIn(PacketTransformer srtcpIn) - { - this.srtcpIn = srtcpIn; - } - - /** - * @param srtcpOut the srtcpOut to set - */ - public void setSrtcpOut(PacketTransformer srtcpOut) - { - this.srtcpOut = srtcpOut; - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/zrtp/ZRTPTransformEngine.java b/src/net/java/sip/communicator/impl/neomedia/transform/zrtp/ZRTPTransformEngine.java deleted file mode 100644 index 0981397d8..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/zrtp/ZRTPTransformEngine.java +++ /dev/null @@ -1,1482 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.zrtp; - -import gnu.java.zrtp.*; -import gnu.java.zrtp.zidfile.*; - -import java.io.*; -import java.util.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.impl.neomedia.transform.*; -import net.java.sip.communicator.impl.neomedia.transform.srtp.*; -import net.java.sip.communicator.service.fileaccess.*; -import net.java.sip.communicator.util.*; - -/** - * JMF extension/connector to support GNU ZRTP4J. - * - * ZRTP was developed by Phil Zimmermann and provides functions to negotiate - * keys and other necessary data (crypto data) to set-up the Secure RTP (SRTP) - * crypto context. Refer to Phil's ZRTP specification at his - * Zfone project site to get more - * detailed information about the capabilities of ZRTP. - * - *

Short overview of the ZRTP4J implementation

- * - * ZRTP is a specific protocol to negotiate encryption algorithms and the - * required key material. ZRTP uses a RTP session to exchange its protocol - * messages. - * - * A complete GNU ZRTP4J implementation consists of two parts, the GNU ZRTP4J - * core and specific code that binds the GNU ZRTP core to the underlying - * RTP/SRTP stack and the operating system: - *
    - *
  • The GNU ZRTP core is independent of a specific RTP/SRTP stack and the - * operating system and consists of the ZRTP protocol state engine, the ZRTP - * protocol messages, and the GNU ZRTP4J engine. The GNU ZRTP4J engine provides - * methods to setup ZRTP message and to analyze received ZRTP messages, to - * compute the crypto data required for SRTP, and to maintain the required - * hashes and HMAC.
  • - *
  • The second part of an implementation is specific glue code - * the binds the GNU ZRTP core to the actual RTP/SRTP implementation and other - * operating system specific services such as timers.
  • - *
- * - * The GNU ZRTP4J core uses a callback interface class (refer to ZrtpCallback) - * to access RTP/SRTP or operating specific methods, for example to send data - * via the RTP/SRTP stack, to access timers, provide mutex handling, and to - * report events to the application. - * - *

The ZRTPTransformEngine

- * - * ZRTPTransformEngine implements code that is specific to the JMF - * implementation. - * - * To perform its tasks ZRTPTransformEngine - *
    - *
  • extends specific classes to hook into the JMF RTP methods and the - * RTP/SRTP send and receive queues
  • - *
  • implements the ZrtpCallback interface to provide to enable data send and - * receive other specific services (timer to GNU ZRTP4J
  • - *
  • provides ZRTP specific methods that applications may use to control and - * setup GNU ZRTP
  • - *
  • can register and use an application specific callback class (refer to - * ZrtpUserCallback)
  • - *
- * - * After instantiating a GNU ZRTP4J session (see below for a short example) - * applications may use the ZRTP specific methods of ZRTPTransformEngine to - * control and setup GNU ZRTP, for example enable or disable ZRTP processing or - * getting ZRTP status information. - * - * GNU ZRTP4J provides a ZrtpUserCallback class that an application may extend - * and register with ZRTPTransformEngine. GNU ZRTP4J and ZRTPTransformEngine use - * the ZrtpUserCallback methods to report ZRTP events to the application. The - * application may display this information to the user or act otherwise. - * - * The following figure depicts the relationships between ZRTPTransformEngine, - * JMF implementation, the GNU ZRTP4J core, and an application that provides an - * ZrtpUserCallback class. - * - *
- *
- *                  +---------------------------+
- *                  |  ZrtpTransformConnector   |
- *                  | extends TransformConnector|
- *                  | implements RTPConnector   |
- *                  +---------------------------+
- *                                |
- *                                | uses
- *                                |
- *  +----------------+      +-----+---------------+
- *  |  Application   |      |                     |      +----------------+
- *  |  instantiates  | uses | ZRTPTransformEngine | uses |                |
- *  | a ZRTP Session +------+    implements       +------+   GNU ZRTP4J   |
- *  |  and provides  |      |   ZrtpCallback      |      |      core      |
- *  |ZrtpUserCallback|      |                     |      | implementation |
- *  +----------------+      +---------------------+      |  (ZRtp et al)  |
- *                                                       |                |
- *                                                       +----------------+
- * 
- * - * The following short code snippets show how an application could instantiate a - * ZrtpTransformConnector, get the ZRTP4J engine and initialize it. Then the - * code get a RTP manager instance and initializes it with the - * ZRTPTransformConnector. Please note: setting the target must be done with the - * connector, not with the RTP manager. - * - *
- * ...
- *   transConnector = (ZrtpTransformConnector)TransformManager
- *                                                  .createZRTPConnector(sa);
- *   zrtpEngine = transConnector.getEngine();
- *   zrtpEngine.setUserCallback(new MyCallback());
- *   if (!zrtpEngine.initialize("test_t.zid"))
- *       System.out.println("iniatlize failed");
- *
- *   // initialize the RTPManager using the ZRTP connector
- *
- *   mgr = RTPManager.newInstance();
- *   mgr.initialize(transConnector);
- *
- *   mgr.addSessionListener(this);
- *   mgr.addReceiveStreamListener(this);
- *
- *   transConnector.addTarget(target);
- *   zrtpEngine.startZrtp();
- *
- *   ...
- * 
- * - * The demo folder contains a small example that shows how to use GNU - * ZRTP4J. - * - * This ZRTPTransformEngine documentation shows the ZRTP specific extensions and - * describes overloaded methods and a possible different behaviour. - * - * @author Werner Dittmann <Werner.Dittmann@t-online.de> - * - */ -public class ZRTPTransformEngine - implements TransformEngine, - PacketTransformer, - ZrtpCallback -{ - /** - * Very simple Timeout provider class. - * - * This very simple timeout provider can handle one timeout request at - * one time only. A second request would overwrite the first one and would - * lead to unexpected results. - * - * @author Werner Dittmann - */ - private class TimeoutProvider extends Thread - { - /** - * Constructs Timeout provider. - * @param name the name of the provider. - */ - public TimeoutProvider(String name) - { - super(name); - } - - /** - * The delay to wait before timeout. - */ - private long nextDelay = 0; - - /** - * Whether to execute the timeout if delay expires. - */ - private boolean newTask = false; - - /** - * Whether thread is stopped. - */ - private boolean stop = false; - - /** - * synchronizes delays and stop. - */ - private final Object sync = new Object(); - - /** - * Request timeout after the specified delay. - * @param delay the delay. - */ - public synchronized void requestTimeout(long delay) - { - synchronized (sync) - { - nextDelay = delay; - newTask = true; - sync.notifyAll(); - } - } - - /** - * Stops the thread. - */ - public void stopRun() - { - synchronized (sync) - { - stop = true; - sync.notifyAll(); - } - } - - /** - * Cancels the last request. - */ - public void cancelRequest() - { - synchronized (sync) - { - newTask = false; - sync.notifyAll(); - } - } - - /** - * The running part of the thread. - */ - @Override - public void run() - { - while (!stop) - { - synchronized (sync) - { - while (!newTask && !stop) - { - try - { - sync.wait(); - } - catch (InterruptedException e) - { - // e.printStackTrace(); - } - } - } - long currentTime = System.currentTimeMillis(); - long endTime = currentTime + nextDelay; - synchronized (sync) { - while ((currentTime < endTime) && newTask && !stop) - { - try - { - sync.wait(endTime - currentTime); - } - catch (InterruptedException e) - { - //e.printStackTrace(); - } - currentTime = System.currentTimeMillis(); - } - } - if (newTask && !stop) - { - newTask = false; - ZRTPTransformEngine.this.handleTimeout(); - } - } - } - } - - /** - * The logger. - */ - private static final Logger logger - = Logger.getLogger(ZRTPTransformEngine.class); - - /** - * Each ZRTP packet has a fixed header of 12 bytes. - */ - protected static final int ZRTP_PACKET_HEADER = 12; - - /** - * This is the connector, required to send ZRTP packets - * via the DatagramSocket. - */ - private AbstractRTPConnector zrtpConnector = null; - - /** - * We need Out SRTPTransformer to transform RTP to SRTP. - */ - private PacketTransformer srtpOutTransformer = null; - - /** - * We need In SRTPTransformer to transform SRTP to RTP. - */ - private PacketTransformer srtpInTransformer = null; - - /** - * User callback class. - */ - private SecurityEventManager securityEventManager = null; - - /** - * The ZRTP engine. - */ - private ZRtp zrtpEngine = null; - - /** - * ZRTP engine enable flag (used for auto-enable at initialization) - */ - private boolean enableZrtp = false; - - /** - * Client ID string initialized with the name of the ZRTP4j library - */ - private String clientIdString = ZrtpConstants.clientId; - - /** - * SSRC identifier for the ZRTP packets - */ - private int ownSSRC = 0; - - /** - * ZRTP packet sequence number - */ - private short senderZrtpSeqNo = 0; - - /** - * The timeout provider instance - * This is used for handling the ZRTP timers - */ - private TimeoutProvider timeoutProvider = null; - - /** - * The current condition of the ZRTP engine - */ - private boolean started = false; - - /** - * Sometimes we need to start muted so we will discard any packets during - * some time after the start of the transformer. This is needed when for - * this time we can receive encrypted packets but we hadn't established - * a secure communication. This happens when a secure stream is recreated. - */ - private boolean muted = false; - - private boolean mitmMode = false; - - /** - * Enable or disable paranoid mode. - * - * The Paranoid mode controls the behaviour and handling of the SAS verify - * flag. If Panaoid mode is set to flase then ZRtp applies the normal - * handling. If Paranoid mode is set to true then the handling is: - * - *
    - *
  • Force the SAS verify flag to be false at srtpSecretsOn() callback. - * This gives the user interface (UI) the indication to handle the SAS - * as not verified. See implementation note below.
  • - *
  • Don't set the SAS verify flag in the Confirm packets, - * thus the other also must report the SAS as not verified.
  • - *
  • ignore the SASVerified() function, thus do not set the - * SAS to verified in the ZRTP cache.
  • - *
  • Disable the Trusted PBX MitM feature. Just send the - * SASRelay packet but do not process the relayed data. - * This protects the user from a malicious "trusted PBX".
  • - *
- * ZRtp performs alls other steps during the ZRTP negotiations as usual, in - * particular it computes, compares, uses, and stores the retained secrets. - * This avoids unnecessary warning messages. The user may enable or disable - * the Paranoid mode on a call-by-call basis without breaking the key - * continuity data. - * - * Implementation note:
- * An application shall always display the SAS code if the SAS verify flag - * is false. The application shall also use mechanisms to - * remind the user to compare the SAS code, for example useing larger fonts, - * different colours and other display features. - */ - private boolean enableParanoidMode = false; - - private ZRTCPTransformer zrtcpTransformer = null; - - /** - * Construct a ZRTPTransformEngine. - * - */ - public ZRTPTransformEngine() - { - senderZrtpSeqNo = 1; // should be a random number - } - - /** - * Returns an instance of ZRTPCTransformer. - * - * @see TransformEngine#getRTCPTransformer() - */ - public ZRTCPTransformer getRTCPTransformer() - { - if(zrtcpTransformer == null) - zrtcpTransformer = new ZRTCPTransformer(); - return zrtcpTransformer; - } - - /** - * Returns this RTPTransformer. - * - * @see TransformEngine#getRTPTransformer() - */ - public PacketTransformer getRTPTransformer() - { - return this; - } - - /** - * Engine initialization method. - * Calling this for engine initialization and start it with auto-sensing - * and a given configuration setting. - * - * @param zidFilename The ZID file name - * @param config The configuration data - * @return true if initialization fails, false if succeeds - */ - public boolean initialize(String zidFilename, ZrtpConfigure config) - { - return initialize(zidFilename, true, config); - } - - /** - * Engine initialization method. - * Calling this for engine initialization and start it with defined - * auto-sensing and a default configuration setting. - * - * @param zidFilename The ZID file name - * @param autoEnable If true start with auto-sensing mode. - * @return true if initialization fails, false if succeeds - */ - public boolean initialize(String zidFilename, boolean autoEnable) - { - return initialize(zidFilename, autoEnable, null); - } - - /** - * Default engine initialization method. - * - * Calling this for engine initialization and start it with auto-sensing - * and default configuration setting. - * - * @param zidFilename The ZID file name - * @return true if initialization fails, false if succeeds - */ - public boolean initialize(String zidFilename) - { - return initialize(zidFilename, true, null); - } - - /** - * Custom engine initialization method. - * This allows to explicit specify if the engine starts with auto-sensing - * or not. - * - * @param zidFilename The ZID file name - * @param autoEnable Set this true to start with auto-sensing and false to - * disable it. - * @param config the zrtp config to use - * @return true if initialization fails, false if succeeds - */ - public synchronized boolean initialize( - String zidFilename, - boolean autoEnable, - ZrtpConfigure config) - { - // Try to get the ZidFile path through the FileAccessService. - File file = null; - FileAccessService faService = NeomediaActivator.getFileAccessService(); - - if (faService != null) - { - try - { - // Create the zid file - file = faService.getPrivatePersistentFile(zidFilename); - } - catch (Exception e) - { - logger.warn("Failed to create the zid file."); - } - } - - // The ZidFile path should be absolute. - String zidFilePath = null; - - try - { - if (file != null) - zidFilePath = file.getAbsolutePath(); - } - catch (SecurityException e) - { - if (logger.isDebugEnabled()) - { - logger.debug( - "Failed to obtain the absolute path of the zid file.", - e); - } - } - - ZidFile zf = ZidFile.getInstance(); - - if (!zf.isOpen()) - { - if (zidFilePath == null) - { - String home = System.getenv("HOME"); - String baseDir - = ((home == null) || (home.length() < 1)) - ? "" - : (home + "/"); - - zidFilePath = baseDir + ".GNUZRTP4J.zid"; - } - if (zf.open(zidFilePath) < 0) - return false; - } - - if (config == null) - { - config = new ZrtpConfigure(); - config.setStandardConfig(); - } - if (enableParanoidMode) - config.setParanoidMode(enableParanoidMode); - - zrtpEngine - = new ZRtp(zf.getZid(), this, clientIdString, config, mitmMode); - - if (timeoutProvider == null) - { - timeoutProvider = new TimeoutProvider("ZRTP"); - // XXX Daemon only if timeoutProvider is a global singleton. - // timeoutProvider.setDaemon(true); - timeoutProvider.start(); - } - - enableZrtp = autoEnable; - return true; - } - - /** - * - * @param startMuted whether to be started as muted if no secure - * communication is established - */ - public void setStartMuted(boolean startMuted) - { - muted = startMuted; - if(startMuted) - { - // make sure we don't mute for long time as secure communication - // may fail. - new Timer().schedule(new TimerTask() - { - public void run() - { - ZRTPTransformEngine.this.muted = false; - } - }, 1500); - } - } - - /** - * Method for getting the default secure status value for communication - * - * @return the default enabled/disabled status value for secure - * communication - */ - public boolean getSecureCommunicationStatus() - { - return srtpInTransformer != null || srtpOutTransformer != null; - } - - /** - * Start the ZRTP stack immediately, not autosensing mode. - */ - public void startZrtp() - { - if (zrtpEngine != null) - { - zrtpEngine.startZrtpEngine(); - started = true; - - securityEventManager.securityNegotiationStarted(); - } - } - - /** - * Close the transformer and underlying transform engine. - * - * The close functions closes all stored crypto contexts. This deletes key data - * and forces a cleanup of the crypto contexts. - */ - public void close() - { - stopZrtp(); - } - - /** - * Stop ZRTP engine. - */ - public void stopZrtp() - { - if (zrtpEngine != null) - { - zrtpEngine.stopZrtp(); - zrtpEngine = null; - started = false; - } - // The SRTP transformer are usually already closed durin security-off - // processing. Check here again just in case ... - if (srtpOutTransformer != null) - { - srtpOutTransformer.close(); - srtpOutTransformer = null; - } - if (srtpInTransformer != null) - { - srtpInTransformer.close(); - srtpOutTransformer = null; - } - if (zrtcpTransformer != null) - { - zrtcpTransformer.close(); - zrtcpTransformer = null; - } - } - - /** - * Cleanup function for any remaining timers - */ - public void cleanup() - { - if (timeoutProvider != null) - { - timeoutProvider.stopRun(); - timeoutProvider = null; - } - } - - /** - * Set the SSRC of the RTP transmitter stream. - * - * ZRTP fills the SSRC in the ZRTP messages. - * - * @param ssrc SSRC to set - */ - public void setOwnSSRC(long ssrc) - { - ownSSRC = (int)(ssrc & 0xffffffff); - } - - /** - * The data output stream calls this method to transform outgoing - * packets. - * - * @see PacketTransformer#transform(RawPacket) - */ - public RawPacket transform(RawPacket pkt) - { - /* - * Never transform outgoing ZRTP (invalid RTP) packets. - */ - if (ZrtpRawPacket.isZrtpData(pkt)) - { - return pkt; - } - - // ZRTP needs the SSRC of the sending stream. - if (enableZrtp && ownSSRC == 0) - { - ownSSRC = pkt.getSSRC(); - } - - // If SRTP is active then srtpTransformer is set, use it. - if (srtpOutTransformer == null) - { - return pkt; - } - - return srtpOutTransformer.transform(pkt); - } - - /** - * The input data stream calls this method to transform - * incoming packets. - * - * @see PacketTransformer#reverseTransform(RawPacket) - */ - public RawPacket reverseTransform(RawPacket pkt) - { - // Check if we need to start ZRTP - if (!started && enableZrtp && ownSSRC != 0) - startZrtp(); - - /* - * Check if incoming packet is a ZRTP packet, if not treat - * it as normal RTP packet and handle it accordingly. - */ - if (!ZrtpRawPacket.isZrtpData(pkt)) - { - if (srtpInTransformer == null) - { - if(muted) - { - return null; - } - else - return pkt; - } - - RawPacket pkt2 = srtpInTransformer.reverseTransform(pkt); - // if packet was valid (i.e. not null) and ZRTP engine started and - // in Wait for Confirm2 Ack then emulate a Conf2Ack packet. - // See ZRTP specification chap. 5.6 - if ((pkt2 != null) - && started - && zrtpEngine - .inState(ZrtpStateClass.ZrtpStates.WaitConfAck)) - { - zrtpEngine.conf2AckSecure(); - } - - return pkt2; - } - - /* - * If ZRTP is enabled process it. - * - * In any case return null because ZRTP packets must never reach - * the application. - */ - if (enableZrtp && started) - { - ZrtpRawPacket zPkt = new ZrtpRawPacket(pkt); - if (!zPkt.checkCrc()) - { - securityEventManager - .showMessage( - ZrtpCodes.MessageSeverity.Warning, - EnumSet.of(ZrtpCodes.WarningCodes.WarningCRCmismatch)); - } - // Check if it is really a ZRTP packet, if not don't process it - else if (zPkt.hasMagic()) - { - int extHeaderOffset = zPkt.getHeaderLength() - - zPkt.getExtensionLength() - RawPacket.EXT_HEADER_SIZE; - // zrtp engine need a "pointer" to the extension header, so - // we give him the extension header and the payload data - byte[] extHeader = zPkt.readRegion( - extHeaderOffset, - RawPacket.EXT_HEADER_SIZE + - zPkt.getExtensionLength() + zPkt.getPayloadLength()); - zrtpEngine.processZrtpMessage(extHeader, zPkt.getSSRC()); - } - } - - return null; - } - - /** - * The callback method required by the ZRTP implementation. - * First allocate space to hold the complete ZRTP packet, copy - * the message part in its place, the initalize the header, counter, - * SSRC and crc. - * - * @param data The ZRTP packet data - * @return true if sending succeeds, false if it fails - */ - public boolean sendDataZRTP(byte[] data) - { - int totalLength = ZRTP_PACKET_HEADER + data.length; - byte[] tmp = new byte[totalLength]; - System.arraycopy(data, 0, tmp, ZRTP_PACKET_HEADER, data.length); - ZrtpRawPacket packet = new ZrtpRawPacket(tmp, 0, tmp.length); - - packet.setSSRC(ownSSRC); - - packet.setSeqNum(senderZrtpSeqNo++); - - packet.setCrc(); - - try - { - zrtpConnector.getDataOutputStream().write( packet.getBuffer(), - packet.getOffset(), - packet.getLength()); - } - catch (IOException e) - { - logger.warn("Failed to send ZRTP data."); - - if (logger.isDebugEnabled()) - logger.debug("Failed to send ZRTP data.", e); - - return false; - } - return true; - } - - /** - * Switch on the security for the defined part. - * - * @param secrets The secret keys and salt negotiated by ZRTP - * @param part An enum that defines sender, receiver, or both. - * @return always return true. - */ - public boolean srtpSecretsReady( - ZrtpSrtpSecrets secrets, EnableSecurity part) - { - SRTPPolicy srtpPolicy = null; - int cipher = 0, authn = 0, authKeyLen = 0; - - if (secrets.getAuthAlgorithm() == ZrtpConstants.SupportedAuthAlgos.HS) - { - authn = SRTPPolicy.HMACSHA1_AUTHENTICATION; - authKeyLen = 20; - } - if (secrets.getAuthAlgorithm() == ZrtpConstants.SupportedAuthAlgos.SK) - { - authn = SRTPPolicy.SKEIN_AUTHENTICATION; - authKeyLen = 32; - } - if (secrets.getSymEncAlgorithm() == ZrtpConstants.SupportedSymAlgos.AES) - cipher = SRTPPolicy.AESCM_ENCRYPTION; - - if (secrets.getSymEncAlgorithm() == ZrtpConstants.SupportedSymAlgos.TwoFish) - cipher = SRTPPolicy.TWOFISH_ENCRYPTION; - - if (part == EnableSecurity.ForSender) - { - // To encrypt packets: initiator uses initiator keys, - // responder uses responder keys - // Create a "half baked" crypto context first and store it. This is - // the main crypto context for the sending part of the connection. - if (secrets.getRole() == Role.Initiator) - { - srtpPolicy = new SRTPPolicy(cipher, - secrets.getInitKeyLen() / 8, // key length - authn, authKeyLen, // auth key length - secrets.getSrtpAuthTagLen() / 8,// auth tag length - secrets.getInitSaltLen() / 8 // salt length - ); - - SRTPTransformEngine engine = new SRTPTransformEngine(secrets - .getKeyInitiator(), secrets.getSaltInitiator(), - srtpPolicy, srtpPolicy); - - srtpOutTransformer = engine.getRTPTransformer(); - getRTCPTransformer().setSrtcpOut(engine.getRTCPTransformer()); - } - else - { - srtpPolicy = new SRTPPolicy(cipher, - secrets.getRespKeyLen() / 8, // key length - authn, authKeyLen, // auth key length - secrets.getSrtpAuthTagLen() / 8,// auth taglength - secrets.getRespSaltLen() / 8 // salt length - ); - - SRTPTransformEngine engine = new SRTPTransformEngine(secrets - .getKeyResponder(), secrets.getSaltResponder(), - srtpPolicy, srtpPolicy); - srtpOutTransformer = engine.getRTPTransformer(); - getRTCPTransformer().setSrtcpOut(engine.getRTCPTransformer()); - } - } - - if (part == EnableSecurity.ForReceiver) - { - // To decrypt packets: initiator uses responder keys, - // responder initiator keys - // See comment above. - if (secrets.getRole() == Role.Initiator) - { - srtpPolicy = new SRTPPolicy(cipher, - secrets.getRespKeyLen() / 8, // key length - authn, authKeyLen, // auth key length - secrets.getSrtpAuthTagLen() / 8,// auth tag length - secrets.getRespSaltLen() / 8 // salt length - ); - - SRTPTransformEngine engine = new SRTPTransformEngine(secrets - .getKeyResponder(), secrets.getSaltResponder(), - srtpPolicy, srtpPolicy); - srtpInTransformer = engine.getRTPTransformer(); - getRTCPTransformer().setSrtcpIn(engine.getRTCPTransformer()); - this.muted = false; - } - else - { - srtpPolicy = new SRTPPolicy(cipher, - secrets.getInitKeyLen() / 8, // key length - authn, authKeyLen, // auth key length - secrets.getSrtpAuthTagLen() / 8,// auth tag length - secrets.getInitSaltLen() / 8 // salt length - ); - - SRTPTransformEngine engine = new SRTPTransformEngine(secrets - .getKeyInitiator(), secrets.getSaltInitiator(), - srtpPolicy, srtpPolicy); - srtpInTransformer = engine.getRTPTransformer(); - getRTCPTransformer().setSrtcpIn(engine.getRTCPTransformer()); - this.muted = false; - } - } - return true; - } - - /** - * - * @param c - * @param s - * @param verified - * @see gnu.java.zrtp.ZrtpCallback#srtpSecretsOn(java.lang.String, - * java.lang.String, boolean) - */ - public void srtpSecretsOn(String c, String s, boolean verified) - { - if (securityEventManager != null) - { - securityEventManager.secureOn(c); - } - - if (securityEventManager != null && (s != null || verified)) - { - securityEventManager.showSAS(s, verified); - } - } - - /** - * This method shall clear the ZRTP secrets. - * - * @param part Defines for which part (sender or receiver) - * to switch on security - */ - public void srtpSecretsOff(EnableSecurity part) - { - if (part == EnableSecurity.ForSender) - { - if (srtpOutTransformer != null) - srtpOutTransformer.close(); - srtpOutTransformer = null; - } - - if (part == EnableSecurity.ForReceiver) - { - if (srtpInTransformer != null) - srtpInTransformer.close(); - srtpInTransformer = null; - } - - if (securityEventManager != null) - { - securityEventManager.secureOff(); - } - } - - /** - * Activate timer. - * @param time The time in ms for the timer. - * @return always return 1. - */ - public int activateTimer(int time) - { - if (timeoutProvider != null) - { - timeoutProvider.requestTimeout(time); - } - - return 1; - } - - /** - * Cancel the active timer. - * @return always return 1. - */ - public int cancelTimer() - { - if (timeoutProvider != null) - { - timeoutProvider.cancelRequest(); - } - return 1; - } - - /** - * Timeout handling function. - * Delegates the handling to the ZRTP engine. - */ - public void handleTimeout() - { - if (zrtpEngine != null) - { - zrtpEngine.processTimeout(); - } - } - - /** - * Send information messages to the hosting environment. - * @param severity This defines the message's severity - * @param subCode The message code. - */ - public void sendInfo(ZrtpCodes.MessageSeverity severity, EnumSet subCode) - { - if (securityEventManager != null) - { - securityEventManager.showMessage(severity, subCode); - } - } - - /** - * Comes a message that zrtp negotiation has failed. - * @param severity This defines the message's severity - * @param subCode The message code. - */ - public void zrtpNegotiationFailed(ZrtpCodes.MessageSeverity severity, - EnumSet subCode) - { - if (securityEventManager != null) - { - securityEventManager.zrtpNegotiationFailed(severity, subCode); - } - } - - /** - * The other part doesn't support zrtp. - */ - public void zrtpNotSuppOther() - { - if (securityEventManager != null) - { - securityEventManager.zrtpNotSuppOther(); - } - } - - /** - * Zrtp ask for Enrollment. - * @param info supplied info. - */ - public void zrtpAskEnrollment(ZrtpCodes.InfoEnrollment info) - { - if (securityEventManager != null) - { - securityEventManager.zrtpAskEnrollment(info); - } - } - - /** - * - * @param info - * @see gnu.java.zrtp.ZrtpCallback#zrtpInformEnrollment( - * gnu.java.zrtp.ZrtpCodes.InfoEnrollment) - */ - public void zrtpInformEnrollment(ZrtpCodes.InfoEnrollment info) - { - if (securityEventManager != null) - { - securityEventManager.zrtpInformEnrollment(info); - } - } - - /** - * - * @param sas - * @see gnu.java.zrtp.ZrtpCallback#signSAS(java.lang.String) - */ - public void signSAS(byte[] sasHash) - { - if (securityEventManager != null) - { - securityEventManager.signSAS(sasHash); - } - } - - /** - * - * @param sas - * @return false if signature check fails, true otherwise - * @see gnu.java.zrtp.ZrtpCallback#checkSASSignature(java.lang.String) - */ - public boolean checkSASSignature(byte[] sasHash) - { - return ((securityEventManager != null) - ? securityEventManager.checkSASSignature(sasHash) - : false); - } - - /** - * Sets the enableZrtp flag. - * - * @param onOff The value for the enableZrtp flag. - */ - public void setEnableZrtp(boolean onOff) - { - enableZrtp = onOff; - } - - /** - * Returns the enableZrtp flag. - * - * @return the enableZrtp flag. - */ - public boolean isEnableZrtp() - { - return enableZrtp; - } - - /** - * Set the SAS as verified internally if the user confirms it - */ - public void SASVerified() - { - if (zrtpEngine != null) - zrtpEngine.SASVerified(); - } - - /** - * Resets the internal engine SAS verified flag - */ - public void resetSASVerified() - { - if (zrtpEngine != null) - zrtpEngine.resetSASVerified(); - } - - /** - * Method called when the user requests through GUI to switch a secured call - * to unsecure mode. Just forwards the request to the Zrtp class. - */ - public void requestGoClear() - { -// if (zrtpEngine != null) -// zrtpEngine.requestGoClear(); - } - - /** - * Method called when the user requests through GUI to switch a previously - * unsecured call back to secure mode. Just forwards the request to the - * Zrtp class. - */ - public void requestGoSecure() - { -// if (zrtpEngine != null) -// zrtpEngine.requestGoSecure(); - } - - /** - * Sets the auxilliary secret data - * - * @param data The auxilliary secret data - */ - public void setAuxSecret(byte[] data) - { - if (zrtpEngine != null) - zrtpEngine.setAuxSecret(data); - } - - /** - * Sets the client ID - * - * @param id The client ID - */ - public void setClientId(String id) - { - clientIdString = id; - } - - /** - * Gets the Hello packet Hash - * - * @return the Hello packet hash - */ - public String getHelloHash() - { - if (zrtpEngine != null) - return zrtpEngine.getHelloHash(); - else - return new String(); - } - - /** - * Get the ZRTP Hello Hash data - separate strings. - * - * @return String array containing the version string at offset 0, the Hello - * hash value as hex-digits at offset 1. Hello hash is available - * immediately after class instantiation. Returns null - * if ZRTP is not available. - */ - public String[] getHelloHashSep() { - if (zrtpEngine != null) - return zrtpEngine.getHelloHashSep(); - else - return null; - } - - /** - * Gets the multistream params - * - * @return the multistream params - */ - public byte[] getMultiStrParams() - { - if (zrtpEngine != null) - return zrtpEngine.getMultiStrParams(); - else - return new byte[0]; - } - - /** - * Sets the multistream params - * (The multistream part needs further development) - * @param parameters the multistream params - */ - public void setMultiStrParams(byte[] parameters) - { - if (zrtpEngine != null) { - zrtpEngine.setMultiStrParams(parameters); - } - } - - /** - * Gets the multistream flag - * (The multistream part needs further development) - * @return the multistream flag - */ - public boolean isMultiStream() - { - return ((zrtpEngine != null) ? zrtpEngine.isMultiStream() : false); - } - - /** - * Used to accept a PBX enrollment request - * (The PBX part needs further development) - * @param accepted The boolean value indicating if the request is accepted - */ - public void acceptEnrollment(boolean accepted) - { - if (zrtpEngine != null) - zrtpEngine.acceptEnrollment(accepted); - } - - /** - * Get the commited SAS rendering algorithm for this ZRTP session. - * - * @return the commited SAS rendering algorithm - */ - public ZrtpConstants.SupportedSASTypes getSasType() { - if (zrtpEngine != null) - return zrtpEngine.getSasType(); - else - return null; - } - - /** - * Get the computed SAS hash for this ZRTP session. - * - * @return a refernce to the byte array that contains the full - * SAS hash. - */ - public byte[] getSasHash() { - if (zrtpEngine != null) - return zrtpEngine.getSasHash(); - else - return null; - } - - /** - * Send the SAS relay packet. - * - * The method creates and sends a SAS relay packet according to the ZRTP - * specifications. Usually only a MitM capable user agent (PBX) uses this - * function. - * - * @param sh the full SAS hash value - * @param render the SAS rendering algorithm - * @return true if the SASReplay packet has been correctly sent, false - * otherwise - */ - public boolean sendSASRelayPacket(byte[] sh, - ZrtpConstants.SupportedSASTypes render) - { - if (zrtpEngine != null) - return zrtpEngine.sendSASRelayPacket(sh, render); - else - return false; - } - /** - * Check the state of the MitM mode flag. - * - * If true then this ZRTP session acts as MitM, usually enabled by a PBX - * based client (user agent) - * - * @return state of mitmMode - */ - public boolean isMitmMode() { - return mitmMode; - } - - /** - * Set the state of the MitM mode flag. - * - * If MitM mode is set to true this ZRTP session acts as MitM, usually - * enabled by a PBX based client (user agent). - * - * @param mitmMode defines the new state of the mitmMode flag - */ - public void setMitmMode(boolean mitmMode) { - this.mitmMode = mitmMode; - } - - /** - * Enables or disables paranoid mode. - * - * For further explanation of paranoid mode refer to the documentation - * of ZRtp class. - * - * @param yesNo - * If set to true then paranoid mode is enabled. - */ - public void setParanoidMode(boolean yesNo) { - enableParanoidMode = yesNo; - } - - /** - * Check status of paranoid mode. - * - * @return - * Returns true if paranoid mode is enabled. - */ - public boolean isParanoidMode() { - return enableParanoidMode; - } - - /** - * Check the state of the enrollment mode. - * - * If true then we will set the enrollment flag (E) in the confirm - * packets and performs the enrollment actions. A MitM (PBX) - * enrollment service sets this flag. - * - * @return status of the enrollmentMode flag. - */ - public boolean isEnrollmentMode() { - if (zrtpEngine != null) - return zrtpEngine.isEnrollmentMode(); - else - return false; - } - - /** - * Set the state of the enrollment mode. - * - * If true then we will set the enrollment flag (E) in the confirm - * packets and perform the enrollment actions. A MitM (PBX) enrollment - * service must set this mode to true. - * - * Can be set to true only if mitmMode is also true. - * - * @param enrollmentMode defines the new state of the enrollmentMode flag - */ - public void setEnrollmentMode(boolean enrollmentMode) { - if (zrtpEngine != null) - zrtpEngine.setEnrollmentMode(enrollmentMode); - } - /** - * Sets signature data for the Confirm packets - * - * @param data the signature data - * @return true if signature data was successfully set - */ - public boolean setSignatureData(byte[] data) - { - return ((zrtpEngine != null) ? zrtpEngine.setSignatureData(data) - : false); - } - - /** - * Gets signature data - * - * @return the signature data - */ - public byte[] getSignatureData() - { - if (zrtpEngine != null) - return zrtpEngine.getSignatureData(); - else - return new byte[0]; - } - - /** - * Gets signature length - * - * @return the signature length - */ - public int getSignatureLength() - { - return ((zrtpEngine != null) ? zrtpEngine.getSignatureLength() : 0); - } - - - /** - * Method called by the Zrtp class as result of a GoClear request from the - * other peer. An explicit user confirmation is needed before switching to - * unsecured mode. This is asked through the user callback. - */ - public void handleGoClear() - { - securityEventManager.confirmGoClear(); - } - - /** - * Sets the RTP connector using this ZRTP engine - * - * @param connector the connector to set - */ - public void setConnector(AbstractRTPConnector connector) - { - zrtpConnector = connector; - } - - /** - * Sets the user callback class used to maintain the GUI ZRTP part - * - * @param ub The user callback class - */ - public void setUserCallback(SecurityEventManager ub) - { - securityEventManager = ub; - } - - /** - * Returns the current status of the ZRTP engine - * - * @return the current status of the ZRTP engine - */ - public boolean isStarted() - { - return started; - } - - /** - * Gets the user callback used to manage the GUI part of ZRTP - * - * @return the user callback - */ - public SecurityEventManager getUserCallback() - { - return securityEventManager; - } - - /** - * Get other party's ZID (ZRTP Identifier) data - * - * This functions returns the other party's ZID that was receivied - * during ZRTP processing. - * - * The ZID data can be retrieved after ZRTP receive the first Hello - * packet from the other party. The application may call this method - * for example during SAS processing in showSAS(...) user callback - * method. - * - * @return the ZID data as byte array. - */ - public byte[] getPeerZid() - { - return ((zrtpEngine != null) ? zrtpEngine.getPeerZid() : null); - } -} diff --git a/src/net/java/sip/communicator/impl/neomedia/transform/zrtp/ZrtpRawPacket.java b/src/net/java/sip/communicator/impl/neomedia/transform/zrtp/ZrtpRawPacket.java deleted file mode 100644 index 2560a9410..000000000 --- a/src/net/java/sip/communicator/impl/neomedia/transform/zrtp/ZrtpRawPacket.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.neomedia.transform.zrtp; - -import gnu.java.zrtp.packets.*; -import gnu.java.zrtp.utils.*; - -import net.java.sip.communicator.impl.neomedia.*; - -/** - * ZRTP packet representation. - * - * This class extends the RawPacket class and adds some methods - * required by the ZRTP transformer. - * - * @author Werner Dittmann - */ -public class ZrtpRawPacket extends RawPacket -{ - /** - * Each ZRTP packet contains this magic number. - */ - public static byte[] zrtpMagic; - - static { - zrtpMagic = new byte[4]; - zrtpMagic[0]= 0x5a; - zrtpMagic[1]= 0x52; - zrtpMagic[2]= 0x54; - zrtpMagic[3]= 0x50; - } - - /** - * Construct an input ZrtpRawPacket using a received RTP raw packet. - * - * @param pkt a raw RTP packet as received - */ - public ZrtpRawPacket(RawPacket pkt) - { - super (pkt.getBuffer(), pkt.getOffset(), pkt.getLength()); - } - - /** - * Construct an output ZrtpRawPacket using specified value. - * - * Initialize this packet and set the ZRTP magic value - * to mark it as a ZRTP packet. - * - * @param buf Byte array holding the content of this Packet - * @param off Start offset of packet content inside buffer - * @param len Length of the packet's data - */ - public ZrtpRawPacket(byte[] buf, int off, int len) - { - super (buf, off, len); - writeByte(0, (byte)0x10); - writeByte(1, (byte)0); - - int at = 4; - writeByte(at++, zrtpMagic[0]); - writeByte(at++, zrtpMagic[1]); - writeByte(at++, zrtpMagic[2]); - writeByte(at, zrtpMagic[3]); - } - - /** - * Check if it could be a ZRTP packet. - * - * The method checks if the first byte of the received data - * matches the defined ZRTP pattern 0x10 - * - * @return true if could be a ZRTP packet, false otherwise. - */ - protected boolean isZrtpPacket() - { - return isZrtpData(this); - } - - /** - * Checks whether extension bit is set and if so is the extension header - * an zrtp one. - * @param pkt the packet to check. - * @return true if data is zrtp packet. - */ - static boolean isZrtpData(RawPacket pkt) - { - if(!pkt.getExtensionBit()) - return false; - - if(pkt.getHeaderExtensionType() == 0x505a) - return true; - - return false; - } - - /** - * Check if it is really a ZRTP packet. - * - * The method checks if the packet contains the ZRTP magic - * number. - * - * @return true if packet contains the magic number, false otherwise. - */ - protected boolean hasMagic() - { - return - (readByte(4) == zrtpMagic[0]) - && (readByte(5) == zrtpMagic[1]) - && (readByte(6) == zrtpMagic[2]) - && (readByte(7) == zrtpMagic[3]); - } - - /** - * Set the sequence number in this packet. - * @param seq sequence number - */ - protected void setSeqNum(short seq) - { - int at = 2; - writeByte(at++, (byte)(seq>>8)); - writeByte(at, (byte)seq); - } - - /** - * Set SSRC in this packet - * @param ssrc SSRC to set - */ - protected void setSSRC(int ssrc) - { - writeInt(8, ssrc); - } - - /** - * Check if the CRC of this packet is ok. - * - * @return true if the CRC is valid, false otherwise - */ - protected boolean checkCrc() - { - int crc = readInt(getLength()-ZrtpPacketBase.CRC_SIZE); - return ZrtpCrc32.zrtpCheckCksum(getBuffer(), getOffset(), - getLength()-ZrtpPacketBase.CRC_SIZE, crc); - } - - /** - * Set ZRTP CRC in this packet - */ - protected void setCrc() - { - int crc = ZrtpCrc32.zrtpGenerateCksum(getBuffer(), getOffset(), - getLength() - ZrtpPacketBase.CRC_SIZE); - // convert and store CRC in crc field of ZRTP packet. - crc = ZrtpCrc32.zrtpEndCksum(crc); - writeInt(getLength() - ZrtpPacketBase.CRC_SIZE, crc); - } -} diff --git a/src/net/java/sip/communicator/impl/netaddr/Ice4jPacketLogger.java b/src/net/java/sip/communicator/impl/netaddr/Ice4jPacketLogger.java index c41e5ad09..526364418 100644 --- a/src/net/java/sip/communicator/impl/netaddr/Ice4jPacketLogger.java +++ b/src/net/java/sip/communicator/impl/netaddr/Ice4jPacketLogger.java @@ -1,7 +1,7 @@ package net.java.sip.communicator.impl.netaddr; -import net.java.sip.communicator.service.packetlogging.*; import org.ice4j.stack.*; +import org.jitsi.service.packetlogging.*; /** * Logs Packets coming and going through ice4j stack. diff --git a/src/net/java/sip/communicator/impl/netaddr/NetaddrActivator.java b/src/net/java/sip/communicator/impl/netaddr/NetaddrActivator.java index a2295c06e..4109f2517 100644 --- a/src/net/java/sip/communicator/impl/netaddr/NetaddrActivator.java +++ b/src/net/java/sip/communicator/impl/netaddr/NetaddrActivator.java @@ -6,12 +6,13 @@ */ package net.java.sip.communicator.impl.netaddr; -import net.java.sip.communicator.service.packetlogging.*; -import org.osgi.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.packetlogging.*; +import org.osgi.framework.*; + /** * The activator manage the the bundles between OSGi framework and the * Network address manager diff --git a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java index 83d685341..92f2ead72 100644 --- a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java +++ b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java @@ -6,17 +6,17 @@ */ package net.java.sip.communicator.impl.netaddr; -import java.lang.reflect.*; import java.beans.*; import java.io.*; +import java.lang.reflect.*; import java.net.*; import java.text.*; import java.util.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.netaddr.event.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.NetworkUtils; import net.java.sip.communicator.util.dns.*; @@ -25,6 +25,8 @@ import org.ice4j.ice.harvest.*; import org.ice4j.security.*; import org.ice4j.stack.*; +import org.jitsi.service.configuration.*; +import org.jitsi.util.*; /** * This implementation of the Network Address Manager allows you to diff --git a/src/net/java/sip/communicator/impl/netaddr/netaddr.manifest.mf b/src/net/java/sip/communicator/impl/netaddr/netaddr.manifest.mf index 597d60607..0cc59bfb9 100644 --- a/src/net/java/sip/communicator/impl/netaddr/netaddr.manifest.mf +++ b/src/net/java/sip/communicator/impl/netaddr/netaddr.manifest.mf @@ -4,8 +4,9 @@ Bundle-Description: A bundle that provides local address selection and negotiati Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes -Import-Package: net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.packetlogging, +Import-Package: org.jitsi.service.configuration, + org.jitsi.service.packetlogging, + org.jitsi.util, net.java.sip.communicator.util, net.java.sip.communicator.util.dns, net.java.sip.communicator.service.sysactivity, diff --git a/src/net/java/sip/communicator/impl/notification/NotificationActivator.java b/src/net/java/sip/communicator/impl/notification/NotificationActivator.java index 99676c8f9..a7d94bd07 100644 --- a/src/net/java/sip/communicator/impl/notification/NotificationActivator.java +++ b/src/net/java/sip/communicator/impl/notification/NotificationActivator.java @@ -6,11 +6,11 @@ */ package net.java.sip.communicator.impl.notification; -import net.java.sip.communicator.service.audionotifier.*; import net.java.sip.communicator.service.notification.*; import net.java.sip.communicator.service.systray.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.audionotifier.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/notification/SoundNotificationHandlerImpl.java b/src/net/java/sip/communicator/impl/notification/SoundNotificationHandlerImpl.java index e5b0fba7c..025e82f15 100644 --- a/src/net/java/sip/communicator/impl/notification/SoundNotificationHandlerImpl.java +++ b/src/net/java/sip/communicator/impl/notification/SoundNotificationHandlerImpl.java @@ -8,10 +8,11 @@ import java.util.*; -import net.java.sip.communicator.service.audionotifier.*; import net.java.sip.communicator.service.notification.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.audionotifier.*; + /** * An implementation of the SoundNotificationHandler interface. * diff --git a/src/net/java/sip/communicator/impl/notification/notification.manifest.mf b/src/net/java/sip/communicator/impl/notification/notification.manifest.mf index c3b7bf9ed..0db21bae0 100644 --- a/src/net/java/sip/communicator/impl/notification/notification.manifest.mf +++ b/src/net/java/sip/communicator/impl/notification/notification.manifest.mf @@ -8,12 +8,12 @@ Import-Package: org.osgi.framework, javax.imageio, net.java.sip.communicator.util, net.java.sip.communicator.service.notification, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, - net.java.sip.communicator.service.audionotifier, + org.jitsi.service.audionotifier, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.protocol, - net.java.sip.communicator.service.neomedia, + org.jitsi.service.neomedia, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.systray diff --git a/src/net/java/sip/communicator/impl/osdependent/Desktop.java b/src/net/java/sip/communicator/impl/osdependent/Desktop.java index b8b39e0bb..d73f2d75f 100644 --- a/src/net/java/sip/communicator/impl/osdependent/Desktop.java +++ b/src/net/java/sip/communicator/impl/osdependent/Desktop.java @@ -11,9 +11,10 @@ import java.lang.reflect.*; import java.net.*; -import org.jdesktop.jdic.desktop.*; +import net.java.sip.communicator.util.Logger; -import net.java.sip.communicator.util.*; +import org.jdesktop.jdic.desktop.*; +import org.jitsi.util.*; /** * The Desktop class handles desktop operations through the default diff --git a/src/net/java/sip/communicator/impl/osdependent/OsDependentActivator.java b/src/net/java/sip/communicator/impl/osdependent/OsDependentActivator.java index d05e21f2d..83c6ba82d 100644 --- a/src/net/java/sip/communicator/impl/osdependent/OsDependentActivator.java +++ b/src/net/java/sip/communicator/impl/osdependent/OsDependentActivator.java @@ -8,14 +8,16 @@ import net.java.sip.communicator.impl.osdependent.jdic.*; import net.java.sip.communicator.impl.osdependent.macosx.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.desktop.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.service.shutdown.*; import net.java.sip.communicator.service.systray.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; +import org.jitsi.service.configuration.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/osdependent/Resources.java b/src/net/java/sip/communicator/impl/osdependent/Resources.java index f4f5da761..0279750be 100644 --- a/src/net/java/sip/communicator/impl/osdependent/Resources.java +++ b/src/net/java/sip/communicator/impl/osdependent/Resources.java @@ -12,6 +12,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Messages class manages the access to the internationalization * properties files. diff --git a/src/net/java/sip/communicator/impl/osdependent/TrayIcon.java b/src/net/java/sip/communicator/impl/osdependent/TrayIcon.java index 7556e00fb..c167b2a46 100644 --- a/src/net/java/sip/communicator/impl/osdependent/TrayIcon.java +++ b/src/net/java/sip/communicator/impl/osdependent/TrayIcon.java @@ -13,8 +13,9 @@ import javax.swing.*; import javax.swing.event.*; -import net.java.sip.communicator.impl.osdependent.SystemTray.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.impl.osdependent.SystemTray.SystemTrayPeer; + +import org.jitsi.util.*; /** * @author Lubomir Marinov diff --git a/src/net/java/sip/communicator/impl/osdependent/jdic/ProviderUnRegistration.java b/src/net/java/sip/communicator/impl/osdependent/jdic/ProviderUnRegistration.java index c1c4cfb23..658303f05 100644 --- a/src/net/java/sip/communicator/impl/osdependent/jdic/ProviderUnRegistration.java +++ b/src/net/java/sip/communicator/impl/osdependent/jdic/ProviderUnRegistration.java @@ -79,4 +79,4 @@ else if (errorCode == OperationFailedException } } } - } \ No newline at end of file + } diff --git a/src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java b/src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java index 81b844b55..3fa31a438 100644 --- a/src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java +++ b/src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java @@ -6,28 +6,30 @@ */ package net.java.sip.communicator.impl.osdependent.jdic; -import com.apple.eawt.*; - -import java.awt.GraphicsEnvironment; -import java.awt.Image; -import java.awt.Toolkit; +import java.awt.*; import java.awt.event.*; import java.net.*; import java.util.*; +import java.util.List; import javax.swing.*; import javax.swing.event.*; import net.java.sip.communicator.impl.osdependent.*; -import net.java.sip.communicator.service.configuration.*; +import net.java.sip.communicator.impl.osdependent.SystemTray; +import net.java.sip.communicator.impl.osdependent.TrayIcon; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.systray.*; import net.java.sip.communicator.service.systray.event.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; +import org.jitsi.service.configuration.*; +import org.jitsi.util.*; import org.osgi.framework.*; +import com.apple.eawt.*; + /** * The Systray provides a Icon and the associated TrayMenu * in the system tray using the Jdic library. diff --git a/src/net/java/sip/communicator/impl/osdependent/jdic/TrayMenuFactory.java b/src/net/java/sip/communicator/impl/osdependent/jdic/TrayMenuFactory.java index a6f8c0ca0..e57e7f235 100644 --- a/src/net/java/sip/communicator/impl/osdependent/jdic/TrayMenuFactory.java +++ b/src/net/java/sip/communicator/impl/osdependent/jdic/TrayMenuFactory.java @@ -14,7 +14,8 @@ import net.java.sip.communicator.impl.osdependent.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.util.*; + +import org.jitsi.util.*; /** * The TrayMenu is the menu that appears when the user right-click @@ -301,4 +302,4 @@ public static boolean isVisible(Object trayMenu) return ((JPopupMenu) trayMenu).isVisible(); return false; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/osdependent/osdependent.manifest.mf b/src/net/java/sip/communicator/impl/osdependent/osdependent.manifest.mf index 0b3a30f6b..6f0ed5fd5 100644 --- a/src/net/java/sip/communicator/impl/osdependent/osdependent.manifest.mf +++ b/src/net/java/sip/communicator/impl/osdependent/osdependent.manifest.mf @@ -13,15 +13,16 @@ Import-Package: org.osgi.framework, com.apple.cocoa.application, com.apple.cocoa.foundation, com.apple.eawt, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.shutdown, net.java.sip.communicator.service.systray, net.java.sip.communicator.service.systray.event, + org.jitsi.util, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.accessibility, diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java index 2fb54b877..3f65c57d6 100644 --- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java +++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java @@ -6,11 +6,11 @@ */ package net.java.sip.communicator.impl.packetlogging; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.fileaccess.*; -import net.java.sip.communicator.service.packetlogging.*; import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.Logger; + +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; +import org.jitsi.service.packetlogging.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigurationImpl.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigurationImpl.java index fb9224d4b..809ee2e68 100644 --- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigurationImpl.java +++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigurationImpl.java @@ -6,8 +6,9 @@ */ package net.java.sip.communicator.impl.packetlogging; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.packetlogging.*; +import org.jitsi.service.configuration.*; + +import org.jitsi.service.packetlogging.*; /** * Extends PacketLoggingConfiguration by storing and loading values from diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java index 4f7f9dc88..08d80b6df 100644 --- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java +++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java @@ -6,12 +6,15 @@ */ package net.java.sip.communicator.impl.packetlogging; -import net.java.sip.communicator.service.packetlogging.*; -import net.java.sip.communicator.util.*; - import java.io.*; import java.util.*; +import net.java.sip.communicator.util.*; + +import org.jitsi.service.packetlogging.*; +import org.jitsi.service.packetlogging.PacketLoggingService.ProtocolName; +import org.jitsi.service.packetlogging.PacketLoggingService.TransportName; + /** * Packet Logging Service implementation dumping logs in * pcap(tcpdump/wireshark) format file. diff --git a/src/net/java/sip/communicator/impl/packetlogging/packetlogging.manifest.mf b/src/net/java/sip/communicator/impl/packetlogging/packetlogging.manifest.mf index c7800d377..9028ca77b 100644 --- a/src/net/java/sip/communicator/impl/packetlogging/packetlogging.manifest.mf +++ b/src/net/java/sip/communicator/impl/packetlogging/packetlogging.manifest.mf @@ -5,10 +5,11 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.configuration, + org.jitsi.service.fileaccess, + org.jitsi.service.packetlogging, net.java.sip.communicator.service.gui, - net.java.sip.communicator.service.neomedia, + org.jitsi.service.neomedia, net.java.sip.communicator.service.protocol, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, @@ -16,4 +17,3 @@ Import-Package: org.osgi.framework, javax.swing.border, javax.swing.event, javax.swing.text -Export-Package: net.java.sip.communicator.service.packetlogging diff --git a/src/net/java/sip/communicator/impl/protocol/dict/DictActivator.java b/src/net/java/sip/communicator/impl/protocol/dict/DictActivator.java index 5e201cb52..5e5b999af 100644 --- a/src/net/java/sip/communicator/impl/protocol/dict/DictActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/dict/DictActivator.java @@ -6,12 +6,13 @@ */ package net.java.sip.communicator.impl.protocol.dict; -import org.osgi.framework.*; - -import net.java.sip.communicator.util.*; import java.util.*; + import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; +import net.java.sip.communicator.util.*; + +import org.jitsi.service.resources.*; +import org.osgi.framework.*; /** * Loads the Dict provider factory and registers its services in the OSGI diff --git a/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java index 0803c029e..469b996b3 100644 --- a/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java @@ -9,9 +9,9 @@ import net.java.dict4j.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.service.version.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.version.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/protocol/dict/dict.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/dict/dict.provider.manifest.mf index 4d0dc9740..eb4be9a45 100644 --- a/src/net/java/sip/communicator/impl/protocol/dict/dict.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/dict/dict.provider.manifest.mf @@ -5,11 +5,11 @@ Bundle-Vendor: jitsi.org Bundle-Version: 1.0.0 System-Bundle: yes Import-Package: org.osgi.framework, + org.jitsi.service.version, net.java.sip.communicator.service.contactlist, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.version Export-Package: net.java.dict4j diff --git a/src/net/java/sip/communicator/impl/protocol/gibberish/GibberishActivator.java b/src/net/java/sip/communicator/impl/protocol/gibberish/GibberishActivator.java index b9263303e..94a0b2358 100644 --- a/src/net/java/sip/communicator/impl/protocol/gibberish/GibberishActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/gibberish/GibberishActivator.java @@ -6,12 +6,13 @@ */ package net.java.sip.communicator.impl.protocol.gibberish; -import org.osgi.framework.*; - -import net.java.sip.communicator.util.*; import java.util.*; + import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; +import net.java.sip.communicator.util.*; + +import org.jitsi.service.resources.*; +import org.osgi.framework.*; /** * Loads the Gibberish provider factory and registers its services in the OSGI diff --git a/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolIconGibberishImpl.java b/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolIconGibberishImpl.java index 356619260..7e479a694 100644 --- a/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolIconGibberishImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolIconGibberishImpl.java @@ -10,9 +10,9 @@ import java.util.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/protocol/gibberish/gibberish.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/gibberish/gibberish.provider.manifest.mf index f026f4ceb..df549896a 100644 --- a/src/net/java/sip/communicator/impl/protocol/gibberish/gibberish.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/gibberish/gibberish.provider.manifest.mf @@ -5,8 +5,8 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, net.java.sip.communicator.util, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, diff --git a/src/net/java/sip/communicator/impl/protocol/icq/IcqActivator.java b/src/net/java/sip/communicator/impl/protocol/icq/IcqActivator.java index e9809e6d4..d201caf7c 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/IcqActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/IcqActivator.java @@ -2,11 +2,11 @@ import java.util.*; -import org.osgi.framework.*; - -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; + +import org.jitsi.service.resources.*; +import org.osgi.framework.*; /** * Loads the ICQ provider factory and registers it with service in the OSGI diff --git a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetExtendedAuthorizationsIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetExtendedAuthorizationsIcqImpl.java index b00d1eb09..d9e1ac2fe 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetExtendedAuthorizationsIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetExtendedAuthorizationsIcqImpl.java @@ -125,4 +125,4 @@ public SubscriptionStatus getSubscriptionStatus(Contact contact) return SubscriptionStatus.Subscribed; } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolIconAimImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolIconAimImpl.java index 461ddd850..61f1bbfa2 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolIconAimImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolIconAimImpl.java @@ -10,8 +10,9 @@ import java.util.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; + +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolIconIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolIconIcqImpl.java index 40687f45e..42c09af6c 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolIconIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolIconIcqImpl.java @@ -10,8 +10,9 @@ import java.util.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; + +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/protocol/icq/VolatileBuddy.java b/src/net/java/sip/communicator/impl/protocol/icq/VolatileBuddy.java index 13a05f81d..903d16a5e 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/VolatileBuddy.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/VolatileBuddy.java @@ -68,4 +68,4 @@ public void setAwaitingAuthorization(boolean value) { this.isAwaitingAuthorization = value; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/icq/icq.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/icq/icq.provider.manifest.mf index b5d364126..83c05c1a8 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/icq.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/icq/icq.provider.manifest.mf @@ -7,8 +7,8 @@ System-Bundle: yes Import-Package: org.osgi.framework, javax.net, sun.misc, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.dns, net.java.sip.communicator.service.protocol, diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomInvitationIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomInvitationIrcImpl.java index d01b2aa10..379aab1be 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomInvitationIrcImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomInvitationIrcImpl.java @@ -96,4 +96,4 @@ public byte[] getChatRoomPassword() { return chatRoomPasword; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/irc/IrcActivator.java b/src/net/java/sip/communicator/impl/protocol/irc/IrcActivator.java index 2b8af5955..92c368f45 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/IrcActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/IrcActivator.java @@ -6,12 +6,14 @@ */ package net.java.sip.communicator.impl.protocol.irc; -import org.osgi.framework.*; - -import net.java.sip.communicator.util.*; import java.util.*; + import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; +import net.java.sip.communicator.util.*; + +import org.jitsi.service.resources.*; +import org.osgi.framework.*; /** * Loads the IRC provider factory and registers its services in the OSGI diff --git a/src/net/java/sip/communicator/impl/protocol/irc/irc.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/irc/irc.provider.manifest.mf index 197023235..42b4a1051 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/irc.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/irc/irc.provider.manifest.mf @@ -5,8 +5,8 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ActiveCallsRepositoryGTalkImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ActiveCallsRepositoryGTalkImpl.java index 5c421b07b..9742e9729 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ActiveCallsRepositoryGTalkImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ActiveCallsRepositoryGTalkImpl.java @@ -120,4 +120,4 @@ protected void fireCallEvent(int eventID, Call sourceCall) { parentOperationSet.fireCallEvent(eventID, sourceCall); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallJabberImpl.java index 44d43a22c..f10667961 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/CallJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallJabberImpl.java @@ -12,12 +12,12 @@ import net.java.sip.communicator.impl.protocol.jabber.extensions.cobri.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; import net.java.sip.communicator.impl.protocol.jabber.jinglesdp.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.filter.*; import org.jivesoftware.smack.packet.*; diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java index fd99abfea..f94059ee0 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java @@ -6,23 +6,23 @@ */ package net.java.sip.communicator.impl.protocol.jabber; -import java.util.*; import java.lang.reflect.*; - -import org.jivesoftware.smack.*; -import org.jivesoftware.smack.filter.*; -import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smackx.packet.*; +import java.util.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; -import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.ContentPacketExtension.*; +import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.ContentPacketExtension.SendersEnum; import net.java.sip.communicator.impl.protocol.jabber.jinglesdp.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; +import org.jivesoftware.smack.*; +import org.jivesoftware.smack.filter.*; +import org.jivesoftware.smack.packet.*; +import org.jivesoftware.smackx.packet.*; + /** * Implements a Jabber CallPeer. * diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerGTalkImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerGTalkImpl.java index 3e9eb889e..f0ebc96a6 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerGTalkImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerGTalkImpl.java @@ -12,13 +12,14 @@ import net.java.sip.communicator.impl.protocol.jabber.extensions.gtalk.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; import net.java.sip.communicator.impl.protocol.jabber.jinglesdp.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.service.neomedia.format.*; + /** * A Google Talk-specific extension of the generic media handler. * diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java index b7dfa37c1..78e59af6b 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java @@ -9,18 +9,18 @@ import java.lang.reflect.*; import java.util.*; -import org.jivesoftware.smack.util.StringUtils; -import org.jivesoftware.smackx.packet.*; - import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; import net.java.sip.communicator.impl.protocol.jabber.jinglesdp.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.service.neomedia.format.*; +import org.jivesoftware.smack.util.StringUtils; +import org.jivesoftware.smackx.packet.*; + /** * An XMPP specific extension of the generic media handler. * diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/IceUdpTransportManager.java b/src/net/java/sip/communicator/impl/protocol/jabber/IceUdpTransportManager.java index c6d4b8f21..c7c532f56 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/IceUdpTransportManager.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/IceUdpTransportManager.java @@ -12,7 +12,6 @@ import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.CandidateType; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; @@ -22,8 +21,8 @@ import org.ice4j.ice.*; import org.ice4j.ice.harvest.*; import org.ice4j.security.*; +import org.jitsi.service.neomedia.*; import org.jivesoftware.smack.packet.*; - import org.xmpp.jnodes.smack.*; /** diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/JabberActivator.java b/src/net/java/sip/communicator/impl/protocol/jabber/JabberActivator.java index 6bfd8afc2..ec53bafa7 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/JabberActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/JabberActivator.java @@ -8,19 +8,20 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; +import net.java.sip.communicator.service.googlecontacts.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.hid.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.netaddr.*; -import net.java.sip.communicator.service.packetlogging.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.service.googlecontacts.*; -import net.java.sip.communicator.service.version.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.packetlogging.*; +import org.jitsi.service.resources.*; +import org.jitsi.service.version.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/JingleNodesHarvester.java b/src/net/java/sip/communicator/impl/protocol/jabber/JingleNodesHarvester.java index 85ff9deec..5147f5e88 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/JingleNodesHarvester.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/JingleNodesHarvester.java @@ -178,4 +178,4 @@ protected JingleNodesCandidate createJingleNodesCandidate( return cand; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetAutoAnswerJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetAutoAnswerJabberImpl.java index 12343d144..1f1bfbdbd 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetAutoAnswerJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetAutoAnswerJabberImpl.java @@ -6,12 +6,11 @@ */ package net.java.sip.communicator.impl.protocol.jabber; -import net.java.sip.communicator.service.neomedia.*; +import java.util.*; + import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.*; -import java.util.*; +import org.jitsi.service.neomedia.*; /** * An Operation Set defining option to unconditionally auto answer incoming diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java index c012e7a7f..70064f6c5 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java @@ -8,18 +8,18 @@ import java.util.*; -import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.gtalk.*; -import net.java.sip.communicator.service.neomedia.*; +import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.filter.*; import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.packet.IQ.*; +import org.jivesoftware.smack.packet.IQ.Type; import org.jivesoftware.smack.provider.*; import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smackx.packet.*; diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDTMFJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDTMFJabberImpl.java index 3af0f89b1..020f6e070 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDTMFJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDTMFJabberImpl.java @@ -8,12 +8,15 @@ import java.util.*; -import net.java.sip.communicator.impl.neomedia.codec.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.format.*; import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.service.protocol.OperationFailedException; import net.java.sip.communicator.util.*; +import org.jitsi.impl.neomedia.codec.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.format.*; +import org.jitsi.service.protocol.*; + /** * Class responsible for sending a DTMF Tone using using rfc4733 or Inband. * diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopSharingServerJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopSharingServerJabberImpl.java index c22fef81b..6f9c406ea 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopSharingServerJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopSharingServerJabberImpl.java @@ -6,25 +6,24 @@ */ package net.java.sip.communicator.impl.protocol.jabber; -import java.util.*; -import java.text.*; - import java.awt.event.*; - -import org.jivesoftware.smack.*; -import org.jivesoftware.smack.filter.*; -import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smackx.packet.*; +import java.text.*; +import java.util.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.inputevt.*; import net.java.sip.communicator.service.hid.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.service.neomedia.format.*; +import org.jivesoftware.smack.*; +import org.jivesoftware.smack.filter.*; +import org.jivesoftware.smack.packet.*; +import org.jivesoftware.smackx.packet.*; + /** * Implements all desktop sharing server-side related functions for Jabber * protocol. diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopStreamingJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopStreamingJabberImpl.java index 6a3323048..8aedbf2f7 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopStreamingJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopStreamingJabberImpl.java @@ -9,12 +9,13 @@ import java.awt.*; import java.text.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.service.neomedia.format.*; + /** * Implements all desktop streaming related functions for XMPP. * diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java index 6c1238860..657e71163 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java @@ -8,19 +8,19 @@ import java.util.*; -import org.jivesoftware.smack.*; -import org.jivesoftware.smack.filter.*; -import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.packet.IQ.*; -import org.jivesoftware.smackx.packet.*; - import net.java.sip.communicator.impl.protocol.jabber.extensions.coin.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.media.*; -import net.java.sip.communicator.util.Logger; +import net.java.sip.communicator.util.*; + +import org.jitsi.service.neomedia.*; +import org.jivesoftware.smack.*; +import org.jivesoftware.smack.filter.*; +import org.jivesoftware.smack.packet.*; +import org.jivesoftware.smack.packet.IQ.Type; +import org.jivesoftware.smackx.packet.*; /** * Implements OperationSetTelephonyConferencing for Jabber. diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetVideoTelephonyJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetVideoTelephonyJabberImpl.java index fa2d91288..76f606042 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetVideoTelephonyJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetVideoTelephonyJabberImpl.java @@ -6,11 +6,12 @@ */ package net.java.sip.communicator.impl.protocol.jabber; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; + /** * Implements OperationSetVideoTelephony in order to give access to * video-specific functionality in the Jabber protocol implementation. diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolIconJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolIconJabberImpl.java index 956cacb98..be35ccfe4 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolIconJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolIconJabberImpl.java @@ -11,9 +11,9 @@ import java.util.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java index 6352de04b..a6e3b7286 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java @@ -32,7 +32,7 @@ import net.java.sip.communicator.impl.protocol.jabber.extensions.coin.*; import net.java.sip.communicator.impl.protocol.jabber.sasl.*; import net.java.sip.communicator.service.certificate.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.packet.*; diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/QualityControlWrapper.java b/src/net/java/sip/communicator/impl/protocol/jabber/QualityControlWrapper.java index ce7386782..77e33bd1f 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/QualityControlWrapper.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/QualityControlWrapper.java @@ -6,11 +6,12 @@ */ package net.java.sip.communicator.impl.protocol.jabber; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.protocol.*; + /** * A wrapper of media quality control. * @@ -57,12 +58,18 @@ public void setPreferredRemoteSendMaxPreset(QualityPreset preset) // re-invites the peer with the new settings peer.sendModifyVideoResolutionContent(); } - catch (Throwable ex) + catch (Throwable cause) { - ProtocolProviderServiceJabberImpl.throwOperationFailedException( - "Failed to re-invite for video quality change.", - OperationFailedException.INTERNAL_ERROR, ex, logger); + String message + = "Failed to re-invite for video quality change."; + + logger.error(message, cause); + + throw new OperationFailedException( + message, + OperationFailedException.INTERNAL_ERROR, + cause); } } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/RawUdpTransportManager.java b/src/net/java/sip/communicator/impl/protocol/jabber/RawUdpTransportManager.java index 2443d608d..0e52d38a0 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/RawUdpTransportManager.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/RawUdpTransportManager.java @@ -12,9 +12,10 @@ import net.java.sip.communicator.impl.protocol.jabber.extensions.cobri.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; import net.java.sip.communicator.impl.protocol.jabber.jinglesdp.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; +import org.jitsi.service.neomedia.*; + /** * A {@link TransportManagerJabberImpl} implementation that would only gather a * single candidate pair (i.e. RTP and RTCP). diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/TransportManagerGTalkImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/TransportManagerGTalkImpl.java index 457e3e444..c93f31bea 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/TransportManagerGTalkImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/TransportManagerGTalkImpl.java @@ -11,27 +11,27 @@ import java.net.*; import java.util.*; -import org.ice4j.*; -import org.ice4j.ice.*; -import org.ice4j.ice.harvest.*; -import org.jivesoftware.smack.*; -import org.jivesoftware.smack.filter.*; -import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.packet.IQ.*; -import org.jivesoftware.smack.util.StringUtils; -import org.xmpp.jnodes.smack.*; - import net.java.sip.communicator.impl.protocol.jabber.extensions.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.gtalk.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingleinfo.*; import net.java.sip.communicator.service.httputil.*; import net.java.sip.communicator.service.httputil.HttpUtils.HTTPResponseResult; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.ice4j.*; +import org.ice4j.ice.*; +import org.ice4j.ice.harvest.*; +import org.jitsi.service.neomedia.*; +import org.jivesoftware.smack.*; +import org.jivesoftware.smack.filter.*; +import org.jivesoftware.smack.packet.IQ.Type; +import org.jivesoftware.smack.packet.*; +import org.jivesoftware.smack.util.StringUtils; +import org.xmpp.jnodes.smack.*; + /** * TransportManagers gather local candidates for incoming and outgoing * calls. Their work starts by calling a start method which, using the remote diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/TransportManagerJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/TransportManagerJabberImpl.java index 31975c4c5..687087d83 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/TransportManagerJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/TransportManagerJabberImpl.java @@ -10,10 +10,11 @@ import java.util.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; +import org.jitsi.service.neomedia.*; + /** * TransportManagers gather local candidates for incoming and outgoing * calls. Their work starts by calling a start method which, using the remote diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/WhiteboardInvitationJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/WhiteboardInvitationJabberImpl.java index 3d280c86b..cac401140 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/WhiteboardInvitationJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/WhiteboardInvitationJabberImpl.java @@ -108,4 +108,4 @@ public WhiteboardObject getWhiteboardInitialObject() { return firstWhiteboardObject; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/debugger/SmackPacketDebugger.java b/src/net/java/sip/communicator/impl/protocol/jabber/debugger/SmackPacketDebugger.java index 77aa3eb5c..1117c8ab9 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/debugger/SmackPacketDebugger.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/debugger/SmackPacketDebugger.java @@ -7,7 +7,8 @@ package net.java.sip.communicator.impl.protocol.jabber.debugger; import net.java.sip.communicator.impl.protocol.jabber.*; -import net.java.sip.communicator.service.packetlogging.*; + +import org.jitsi.service.packetlogging.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.packet.*; diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java index aab2c61cd..1142b3830 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java @@ -13,7 +13,7 @@ import java.util.concurrent.*; import net.java.sip.communicator.impl.protocol.jabber.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.Logger; // disambiguation diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/cobri/CobriStreamConnector.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/cobri/CobriStreamConnector.java index 288da0e3f..a682ea662 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/cobri/CobriStreamConnector.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/cobri/CobriStreamConnector.java @@ -6,7 +6,7 @@ */ package net.java.sip.communicator.impl.protocol.jabber.extensions.cobri; -import net.java.sip.communicator.service.neomedia.*; +import org.jitsi.service.neomedia.*; /** * Implements a StreamConnector which allows sharing a specific diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/coin/StateProvider.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/coin/StateProvider.java index 4ff4b2dc1..81ad6642b 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/coin/StateProvider.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/coin/StateProvider.java @@ -75,4 +75,4 @@ else if (eventType == XmlPullParser.END_TAG) return ext; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/gtalk/SrcIdPacketExtension.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/gtalk/SrcIdPacketExtension.java index 85fa65987..a5e2af36c 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/gtalk/SrcIdPacketExtension.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/gtalk/SrcIdPacketExtension.java @@ -45,4 +45,4 @@ public void setSrcId(String srcId) { this.setText(srcId); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/gtalk/UsagePacketExtension.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/gtalk/UsagePacketExtension.java index 4e05d06ec..1664a3b0d 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/gtalk/UsagePacketExtension.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/gtalk/UsagePacketExtension.java @@ -33,4 +33,4 @@ public UsagePacketExtension() { super(NAMESPACE, ELEMENT_NAME); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/CoinPacketExtension.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/CoinPacketExtension.java index 17aa4dd2f..73cdcb163 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/CoinPacketExtension.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/CoinPacketExtension.java @@ -51,4 +51,4 @@ public CoinPacketExtension(boolean isFocus) super(NAMESPACE, ELEMENT_NAME); setAttribute(ISFOCUS_ATTR_NAME, isFocus); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/version/VersionManager.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/version/VersionManager.java index fa2e79ba2..8bf8168f8 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/version/VersionManager.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/version/VersionManager.java @@ -8,8 +8,9 @@ import net.java.sip.communicator.impl.protocol.jabber.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.version.Version; import net.java.sip.communicator.service.protocol.event.*; + +import org.jitsi.service.version.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.filter.*; import org.jivesoftware.smack.packet.*; diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectImageJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectImageJabberImpl.java index d9136f781..ad48129fd 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectImageJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectImageJabberImpl.java @@ -219,4 +219,4 @@ public String toXML () return s; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectJabberImpl.java index 67c5d9777..1e32aa6e0 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectJabberImpl.java @@ -195,4 +195,4 @@ public void setThickness (int thickness) * method */ public abstract String toXML (); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectJabberProvider.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectJabberProvider.java index 9543406b5..1a58bf9b7 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectJabberProvider.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectJabberProvider.java @@ -86,4 +86,4 @@ else if (eventType == XmlPullParser.END_TAG return extension; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectLineJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectLineJabberImpl.java index 42a45095a..e9baf038f 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectLineJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectLineJabberImpl.java @@ -168,4 +168,4 @@ public String toXML () return s; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectPacketExtension.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectPacketExtension.java index 4da11d516..46c37a0df 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectPacketExtension.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectPacketExtension.java @@ -284,4 +284,4 @@ public void setWhiteboardObjectID (String objectID) { this.whiteboardObjectID = objectID; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectRectJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectRectJabberImpl.java index 57a049b47..65e3b387c 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectRectJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectRectJabberImpl.java @@ -277,4 +277,4 @@ public String toXML () return s; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectTextJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectTextJabberImpl.java index 6f7cbf13c..ea9e730fe 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectTextJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/whiteboard/WhiteboardObjectTextJabberImpl.java @@ -220,4 +220,4 @@ public String toXML () return s; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/jabber.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/jabber/jabber.provider.manifest.mf index 8872df07b..f4bee41fd 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/jabber.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/jabber/jabber.provider.manifest.mf @@ -31,22 +31,23 @@ Import-Package: org.osgi.framework, org.jivesoftware.smackx.jingle.provider, org.jivesoftware.smackx.filetransfer, org.jivesoftware.smackx.provider, + org.jitsi.service.version, org.w3c.dom, net.java.sip.communicator.service.customavatar, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.dns, - net.java.sip.communicator.service.packetlogging, + org.jitsi.service.packetlogging, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.jabberconstants, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.whiteboardobjects, net.java.sip.communicator.service.protocol.media, - net.java.sip.communicator.service.neomedia, - net.java.sip.communicator.service.neomedia.device, - net.java.sip.communicator.service.neomedia.event, - net.java.sip.communicator.service.neomedia.format, + org.jitsi.service.neomedia, + org.jitsi.service.neomedia.device, + org.jitsi.service.neomedia.event, + org.jitsi.service.neomedia.format, net.java.sip.communicator.service.credentialsstorage, net.java.sip.communicator.service.hid, net.java.sip.communicator.service.netaddr, @@ -54,7 +55,6 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.certificate, net.java.sip.communicator.service.httputil, net.java.sip.communicator.service.gui, - net.java.sip.communicator.service.version, org.xmlpull.v1, org.xmlpull.mxp1, javax.xml.parsers, diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/jinglesdp/JingleUtils.java b/src/net/java/sip/communicator/impl/protocol/jabber/jinglesdp/JingleUtils.java index 6edf49551..097dd4e6c 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/jinglesdp/JingleUtils.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/jinglesdp/JingleUtils.java @@ -11,12 +11,14 @@ import net.java.sip.communicator.impl.protocol.jabber.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.format.*; +import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.ContentPacketExtension.CreatorEnum; +import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.ContentPacketExtension.SendersEnum; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.NetworkUtils; //disambiguates with ice4j's network utils. -import static net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.ContentPacketExtension.*; + +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.format.*; +//disambiguates with ice4j's network utils. /** * The class contains a number of utility methods that are meant to facilitate diff --git a/src/net/java/sip/communicator/impl/protocol/msn/MsnActivator.java b/src/net/java/sip/communicator/impl/protocol/msn/MsnActivator.java index 31e22d941..50b1fd219 100644 --- a/src/net/java/sip/communicator/impl/protocol/msn/MsnActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/msn/MsnActivator.java @@ -8,12 +8,13 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; - import net.java.sip.communicator.util.*; + +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf index bc2168875..e7c6189d1 100644 --- a/src/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf @@ -29,9 +29,9 @@ Import-Package: org.apache.commons.logging, javax.xml.datatype, sun.security.action, javax.imageio, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.fileaccess, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.fileaccess, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.dns, net.java.sip.communicator.service.protocol, diff --git a/src/net/java/sip/communicator/impl/protocol/rss/ProtocolIconRssImpl.java b/src/net/java/sip/communicator/impl/protocol/rss/ProtocolIconRssImpl.java index e6152a77f..47839623c 100644 --- a/src/net/java/sip/communicator/impl/protocol/rss/ProtocolIconRssImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/rss/ProtocolIconRssImpl.java @@ -10,9 +10,9 @@ import java.util.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/protocol/rss/RssActivator.java b/src/net/java/sip/communicator/impl/protocol/rss/RssActivator.java index b275b2dd9..f25e531ee 100644 --- a/src/net/java/sip/communicator/impl/protocol/rss/RssActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/rss/RssActivator.java @@ -6,8 +6,6 @@ */ package net.java.sip.communicator.impl.protocol.rss; -import org.osgi.framework.*; - import java.util.*; import net.java.sip.communicator.service.gui.*; @@ -15,6 +13,9 @@ import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; + /** * Loads the Rss provider factory and registers its services in the OSGI * bundle context. diff --git a/src/net/java/sip/communicator/impl/protocol/rss/rss.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/rss/rss.provider.manifest.mf index 6a018f051..508ec35ab 100644 --- a/src/net/java/sip/communicator/impl/protocol/rss/rss.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/rss/rss.provider.manifest.mf @@ -13,9 +13,9 @@ Import-Package: org.osgi.framework, javax.xml.parsers, javax.imageio, javax.net.ssl, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandlerSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandlerSipImpl.java index 0aab3541a..8de5f0702 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandlerSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandlerSipImpl.java @@ -12,15 +12,16 @@ import javax.sdp.*; import net.java.sip.communicator.impl.protocol.sip.sdp.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.service.neomedia.format.*; + /** * The media handler class handles all media management for a single * CallPeer. This includes initializing and configuring streams, diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java index eaccbcd05..f43d06b66 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java @@ -6,6 +6,9 @@ */ package net.java.sip.communicator.impl.protocol.sip; +import static net.java.sip.communicator.service.protocol.OperationSetBasicTelephony.HANGUP_REASON_ENCRYPTION_REQUIRED; +import static net.java.sip.communicator.service.protocol.OperationSetBasicTelephony.HANGUP_REASON_NORMAL_CLEARING; +import static net.java.sip.communicator.service.protocol.OperationSetBasicTelephony.HANGUP_REASON_TIMEOUT; import gov.nist.javax.sip.header.*; import java.net.*; @@ -19,14 +22,13 @@ import javax.sip.message.*; import net.java.sip.communicator.impl.protocol.sip.sdp.*; -import net.java.sip.communicator.service.neomedia.control.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.Contact; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; -import static net.java.sip.communicator.service.protocol.OperationSetBasicTelephony.*; +import org.jitsi.service.neomedia.control.*; /** * Our SIP implementation of the default CallPeer; diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java index c02ddd6ce..8bd051c70 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java @@ -14,12 +14,13 @@ import javax.sip.message.*; import net.java.sip.communicator.impl.protocol.sip.sdp.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; + /** * A SIP implementation of the Call abstract class encapsulating SIP dialogs. * diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetAutoAnswerSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetAutoAnswerSipImpl.java index 888331705..1cbf3f176 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetAutoAnswerSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetAutoAnswerSipImpl.java @@ -7,18 +7,22 @@ package net.java.sip.communicator.impl.protocol.sip; import gov.nist.javax.sip.header.*; -import net.java.sip.communicator.impl.protocol.sip.sdp.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.*; +import java.util.*; + +import javax.sdp.*; import javax.sip.*; import javax.sip.address.*; -import javax.sip.header.ContactHeader; // Disambiguation. +import javax.sip.header.*; import javax.sip.message.*; -import javax.sdp.*; -import java.util.*; + +import net.java.sip.communicator.impl.protocol.sip.sdp.*; +import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.util.*; + +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.MediaType; +// Disambiguation. /** * An Operation Set defining options to auto answer/forward incoming calls. diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDTMFSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDTMFSipImpl.java index a2002f5e4..7142577d3 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDTMFSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDTMFSipImpl.java @@ -8,13 +8,16 @@ import java.util.*; -import net.java.sip.communicator.impl.neomedia.codec.*; import net.java.sip.communicator.impl.protocol.sip.dtmf.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.format.*; import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.service.protocol.OperationFailedException; import net.java.sip.communicator.util.*; +import org.jitsi.impl.neomedia.codec.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.format.*; +import org.jitsi.service.protocol.*; + /** * Class responsible for sending a DTMF Tone using SIP INFO or using rfc4733. * diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopSharingServerSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopSharingServerSipImpl.java index 178ec1b16..63eb35321 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopSharingServerSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopSharingServerSipImpl.java @@ -6,30 +6,30 @@ */ package net.java.sip.communicator.impl.protocol.sip; -import java.io.*; -import java.util.List; // disambiguation -import java.text.*; import java.awt.*; import java.awt.event.*; +import java.io.*; +import java.text.*; +import java.util.List; -import javax.sip.Dialog; // disambiguation import javax.sip.*; +import javax.sip.Dialog; import javax.sip.address.*; import javax.sip.header.*; import javax.sip.message.*; import javax.xml.parsers.*; -import org.w3c.dom.*; -import org.xml.sax.*; - -import net.java.sip.communicator.service.neomedia.MediaType; // disambiguation -import net.java.sip.communicator.service.neomedia.format.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.hid.*; +import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.MediaType; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.service.neomedia.format.*; +import org.w3c.dom.*; +import org.xml.sax.*; + /** * Implements all desktop sharing server-side related functions for SIP * protocol. diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopStreamingSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopStreamingSipImpl.java index 6bb873a37..a906535dc 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopStreamingSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopStreamingSipImpl.java @@ -11,11 +11,12 @@ import javax.sip.address.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; import net.java.sip.communicator.service.protocol.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.service.neomedia.format.*; + /** * Implements all desktop streaming related functions for SIP. * diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetTelephonyConferencingSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetTelephonyConferencingSipImpl.java index 757513552..e4e573669 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetTelephonyConferencingSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetTelephonyConferencingSipImpl.java @@ -17,18 +17,18 @@ import javax.sip.address.*; import javax.sip.header.*; import javax.sip.message.*; -import javax.sip.message.Message; // disambiguation +import javax.sip.message.Message; import javax.xml.parsers.*; import net.java.sip.communicator.impl.protocol.sip.sdp.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.MediaType; // disambiguation import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.xml.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.MediaType; import org.w3c.dom.*; import org.xml.sax.*; diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetVideoTelephonySipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetVideoTelephonySipImpl.java index aa2a390f6..3ebfd52f8 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetVideoTelephonySipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetVideoTelephonySipImpl.java @@ -10,15 +10,16 @@ import java.text.*; import javax.sip.*; -import javax.sip.address.Address; +import javax.sip.address.*; import javax.sip.header.*; import javax.sip.message.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; + /** * Implements OperationSetVideoTelephony in order to give access to * video-specific functionality in the SIP protocol implementation such as diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolIconSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolIconSipImpl.java index 9bd47822a..c361d7f30 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolIconSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolIconSipImpl.java @@ -10,9 +10,10 @@ import java.util.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; + /** * Represents the Sip protocol icon. Implements the ProtocolIcon * interface in order to provide an sip icon image in two different sizes. diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java index f4c91dcd9..9fb5b2e70 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java @@ -9,24 +9,26 @@ import gov.nist.javax.sip.address.*; import gov.nist.javax.sip.header.*; import gov.nist.javax.sip.message.*; + +import java.net.*; +import java.text.*; +import java.util.*; + +import javax.sip.*; +import javax.sip.address.*; +import javax.sip.header.*; +import javax.sip.message.*; + import net.java.sip.communicator.impl.protocol.sip.net.*; import net.java.sip.communicator.impl.protocol.sip.security.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.service.version.Version; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.dns.*; +import org.jitsi.service.version.Version; import org.osgi.framework.*; -import javax.sip.*; -import javax.sip.address.*; -import javax.sip.header.*; -import javax.sip.message.*; -import java.net.*; -import java.text.*; -import java.util.*; - /** * A SIP implementation of the Protocol Provider Service. * diff --git a/src/net/java/sip/communicator/impl/protocol/sip/QualityControlWrapper.java b/src/net/java/sip/communicator/impl/protocol/sip/QualityControlWrapper.java index 7b3ffcbd0..851636eff 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/QualityControlWrapper.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/QualityControlWrapper.java @@ -6,11 +6,12 @@ */ package net.java.sip.communicator.impl.protocol.sip; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.protocol.*; + /** * A wrapper of media quality control. * @author Damian Minkov @@ -55,11 +56,17 @@ public void setPreferredRemoteSendMaxPreset(QualityPreset preset) // re-invites the peer with the new settings peer.sendReInvite(); } - catch (Throwable ex) + catch (Throwable cause) { - ProtocolProviderServiceSipImpl.throwOperationFailedException( - "Failed to re-invite for video quality change.", - OperationFailedException.INTERNAL_ERROR, ex, logger); + String message + = "Failed to re-invite for video quality change."; + + logger.error(message, cause); + + throw new OperationFailedException( + message, + OperationFailedException.INTERNAL_ERROR, + cause); } } } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactListXivoImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactListXivoImpl.java index 374871876..751e852b1 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactListXivoImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactListXivoImpl.java @@ -7,18 +7,23 @@ package net.java.sip.communicator.impl.protocol.sip; import gov.nist.javax.sip.address.*; -import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.*; -import org.json.*; -import javax.sip.address.*; import java.io.*; import java.net.*; import java.net.URI; import java.util.*; +import javax.sip.address.*; + +import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.service.protocol.event.*; +import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; + +import org.jitsi.util.*; +import org.json.*; + /** * Xivo server stored contact list. Currently no modifications are possible. * Just connecting and downloading server contact list. diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipActivator.java b/src/net/java/sip/communicator/impl/protocol/sip/SipActivator.java index 2c7ff8c08..ad72d2220 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipActivator.java @@ -8,21 +8,21 @@ import java.util.*; -import net.java.sip.communicator.service.packetlogging.*; -import org.osgi.framework.*; - import net.java.sip.communicator.service.certificate.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.hid.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.service.version.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.packetlogging.*; +import org.jitsi.service.resources.*; +import org.jitsi.service.version.*; +import org.osgi.framework.*; + /** * Activates the SIP package * @author Emil Ivov diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipLogger.java b/src/net/java/sip/communicator/impl/protocol/sip/SipLogger.java index 02c1950f7..4329c85da 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipLogger.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipLogger.java @@ -9,14 +9,17 @@ import gov.nist.core.*; import gov.nist.javax.sip.*; import gov.nist.javax.sip.message.*; -import javax.sip.*; + import java.io.*; import java.net.*; import java.util.*; -import net.java.sip.communicator.service.packetlogging.*; +import javax.sip.*; + import net.java.sip.communicator.util.*; +import org.jitsi.service.packetlogging.*; + /** * This class passes log calls from JAIN-SIP to log4j, so that it is possible * to change the log level for the JAIN-SIP stack in logging.properties diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipStackProperties.java b/src/net/java/sip/communicator/impl/protocol/sip/SipStackProperties.java index b57243f71..ec87c51a5 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipStackProperties.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipStackProperties.java @@ -9,12 +9,14 @@ import java.io.*; import java.util.*; import java.util.logging.*; -import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.Logger; import javax.net.ssl.*; import net.java.sip.communicator.impl.protocol.sip.net.*; +import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; + +import org.jitsi.util.*; /** * The properties used at the creation of the JAIN-SIP stack. diff --git a/src/net/java/sip/communicator/impl/protocol/sip/dtmf/DTMFInfo.java b/src/net/java/sip/communicator/impl/protocol/sip/dtmf/DTMFInfo.java index 612030f90..04afee618 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/dtmf/DTMFInfo.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/dtmf/DTMFInfo.java @@ -18,9 +18,12 @@ import net.java.sip.communicator.impl.protocol.sip.*; import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.service.protocol.OperationFailedException; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.protocol.*; + /** * Sending DTMFs with SIP INFO. * diff --git a/src/net/java/sip/communicator/impl/protocol/sip/net/SslNetworkLayer.java b/src/net/java/sip/communicator/impl/protocol/sip/net/SslNetworkLayer.java index 850b3bc30..f4700cd11 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/net/SslNetworkLayer.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/net/SslNetworkLayer.java @@ -17,7 +17,7 @@ import net.java.sip.communicator.impl.protocol.sip.*; import net.java.sip.communicator.service.certificate.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.Logger; diff --git a/src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java b/src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java index 4b200df9a..a722d50f1 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java @@ -12,15 +12,18 @@ import java.util.*; import javax.sdp.*; -import javax.sip.header.ContentTypeHeader; // disambiguates MediaType +import javax.sip.header.*; import net.java.sip.communicator.impl.protocol.sip.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.format.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.MediaType; +import org.jitsi.service.neomedia.format.*; +// disambiguates MediaType + /** * The class contains a number of utility methods that are meant to facilitate * creating and parsing SDP descriptions. diff --git a/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf index 6f586f45a..37f89fd3e 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf @@ -31,29 +31,30 @@ Import-Package: org.apache.log4j, org.apache.http.conn.ssl, org.apache.http.conn.util, org.apache.http.impl.client, + org.jitsi.service.version, org.osgi.framework, org.w3c.dom, org.xml.sax, org.json, net.java.sip.communicator.service.argdelegation, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.credentialsstorage, net.java.sip.communicator.service.certificate, net.java.sip.communicator.service.gui, - net.java.sip.communicator.service.neomedia, - net.java.sip.communicator.service.neomedia.control, - net.java.sip.communicator.service.neomedia.device, - net.java.sip.communicator.service.neomedia.event, - net.java.sip.communicator.service.neomedia.format, + org.jitsi.service.neomedia, + org.jitsi.service.neomedia.control, + org.jitsi.service.neomedia.device, + org.jitsi.service.neomedia.event, + org.jitsi.service.neomedia.format, net.java.sip.communicator.service.hid, net.java.sip.communicator.service.netaddr, net.java.sip.communicator.service.netaddr.event, - net.java.sip.communicator.service.packetlogging, + org.jitsi.service.packetlogging, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.media, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.service.version, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + org.jitsi.util, net.java.sip.communicator.util, net.java.sip.communicator.util.dns, net.java.sip.communicator.util.xml, diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/BaseHttpXCapClient.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/BaseHttpXCapClient.java index 6d3ba2a74..060d4e01d 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/BaseHttpXCapClient.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/BaseHttpXCapClient.java @@ -582,4 +582,4 @@ protected String getXCapErrorMessage(XCapHttpResponse response) return null; } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/ParsingException.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/ParsingException.java index ed1ee1303..55e602c29 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/ParsingException.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/ParsingException.java @@ -65,4 +65,4 @@ public ParsingException(Throwable cause) { super(cause); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/prescontent/DataType.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/prescontent/DataType.java index 4c04e492a..6c298241e 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/prescontent/DataType.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/prescontent/DataType.java @@ -57,4 +57,4 @@ public Map getAnyAttributes() { return anyAttributes; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/prescontent/EncodingType.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/prescontent/EncodingType.java index 1809e971b..a4d387ffe 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/prescontent/EncodingType.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/prescontent/EncodingType.java @@ -57,4 +57,4 @@ public Map getAnyAttributes() { return anyAttributes; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/prescontent/MimeType.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/prescontent/MimeType.java index c4a0b1563..564187072 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/prescontent/MimeType.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/prescontent/MimeType.java @@ -57,4 +57,4 @@ public Map getAnyAttributes() { return anyAttributes; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/ClassType.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/ClassType.java index b36c5c94b..13a7ab85f 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/ClassType.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/ClassType.java @@ -43,4 +43,4 @@ public void setValue(String value) { this.value = value; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/OccurrenceIdType.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/OccurrenceIdType.java index c1669bf89..3a7e9fc01 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/OccurrenceIdType.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/OccurrenceIdType.java @@ -43,4 +43,4 @@ public void setValue(String value) { this.value = value; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/PresRulesParser.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/PresRulesParser.java index b3fdc19f6..f48ee4de4 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/PresRulesParser.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/PresRulesParser.java @@ -718,4 +718,4 @@ public static Element elementFromPersonPermission( processAny(element, personPermission.getAny()); return element; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/ProvideServicePermissionType.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/ProvideServicePermissionType.java index 992c9fd21..ffa5f0c64 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/ProvideServicePermissionType.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/ProvideServicePermissionType.java @@ -241,4 +241,4 @@ public void setValue(String value) this.value = value; } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/SubHandlingType.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/SubHandlingType.java index d71c10e1d..8a40956ff 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/SubHandlingType.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/presrules/SubHandlingType.java @@ -84,4 +84,4 @@ public static SubHandlingType fromString(String value) } return null; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/resourcelists/ListType.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/resourcelists/ListType.java index 95b66fdcb..e6b27ac4c 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/resourcelists/ListType.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/resourcelists/ListType.java @@ -199,4 +199,4 @@ public void setAnyAttributes(Map anyAttributes) { this.anyAttributes = anyAttributes; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/resourcelists/ResourceListsParser.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/resourcelists/ResourceListsParser.java index fed90b96d..02f2faef6 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/resourcelists/ResourceListsParser.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/model/resourcelists/ResourceListsParser.java @@ -714,4 +714,4 @@ else if (!isStandartXmlNamespace(namespaceUri)) displayName.setValue(displayNameElement.getTextContent()); return displayName; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java index c799077c7..8572eab41 100644 --- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java @@ -13,10 +13,12 @@ import java.util.*; -import org.osgi.framework.*; -import net.java.sip.communicator.util.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; +import net.java.sip.communicator.util.*; + +import org.jitsi.service.resources.*; +import org.osgi.framework.*; /** * Loads the SSH provider factory and registers its services in the OSGI diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ssh.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/ssh/ssh.provider.manifest.mf index 682107a73..4a1d6e132 100644 --- a/src/net/java/sip/communicator/impl/protocol/ssh/ssh.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/ssh/ssh.provider.manifest.mf @@ -11,10 +11,10 @@ Import-Package: org.osgi.framework, javax.swing, javax.swing.border, javax.swing.text, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolIconYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolIconYahooImpl.java index 30129f40d..0bfcbd853 100644 --- a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolIconYahooImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolIconYahooImpl.java @@ -9,12 +9,12 @@ import java.io.*; import java.util.*; -import org.osgi.framework.*; - import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; + /** * Represents the Yahoo protocol icon. Implements the ProtocolIcon * interface in order to provide an Yahoo icon image in two different sizes. diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/YahooActivator.java b/src/net/java/sip/communicator/impl/protocol/yahoo/YahooActivator.java index e9e712e0f..7b5063283 100644 --- a/src/net/java/sip/communicator/impl/protocol/yahoo/YahooActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/yahoo/YahooActivator.java @@ -8,10 +8,11 @@ import java.util.*; -import org.osgi.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; + +import org.jitsi.service.resources.*; +import org.osgi.framework.*; /** * Loads the Yahoo provider factory and registers it with service in the OSGI diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/yahoo.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/yahoo/yahoo.provider.manifest.mf index d39975759..65394a31f 100644 --- a/src/net/java/sip/communicator/impl/protocol/yahoo/yahoo.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/yahoo/yahoo.provider.manifest.mf @@ -13,8 +13,8 @@ Import-Package: org.osgi.framework, javax.naming.directory, org.xml.sax, sun.security.action, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.dns, net.java.sip.communicator.service.protocol, diff --git a/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolIconZeroconfImpl.java b/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolIconZeroconfImpl.java index ccc1b896e..9f177add1 100644 --- a/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolIconZeroconfImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolIconZeroconfImpl.java @@ -10,9 +10,9 @@ import java.util.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/protocol/zeroconf/zeroconf.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/zeroconf/zeroconf.provider.manifest.mf index ce5882098..b6b0a703c 100644 --- a/src/net/java/sip/communicator/impl/protocol/zeroconf/zeroconf.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/zeroconf/zeroconf.provider.manifest.mf @@ -5,8 +5,8 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event diff --git a/src/net/java/sip/communicator/impl/provdisc/dhcp/ProvisioningDiscoveryServiceDHCPImpl.java b/src/net/java/sip/communicator/impl/provdisc/dhcp/ProvisioningDiscoveryServiceDHCPImpl.java index 2804e966d..7f3a820b8 100644 --- a/src/net/java/sip/communicator/impl/provdisc/dhcp/ProvisioningDiscoveryServiceDHCPImpl.java +++ b/src/net/java/sip/communicator/impl/provdisc/dhcp/ProvisioningDiscoveryServiceDHCPImpl.java @@ -106,4 +106,4 @@ public void notifyProvisioningURL(DiscoveryEvent event) { fireDiscoveryEvent(event); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/bliptv/BliptvActivator.java b/src/net/java/sip/communicator/impl/replacement/bliptv/BliptvActivator.java index 1e876f0ad..2bddcdd00 100644 --- a/src/net/java/sip/communicator/impl/replacement/bliptv/BliptvActivator.java +++ b/src/net/java/sip/communicator/impl/replacement/bliptv/BliptvActivator.java @@ -68,4 +68,4 @@ public void stop(BundleContext context) throws Exception bliptvServReg.unregister(); logger.info("Blip.TV source implementation [STOPPED]."); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/bliptv/ReplacementServiceBliptvImpl.java b/src/net/java/sip/communicator/impl/replacement/bliptv/ReplacementServiceBliptvImpl.java index a88eafdfe..8942201d5 100644 --- a/src/net/java/sip/communicator/impl/replacement/bliptv/ReplacementServiceBliptvImpl.java +++ b/src/net/java/sip/communicator/impl/replacement/bliptv/ReplacementServiceBliptvImpl.java @@ -114,4 +114,4 @@ public String getPattern() { return BLIPTV_PATTERN; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/bliptv/bliptv.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/bliptv/bliptv.source.manifest.mf index 6fc5ea13a..fd9d81540 100644 --- a/src/net/java/sip/communicator/impl/replacement/bliptv/bliptv.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/bliptv/bliptv.source.manifest.mf @@ -6,8 +6,8 @@ Bundle-Version: 1.0.0 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, org.apache.http, - org.json \ No newline at end of file + org.json diff --git a/src/net/java/sip/communicator/impl/replacement/dailymotion/DailymotionActivator.java b/src/net/java/sip/communicator/impl/replacement/dailymotion/DailymotionActivator.java index 6db97e05d..120963435 100644 --- a/src/net/java/sip/communicator/impl/replacement/dailymotion/DailymotionActivator.java +++ b/src/net/java/sip/communicator/impl/replacement/dailymotion/DailymotionActivator.java @@ -67,4 +67,4 @@ public void stop(BundleContext context) throws Exception dailymotionSourceServReg.unregister(); logger.info("Dailymotion source implementation [STOPPED]."); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/dailymotion/ReplacementServiceDailymotionImpl.java b/src/net/java/sip/communicator/impl/replacement/dailymotion/ReplacementServiceDailymotionImpl.java index 58425e993..2db20fda9 100644 --- a/src/net/java/sip/communicator/impl/replacement/dailymotion/ReplacementServiceDailymotionImpl.java +++ b/src/net/java/sip/communicator/impl/replacement/dailymotion/ReplacementServiceDailymotionImpl.java @@ -93,4 +93,4 @@ public String getPattern() { return DAILYMOTION_PATTERN; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/dailymotion/dailymotion.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/dailymotion/dailymotion.source.manifest.mf index 019f210f7..b48159b96 100644 --- a/src/net/java/sip/communicator/impl/replacement/dailymotion/dailymotion.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/dailymotion/dailymotion.source.manifest.mf @@ -5,8 +5,8 @@ Bundle-Vendor: jitsi.org Bundle-Version: 1.0.0 System-Bundle: yes Import-Package: org.osgi.framework, + org.jitsi.service.version, net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.util, - net.java.sip.communicator.service.version \ No newline at end of file + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + net.java.sip.communicator.util diff --git a/src/net/java/sip/communicator/impl/replacement/directimage/DirectImageActivator.java b/src/net/java/sip/communicator/impl/replacement/directimage/DirectImageActivator.java index 548033e48..885df716d 100644 --- a/src/net/java/sip/communicator/impl/replacement/directimage/DirectImageActivator.java +++ b/src/net/java/sip/communicator/impl/replacement/directimage/DirectImageActivator.java @@ -68,4 +68,4 @@ public void stop(BundleContext context) throws Exception directImageSourceServReg.unregister(); logger.info("Direct Image Link source implementation [STOPPED]."); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/directimage/ReplacementServiceDirectImageImpl.java b/src/net/java/sip/communicator/impl/replacement/directimage/ReplacementServiceDirectImageImpl.java index 6de36b84a..f3fdb931b 100644 --- a/src/net/java/sip/communicator/impl/replacement/directimage/ReplacementServiceDirectImageImpl.java +++ b/src/net/java/sip/communicator/impl/replacement/directimage/ReplacementServiceDirectImageImpl.java @@ -77,4 +77,4 @@ public String getPattern() { return URL_PATTERN; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/directimage/directimage.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/directimage/directimage.source.manifest.mf index 331f52244..868724487 100644 --- a/src/net/java/sip/communicator/impl/replacement/directimage/directimage.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/directimage/directimage.source.manifest.mf @@ -5,8 +5,8 @@ Bundle-Vendor: jitsi.org Bundle-Version: 1.0.0 System-Bundle: yes Import-Package: org.osgi.framework, + org.jitsi.service.version, net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.util, - net.java.sip.communicator.service.version \ No newline at end of file + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + net.java.sip.communicator.util diff --git a/src/net/java/sip/communicator/impl/replacement/flickr/FlickrActivator.java b/src/net/java/sip/communicator/impl/replacement/flickr/FlickrActivator.java index 7088da02a..cf7e7e90f 100644 --- a/src/net/java/sip/communicator/impl/replacement/flickr/FlickrActivator.java +++ b/src/net/java/sip/communicator/impl/replacement/flickr/FlickrActivator.java @@ -68,4 +68,4 @@ public void stop(BundleContext context) throws Exception flickrServReg.unregister(); logger.info("Flickr source implementation [STOPPED]."); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/flickr/ReplacementServiceFlickrImpl.java b/src/net/java/sip/communicator/impl/replacement/flickr/ReplacementServiceFlickrImpl.java index 5b10caa17..fe79e2028 100644 --- a/src/net/java/sip/communicator/impl/replacement/flickr/ReplacementServiceFlickrImpl.java +++ b/src/net/java/sip/communicator/impl/replacement/flickr/ReplacementServiceFlickrImpl.java @@ -145,4 +145,4 @@ public String getPattern() { return FLICKR_PATTERN; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/flickr/flickr.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/flickr/flickr.source.manifest.mf index 5d91f2cbe..231f4959d 100644 --- a/src/net/java/sip/communicator/impl/replacement/flickr/flickr.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/flickr/flickr.source.manifest.mf @@ -6,8 +6,8 @@ Bundle-Version: 1.0.0 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, org.apache.http, - org.json \ No newline at end of file + org.json diff --git a/src/net/java/sip/communicator/impl/replacement/hulu/HuluActivator.java b/src/net/java/sip/communicator/impl/replacement/hulu/HuluActivator.java index 42faadc7d..b445a3ac3 100644 --- a/src/net/java/sip/communicator/impl/replacement/hulu/HuluActivator.java +++ b/src/net/java/sip/communicator/impl/replacement/hulu/HuluActivator.java @@ -67,4 +67,4 @@ public void stop(BundleContext context) throws Exception huluServReg.unregister(); logger.info("Hulu source implementation [STOPPED]."); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/hulu/ReplacementServiceHuluImpl.java b/src/net/java/sip/communicator/impl/replacement/hulu/ReplacementServiceHuluImpl.java index 303c0047f..58a5841db 100644 --- a/src/net/java/sip/communicator/impl/replacement/hulu/ReplacementServiceHuluImpl.java +++ b/src/net/java/sip/communicator/impl/replacement/hulu/ReplacementServiceHuluImpl.java @@ -112,4 +112,4 @@ public String getPattern() { return HULU_PATTERN; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/hulu/hulu.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/hulu/hulu.source.manifest.mf index 39d1b5115..b50cd0d0f 100644 --- a/src/net/java/sip/communicator/impl/replacement/hulu/hulu.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/hulu/hulu.source.manifest.mf @@ -6,8 +6,8 @@ Bundle-Version: 1.0.0 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, org.apache.http, - org.json \ No newline at end of file + org.json diff --git a/src/net/java/sip/communicator/impl/replacement/metacafe/MetacafeActivator.java b/src/net/java/sip/communicator/impl/replacement/metacafe/MetacafeActivator.java index f8b30c586..1d5ec4e5b 100644 --- a/src/net/java/sip/communicator/impl/replacement/metacafe/MetacafeActivator.java +++ b/src/net/java/sip/communicator/impl/replacement/metacafe/MetacafeActivator.java @@ -68,4 +68,4 @@ public void stop(BundleContext context) throws Exception metacafeServReg.unregister(); logger.info("Metacafe source implementation [STOPPED]."); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/metacafe/ReplacementServiceMetacafeImpl.java b/src/net/java/sip/communicator/impl/replacement/metacafe/ReplacementServiceMetacafeImpl.java index 2d0c116f6..6a156caec 100644 --- a/src/net/java/sip/communicator/impl/replacement/metacafe/ReplacementServiceMetacafeImpl.java +++ b/src/net/java/sip/communicator/impl/replacement/metacafe/ReplacementServiceMetacafeImpl.java @@ -92,4 +92,4 @@ public String getPattern() { return METACAFE_PATTERN; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/metacafe/metacafe.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/metacafe/metacafe.source.manifest.mf index df612234e..02a2a1b2f 100644 --- a/src/net/java/sip/communicator/impl/replacement/metacafe/metacafe.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/metacafe/metacafe.source.manifest.mf @@ -6,6 +6,6 @@ Bundle-Version: 1.0.0 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.util \ No newline at end of file + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + net.java.sip.communicator.util diff --git a/src/net/java/sip/communicator/impl/replacement/smiley/SmileyActivator.java b/src/net/java/sip/communicator/impl/replacement/smiley/SmileyActivator.java index 03b32aa8f..5b7c0363a 100644 --- a/src/net/java/sip/communicator/impl/replacement/smiley/SmileyActivator.java +++ b/src/net/java/sip/communicator/impl/replacement/smiley/SmileyActivator.java @@ -10,9 +10,9 @@ import net.java.sip.communicator.service.replacement.*; import net.java.sip.communicator.service.replacement.smilies.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** @@ -113,4 +113,4 @@ public static ResourceManagementService getResources() } return resourcesService; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/smiley/SmileyImpl.java b/src/net/java/sip/communicator/impl/replacement/smiley/SmileyImpl.java index a91c96787..4d2779483 100644 --- a/src/net/java/sip/communicator/impl/replacement/smiley/SmileyImpl.java +++ b/src/net/java/sip/communicator/impl/replacement/smiley/SmileyImpl.java @@ -103,4 +103,4 @@ public String getImagePath() return url.toString(); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/smiley/smiley.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/smiley/smiley.source.manifest.mf index 34ce08c9e..c02d7a151 100644 --- a/src/net/java/sip/communicator/impl/replacement/smiley/smiley.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/smiley/smiley.source.manifest.mf @@ -7,8 +7,8 @@ System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.replacement, net.java.sip.communicator.service.replacement.smilies, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.service.neomedia, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + org.jitsi.service.neomedia, net.java.sip.communicator.util, - net.java.sip.communicator.service.gui \ No newline at end of file + net.java.sip.communicator.service.gui diff --git a/src/net/java/sip/communicator/impl/replacement/twitpic/ReplacementServiceTwitpicImpl.java b/src/net/java/sip/communicator/impl/replacement/twitpic/ReplacementServiceTwitpicImpl.java index 167a974f4..7c0be3f15 100644 --- a/src/net/java/sip/communicator/impl/replacement/twitpic/ReplacementServiceTwitpicImpl.java +++ b/src/net/java/sip/communicator/impl/replacement/twitpic/ReplacementServiceTwitpicImpl.java @@ -92,4 +92,4 @@ public String getPattern() { return TWITPIC_PATTERN; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/twitpic/TwitpicActivator.java b/src/net/java/sip/communicator/impl/replacement/twitpic/TwitpicActivator.java index 0a627d5bf..a2f0d8f6f 100644 --- a/src/net/java/sip/communicator/impl/replacement/twitpic/TwitpicActivator.java +++ b/src/net/java/sip/communicator/impl/replacement/twitpic/TwitpicActivator.java @@ -68,4 +68,4 @@ public void stop(BundleContext context) throws Exception twitpicServReg.unregister(); logger.info("Twitpic source implementation [STOPPED]."); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/twitpic/twitpic.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/twitpic/twitpic.source.manifest.mf index 7e70d844a..e34d774d5 100644 --- a/src/net/java/sip/communicator/impl/replacement/twitpic/twitpic.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/twitpic/twitpic.source.manifest.mf @@ -6,6 +6,6 @@ Bundle-Version: 1.0.0 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.util \ No newline at end of file + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + net.java.sip.communicator.util diff --git a/src/net/java/sip/communicator/impl/replacement/vbox7/ReplacementServiceVbox7Impl.java b/src/net/java/sip/communicator/impl/replacement/vbox7/ReplacementServiceVbox7Impl.java index 3dcb71761..e05b5a2de 100644 --- a/src/net/java/sip/communicator/impl/replacement/vbox7/ReplacementServiceVbox7Impl.java +++ b/src/net/java/sip/communicator/impl/replacement/vbox7/ReplacementServiceVbox7Impl.java @@ -91,4 +91,4 @@ public String getPattern() { return VBOX7_PATTERN; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/vbox7/Vbox7Activator.java b/src/net/java/sip/communicator/impl/replacement/vbox7/Vbox7Activator.java index 05f030389..6c3438fba 100644 --- a/src/net/java/sip/communicator/impl/replacement/vbox7/Vbox7Activator.java +++ b/src/net/java/sip/communicator/impl/replacement/vbox7/Vbox7Activator.java @@ -68,4 +68,4 @@ public void stop(BundleContext context) throws Exception vbox7ServReg.unregister(); logger.info("Vbox7 source implementation [STOPPED]."); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/vbox7/vbox7.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/vbox7/vbox7.source.manifest.mf index 60e802ed6..53705dd16 100644 --- a/src/net/java/sip/communicator/impl/replacement/vbox7/vbox7.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/vbox7/vbox7.source.manifest.mf @@ -6,6 +6,6 @@ Bundle-Version: 1.0.0 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.util \ No newline at end of file + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + net.java.sip.communicator.util diff --git a/src/net/java/sip/communicator/impl/replacement/viddler/ReplacementServiceViddlerImpl.java b/src/net/java/sip/communicator/impl/replacement/viddler/ReplacementServiceViddlerImpl.java index 1ccb9aab6..56cb8c40d 100644 --- a/src/net/java/sip/communicator/impl/replacement/viddler/ReplacementServiceViddlerImpl.java +++ b/src/net/java/sip/communicator/impl/replacement/viddler/ReplacementServiceViddlerImpl.java @@ -131,4 +131,4 @@ public String getPattern() { return VIDDLER_PATTERN; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/viddler/ViddlerActivator.java b/src/net/java/sip/communicator/impl/replacement/viddler/ViddlerActivator.java index 92d1283f6..63a68d54d 100644 --- a/src/net/java/sip/communicator/impl/replacement/viddler/ViddlerActivator.java +++ b/src/net/java/sip/communicator/impl/replacement/viddler/ViddlerActivator.java @@ -69,4 +69,4 @@ public void stop(BundleContext bc) throws Exception viddlerServReg.unregister(); logger.info("Viddler source implementation [STOPPED]."); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/viddler/viddler.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/viddler/viddler.source.manifest.mf index 2c5ca73fa..94859a9b4 100644 --- a/src/net/java/sip/communicator/impl/replacement/viddler/viddler.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/viddler/viddler.source.manifest.mf @@ -6,7 +6,7 @@ Bundle-Version: 1.0.0 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, - org.apache.http \ No newline at end of file + org.apache.http diff --git a/src/net/java/sip/communicator/impl/replacement/vimeo/ReplacementServiceVimeoImpl.java b/src/net/java/sip/communicator/impl/replacement/vimeo/ReplacementServiceVimeoImpl.java index 320461a55..d3305441b 100644 --- a/src/net/java/sip/communicator/impl/replacement/vimeo/ReplacementServiceVimeoImpl.java +++ b/src/net/java/sip/communicator/impl/replacement/vimeo/ReplacementServiceVimeoImpl.java @@ -125,4 +125,4 @@ public String getPattern() { return VIMEO_PATTERN; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/vimeo/VimeoActivator.java b/src/net/java/sip/communicator/impl/replacement/vimeo/VimeoActivator.java index 1a0e1b530..202631001 100644 --- a/src/net/java/sip/communicator/impl/replacement/vimeo/VimeoActivator.java +++ b/src/net/java/sip/communicator/impl/replacement/vimeo/VimeoActivator.java @@ -67,4 +67,4 @@ public void stop(BundleContext context) throws Exception vimeoServReg.unregister(); logger.info("Vimeo source implementation [STOPPED]."); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/vimeo/vimeo.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/vimeo/vimeo.source.manifest.mf index 0b7c8a914..019f275b5 100644 --- a/src/net/java/sip/communicator/impl/replacement/vimeo/vimeo.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/vimeo/vimeo.source.manifest.mf @@ -6,8 +6,8 @@ Bundle-Version: 1.0.0 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, org.apache.http, - org.json \ No newline at end of file + org.json diff --git a/src/net/java/sip/communicator/impl/replacement/youtube/ReplacementServiceYoutubeImpl.java b/src/net/java/sip/communicator/impl/replacement/youtube/ReplacementServiceYoutubeImpl.java index 7bd29100c..8201714d4 100644 --- a/src/net/java/sip/communicator/impl/replacement/youtube/ReplacementServiceYoutubeImpl.java +++ b/src/net/java/sip/communicator/impl/replacement/youtube/ReplacementServiceYoutubeImpl.java @@ -112,4 +112,4 @@ public String getPattern() { return YOUTUBE_PATTERN; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/youtube/YoutubeActivator.java b/src/net/java/sip/communicator/impl/replacement/youtube/YoutubeActivator.java index d7215bdf9..b1758e639 100644 --- a/src/net/java/sip/communicator/impl/replacement/youtube/YoutubeActivator.java +++ b/src/net/java/sip/communicator/impl/replacement/youtube/YoutubeActivator.java @@ -67,4 +67,4 @@ public void stop(BundleContext context) throws Exception youtubeSourceServReg.unregister(); logger.info("Youtube source implementation [STOPPED]."); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/replacement/youtube/youtube.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/youtube/youtube.source.manifest.mf index c64f517ba..fabe1989a 100644 --- a/src/net/java/sip/communicator/impl/replacement/youtube/youtube.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/youtube/youtube.source.manifest.mf @@ -6,8 +6,8 @@ Bundle-Version: 1.0.0 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, org.apache.http, - org.json \ No newline at end of file + org.json diff --git a/src/net/java/sip/communicator/impl/resources/ResourceManagementActivator.java b/src/net/java/sip/communicator/impl/resources/ResourceManagementActivator.java index 0bebe765d..e8f02380c 100644 --- a/src/net/java/sip/communicator/impl/resources/ResourceManagementActivator.java +++ b/src/net/java/sip/communicator/impl/resources/ResourceManagementActivator.java @@ -6,10 +6,10 @@ */ package net.java.sip.communicator.impl.resources; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.resources.*; - +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.*; + +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java b/src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java index 4a0f0a9e4..c4ef3b84b 100644 --- a/src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java +++ b/src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java @@ -18,6 +18,7 @@ import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/resources/resourcemanagement.manifest.mf b/src/net/java/sip/communicator/impl/resources/resourcemanagement.manifest.mf index 83fe65133..95ac100aa 100644 --- a/src/net/java/sip/communicator/impl/resources/resourcemanagement.manifest.mf +++ b/src/net/java/sip/communicator/impl/resources/resourcemanagement.manifest.mf @@ -6,7 +6,8 @@ Bundle-Version: 0.0.1 System-Bundle: yes Export-Package: net.java.sip.communicator.service.resources Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.service.gui, javax.imageio, diff --git a/src/net/java/sip/communicator/impl/shutdowntimeout/shutdown.timeout.manifest.mf b/src/net/java/sip/communicator/impl/shutdowntimeout/shutdown.timeout.manifest.mf index 68144976c..6991b2f39 100644 --- a/src/net/java/sip/communicator/impl/shutdowntimeout/shutdown.timeout.manifest.mf +++ b/src/net/java/sip/communicator/impl/shutdowntimeout/shutdown.timeout.manifest.mf @@ -5,5 +5,5 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.util diff --git a/src/net/java/sip/communicator/impl/sparkle/SparkleActivator.java b/src/net/java/sip/communicator/impl/sparkle/SparkleActivator.java index d521fdb0e..45637d3fc 100644 --- a/src/net/java/sip/communicator/impl/sparkle/SparkleActivator.java +++ b/src/net/java/sip/communicator/impl/sparkle/SparkleActivator.java @@ -9,7 +9,7 @@ import net.java.sip.communicator.service.resources.*; import org.osgi.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.*; /** diff --git a/src/net/java/sip/communicator/impl/sparkle/sparkle.manifest.mf b/src/net/java/sip/communicator/impl/sparkle/sparkle.manifest.mf index ea9588197..72b68f01b 100644 --- a/src/net/java/sip/communicator/impl/sparkle/sparkle.manifest.mf +++ b/src/net/java/sip/communicator/impl/sparkle/sparkle.manifest.mf @@ -5,6 +5,6 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util diff --git a/src/net/java/sip/communicator/impl/swingnotification/SwingNotificationActivator.java b/src/net/java/sip/communicator/impl/swingnotification/SwingNotificationActivator.java index 959945994..e22d62946 100644 --- a/src/net/java/sip/communicator/impl/swingnotification/SwingNotificationActivator.java +++ b/src/net/java/sip/communicator/impl/swingnotification/SwingNotificationActivator.java @@ -6,13 +6,14 @@ */ package net.java.sip.communicator.impl.swingnotification; -import org.osgi.framework.*; - -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.service.systray.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; + /** * Activator for the swing notification service. * @author Symphorien Wanko diff --git a/src/net/java/sip/communicator/impl/swingnotification/swingnotification.manifest.mf b/src/net/java/sip/communicator/impl/swingnotification/swingnotification.manifest.mf index 7fb886704..5558ef8cd 100644 --- a/src/net/java/sip/communicator/impl/swingnotification/swingnotification.manifest.mf +++ b/src/net/java/sip/communicator/impl/swingnotification/swingnotification.manifest.mf @@ -5,9 +5,9 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.protocol, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.systray, net.java.sip.communicator.service.systray.event, net.java.sip.communicator.util, diff --git a/src/net/java/sip/communicator/impl/sysactivity/NetworkManagerListenerImpl.java b/src/net/java/sip/communicator/impl/sysactivity/NetworkManagerListenerImpl.java index 6208a8439..113d4b6b5 100644 --- a/src/net/java/sip/communicator/impl/sysactivity/NetworkManagerListenerImpl.java +++ b/src/net/java/sip/communicator/impl/sysactivity/NetworkManagerListenerImpl.java @@ -8,6 +8,7 @@ import net.java.sip.communicator.service.sysactivity.event.*; import net.java.sip.communicator.util.*; + import org.freedesktop.*; import org.freedesktop.dbus.*; import org.freedesktop.dbus.exceptions.*; diff --git a/src/net/java/sip/communicator/impl/sysactivity/SysActivityActivator.java b/src/net/java/sip/communicator/impl/sysactivity/SysActivityActivator.java index ea60cfc7b..90b30df3f 100644 --- a/src/net/java/sip/communicator/impl/sysactivity/SysActivityActivator.java +++ b/src/net/java/sip/communicator/impl/sysactivity/SysActivityActivator.java @@ -7,10 +7,10 @@ package net.java.sip.communicator.impl.sysactivity; import net.java.sip.communicator.service.sysactivity.*; -import org.osgi.framework.*; - import net.java.sip.communicator.util.*; +import org.osgi.framework.*; + /** * Listens for system activity changes like sleep, network change, inactivity * and inform all its listeners. @@ -23,8 +23,7 @@ public class SysActivityActivator /** * The logger. */ - private Logger logger = Logger.getLogger( - SysActivityActivator.class.getName()); + private final Logger logger = Logger.getLogger(SysActivityActivator.class); /** * The OSGi service registration. diff --git a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityEventDispatcher.java b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityEventDispatcher.java index be16d8878..8e091a541 100644 --- a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityEventDispatcher.java +++ b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityEventDispatcher.java @@ -6,12 +6,12 @@ */ package net.java.sip.communicator.impl.sysactivity; +import java.util.*; + import net.java.sip.communicator.service.sysactivity.*; import net.java.sip.communicator.service.sysactivity.event.*; import net.java.sip.communicator.util.*; -import java.util.*; - /** * The class implements a dispatch event thread. The thread will * fire event every time it is added through the fireSystemActivityEvent() diff --git a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java index ea3c78fb3..9a2ad63a4 100644 --- a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java +++ b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java @@ -6,11 +6,13 @@ */ package net.java.sip.communicator.impl.sysactivity; +import java.util.*; + import net.java.sip.communicator.service.sysactivity.*; import net.java.sip.communicator.service.sysactivity.event.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; -import java.util.*; +import org.jitsi.util.*; /** * Service implementation listens for computer changes as sleeping, network diff --git a/src/net/java/sip/communicator/impl/sysactivity/sysactivity.impl.manifest.mf b/src/net/java/sip/communicator/impl/sysactivity/sysactivity.impl.manifest.mf index f60184d86..3785a2694 100644 --- a/src/net/java/sip/communicator/impl/sysactivity/sysactivity.impl.manifest.mf +++ b/src/net/java/sip/communicator/impl/sysactivity/sysactivity.impl.manifest.mf @@ -5,9 +5,10 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.util, - net.java.sip.communicator.service.version + org.jitsi.service.version, + org.jitsi.service.configuration, + org.jitsi.util, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + net.java.sip.communicator.util Export-Package: net.java.sip.communicator.service.sysactivity, net.java.sip.communicator.service.sysactivity.event diff --git a/src/net/java/sip/communicator/impl/version/VersionActivator.java b/src/net/java/sip/communicator/impl/version/VersionActivator.java index 30f4c151d..45da6be88 100644 --- a/src/net/java/sip/communicator/impl/version/VersionActivator.java +++ b/src/net/java/sip/communicator/impl/version/VersionActivator.java @@ -6,11 +6,11 @@ */ package net.java.sip.communicator.impl.version; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.version.*; -import net.java.sip.communicator.service.version.Version; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.version.*; +import org.jitsi.service.version.Version; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/version/VersionImpl.java b/src/net/java/sip/communicator/impl/version/VersionImpl.java index 1c6d74ce5..bafc75c49 100644 --- a/src/net/java/sip/communicator/impl/version/VersionImpl.java +++ b/src/net/java/sip/communicator/impl/version/VersionImpl.java @@ -6,10 +6,11 @@ */ package net.java.sip.communicator.impl.version; -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.service.version.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; +import org.jitsi.service.version.*; + /** * A static implementation of the Version interface. */ diff --git a/src/net/java/sip/communicator/impl/version/VersionServiceImpl.java b/src/net/java/sip/communicator/impl/version/VersionServiceImpl.java index a5950683c..db0ea7e8a 100644 --- a/src/net/java/sip/communicator/impl/version/VersionServiceImpl.java +++ b/src/net/java/sip/communicator/impl/version/VersionServiceImpl.java @@ -6,7 +6,7 @@ */ package net.java.sip.communicator.impl.version; -import net.java.sip.communicator.service.version.*; +import org.jitsi.service.version.*; /** * The version service keeps track of the SIP Communicator version that we are diff --git a/src/net/java/sip/communicator/impl/version/version.impl.manifest.mf b/src/net/java/sip/communicator/impl/version/version.impl.manifest.mf index 0f3f76e91..a526ab94d 100755 --- a/src/net/java/sip/communicator/impl/version/version.impl.manifest.mf +++ b/src/net/java/sip/communicator/impl/version/version.impl.manifest.mf @@ -5,7 +5,7 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.util, - net.java.sip.communicator.service.version + org.jitsi.service.configuration, + org.jitsi.service.version, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + net.java.sip.communicator.util diff --git a/src/net/java/sip/communicator/launcher/BrowserLauncher.java b/src/net/java/sip/communicator/launcher/BrowserLauncher.java index 97aedcb26..e88bfeab8 100644 --- a/src/net/java/sip/communicator/launcher/BrowserLauncher.java +++ b/src/net/java/sip/communicator/launcher/BrowserLauncher.java @@ -6,9 +6,9 @@ */ package net.java.sip.communicator.launcher; -import com.apple.eio.*; +import org.jitsi.util.*; -import net.java.sip.communicator.util.*; +import com.apple.eio.*; /** * A simple implementation of the BrowserLauncherService. Checks the operating diff --git a/src/net/java/sip/communicator/plugin/accountinfo/Resources.java b/src/net/java/sip/communicator/plugin/accountinfo/Resources.java index 7ece21a3b..f6bd38750 100644 --- a/src/net/java/sip/communicator/plugin/accountinfo/Resources.java +++ b/src/net/java/sip/communicator/plugin/accountinfo/Resources.java @@ -10,6 +10,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/accountinfo/accountinfo.manifest.mf b/src/net/java/sip/communicator/plugin/accountinfo/accountinfo.manifest.mf index 47ccf4bca..e32907692 100644 --- a/src/net/java/sip/communicator/plugin/accountinfo/accountinfo.manifest.mf +++ b/src/net/java/sip/communicator/plugin/accountinfo/accountinfo.manifest.mf @@ -12,7 +12,7 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java b/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java index a19b16fca..7c3dafa7a 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java +++ b/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java @@ -8,13 +8,15 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.contactsource.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; +import org.jitsi.service.configuration.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java b/src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java index dcb7ce495..f88c27cd9 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java +++ b/src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java @@ -10,11 +10,12 @@ import javax.swing.*; -import net.java.sip.communicator.plugin.addrbook.macosx.MacOSXAddrBookContactSourceService; -import net.java.sip.communicator.plugin.addrbook.msoutlook.MsOutlookAddrBookContactSourceService; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.plugin.addrbook.macosx.*; +import net.java.sip.communicator.plugin.addrbook.msoutlook.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.util.*; + /** * Implementation of the advanced address book configuration form. * @@ -156,4 +157,4 @@ public void focusLost(FocusEvent e) }); return prefixPanel; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/addrbook/addrbook.manifest.mf b/src/net/java/sip/communicator/plugin/addrbook/addrbook.manifest.mf index 70110fbcb..ee9e92daf 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/addrbook.manifest.mf +++ b/src/net/java/sip/communicator/plugin/addrbook/addrbook.manifest.mf @@ -4,11 +4,12 @@ Bundle-Name: OS-specific Address Book support Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 Import-Package: javax.swing, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, + org.jitsi.util, net.java.sip.communicator.service.contactsource, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.protocol, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, org.osgi.framework diff --git a/src/net/java/sip/communicator/plugin/advancedconfig/AdvancedConfigActivator.java b/src/net/java/sip/communicator/plugin/advancedconfig/AdvancedConfigActivator.java index feff4b0f7..82d0d2232 100644 --- a/src/net/java/sip/communicator/plugin/advancedconfig/AdvancedConfigActivator.java +++ b/src/net/java/sip/communicator/plugin/advancedconfig/AdvancedConfigActivator.java @@ -2,11 +2,12 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/advancedconfig/advancedconfig.manifest.mf b/src/net/java/sip/communicator/plugin/advancedconfig/advancedconfig.manifest.mf index 8bd44ca63..b0065cf9b 100644 --- a/src/net/java/sip/communicator/plugin/advancedconfig/advancedconfig.manifest.mf +++ b/src/net/java/sip/communicator/plugin/advancedconfig/advancedconfig.manifest.mf @@ -5,13 +5,13 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.systray, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, diff --git a/src/net/java/sip/communicator/plugin/aimaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/aimaccregwizz/Resources.java index de35837ad..82df085fc 100644 --- a/src/net/java/sip/communicator/plugin/aimaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/aimaccregwizz/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/aimaccregwizz/aimaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/aimaccregwizz/aimaccregwizz.manifest.mf index b59193200..d71dd9183 100644 --- a/src/net/java/sip/communicator/plugin/aimaccregwizz/aimaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/aimaccregwizz/aimaccregwizz.manifest.mf @@ -6,7 +6,7 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.gui, @@ -15,7 +15,7 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.protocol.aimconstants, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.icqconstants, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/branding/AboutWindow.java b/src/net/java/sip/communicator/plugin/branding/AboutWindow.java index 35ea79554..47ba575b5 100644 --- a/src/net/java/sip/communicator/plugin/branding/AboutWindow.java +++ b/src/net/java/sip/communicator/plugin/branding/AboutWindow.java @@ -16,12 +16,14 @@ import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.plaf.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java b/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java index 327478552..e0786ff5c 100644 --- a/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java +++ b/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java @@ -9,11 +9,12 @@ import java.lang.reflect.*; import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/branding/JitsiWarningWindow.java b/src/net/java/sip/communicator/plugin/branding/JitsiWarningWindow.java index e037729c0..b07286990 100644 --- a/src/net/java/sip/communicator/plugin/branding/JitsiWarningWindow.java +++ b/src/net/java/sip/communicator/plugin/branding/JitsiWarningWindow.java @@ -12,10 +12,10 @@ import javax.swing.*; import net.java.sip.communicator.service.browserlauncher.*; -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java b/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java index 61e7a9e1c..345546bab 100644 --- a/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java +++ b/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java @@ -14,9 +14,10 @@ import javax.imageio.*; import javax.swing.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * The WelcomeWindow is actually the splash screen shown while the * application is loading. It displays the status of the loading process and diff --git a/src/net/java/sip/communicator/plugin/branding/branding.manifest.mf b/src/net/java/sip/communicator/plugin/branding/branding.manifest.mf index 9388e0d8b..659f89d66 100755 --- a/src/net/java/sip/communicator/plugin/branding/branding.manifest.mf +++ b/src/net/java/sip/communicator/plugin/branding/branding.manifest.mf @@ -6,11 +6,12 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, + org.jitsi.util, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, net.java.sip.communicator.util.swing.plaf, diff --git a/src/net/java/sip/communicator/plugin/certconfig/CertConfigActivator.java b/src/net/java/sip/communicator/plugin/certconfig/CertConfigActivator.java index 12bb09370..95d8880e6 100644 --- a/src/net/java/sip/communicator/plugin/certconfig/CertConfigActivator.java +++ b/src/net/java/sip/communicator/plugin/certconfig/CertConfigActivator.java @@ -9,12 +9,12 @@ import java.util.*; import net.java.sip.communicator.service.certificate.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.credentialsstorage.CredentialsStorageService; +import org.jitsi.service.configuration.*; +import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/certconfig/CertConfigEntryDialog.java b/src/net/java/sip/communicator/plugin/certconfig/CertConfigEntryDialog.java index cfc43c073..861820c59 100644 --- a/src/net/java/sip/communicator/plugin/certconfig/CertConfigEntryDialog.java +++ b/src/net/java/sip/communicator/plugin/certconfig/CertConfigEntryDialog.java @@ -11,19 +11,19 @@ import java.io.*; import java.lang.reflect.*; import java.security.*; -import java.security.cert.X509Certificate; +import java.security.cert.*; import java.util.*; import javax.security.auth.callback.*; import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; +import javax.swing.event.*; import net.java.sip.communicator.service.certificate.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * Dialog window to add/edit client certificate configuration entries. * diff --git a/src/net/java/sip/communicator/plugin/certconfig/CertConfigPanel.java b/src/net/java/sip/communicator/plugin/certconfig/CertConfigPanel.java index bbf636454..86e9c573c 100644 --- a/src/net/java/sip/communicator/plugin/certconfig/CertConfigPanel.java +++ b/src/net/java/sip/communicator/plugin/certconfig/CertConfigPanel.java @@ -10,15 +10,16 @@ import java.awt.event.*; import javax.swing.*; -import javax.swing.border.EmptyBorder; +import javax.swing.border.*; import javax.swing.event.*; import net.java.sip.communicator.service.certificate.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.*; + /** * Advanced configuration form to define client TLS certificate templates. * diff --git a/src/net/java/sip/communicator/plugin/certconfig/CertConfigTableModel.java b/src/net/java/sip/communicator/plugin/certconfig/CertConfigTableModel.java index 493366123..198baf72b 100644 --- a/src/net/java/sip/communicator/plugin/certconfig/CertConfigTableModel.java +++ b/src/net/java/sip/communicator/plugin/certconfig/CertConfigTableModel.java @@ -12,7 +12,8 @@ import javax.swing.table.*; import net.java.sip.communicator.service.certificate.*; -import net.java.sip.communicator.service.resources.*; + +import org.jitsi.service.resources.*; /** * Backing data model for a JTable that displays the client certificate diff --git a/src/net/java/sip/communicator/plugin/certconfig/certconfig.manifest.mf b/src/net/java/sip/communicator/plugin/certconfig/certconfig.manifest.mf index 99a98993a..5989fec5b 100644 --- a/src/net/java/sip/communicator/plugin/certconfig/certconfig.manifest.mf +++ b/src/net/java/sip/communicator/plugin/certconfig/certconfig.manifest.mf @@ -6,10 +6,11 @@ Bundle-Version: 0.0.1 System-Bundle: no Import-Package: org.osgi.framework, net.java.sip.communicator.service.certificate, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.credentialsstorage, net.java.sip.communicator.service.gui, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + org.jitsi.util, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, @@ -18,4 +19,4 @@ Import-Package: org.osgi.framework, javax.swing.table, javax.security.auth, javax.security.auth.callback, - sun.security.pkcs11 \ No newline at end of file + sun.security.pkcs11 diff --git a/src/net/java/sip/communicator/plugin/chatalerter/ChatAlerterActivator.java b/src/net/java/sip/communicator/plugin/chatalerter/ChatAlerterActivator.java index 9b8e7f2a3..449aa1a48 100644 --- a/src/net/java/sip/communicator/plugin/chatalerter/ChatAlerterActivator.java +++ b/src/net/java/sip/communicator/plugin/chatalerter/ChatAlerterActivator.java @@ -11,9 +11,10 @@ import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import org.jdesktop.jdic.misc.*; +import org.jitsi.util.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/chatalerter/chatalerter.manifest.mf b/src/net/java/sip/communicator/plugin/chatalerter/chatalerter.manifest.mf index ac6b9eb82..cd6349c87 100644 --- a/src/net/java/sip/communicator/plugin/chatalerter/chatalerter.manifest.mf +++ b/src/net/java/sip/communicator/plugin/chatalerter/chatalerter.manifest.mf @@ -5,9 +5,10 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.util, - net.java.sip.communicator.service.gui, - net.java.sip.communicator.service.protocol, - net.java.sip.communicator.service.protocol.event, - com.apple.eawt, - javax.swing + org.jitsi.util, + net.java.sip.communicator.util, + net.java.sip.communicator.service.gui, + net.java.sip.communicator.service.protocol, + net.java.sip.communicator.service.protocol.event, + com.apple.eawt, + javax.swing diff --git a/src/net/java/sip/communicator/plugin/chatconfig/ChatConfigActivator.java b/src/net/java/sip/communicator/plugin/chatconfig/ChatConfigActivator.java index 61fa681c5..181c4174f 100644 --- a/src/net/java/sip/communicator/plugin/chatconfig/ChatConfigActivator.java +++ b/src/net/java/sip/communicator/plugin/chatconfig/ChatConfigActivator.java @@ -10,13 +10,14 @@ import javax.swing.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.replacement.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/chatconfig/ChatConfigPanel.java b/src/net/java/sip/communicator/plugin/chatconfig/ChatConfigPanel.java index f96dc0aad..fbdedc749 100644 --- a/src/net/java/sip/communicator/plugin/chatconfig/ChatConfigPanel.java +++ b/src/net/java/sip/communicator/plugin/chatconfig/ChatConfigPanel.java @@ -40,4 +40,4 @@ public ChatConfigPanel() mainPanel.add(new ReplacementConfigPanel()); mainPanel.add(Box.createVerticalStrut(10)); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/chatconfig/chatconfig.manifest.mf b/src/net/java/sip/communicator/plugin/chatconfig/chatconfig.manifest.mf index 49d96b594..f332b74d0 100644 --- a/src/net/java/sip/communicator/plugin/chatconfig/chatconfig.manifest.mf +++ b/src/net/java/sip/communicator/plugin/chatconfig/chatconfig.manifest.mf @@ -5,10 +5,10 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, net.java.sip.communicator.service.replacement, @@ -25,4 +25,4 @@ Import-Package: org.osgi.framework, javax.swing.filechooser, javax.swing.tree, javax.swing.undo, - javax.swing.border \ No newline at end of file + javax.swing.border diff --git a/src/net/java/sip/communicator/plugin/chatconfig/replacement/ReplacementConfigPanel.java b/src/net/java/sip/communicator/plugin/chatconfig/replacement/ReplacementConfigPanel.java index 8223ed2ac..117d9356d 100644 --- a/src/net/java/sip/communicator/plugin/chatconfig/replacement/ReplacementConfigPanel.java +++ b/src/net/java/sip/communicator/plugin/chatconfig/replacement/ReplacementConfigPanel.java @@ -14,7 +14,7 @@ import net.java.sip.communicator.impl.replacement.smiley.*; import net.java.sip.communicator.plugin.chatconfig.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.replacement.*; import net.java.sip.communicator.util.swing.*; @@ -250,4 +250,4 @@ public Component getTableCellRendererComponent(JTable table, Object value, return this; } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/chatconfig/replacement/ReplacementConfigurationTableModel.java b/src/net/java/sip/communicator/plugin/chatconfig/replacement/ReplacementConfigurationTableModel.java index 482c7c485..3f3d619ad 100644 --- a/src/net/java/sip/communicator/plugin/chatconfig/replacement/ReplacementConfigurationTableModel.java +++ b/src/net/java/sip/communicator/plugin/chatconfig/replacement/ReplacementConfigurationTableModel.java @@ -10,7 +10,7 @@ import javax.swing.table.*; import net.java.sip.communicator.plugin.chatconfig.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.replacement.*; /** @@ -141,4 +141,4 @@ public void setValueAt(Object value, int rowIndex, int columnIndex) } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java index db3ec8e5a..3f3eba093 100644 --- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java +++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java @@ -68,4 +68,4 @@ public static BrowserLauncherService getBrowserLauncher() return browserLauncherService; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/contactinfo/Resources.java b/src/net/java/sip/communicator/plugin/contactinfo/Resources.java index 5a77b2e35..dbb8ff45e 100644 --- a/src/net/java/sip/communicator/plugin/contactinfo/Resources.java +++ b/src/net/java/sip/communicator/plugin/contactinfo/Resources.java @@ -15,6 +15,8 @@ import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/contactinfo/contactinfo.manifest.mf b/src/net/java/sip/communicator/plugin/contactinfo/contactinfo.manifest.mf index 1e1e3bc4a..09bf6c159 100644 --- a/src/net/java/sip/communicator/plugin/contactinfo/contactinfo.manifest.mf +++ b/src/net/java/sip/communicator/plugin/contactinfo/contactinfo.manifest.mf @@ -11,7 +11,7 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/contactsourceconfig/ContactSourceConfigActivator.java b/src/net/java/sip/communicator/plugin/contactsourceconfig/ContactSourceConfigActivator.java index f0b4d68fd..6fde91b3b 100644 --- a/src/net/java/sip/communicator/plugin/contactsourceconfig/ContactSourceConfigActivator.java +++ b/src/net/java/sip/communicator/plugin/contactsourceconfig/ContactSourceConfigActivator.java @@ -7,11 +7,13 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import net.java.sip.communicator.plugin.securityconfig.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/contactsourceconfig/contactsourceconfig.manifest.mf b/src/net/java/sip/communicator/plugin/contactsourceconfig/contactsourceconfig.manifest.mf index 8b306b468..0814977c3 100644 --- a/src/net/java/sip/communicator/plugin/contactsourceconfig/contactsourceconfig.manifest.mf +++ b/src/net/java/sip/communicator/plugin/contactsourceconfig/contactsourceconfig.manifest.mf @@ -8,8 +8,8 @@ Import-Package: net.java.sip.communicator.service.contactsource, net.java.sip.communicator.util, net.java.sip.communicator.service.gui, net.java.sip.communicator.util.swing, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, org.osgi.framework, javax.swing System-Bundle: yes diff --git a/src/net/java/sip/communicator/plugin/defaultresourcepack/defaultresourcepack.manifest.mf b/src/net/java/sip/communicator/plugin/defaultresourcepack/defaultresourcepack.manifest.mf index a6c46c673..467bf888a 100644 --- a/src/net/java/sip/communicator/plugin/defaultresourcepack/defaultresourcepack.manifest.mf +++ b/src/net/java/sip/communicator/plugin/defaultresourcepack/defaultresourcepack.manifest.mf @@ -6,4 +6,4 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.util, - net.java.sip.communicator.service.resources + org.jitsi.service.resources, net.java.sip.communicator.service.resources diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java index aae29db66..c520207ca 100644 --- a/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf index 7e9a51c0a..ebf4a69ad 100644 --- a/src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf @@ -7,7 +7,7 @@ System-Bundle: yes Import-Package: org.osgi.framework, net.java.dict4j, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.gui, @@ -15,7 +15,7 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.icqconstants, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/dnsconfig/DnsConfigActivator.java b/src/net/java/sip/communicator/plugin/dnsconfig/DnsConfigActivator.java index 4c1b00ce6..c8acab7b4 100644 --- a/src/net/java/sip/communicator/plugin/dnsconfig/DnsConfigActivator.java +++ b/src/net/java/sip/communicator/plugin/dnsconfig/DnsConfigActivator.java @@ -8,11 +8,11 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/dnsconfig/DnsContainerPanel.java b/src/net/java/sip/communicator/plugin/dnsconfig/DnsContainerPanel.java index 487bcf1c9..ff55fbcd8 100644 --- a/src/net/java/sip/communicator/plugin/dnsconfig/DnsContainerPanel.java +++ b/src/net/java/sip/communicator/plugin/dnsconfig/DnsContainerPanel.java @@ -6,12 +6,12 @@ */ package net.java.sip.communicator.plugin.dnsconfig; -import org.osgi.framework.*; - -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; + /** * Container for all DNS configuration panels. * diff --git a/src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java b/src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java index c663eb35e..2bdfde0a2 100644 --- a/src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java +++ b/src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java @@ -8,21 +8,21 @@ import java.awt.*; import java.awt.event.*; -import java.io.File; +import java.io.*; import javax.swing.*; import javax.swing.plaf.basic.*; import javax.swing.table.*; -import org.osgi.framework.*; - -import net.java.sip.communicator.impl.gui.customcontrols.ErrorDialog; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.resources.*; +import net.java.sip.communicator.impl.gui.customcontrols.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.dns.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; + /** * Configuration of the DNSSEC validating resolver. * diff --git a/src/net/java/sip/communicator/plugin/dnsconfig/DnssecTableModel.java b/src/net/java/sip/communicator/plugin/dnsconfig/DnssecTableModel.java index accdfbbb5..68ff7754c 100644 --- a/src/net/java/sip/communicator/plugin/dnsconfig/DnssecTableModel.java +++ b/src/net/java/sip/communicator/plugin/dnsconfig/DnssecTableModel.java @@ -12,11 +12,11 @@ import javax.swing.table.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.dns.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/dnsconfig/ParallelDnsPanel.java b/src/net/java/sip/communicator/plugin/dnsconfig/ParallelDnsPanel.java index 79975ceda..85eca21fc 100644 --- a/src/net/java/sip/communicator/plugin/dnsconfig/ParallelDnsPanel.java +++ b/src/net/java/sip/communicator/plugin/dnsconfig/ParallelDnsPanel.java @@ -6,26 +6,36 @@ */ package net.java.sip.communicator.plugin.dnsconfig; +import static net.java.sip.communicator.util.NetworkUtils.DEFAULT_BACKUP_RESOLVER; +import static net.java.sip.communicator.util.NetworkUtils.PDEFAULT_BACKUP_RESOLVER_ENABLED; +import static net.java.sip.communicator.util.NetworkUtils.PNAME_BACKUP_RESOLVER; +import static net.java.sip.communicator.util.NetworkUtils.PNAME_BACKUP_RESOLVER_ENABLED; +import static net.java.sip.communicator.util.NetworkUtils.PNAME_BACKUP_RESOLVER_FALLBACK_IP; +import static net.java.sip.communicator.util.NetworkUtils.PNAME_BACKUP_RESOLVER_PORT; +import static net.java.sip.communicator.util.NetworkUtils.getDefaultDnsPort; +import static net.java.sip.communicator.util.NetworkUtils.isIPv4Address; +import static net.java.sip.communicator.util.NetworkUtils.isIPv6Address; +import static net.java.sip.communicator.util.dns.ParallelResolver.DNS_PATIENCE; +import static net.java.sip.communicator.util.dns.ParallelResolver.DNS_REDEMPTION; +import static net.java.sip.communicator.util.dns.ParallelResolver.PNAME_DNS_PATIENCE; +import static net.java.sip.communicator.util.dns.ParallelResolver.PNAME_DNS_REDEMPTION; + import java.awt.*; import java.awt.event.*; import java.text.*; -import java.util.EventObject; +import java.util.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; - -import org.osgi.framework.*; - -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.dns.*; import net.java.sip.communicator.util.swing.*; -import static net.java.sip.communicator.util.NetworkUtils.*; -import static net.java.sip.communicator.util.dns.ParallelResolver.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; /** * Page inside the advanced configuration options that allow the user to diff --git a/src/net/java/sip/communicator/plugin/dnsconfig/dnsconfig.manifest.mf b/src/net/java/sip/communicator/plugin/dnsconfig/dnsconfig.manifest.mf index 61c903d0d..b6a4bc3ad 100644 --- a/src/net/java/sip/communicator/plugin/dnsconfig/dnsconfig.manifest.mf +++ b/src/net/java/sip/communicator/plugin/dnsconfig/dnsconfig.manifest.mf @@ -5,11 +5,11 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: no Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.configuration, + org.jitsi.service.fileaccess, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.dns, net.java.sip.communicator.util.swing, diff --git a/src/net/java/sip/communicator/plugin/facebookaccregwizz/FacebookAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/facebookaccregwizz/FacebookAccRegWizzActivator.java index 1b7fdced8..ae518bdc8 100644 --- a/src/net/java/sip/communicator/plugin/facebookaccregwizz/FacebookAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/facebookaccregwizz/FacebookAccRegWizzActivator.java @@ -8,12 +8,13 @@ import java.util.*; +import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/facebookaccregwizz/facebookaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/facebookaccregwizz/facebookaccregwizz.manifest.mf index 5e5b36e4d..a6143fea3 100644 --- a/src/net/java/sip/communicator/plugin/facebookaccregwizz/facebookaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/facebookaccregwizz/facebookaccregwizz.manifest.mf @@ -6,14 +6,14 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, net.java.sip.communicator.plugin.jabberaccregwizz, diff --git a/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java b/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java index 6d1adbacf..56f2aa4f4 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java @@ -11,11 +11,13 @@ import javax.net.ssl.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; + public class ConfigurationManager { private static final Logger logger diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java index 227ce81aa..dfdb32f2a 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java @@ -13,7 +13,7 @@ import javax.swing.border.*; import net.java.sip.communicator.plugin.generalconfig.autoaway.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; @@ -21,6 +21,7 @@ import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java index 0cf8ae0d7..537c98ecc 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java @@ -17,9 +17,10 @@ import net.java.sip.communicator.plugin.generalconfig.autoaway.*; import net.java.sip.communicator.service.systray.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.swing.*; +import org.jitsi.util.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/generalconfig/Resources.java b/src/net/java/sip/communicator/plugin/generalconfig/Resources.java index 8c8d75b6a..87f283f81 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/Resources.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/generalconfig/SIPConfigForm.java b/src/net/java/sip/communicator/plugin/generalconfig/SIPConfigForm.java index 186d554ec..d65b9e376 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/SIPConfigForm.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/SIPConfigForm.java @@ -182,4 +182,4 @@ public void actionPerformed(ActionEvent e) ConfigurationManager.setEnabledSslProtocols( enabledSslProtocols.toArray(new String[]{})); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayConfigurationPanel.java b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayConfigurationPanel.java index e0ad1fc5f..b4fe353f1 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayConfigurationPanel.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayConfigurationPanel.java @@ -13,10 +13,11 @@ import javax.swing.event.*; import net.java.sip.communicator.plugin.generalconfig.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * The ConfigurationForm that would be added in the user interface * configuration window. diff --git a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java index 382861ff1..b9d5a741c 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java @@ -7,7 +7,7 @@ package net.java.sip.communicator.plugin.generalconfig.autoaway; import net.java.sip.communicator.plugin.generalconfig.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.sysactivity.*; diff --git a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/Preferences.java b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/Preferences.java index 5573e2bdc..80faf2a45 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/Preferences.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/Preferences.java @@ -18,4 +18,4 @@ public final class Preferences "net.java.sip.communicator.plugin.statusupdate.enable"; public static final String TIMER = "net.java.sip.communicator.plugin.statusupdate.timer"; -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/StatusUpdateThread.java b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/StatusUpdateThread.java index 2c97bfa5e..6399672a2 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/StatusUpdateThread.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/StatusUpdateThread.java @@ -10,9 +10,10 @@ import java.util.*; import net.java.sip.communicator.plugin.generalconfig.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; + +import org.jitsi.service.resources.*; /** * A Runnable, which permanently looks at the mouse position. If the mouse is diff --git a/src/net/java/sip/communicator/plugin/generalconfig/generalconfig.manifest.mf b/src/net/java/sip/communicator/plugin/generalconfig/generalconfig.manifest.mf index e5741a735..67c6e59d9 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/generalconfig.manifest.mf +++ b/src/net/java/sip/communicator/plugin/generalconfig/generalconfig.manifest.mf @@ -5,14 +5,15 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, + org.jitsi.util, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.systray, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, diff --git a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java index bf5e634f9..ab2ba3675 100644 --- a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/gibberishaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/gibberishaccregwizz.manifest.mf index 98aacf211..88de8d48f 100644 --- a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/gibberishaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/gibberishaccregwizz.manifest.mf @@ -6,14 +6,14 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyConfigForm.java b/src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyConfigForm.java index cb2cb586f..240f33d18 100644 --- a/src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyConfigForm.java +++ b/src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyConfigForm.java @@ -9,7 +9,7 @@ import java.awt.event.*; import javax.swing.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.swing.*; diff --git a/src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyPluginActivator.java b/src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyPluginActivator.java index e665bb524..73bd752f8 100644 --- a/src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyPluginActivator.java +++ b/src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyPluginActivator.java @@ -9,7 +9,7 @@ import java.net.*; import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; diff --git a/src/net/java/sip/communicator/plugin/globalproxyconfig/Resources.java b/src/net/java/sip/communicator/plugin/globalproxyconfig/Resources.java index ae6660855..ca301e7bf 100644 --- a/src/net/java/sip/communicator/plugin/globalproxyconfig/Resources.java +++ b/src/net/java/sip/communicator/plugin/globalproxyconfig/Resources.java @@ -7,8 +7,7 @@ package net.java.sip.communicator.plugin.globalproxyconfig; -import net.java.sip.communicator.service.resources.*; - +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/globalproxyconfig/globalproxyconfig.manifest.mf b/src/net/java/sip/communicator/plugin/globalproxyconfig/globalproxyconfig.manifest.mf index fae4f8d47..58d2153bc 100644 --- a/src/net/java/sip/communicator/plugin/globalproxyconfig/globalproxyconfig.manifest.mf +++ b/src/net/java/sip/communicator/plugin/globalproxyconfig/globalproxyconfig.manifest.mf @@ -9,8 +9,8 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.util.swing, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.protocol, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, javax.swing, javax.swing.event, javax.swing.table, diff --git a/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccRegWizzActivator.java index ed93d89e0..f7bbe2b64 100644 --- a/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccRegWizzActivator.java @@ -8,14 +8,15 @@ import java.util.*; -import org.osgi.framework.*; - import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; + /** * Registers the GoogleTalkAccountRegistrationWizard in the UI Service. * diff --git a/src/net/java/sip/communicator/plugin/googletalkaccregwizz/googletalkaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/googletalkaccregwizz/googletalkaccregwizz.manifest.mf index c63b034a2..248077b79 100644 --- a/src/net/java/sip/communicator/plugin/googletalkaccregwizz/googletalkaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/googletalkaccregwizz/googletalkaccregwizz.manifest.mf @@ -6,16 +6,16 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.fileaccess, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.icqconstants, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, net.java.sip.communicator.plugin.jabberaccregwizz, diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java index 28a3c9308..a6909a17b 100644 --- a/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/icqaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/icqaccregwizz/icqaccregwizz.manifest.mf index d6d635848..d22b94be1 100644 --- a/src/net/java/sip/communicator/plugin/icqaccregwizz/icqaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/icqaccregwizz.manifest.mf @@ -6,7 +6,7 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.gui, @@ -14,7 +14,7 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.icqconstants, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/ippiaccregwizz/IppiAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/ippiaccregwizz/IppiAccRegWizzActivator.java index fde883d28..2a559aad7 100644 --- a/src/net/java/sip/communicator/plugin/ippiaccregwizz/IppiAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/ippiaccregwizz/IppiAccRegWizzActivator.java @@ -8,13 +8,14 @@ import java.util.*; -import org.osgi.framework.*; - import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; + /** * Registers the IppiAccountRegistrationWizard in the UI Service. * diff --git a/src/net/java/sip/communicator/plugin/ippiaccregwizz/ippiaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/ippiaccregwizz/ippiaccregwizz.manifest.mf index 42ed35a61..34479665d 100644 --- a/src/net/java/sip/communicator/plugin/ippiaccregwizz/ippiaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/ippiaccregwizz/ippiaccregwizz.manifest.mf @@ -6,16 +6,16 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.fileaccess, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.icqconstants, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, net.java.sip.communicator.plugin.sipaccregwizz, diff --git a/src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccRegWizzActivator.java index eaa411747..dda76d2f0 100644 --- a/src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccRegWizzActivator.java @@ -8,14 +8,15 @@ import java.util.*; -import org.osgi.framework.*; - import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; + /** * Registers the GoogleTalkAccountRegistrationWizard in the UI Service. * diff --git a/src/net/java/sip/communicator/plugin/iptelaccregwizz/iptelaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/iptelaccregwizz/iptelaccregwizz.manifest.mf index bb42ab481..03df9d7ca 100644 --- a/src/net/java/sip/communicator/plugin/iptelaccregwizz/iptelaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/iptelaccregwizz/iptelaccregwizz.manifest.mf @@ -6,16 +6,16 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.fileaccess, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.icqconstants, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, net.java.sip.communicator.plugin.sipaccregwizz, diff --git a/src/net/java/sip/communicator/plugin/ircaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/ircaccregwizz/Resources.java index 110f157f2..a9a588649 100644 --- a/src/net/java/sip/communicator/plugin/ircaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/ircaccregwizz/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Messages class manages the access to the internationalization * properties files. diff --git a/src/net/java/sip/communicator/plugin/ircaccregwizz/ircaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/ircaccregwizz/ircaccregwizz.manifest.mf index ccc4971b5..5731d33ce 100644 --- a/src/net/java/sip/communicator/plugin/ircaccregwizz/ircaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/ircaccregwizz/ircaccregwizz.manifest.mf @@ -6,12 +6,12 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccRegWizzActivator.java index cd567cdc3..d9d03be82 100644 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccRegWizzActivator.java @@ -11,7 +11,7 @@ import org.osgi.framework.*; import net.java.sip.communicator.service.browserlauncher.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java index 4e579b44a..799eff394 100755 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java @@ -816,4 +816,4 @@ public void setDefaultDTMFMethod(String defaultDTMFMethod) { this.defaultDTMFMethod = defaultDTMFMethod; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java index 5c6a58b7d..eec4b284a 100644 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java @@ -729,4 +729,4 @@ protected String getHomeLinkLabel() { return null; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberServerChooserDialog.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberServerChooserDialog.java index c89322330..079fc7661 100644 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberServerChooserDialog.java +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberServerChooserDialog.java @@ -19,10 +19,10 @@ import javax.swing.table.*; import javax.xml.parsers.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.fileaccess.*; import org.osgi.framework.*; import org.w3c.dom.*; import org.xml.sax.*; diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/Resources.java index 7ede295d4..7e241d2f1 100644 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/Resources.java @@ -10,6 +10,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/jabberaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/jabberaccregwizz/jabberaccregwizz.manifest.mf index 4a06c859c..184dd65eb 100755 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/jabberaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/jabberaccregwizz.manifest.mf @@ -7,17 +7,17 @@ System-Bundle: yes Export-package: net.java.sip.communicator.plugin.jabberaccregwizz Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.credentialsstorage, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.fileaccess, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.icqconstants, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.naming, diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java b/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java index 1fc6ab0af..77e0a993f 100644 --- a/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java +++ b/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java @@ -8,13 +8,14 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.globalshortcut.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.keybindings.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutDialog.java b/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutDialog.java index 2c862deac..68f9ef561 100644 --- a/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutDialog.java +++ b/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutDialog.java @@ -9,17 +9,19 @@ import java.awt.*; import java.awt.event.*; import java.util.*; -import java.util.List; // disambiguation +import java.util.List; import javax.swing.*; import net.java.sip.communicator.plugin.keybindingchooser.*; import net.java.sip.communicator.service.globalshortcut.*; -import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.plaf.*; +import org.jitsi.util.*; +// disambiguation + /** * Dialog to choose the shortcut. * diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/keybindingChooser.manifest.mf b/src/net/java/sip/communicator/plugin/keybindingchooser/keybindingChooser.manifest.mf index 26c565894..780e86026 100644 --- a/src/net/java/sip/communicator/plugin/keybindingchooser/keybindingChooser.manifest.mf +++ b/src/net/java/sip/communicator/plugin/keybindingchooser/keybindingChooser.manifest.mf @@ -7,9 +7,10 @@ System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.keybindings, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, net.java.sip.communicator.service.globalshortcut, + org.jitsi.util, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, net.java.sip.communicator.util.swing.plaf, diff --git a/src/net/java/sip/communicator/plugin/ldap/LdapActivator.java b/src/net/java/sip/communicator/plugin/ldap/LdapActivator.java index 99414a0bb..2baaa19cb 100644 --- a/src/net/java/sip/communicator/plugin/ldap/LdapActivator.java +++ b/src/net/java/sip/communicator/plugin/ldap/LdapActivator.java @@ -10,9 +10,9 @@ import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.ldap.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/ldap/ldap.manifest.mf b/src/net/java/sip/communicator/plugin/ldap/ldap.manifest.mf index a6a00ba60..a418501c6 100644 --- a/src/net/java/sip/communicator/plugin/ldap/ldap.manifest.mf +++ b/src/net/java/sip/communicator/plugin/ldap/ldap.manifest.mf @@ -4,7 +4,7 @@ Bundle-Name: LDAP support Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 Import-Package: net.java.sip.communicator.service.contactsource, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.ldap, @@ -18,4 +18,4 @@ Import-Package: net.java.sip.communicator.service.contactsource, javax.swing.tree, javax.swing.text, org.osgi.framework -System-Bundle: yes \ No newline at end of file +System-Bundle: yes diff --git a/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java b/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java index 0bb08392b..7af0bdd77 100644 --- a/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java +++ b/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java @@ -5,19 +5,21 @@ */ package net.java.sip.communicator.plugin.loggingutils; +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.util.*; + +import javax.swing.*; +import javax.swing.event.*; + import net.java.sip.communicator.service.httputil.*; import net.java.sip.communicator.service.notification.*; -import net.java.sip.communicator.service.packetlogging.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; -import javax.swing.*; -import javax.swing.event.*; -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.util.*; +import org.jitsi.service.packetlogging.*; +import org.jitsi.service.resources.*; /** * The Logging configuration form. diff --git a/src/net/java/sip/communicator/plugin/loggingutils/LoggingUtilsActivator.java b/src/net/java/sip/communicator/plugin/loggingutils/LoggingUtilsActivator.java index a6d531fea..075111fbd 100644 --- a/src/net/java/sip/communicator/plugin/loggingutils/LoggingUtilsActivator.java +++ b/src/net/java/sip/communicator/plugin/loggingutils/LoggingUtilsActivator.java @@ -6,16 +6,17 @@ */ package net.java.sip.communicator.plugin.loggingutils; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.fileaccess.*; +import java.util.*; + import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.notification.*; -import net.java.sip.communicator.service.packetlogging.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; -import org.osgi.framework.*; -import java.util.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; +import org.jitsi.service.packetlogging.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; /** * Creates and registers logging config form. diff --git a/src/net/java/sip/communicator/plugin/loggingutils/LogsCollector.java b/src/net/java/sip/communicator/plugin/loggingutils/LogsCollector.java index cb0b3d8f8..d88ffd0ae 100644 --- a/src/net/java/sip/communicator/plugin/loggingutils/LogsCollector.java +++ b/src/net/java/sip/communicator/plugin/loggingutils/LogsCollector.java @@ -5,14 +5,16 @@ */ package net.java.sip.communicator.plugin.loggingutils; -import net.java.sip.communicator.util.*; - import java.io.*; import java.text.*; import java.util.*; import java.util.regex.*; import java.util.zip.*; +import net.java.sip.communicator.util.Logger; + +import org.jitsi.util.*; + /** * Collects logs and save them in compressed zip file. * @author Damian Minkov diff --git a/src/net/java/sip/communicator/plugin/loggingutils/loggingutils.manifest.mf b/src/net/java/sip/communicator/plugin/loggingutils/loggingutils.manifest.mf index 284b59689..44d864f6e 100644 --- a/src/net/java/sip/communicator/plugin/loggingutils/loggingutils.manifest.mf +++ b/src/net/java/sip/communicator/plugin/loggingutils/loggingutils.manifest.mf @@ -5,13 +5,14 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.configuration, + org.jitsi.service.fileaccess, + org.jitsi.util, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.httputil, net.java.sip.communicator.service.notification, - net.java.sip.communicator.service.packetlogging, - net.java.sip.communicator.service.resources, + org.jitsi.service.packetlogging, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.net.ssl, diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/Resources.java index 250af24c3..5c01e8824 100644 --- a/src/net/java/sip/communicator/plugin/msnaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/msnaccregwizz/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/msnaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/msnaccregwizz/msnaccregwizz.manifest.mf index c151aecbb..c18c354e8 100755 --- a/src/net/java/sip/communicator/plugin/msnaccregwizz/msnaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/msnaccregwizz/msnaccregwizz.manifest.mf @@ -6,7 +6,7 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.gui, @@ -14,7 +14,7 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.icqconstants, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java b/src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java index e59f10a49..6b8af557f 100644 --- a/src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java +++ b/src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java @@ -6,8 +6,7 @@ */ package net.java.sip.communicator.plugin.msofficecomm; -import net.java.sip.communicator.util.*; - +import org.jitsi.util.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/msofficecomm.manifest.mf b/src/net/java/sip/communicator/plugin/msofficecomm/msofficecomm.manifest.mf index 96421c21b..2e8b5042d 100644 --- a/src/net/java/sip/communicator/plugin/msofficecomm/msofficecomm.manifest.mf +++ b/src/net/java/sip/communicator/plugin/msofficecomm/msofficecomm.manifest.mf @@ -12,4 +12,5 @@ Import-Package: javax.swing, net.java.sip.communicator.service.protocol.msnconstants, net.java.sip.communicator.service.protocol.yahooconstants, net.java.sip.communicator.util, + org.jitsi.util, org.osgi.framework diff --git a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationActivator.java b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationActivator.java index 38e8765ef..262829ccb 100644 --- a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationActivator.java +++ b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationActivator.java @@ -8,12 +8,12 @@ import java.util.*; -import net.java.sip.communicator.service.audionotifier.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.notification.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.audionotifier.*; +import org.jitsi.service.configuration.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java index b5cc785a5..b561da00c 100644 --- a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java +++ b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java @@ -14,11 +14,13 @@ import javax.swing.*; import javax.swing.event.*; -import net.java.sip.communicator.service.audionotifier.*; import net.java.sip.communicator.service.notification.*; -import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.audionotifier.*; +import org.jitsi.util.*; + /** * The UI of ConfigurationForm that would be added in the user * interface configuration window. It contains a list of all installed diff --git a/src/net/java/sip/communicator/plugin/notificationconfiguration/Resources.java b/src/net/java/sip/communicator/plugin/notificationconfiguration/Resources.java index 035499611..8e2d3fdb9 100644 --- a/src/net/java/sip/communicator/plugin/notificationconfiguration/Resources.java +++ b/src/net/java/sip/communicator/plugin/notificationconfiguration/Resources.java @@ -10,6 +10,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Messages class manages the access to the internationalization * properties files. diff --git a/src/net/java/sip/communicator/plugin/notificationconfiguration/SoundFilter.java b/src/net/java/sip/communicator/plugin/notificationconfiguration/SoundFilter.java index 83c7e90f8..9604b1b3a 100644 --- a/src/net/java/sip/communicator/plugin/notificationconfiguration/SoundFilter.java +++ b/src/net/java/sip/communicator/plugin/notificationconfiguration/SoundFilter.java @@ -9,9 +9,10 @@ import java.io.*; -import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.util.*; + /** * Filter to display only the sound files in the filechooser. * diff --git a/src/net/java/sip/communicator/plugin/notificationconfiguration/notificationconfiguration.manifest.mf b/src/net/java/sip/communicator/plugin/notificationconfiguration/notificationconfiguration.manifest.mf index 2f0b01f55..0e9d8c2bf 100644 --- a/src/net/java/sip/communicator/plugin/notificationconfiguration/notificationconfiguration.manifest.mf +++ b/src/net/java/sip/communicator/plugin/notificationconfiguration/notificationconfiguration.manifest.mf @@ -5,13 +5,13 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.audionotifier, - net.java.sip.communicator.service.configuration, + org.jitsi.service.audionotifier, + org.jitsi.service.configuration, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.notification, net.java.sip.communicator.service.notification.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/notificationwiring/NotificationManager.java b/src/net/java/sip/communicator/plugin/notificationwiring/NotificationManager.java index 3c3d8d0ce..53526f6a1 100644 --- a/src/net/java/sip/communicator/plugin/notificationwiring/NotificationManager.java +++ b/src/net/java/sip/communicator/plugin/notificationwiring/NotificationManager.java @@ -6,20 +6,23 @@ */ package net.java.sip.communicator.plugin.notificationwiring; +import java.awt.image.*; +import java.net.*; +import java.util.*; + +import javax.imageio.*; + import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.notification.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; -import org.osgi.framework.*; -import javax.imageio.*; -import java.awt.image.*; -import java.net.*; -import java.util.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.protocol.event.*; +import org.osgi.framework.*; /** * Listens for all kinds of events and triggers when needed a notification, diff --git a/src/net/java/sip/communicator/plugin/notificationwiring/NotificationWiringActivator.java b/src/net/java/sip/communicator/plugin/notificationwiring/NotificationWiringActivator.java index a4ee0ba20..cbde8d0cd 100644 --- a/src/net/java/sip/communicator/plugin/notificationwiring/NotificationWiringActivator.java +++ b/src/net/java/sip/communicator/plugin/notificationwiring/NotificationWiringActivator.java @@ -7,11 +7,11 @@ package net.java.sip.communicator.plugin.notificationwiring; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.notification.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/notificationwiring/SoundProperties.java b/src/net/java/sip/communicator/plugin/notificationwiring/SoundProperties.java index 73b3b9bfc..3d411a443 100644 --- a/src/net/java/sip/communicator/plugin/notificationwiring/SoundProperties.java +++ b/src/net/java/sip/communicator/plugin/notificationwiring/SoundProperties.java @@ -6,7 +6,7 @@ */ package net.java.sip.communicator.plugin.notificationwiring; -import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; /** * Manages the access to the properties file containing all sounds paths. diff --git a/src/net/java/sip/communicator/plugin/notificationwiring/notificationwiring.manifest.mf b/src/net/java/sip/communicator/plugin/notificationwiring/notificationwiring.manifest.mf index 0ad7d4491..a94675d55 100644 --- a/src/net/java/sip/communicator/plugin/notificationwiring/notificationwiring.manifest.mf +++ b/src/net/java/sip/communicator/plugin/notificationwiring/notificationwiring.manifest.mf @@ -9,8 +9,8 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.util, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.gui, - net.java.sip.communicator.service.neomedia, + org.jitsi.service.neomedia, net.java.sip.communicator.service.notification, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources + org.jitsi.service.resources, net.java.sip.communicator.service.resources diff --git a/src/net/java/sip/communicator/plugin/otr/OtrActionHandlers.java b/src/net/java/sip/communicator/plugin/otr/OtrActionHandlers.java index e4cd81fc8..ede2733b5 100644 --- a/src/net/java/sip/communicator/plugin/otr/OtrActionHandlers.java +++ b/src/net/java/sip/communicator/plugin/otr/OtrActionHandlers.java @@ -33,4 +33,4 @@ static void openAuthDialog(Contact contact) - authenticateBuddyDialog.getHeight() / 2); authenticateBuddyDialog.setVisible(true); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/otr/OtrActivator.java b/src/net/java/sip/communicator/plugin/otr/OtrActivator.java index bcd8a184f..643399909 100644 --- a/src/net/java/sip/communicator/plugin/otr/OtrActivator.java +++ b/src/net/java/sip/communicator/plugin/otr/OtrActivator.java @@ -8,12 +8,13 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/otr/OtrConfigurationPanel.java b/src/net/java/sip/communicator/plugin/otr/OtrConfigurationPanel.java index fab645566..59fd25a9d 100644 --- a/src/net/java/sip/communicator/plugin/otr/OtrConfigurationPanel.java +++ b/src/net/java/sip/communicator/plugin/otr/OtrConfigurationPanel.java @@ -353,4 +353,4 @@ private void initComponents() c.gridy = 2; this.add(pnlPolicy, c); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/otr/OtrConfigurator.java b/src/net/java/sip/communicator/plugin/otr/OtrConfigurator.java index 5b787a9de..9eeeb69ba 100755 --- a/src/net/java/sip/communicator/plugin/otr/OtrConfigurator.java +++ b/src/net/java/sip/communicator/plugin/otr/OtrConfigurator.java @@ -6,7 +6,7 @@ */ package net.java.sip.communicator.plugin.otr; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import org.bouncycastle.util.encoders.*; diff --git a/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManager.java b/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManager.java index 246fc1b3f..f1d3dcff0 100755 --- a/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManager.java +++ b/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManager.java @@ -40,4 +40,4 @@ public interface ScOtrKeyManager public abstract void generateKeyPair(AccountID accountID); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/otr/otr.manifest.mf b/src/net/java/sip/communicator/plugin/otr/otr.manifest.mf index 24aabd876..c8296e598 100644 --- a/src/net/java/sip/communicator/plugin/otr/otr.manifest.mf +++ b/src/net/java/sip/communicator/plugin/otr/otr.manifest.mf @@ -6,12 +6,12 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.imageio, diff --git a/src/net/java/sip/communicator/plugin/pluginmanager/PluginManagerActivator.java b/src/net/java/sip/communicator/plugin/pluginmanager/PluginManagerActivator.java index 5ef6833d7..8c602f9e8 100644 --- a/src/net/java/sip/communicator/plugin/pluginmanager/PluginManagerActivator.java +++ b/src/net/java/sip/communicator/plugin/pluginmanager/PluginManagerActivator.java @@ -7,7 +7,7 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.gui.*; import org.osgi.framework.*; diff --git a/src/net/java/sip/communicator/plugin/pluginmanager/Resources.java b/src/net/java/sip/communicator/plugin/pluginmanager/Resources.java index d14698634..8d4e93cff 100644 --- a/src/net/java/sip/communicator/plugin/pluginmanager/Resources.java +++ b/src/net/java/sip/communicator/plugin/pluginmanager/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/pluginmanager/pluginmanager.manifest.mf b/src/net/java/sip/communicator/plugin/pluginmanager/pluginmanager.manifest.mf index 71cd57e74..2b2d31ba6 100644 --- a/src/net/java/sip/communicator/plugin/pluginmanager/pluginmanager.manifest.mf +++ b/src/net/java/sip/communicator/plugin/pluginmanager/pluginmanager.manifest.mf @@ -5,10 +5,10 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/profiler4j/Resources.java b/src/net/java/sip/communicator/plugin/profiler4j/Resources.java index 82e9d809e..a995ea757 100644 --- a/src/net/java/sip/communicator/plugin/profiler4j/Resources.java +++ b/src/net/java/sip/communicator/plugin/profiler4j/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Messages class manages the access to the internationalization properties * files. diff --git a/src/net/java/sip/communicator/plugin/profiler4j/profiler4j.manifest.mf b/src/net/java/sip/communicator/plugin/profiler4j/profiler4j.manifest.mf index b817d4594..c956cc65d 100644 --- a/src/net/java/sip/communicator/plugin/profiler4j/profiler4j.manifest.mf +++ b/src/net/java/sip/communicator/plugin/profiler4j/profiler4j.manifest.mf @@ -11,7 +11,7 @@ Import-Package: org.apache.commons.logging, org.xml.sax.helpers, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.gui, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.protocol, net.java.sip.communicator.util, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/provisioning/ProvisioningActivator.java b/src/net/java/sip/communicator/plugin/provisioning/ProvisioningActivator.java index bd081a835..9da4a694f 100644 --- a/src/net/java/sip/communicator/plugin/provisioning/ProvisioningActivator.java +++ b/src/net/java/sip/communicator/plugin/provisioning/ProvisioningActivator.java @@ -8,15 +8,15 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.provdisc.*; import net.java.sip.communicator.service.provisioning.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/provisioning/ProvisioningForm.java b/src/net/java/sip/communicator/plugin/provisioning/ProvisioningForm.java index 151a11915..636cf758b 100644 --- a/src/net/java/sip/communicator/plugin/provisioning/ProvisioningForm.java +++ b/src/net/java/sip/communicator/plugin/provisioning/ProvisioningForm.java @@ -13,11 +13,12 @@ import javax.swing.*; import javax.swing.event.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * * @author Yana Stamcheva diff --git a/src/net/java/sip/communicator/plugin/provisioning/ProvisioningServiceImpl.java b/src/net/java/sip/communicator/plugin/provisioning/ProvisioningServiceImpl.java index 8a63586ce..89e2fce94 100644 --- a/src/net/java/sip/communicator/plugin/provisioning/ProvisioningServiceImpl.java +++ b/src/net/java/sip/communicator/plugin/provisioning/ProvisioningServiceImpl.java @@ -8,7 +8,7 @@ import javax.swing.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.httputil.*; import net.java.sip.communicator.service.provisioning.*; import net.java.sip.communicator.util.*; diff --git a/src/net/java/sip/communicator/plugin/provisioning/provisioning.manifest.mf b/src/net/java/sip/communicator/plugin/provisioning/provisioning.manifest.mf index 8b9305b85..ee967c133 100644 --- a/src/net/java/sip/communicator/plugin/provisioning/provisioning.manifest.mf +++ b/src/net/java/sip/communicator/plugin/provisioning/provisioning.manifest.mf @@ -5,11 +5,11 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.httputil, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.provdisc, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.netaddr, diff --git a/src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java b/src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java index 3fa83c11d..db24090da 100644 --- a/src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java +++ b/src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java @@ -8,16 +8,16 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.netaddr.event.*; import net.java.sip.communicator.service.notification.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/reconnectplugin/reconnectplugin.manifest.mf b/src/net/java/sip/communicator/plugin/reconnectplugin/reconnectplugin.manifest.mf index a2b463fc1..9163cb26b 100644 --- a/src/net/java/sip/communicator/plugin/reconnectplugin/reconnectplugin.manifest.mf +++ b/src/net/java/sip/communicator/plugin/reconnectplugin/reconnectplugin.manifest.mf @@ -7,11 +7,11 @@ System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.netaddr, net.java.sip.communicator.service.netaddr.event, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.notification, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, - net.java.sip.communicator.util.swing \ No newline at end of file + net.java.sip.communicator.util.swing diff --git a/src/net/java/sip/communicator/plugin/rssaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/rssaccregwizz/Resources.java index 371faacd8..fedca1076 100644 --- a/src/net/java/sip/communicator/plugin/rssaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/rssaccregwizz/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/rssaccregwizz/rssaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/rssaccregwizz/rssaccregwizz.manifest.mf index 60c642952..81e2df7b2 100644 --- a/src/net/java/sip/communicator/plugin/rssaccregwizz/rssaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/rssaccregwizz/rssaccregwizz.manifest.mf @@ -6,14 +6,14 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/securityconfig/SecurityConfigActivator.java b/src/net/java/sip/communicator/plugin/securityconfig/SecurityConfigActivator.java index 6842b9e60..5a90a92db 100644 --- a/src/net/java/sip/communicator/plugin/securityconfig/SecurityConfigActivator.java +++ b/src/net/java/sip/communicator/plugin/securityconfig/SecurityConfigActivator.java @@ -7,13 +7,14 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/securityconfig/SecurityConfigurationPanel.java b/src/net/java/sip/communicator/plugin/securityconfig/SecurityConfigurationPanel.java index 50a1bd283..c60d871fd 100644 --- a/src/net/java/sip/communicator/plugin/securityconfig/SecurityConfigurationPanel.java +++ b/src/net/java/sip/communicator/plugin/securityconfig/SecurityConfigurationPanel.java @@ -131,4 +131,4 @@ private void addConfigForm(ConfigurationForm form) formTitle, cIndex); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/MasterPasswordChangeDialog.java b/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/MasterPasswordChangeDialog.java index 333eb2b22..24ce6f772 100644 --- a/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/MasterPasswordChangeDialog.java +++ b/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/MasterPasswordChangeDialog.java @@ -15,9 +15,10 @@ import net.java.sip.communicator.plugin.securityconfig.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * UI dialog to change the master password. * diff --git a/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/MasterPasswordPanel.java b/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/MasterPasswordPanel.java index 598888e91..7e85595db 100644 --- a/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/MasterPasswordPanel.java +++ b/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/MasterPasswordPanel.java @@ -12,12 +12,13 @@ import javax.swing.*; import net.java.sip.communicator.plugin.securityconfig.*; -import net.java.sip.communicator.plugin.securityconfig.masterpassword.MasterPasswordChangeDialog.*; +import net.java.sip.communicator.plugin.securityconfig.masterpassword.MasterPasswordChangeDialog.MasterPasswordExecutable; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; + /** * Panel containing the master password checkbox and change button. * diff --git a/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/SavedPasswordsDialog.java b/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/SavedPasswordsDialog.java index 495f9b43a..4f8813eeb 100644 --- a/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/SavedPasswordsDialog.java +++ b/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/SavedPasswordsDialog.java @@ -9,7 +9,7 @@ import java.awt.*; import java.awt.event.*; import java.util.*; -import java.util.List; // disambiguation +import java.util.List; import javax.swing.*; import javax.swing.border.*; @@ -17,13 +17,15 @@ import javax.swing.table.*; import net.java.sip.communicator.plugin.securityconfig.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; +// disambiguation + /** * The dialog that displays all saved account passwords. * diff --git a/src/net/java/sip/communicator/plugin/securityconfig/securityconfig.manifest.mf b/src/net/java/sip/communicator/plugin/securityconfig/securityconfig.manifest.mf index 1fb372ef9..261175b10 100644 --- a/src/net/java/sip/communicator/plugin/securityconfig/securityconfig.manifest.mf +++ b/src/net/java/sip/communicator/plugin/securityconfig/securityconfig.manifest.mf @@ -5,13 +5,13 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.credentialsstorage, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, gnu.java.zrtp, diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java index 98937375a..a433adabb 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java @@ -15,7 +15,7 @@ import javax.swing.*; import javax.swing.text.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java b/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java index 663aab359..4b614dd2b 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java @@ -7,8 +7,11 @@ package net.java.sip.communicator.plugin.simpleaccreg; import javax.swing.*; + import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java b/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java index 17bc36531..0d627e8ac 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java @@ -9,13 +9,13 @@ import java.awt.*; import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/simpleaccreg.manifest.mf b/src/net/java/sip/communicator/plugin/simpleaccreg/simpleaccreg.manifest.mf index 242e94f5d..791a58659 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/simpleaccreg.manifest.mf +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/simpleaccreg.manifest.mf @@ -6,14 +6,14 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/Sip2SipAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/Sip2SipAccRegWizzActivator.java index be62d3718..84ce64ea9 100644 --- a/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/Sip2SipAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/Sip2SipAccRegWizzActivator.java @@ -8,13 +8,14 @@ import java.util.*; -import org.osgi.framework.*; - import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; + /** * Registers the GoogleTalkAccountRegistrationWizard in the UI Service. * diff --git a/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/sip2sipaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/sip2sipaccregwizz.manifest.mf index d94956243..98f186f60 100644 --- a/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/sip2sipaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/sip2sipaccregwizz.manifest.mf @@ -6,16 +6,16 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.fileaccess, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.icqconstants, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, net.java.sip.communicator.plugin.sipaccregwizz, diff --git a/src/net/java/sip/communicator/plugin/sipaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/sipaccregwizz/Resources.java index 4e410f676..6d65a0b2a 100644 --- a/src/net/java/sip/communicator/plugin/sipaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/sipaccregwizz/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccRegWizzActivator.java index d0c9fa735..3caf86758 100644 --- a/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccRegWizzActivator.java @@ -11,7 +11,7 @@ import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.certificate.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; diff --git a/src/net/java/sip/communicator/plugin/sipaccregwizz/SecurityPanel.java b/src/net/java/sip/communicator/plugin/sipaccregwizz/SecurityPanel.java index 079788c05..c64c21194 100644 --- a/src/net/java/sip/communicator/plugin/sipaccregwizz/SecurityPanel.java +++ b/src/net/java/sip/communicator/plugin/sipaccregwizz/SecurityPanel.java @@ -9,12 +9,13 @@ import javax.swing.border.*; import javax.swing.table.*; -import ch.imvs.sdes4j.srtp.SrtpCryptoSuite; - -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.neomedia.*; + +import ch.imvs.sdes4j.srtp.*; + /** * Contains the security settings for SIP media encryption. * diff --git a/src/net/java/sip/communicator/plugin/sipaccregwizz/sipaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/sipaccregwizz/sipaccregwizz.manifest.mf index 3c75af414..054b038ae 100644 --- a/src/net/java/sip/communicator/plugin/sipaccregwizz/sipaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/sipaccregwizz/sipaccregwizz.manifest.mf @@ -8,16 +8,16 @@ Export-package: net.java.sip.communicator.plugin.sipaccregwizz Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, net.java.sip.communicator.service.certificate, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, - net.java.sip.communicator.service.neomedia, + org.jitsi.service.neomedia, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.icqconstants, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/skinmanager/Resources.java b/src/net/java/sip/communicator/plugin/skinmanager/Resources.java index 4d99e1f6d..b523cf048 100644 --- a/src/net/java/sip/communicator/plugin/skinmanager/Resources.java +++ b/src/net/java/sip/communicator/plugin/skinmanager/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/skinmanager/SkinManagerActivator.java b/src/net/java/sip/communicator/plugin/skinmanager/SkinManagerActivator.java index 9953a0d10..a91b270a2 100644 --- a/src/net/java/sip/communicator/plugin/skinmanager/SkinManagerActivator.java +++ b/src/net/java/sip/communicator/plugin/skinmanager/SkinManagerActivator.java @@ -7,7 +7,7 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.util.*; diff --git a/src/net/java/sip/communicator/plugin/skinmanager/SkinSelectionListener.java b/src/net/java/sip/communicator/plugin/skinmanager/SkinSelectionListener.java index 1b66204a6..41cc4fb7e 100644 --- a/src/net/java/sip/communicator/plugin/skinmanager/SkinSelectionListener.java +++ b/src/net/java/sip/communicator/plugin/skinmanager/SkinSelectionListener.java @@ -215,4 +215,4 @@ public String getDescription() return chooser; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/skinmanager/SkinSelector.java b/src/net/java/sip/communicator/plugin/skinmanager/SkinSelector.java index 6cc408fa9..87148dd4e 100644 --- a/src/net/java/sip/communicator/plugin/skinmanager/SkinSelector.java +++ b/src/net/java/sip/communicator/plugin/skinmanager/SkinSelector.java @@ -292,4 +292,4 @@ private boolean isSkin(Bundle bundle) return false; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/skinmanager/skinmanager.manifest.mf b/src/net/java/sip/communicator/plugin/skinmanager/skinmanager.manifest.mf index bfe0c717d..1464ff50c 100644 --- a/src/net/java/sip/communicator/plugin/skinmanager/skinmanager.manifest.mf +++ b/src/net/java/sip/communicator/plugin/skinmanager/skinmanager.manifest.mf @@ -5,10 +5,10 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/skinresourcepack/skinresourcepack.manifest.mf b/src/net/java/sip/communicator/plugin/skinresourcepack/skinresourcepack.manifest.mf index d64b30676..dd07b2c88 100644 --- a/src/net/java/sip/communicator/plugin/skinresourcepack/skinresourcepack.manifest.mf +++ b/src/net/java/sip/communicator/plugin/skinresourcepack/skinresourcepack.manifest.mf @@ -6,5 +6,5 @@ Bundle-Vendor: jitsi.org, Adam Netocny, CircleTech, s.r.o. Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util diff --git a/src/net/java/sip/communicator/plugin/spellcheck/ChatAttachments.java b/src/net/java/sip/communicator/plugin/spellcheck/ChatAttachments.java index 4954dab90..89b413ef4 100644 --- a/src/net/java/sip/communicator/plugin/spellcheck/ChatAttachments.java +++ b/src/net/java/sip/communicator/plugin/spellcheck/ChatAttachments.java @@ -14,10 +14,10 @@ import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.event.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import org.dts.spell.dictionary.*; +import org.jitsi.service.resources.*; /** * Wrapper for handling the multiple listeners associated with chats for the @@ -312,4 +312,4 @@ public void actionPerformed(ActionEvent event) chat.setMessage(newMessage.toString()); } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/spellcheck/DocUnderliner.java b/src/net/java/sip/communicator/plugin/spellcheck/DocUnderliner.java index b00bc1ada..860333b00 100644 --- a/src/net/java/sip/communicator/plugin/spellcheck/DocUnderliner.java +++ b/src/net/java/sip/communicator/plugin/spellcheck/DocUnderliner.java @@ -442,4 +442,4 @@ public void reset(String message) promptRepaint(); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/spellcheck/Parameters.java b/src/net/java/sip/communicator/plugin/spellcheck/Parameters.java index 3993be2c1..10d78f4fd 100644 --- a/src/net/java/sip/communicator/plugin/spellcheck/Parameters.java +++ b/src/net/java/sip/communicator/plugin/spellcheck/Parameters.java @@ -318,4 +318,4 @@ public String toString() return this.tag; } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/spellcheck/Resources.java b/src/net/java/sip/communicator/plugin/spellcheck/Resources.java index 7e5c79277..b58a4c072 100644 --- a/src/net/java/sip/communicator/plugin/spellcheck/Resources.java +++ b/src/net/java/sip/communicator/plugin/spellcheck/Resources.java @@ -11,9 +11,9 @@ import javax.imageio.*; import javax.swing.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** @@ -136,4 +136,4 @@ public static ResourceManagementService getResources() return resourceService; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/spellcheck/SpellCheckActivator.java b/src/net/java/sip/communicator/plugin/spellcheck/SpellCheckActivator.java index eb6cae0de..6c8b4fdef 100644 --- a/src/net/java/sip/communicator/plugin/spellcheck/SpellCheckActivator.java +++ b/src/net/java/sip/communicator/plugin/spellcheck/SpellCheckActivator.java @@ -7,10 +7,10 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.gui.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.fileaccess.*; import org.osgi.framework.*; /** @@ -119,4 +119,4 @@ public void stop(BundleContext arg0) throws Exception { this.checker.stop(); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/spellcheck/SpellChecker.java b/src/net/java/sip/communicator/plugin/spellcheck/SpellChecker.java index bc2765b62..b661cb667 100644 --- a/src/net/java/sip/communicator/plugin/spellcheck/SpellChecker.java +++ b/src/net/java/sip/communicator/plugin/spellcheck/SpellChecker.java @@ -9,12 +9,12 @@ import java.net.*; import java.util.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.event.*; -import net.java.sip.communicator.util.Logger; +import net.java.sip.communicator.util.*; import org.dts.spell.dictionary.*; +import org.jitsi.service.fileaccess.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/spellcheck/SpellCheckerConfigDialog.java b/src/net/java/sip/communicator/plugin/spellcheck/SpellCheckerConfigDialog.java index 579318645..ac51b2799 100644 --- a/src/net/java/sip/communicator/plugin/spellcheck/SpellCheckerConfigDialog.java +++ b/src/net/java/sip/communicator/plugin/spellcheck/SpellCheckerConfigDialog.java @@ -13,13 +13,13 @@ import javax.swing.event.*; import javax.swing.text.*; -import org.dts.spell.dictionary.*; - import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.Logger; +import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.dts.spell.dictionary.*; +import org.jitsi.service.resources.*; + /** * The spell check dialog that would be opened from the right click menu in the * chat window. diff --git a/src/net/java/sip/communicator/plugin/spellcheck/Word.java b/src/net/java/sip/communicator/plugin/spellcheck/Word.java index 1ba21cfcc..9c87c03d8 100644 --- a/src/net/java/sip/communicator/plugin/spellcheck/Word.java +++ b/src/net/java/sip/communicator/plugin/spellcheck/Word.java @@ -83,4 +83,4 @@ public String toString() { return this.text; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/spellcheck/spellCheck.manifest.mf b/src/net/java/sip/communicator/plugin/spellcheck/spellCheck.manifest.mf index aaf654774..32977475d 100644 --- a/src/net/java/sip/communicator/plugin/spellcheck/spellCheck.manifest.mf +++ b/src/net/java/sip/communicator/plugin/spellcheck/spellCheck.manifest.mf @@ -5,11 +5,11 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 Import-Package: org.osgi.framework, net.java.sip.communicator.util, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.fileaccess, + org.jitsi.service.configuration, + org.jitsi.service.fileaccess, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util.swing, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.protocol, @@ -20,4 +20,4 @@ Import-Package: org.osgi.framework, javax.imageio, javax.xml.parsers, org.w3c.dom, - org.xml.sax \ No newline at end of file + org.xml.sax diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/sshaccregwizz/Resources.java index 97a5ff369..444dd688b 100644 --- a/src/net/java/sip/communicator/plugin/sshaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/sshaccregwizz/Resources.java @@ -15,6 +15,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/sshaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/sshaccregwizz/sshaccregwizz.manifest.mf index f6c650f6d..d4fa3372b 100644 --- a/src/net/java/sip/communicator/plugin/sshaccregwizz/sshaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/sshaccregwizz/sshaccregwizz.manifest.mf @@ -6,14 +6,14 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/update/Resources.java b/src/net/java/sip/communicator/plugin/update/Resources.java index 3aff8917d..c622fda1c 100644 --- a/src/net/java/sip/communicator/plugin/update/Resources.java +++ b/src/net/java/sip/communicator/plugin/update/Resources.java @@ -8,9 +8,10 @@ import java.io.*; import java.util.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; + /** * Implements methods to facilitate dealing with resources in the update * plug-in. diff --git a/src/net/java/sip/communicator/plugin/update/Update.java b/src/net/java/sip/communicator/plugin/update/Update.java index bdba08aa2..749a1e710 100644 --- a/src/net/java/sip/communicator/plugin/update/Update.java +++ b/src/net/java/sip/communicator/plugin/update/Update.java @@ -11,19 +11,23 @@ import java.io.*; import java.net.*; import java.util.*; -import java.util.List; // disambiguation +import java.util.List; import javax.swing.*; import javax.swing.text.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.httputil.*; -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.service.update.UpdateService; -import net.java.sip.communicator.service.version.*; +import net.java.sip.communicator.service.update.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; +import org.jitsi.service.version.*; +import org.jitsi.util.*; +// disambiguation + /** * Implements checking for software updates, downloading and applying them i.e. * the very logic of the update plug-in. diff --git a/src/net/java/sip/communicator/plugin/update/UpdateActivator.java b/src/net/java/sip/communicator/plugin/update/UpdateActivator.java index f9ff19887..14951d5d3 100644 --- a/src/net/java/sip/communicator/plugin/update/UpdateActivator.java +++ b/src/net/java/sip/communicator/plugin/update/UpdateActivator.java @@ -9,12 +9,14 @@ import java.util.*; import net.java.sip.communicator.service.browserlauncher.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.shutdown.*; -import net.java.sip.communicator.service.update.UpdateService; +import net.java.sip.communicator.service.update.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; +import org.jitsi.service.configuration.*; +import org.jitsi.util.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/plugin/update/update.manifest.mf b/src/net/java/sip/communicator/plugin/update/update.manifest.mf index 5a822e830..98b694828 100644 --- a/src/net/java/sip/communicator/plugin/update/update.manifest.mf +++ b/src/net/java/sip/communicator/plugin/update/update.manifest.mf @@ -5,14 +5,16 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, + org.jitsi.service.configuration, + org.jitsi.service.resources, + org.jitsi.service.version, + org.jitsi.util, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, net.java.sip.communicator.service.httputil, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.shutdown, - net.java.sip.communicator.service.version, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, net.java.sip.communicator.service.update, diff --git a/src/net/java/sip/communicator/plugin/whiteboard/Resources.java b/src/net/java/sip/communicator/plugin/whiteboard/Resources.java index 05d273d18..12880109c 100644 --- a/src/net/java/sip/communicator/plugin/whiteboard/Resources.java +++ b/src/net/java/sip/communicator/plugin/whiteboard/Resources.java @@ -9,6 +9,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java b/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java index a1941113f..de1872de7 100644 --- a/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java +++ b/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java @@ -158,4 +158,4 @@ public String getName() { return whiteboardMenu.getText(); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardFileFilter.java b/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardFileFilter.java index 18706db60..23e330c58 100644 --- a/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardFileFilter.java +++ b/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardFileFilter.java @@ -89,4 +89,4 @@ public String getExtension (File f) { } return null; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardPanel.java b/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardPanel.java index 696612918..5282b66a1 100644 --- a/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardPanel.java +++ b/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardPanel.java @@ -302,4 +302,4 @@ private void checkPopupEvent(MouseEvent e) popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/whiteboard/gui/whiteboardshapes/WhiteboardShape.java b/src/net/java/sip/communicator/plugin/whiteboard/gui/whiteboardshapes/WhiteboardShape.java index 0bd074643..c303fba2a 100644 --- a/src/net/java/sip/communicator/plugin/whiteboard/gui/whiteboardshapes/WhiteboardShape.java +++ b/src/net/java/sip/communicator/plugin/whiteboard/gui/whiteboardshapes/WhiteboardShape.java @@ -368,4 +368,4 @@ public boolean equals (Object obj) */ public abstract WhiteboardPoint getSelectionPoint (Point2D p); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/whiteboard/whiteboard.manifest.mf b/src/net/java/sip/communicator/plugin/whiteboard/whiteboard.manifest.mf index 080d8f925..14cd534d8 100644 --- a/src/net/java/sip/communicator/plugin/whiteboard/whiteboard.manifest.mf +++ b/src/net/java/sip/communicator/plugin/whiteboard/whiteboard.manifest.mf @@ -12,7 +12,7 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.whiteboardobjects, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/yahooaccregwizz/Resources.java index 5f7c6eb31..a33650998 100644 --- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/yahooaccregwizz/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the image resources used in this plugin. diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/yahooaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/yahooaccregwizz/yahooaccregwizz.manifest.mf index aecb0aa04..1f27b2b91 100644 --- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/yahooaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/yahooaccregwizz/yahooaccregwizz.manifest.mf @@ -6,7 +6,7 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.gui, @@ -14,7 +14,7 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.icqconstants, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/Resources.java index bfa379f76..253ea9cb1 100644 --- a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/Resources.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * The Resources class manages the access to the internationalization * properties files and the images properties file. diff --git a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/zeroconfaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/zeroconfaccregwizz.manifest.mf index 728fedcf4..611a2d846 100644 --- a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/zeroconfaccregwizz.manifest.mf +++ b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/zeroconfaccregwizz.manifest.mf @@ -6,14 +6,14 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.service.browserlauncher, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.contactlist.event, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/service/audionotifier/AudioNotifierService.java b/src/net/java/sip/communicator/service/audionotifier/AudioNotifierService.java deleted file mode 100644 index 3ae86337b..000000000 --- a/src/net/java/sip/communicator/service/audionotifier/AudioNotifierService.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.audionotifier; - -/** - * The AudioNotifierService is meant to be used to control all sounds in the - * application. An audio could be created by calling the createAudio method. - * In order to stop all sounds in the application one could call the setMute - * method. To check whether the sound is currently enabled the isMute method - * could be used. - * - * @author Yana Stamcheva - */ -public interface AudioNotifierService -{ - /** - * Creates an SCAudioClip and returns it. - * @param uri the uri, which will be the source of the audio - * @return the created SCAudioClip, that could be played. - */ - public SCAudioClip createAudio(String uri); - - /** - * Destroys the given audio. - * - * @param audio SCAudioClip to destroy - */ - public void destroyAudio(SCAudioClip audio); - - /** - * Stops/Restores all currently playing sounds. - * - * @param isMute mute or not currently playing sounds - */ - public void setMute(boolean isMute); - - /** - * Specifies if currently the sound is off. - * - * @return TRUE if currently the sound is off, FALSE otherwise - */ - public boolean isMute(); -} diff --git a/src/net/java/sip/communicator/service/audionotifier/SCAudioClip.java b/src/net/java/sip/communicator/service/audionotifier/SCAudioClip.java deleted file mode 100644 index daf81c753..000000000 --- a/src/net/java/sip/communicator/service/audionotifier/SCAudioClip.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.audionotifier; - -/** - * SCAudioClip represents an audio clip created using the AudioNotifierService. - * Like any audio it could be played, stopped or played in loop. - * - * @author Yana Stamcheva - */ -public interface SCAudioClip -{ - /** - * Plays this audio. - */ - public void play(); - - /** - * Plays this audio in loop. - * - * @param silenceInterval interval between loops - */ - public void playInLoop(int silenceInterval); - - /** - * Stops this audio. - */ - public void stop(); -} diff --git a/src/net/java/sip/communicator/service/certificate/CertificateService.java b/src/net/java/sip/communicator/service/certificate/CertificateService.java index 33a2ed9ae..795fdfa15 100644 --- a/src/net/java/sip/communicator/service/certificate/CertificateService.java +++ b/src/net/java/sip/communicator/service/certificate/CertificateService.java @@ -250,4 +250,4 @@ public X509TrustManager getTrustManager( */ public void addCertificateToTrust(Certificate cert, String trustFor, int trustMode) throws CertificateException; -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/certificate/KeyStoreType.java b/src/net/java/sip/communicator/service/certificate/KeyStoreType.java index b292684cc..d015e395e 100644 --- a/src/net/java/sip/communicator/service/certificate/KeyStoreType.java +++ b/src/net/java/sip/communicator/service/certificate/KeyStoreType.java @@ -65,4 +65,4 @@ public boolean hasKeyStorePassword() { return hasKeyStorePassword; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/configuration/ConfigPropertyVetoException.java b/src/net/java/sip/communicator/service/configuration/ConfigPropertyVetoException.java deleted file mode 100644 index 733101e1c..000000000 --- a/src/net/java/sip/communicator/service/configuration/ConfigPropertyVetoException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.configuration; - -import java.beans.*; - -/** - * A PropertyVetoException is thrown when a proposed change to a - * property represents an unacceptable value. - * - * @author Emil Ivov - */ -public class ConfigPropertyVetoException - extends RuntimeException -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * A PropertyChangeEvent describing the vetoed change. - */ - private final PropertyChangeEvent evt; - - /** - * Constructs a PropertyVetoException with a - * detailed message. - * - * @param message Descriptive message - * @param evt A PropertyChangeEvent describing the vetoed change. - */ - public ConfigPropertyVetoException(String message, PropertyChangeEvent evt) - { - super(message); - - this.evt = evt; - } - - /** - * Gets the vetoed PropertyChangeEvent. - * - * @return A PropertyChangeEvent describing the vetoed change. - */ - public PropertyChangeEvent getPropertyChangeEvent() - { - return evt; - } -} diff --git a/src/net/java/sip/communicator/service/configuration/ConfigVetoableChangeListener.java b/src/net/java/sip/communicator/service/configuration/ConfigVetoableChangeListener.java deleted file mode 100644 index 075d56e25..000000000 --- a/src/net/java/sip/communicator/service/configuration/ConfigVetoableChangeListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package net.java.sip.communicator.service.configuration; - -import java.beans.*; -import java.util.EventListener; - -/** - * This interface uses SC's own ProperteyVetoException. - */ -public interface ConfigVetoableChangeListener extends EventListener -{ - /** - * Fired before a Bean's property changes. - * - * @param e the change (containing the old and new values) - * @throws ConfigPropertyVetoException if the change is vetoed by the listener - */ - void vetoableChange(PropertyChangeEvent e) throws ConfigPropertyVetoException; -} diff --git a/src/net/java/sip/communicator/service/configuration/ConfigurationService.java b/src/net/java/sip/communicator/service/configuration/ConfigurationService.java deleted file mode 100644 index 9e91dc2ac..000000000 --- a/src/net/java/sip/communicator/service/configuration/ConfigurationService.java +++ /dev/null @@ -1,454 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.configuration; - -import java.beans.*; -import java.io.*; -import java.util.*; - -import net.java.sip.communicator.util.xml.*; - -/** - * The configuration services provides a centralized approach of storing - * persistent configuration data. - * - * @author Emil Ivov - * @author Lyubomir Marinov - * @author Dmitri Melnikov - */ -public interface ConfigurationService -{ - /** - * The name of the property that indicates the name of the directory where - * SIP Communicator is to store user specific data such as configuration - * files, message and call history as well as is bundle repository. - */ - public static final String PNAME_SC_HOME_DIR_NAME - = "net.java.sip.communicator.SC_HOME_DIR_NAME"; - - /** - * The name of the property that indicates the location of the directory - * where SIP Communicator is to store user specific data such as - * configuration files, message and call history as well as is bundle - * repository. - */ - public static final String PNAME_SC_HOME_DIR_LOCATION - = "net.java.sip.communicator.SC_HOME_DIR_LOCATION"; - - /** - * The name of the boolean system property which indicates whether the - * configuration file is to be considered read-only. The default value is - * false which means that the configuration file is considered - * writable. - */ - public static final String PNAME_CONFIGURATION_FILE_IS_READ_ONLY - = "net.java.sip.communicator.CONFIGURATION_FILE_IS_READ_ONLY"; - - /** - * The name of the system property that stores the name of the configuration - * file. - */ - public static final String PNAME_CONFIGURATION_FILE_NAME - = "net.java.sip.communicator.CONFIGURATION_FILE_NAME"; - - /** - * Sets the property with the specified name to the specified value. Calling - * this method would first trigger a PropertyChangeEvent that will - * be dispatched to all VetoableChangeListeners. In case no complaints - * (PropertyVetoException) have been received, the property will be actually - * changed and a PropertyChangeEvent will be dispatched. - *

- * @param propertyName the name of the property to change. - * @param property the new value of the specified property. - * @throws ConfigPropertyVetoException in case the changed has been refused by - * at least one propertychange listener. - */ - public void setProperty(String propertyName, Object property); - // throws PropertyVetoException; - - /** - * Sets the property with the specified name to the specified. Calling - * this method would first trigger a PropertyChangeEvent that will - * be dispatched to all VetoableChangeListeners. In case no complaints - * (PropertyVetoException) have been received, the property will be actually - * changed and a PropertyChangeEvent will be dispatched. This method also - * allows the caller to specify whether or not the specified property is a - * system one. - *

- * @param propertyName the name of the property to change. - * @param property the new value of the specified property. - * @param isSystem specifies whether or not the property being is a System - * property and should be resolved against the system - * property set - * @throws ConfigPropertyVetoException in case the changed has been refused by - * at least one propertychange listener. - */ - public void setProperty(String propertyName, - Object property, - boolean isSystem); - // throws PropertyVetoException; - - /** - * Sets a set of specific properties to specific values as a batch operation - * meaning that first VetoableChangeListeners are asked to - * approve the modifications of the specified properties to the specified - * values, then the modifications are performed if no complaints have been - * raised in the form of PropetyVetoException and finally - * PropertyChangeListeners are notified about the changes of - * each of the specified properties. The batch operations allows the - * ConfigurationService implementations to optimize, for - * example, the saving of the configuration which in this case can be - * performed only once for the setting of multiple properties. - * - * @param properties - * a Map of property names to their new values to be - * set - * @throws ConfigPropertyVetoException - * if a change in at least one of the properties has been - * refused by at least one of the - * VetoableChangeListeners - */ - public void setProperties(Map properties); - // throws PropertyVetoException; - - /** - * Returns the value of the property with the specified name or null if no - * such property exists. - * @param propertyName the name of the property that is being queried. - * @return the value of the property with the specified name. - */ - public Object getProperty(String propertyName); - - /** - * Removes the property with the specified name. Calling - * this method would first trigger a PropertyChangeEvent that will - * be dispatched to all VetoableChangeListeners. In case no complaints - * (PropertyVetoException) have been received, the property will be actually - * changed and a PropertyChangeEvent will be dispatched. - * All properties with prefix propertyName will also be removed. - *

- * @param propertyName the name of the property to change. - * @throws ConfigPropertyVetoException in case the changed has been refused by - * at least one propertychange listener. - */ - public void removeProperty(String propertyName); - // throws PropertyVetoException; - - /** - * Returns a java.util.List of Strings containing all - * property names. - * - * @return a java.util.Listcontaining all property names - */ - public List getAllPropertyNames(); - - /** - * Returns a java.util.List of Strings containing the - * all property names that have the specified prefix. Depending on the value - * of the exactPrefixMatch parameter the method will (when false) - * or will not (when exactPrefixMatch is true) include property names that - * have prefixes longer than the specified prefix param. - *

- * Example: - *

- * Imagine a configuration service instance containing 2 properties only:
- * - * net.java.sip.communicator.PROP1=value1
- * net.java.sip.communicator.service.protocol.PROP1=value2 - *
- *

- * A call to this method with a prefix="net.java.sip.communicator" and - * exactPrefixMatch=true would only return the first property - - * net.java.sip.communicator.PROP1, whereas the same call with - * exactPrefixMatch=false would return both properties as the second prefix - * includes the requested prefix string. - *

- * @param prefix a String containing the prefix (the non dotted non-caps - * part of a property name) that we're looking for. - * @param exactPrefixMatch a boolean indicating whether the returned - * property names should all have a prefix that is an exact match of the - * the prefix param or whether properties with prefixes that - * contain it but are longer than it are also accepted. - * @return a java.util.Listcontaining all property name String-s - * matching the specified conditions. - */ - public List getPropertyNamesByPrefix(String prefix, - boolean exactPrefixMatch); - - /** - * Returns a List of Strings containing the property names - * that have the specified suffix. A suffix is considered to be everything - * after the last dot in the property name. - *

- * For example, imagine a configuration service instance containing two - * properties only: - *

- * - * net.java.sip.communicator.PROP1=value1 - * net.java.sip.communicator.service.protocol.PROP1=value2 - * - *

- * A call to this method with suffix equal to "PROP1" will return - * both properties, whereas the call with suffix equal to - * "communicator.PROP1" or "PROP2" will return an empty List. Thus, - * if the suffix argument contains a dot, nothing will be found. - *

- * - * @param suffix the suffix for the property names to be returned - * @return a List of Strings containing the property names - * which contain the specified suffix - */ - public List getPropertyNamesBySuffix(String suffix); - - /** - * Returns the String value of the specified property and null in case no - * property value was mapped against the specified propertyName, or in - * case the returned property string had zero length or contained - * whitespaces only. - * - * @param propertyName the name of the property that is being queried. - * @return the result of calling the property's toString method and null in - * case there was no value mapped against the specified - * propertyName, or the returned string had zero length or - * contained whitespaces only. - */ - public String getString(String propertyName); - - /** - * Returns the String value of the specified property and null in case no - * property value was mapped against the specified propertyName, or in - * case the returned property string had zero length or contained - * whitespaces only. - * - * @param propertyName the name of the property that is being queried. - * @param defaultValue the value to be returned if the specified property - * name is not associated with a value in this - * ConfigurationService - * @return the result of calling the property's toString method and - * defaultValue in case there was no value mapped against - * the specified propertyName, or the returned string had zero - * length or contained whitespaces only. - */ - public String getString(String propertyName, String defaultValue); - - /** - * Gets the value of a specific property as a boolean. If the specified - * property name is associated with a value in this - * ConfigurationService, the string representation of the value - * is parsed into a boolean according to the rules of - * {@link Boolean#parseBoolean(String)} . Otherwise, - * defaultValue is returned. - * - * @param propertyName - * the name of the property to get the value of as a boolean - * @param defaultValue - * the value to be returned if the specified property name is not - * associated with a value in this - * ConfigurationService - * @return the value of the property with the specified name in this - * ConfigurationService as a boolean; - * defaultValue if the property with the specified name - * is not associated with a value in this - * ConfigurationService - */ - public boolean getBoolean(String propertyName, boolean defaultValue); - - /** - * Gets the value of a specific property as a signed decimal integer. If the - * specified property name is associated with a value in this - * ConfigurationService, the string representation of the value is - * parsed into a signed decimal integer according to the rules of - * {@link Integer#parseInt(String)} . If parsing the value as a signed - * decimal integer fails or there is no value associated with the specified - * property name, defaultValue is returned. - * - * @param propertyName the name of the property to get the value of as a - * signed decimal integer - * @param defaultValue the value to be returned if parsing the value of the - * specified property name as a signed decimal integer fails or there is no - * value associated with the specified property name in this - * ConfigurationService - * @return the value of the property with the specified name in this - * ConfigurationService as a signed decimal integer; - * defaultValue if parsing the value of the specified property name - * fails or no value is associated in this ConfigurationService - * with the specified property name - */ - public int getInt(String propertyName, int defaultValue); - - /** - * Gets the value of a specific property as a signed decimal long integer. - * If the specified property name is associated with a value in this - * ConfigurationService, the string representation of the value is - * parsed into a signed decimal long integer according to the rules of - * {@link Long#parseLong(String)} . If parsing the value as a signed - * decimal long integer fails or there is no value associated with the - * specified property name, defaultValue is returned. - * - * @param propertyName the name of the property to get the value of as a - * signed decimal long integer - * @param defaultValue the value to be returned if parsing the value of the - * specified property name as a signed decimal long integer fails or there - * is no value associated with the specified property name in this - * ConfigurationService - * @return the value of the property with the specified name in this - * ConfigurationService as a signed decimal long integer; - * defaultValue if parsing the value of the specified property name - * fails or no value is associated in this ConfigurationService - * with the specified property name - */ - public long getLong(String propertyName, long defaultValue); - - /** - * Adds a PropertyChangeListener to the listener list. The listener is - * registered for all properties in the current configuration. - *

- * @param listener the PropertyChangeListener to be added - */ - public void addPropertyChangeListener(PropertyChangeListener listener); - - /** - * Removes a PropertyChangeListener from the listener list. - *

- * @param listener the PropertyChangeListener to be removed - */ - public void removePropertyChangeListener(PropertyChangeListener listener); - - /** - * Adds a PropertyChangeListener to the listener list for a specific - * property. In case a property with the specified name does not exist the - * listener is still added and would only be taken into account from the - * moment such a property is set by someone. - *

- * @param propertyName one of the property names listed above - * @param listener the PropertyChangeListener to be added - */ - public void addPropertyChangeListener(String propertyName, - PropertyChangeListener listener); - - /** - * Removes a PropertyChangeListener from the listener list for a specific - * property. This method should be used to remove PropertyChangeListeners - * that were registered for a specific property. The method has no effect - * when called for a listener that was not registered for that specifiec - * property. - *

- * - * @param propertyName a valid property name - * @param listener the PropertyChangeListener to be removed - */ - public void removePropertyChangeListener(String propertyName, - PropertyChangeListener listener); - - /** - * Adds a VetoableChangeListener to the listener list. The listener is - * registered for all properties in the configuration. - *

- * @param listener the VetoableChangeListener to be added - */ - public void addVetoableChangeListener(ConfigVetoableChangeListener listener); - - /** - * Removes a VetoableChangeListener from the listener list. - *

- * - * @param listener the VetoableChangeListener to be removed - */ - public void removeVetoableChangeListener(ConfigVetoableChangeListener listener); - - /** - * Adds a VetoableChangeListener to the listener list for a specific - * property. - *

- * - * @param propertyName one of the property names listed above - * @param listener the VetoableChangeListener to be added - */ - public void addVetoableChangeListener(String propertyName, - ConfigVetoableChangeListener listener); - - /** - * Removes a VetoableChangeListener from the listener list for a specific - * property. - *

- * - * @param propertyName a valid property name - * @param listener the VetoableChangeListener to be removed - */ - public void removeVetoableChangeListener(String propertyName, - ConfigVetoableChangeListener listener); - - /** - * Store the current set of properties back to the configuration file. The - * name of the configuration file is queried from the system property - * net.java.sip.communicator.PROPERTIES_FILE_NAME, and is set to - * sip-communicator.xml in case the property does not contain a valid file - * name. The location might be one of three possibile, checked in the - * following order:
- * 1. The current directory.
- * 2. The sip-communicator directory in the user.home - * ($HOME/.sip-communicator) - * 3. A location in the classpath (such as the sip-communicator jar file). - *

- * In the last case the file is copied to the sip-communicator configuration - * directory right after being extracted from the classpath location. - * - * @throws IOException in case storing the configuration failed. - */ - public void storeConfiguration() - throws IOException; - - /** - * Deletes the current configuration and reloads it from the configuration - * file. The - * name of the configuration file is queried from the system property - * net.java.sip.communicator.PROPERTIES_FILE_NAME, and is set to - * sip-communicator.xml in case the property does not contain a valid file - * name. The location might be one of three possibile, checked in the - * following order:
- * 1. The current directory.
- * 2. The sip-communicator directory in the user.home - * ($HOME/.sip-communicator) - * 3. A location in the classpath (such as the sip-communicator jar file). - *

- * In the last case the file is copied to the sip-communicator configuration - * directory right after being extracted from the classpath location. - * @throws IOException in case reading the configuration failes - * @throws XMLException in case parsing the configuration file has failed - */ - public void reloadConfiguration() - throws IOException, XMLException; - - /** - * Removes all locally stored properties leaving an empty configuration. - * Implementations that use a file for storing properties may simply delete - * it when this method is called. - */ - public void purgeStoredConfiguration(); - - /** - * Returns the name of the directory where SIP Communicator is to store user - * specific data such as configuration files, message and call history - * as well as is bundle repository. - * - * @return the name of the directory where SIP Communicator is to store - * user specific data such as configuration files, message and call history - * as well as is bundle repository. - */ - public String getScHomeDirName(); - - /** - * Returns the location of the directory where SIP Communicator is to store - * user specific data such as configuration files, message and call history - * as well as is bundle repository. - * - * @return the location of the directory where SIP Communicator is to store - * user specific data such as configuration files, message and call history - * as well as is bundle repository. - */ - public String getScHomeDirLocation(); -} diff --git a/src/net/java/sip/communicator/service/contactsource/SourceContact.java b/src/net/java/sip/communicator/service/contactsource/SourceContact.java index b41b33c56..9d4536e99 100644 --- a/src/net/java/sip/communicator/service/contactsource/SourceContact.java +++ b/src/net/java/sip/communicator/service/contactsource/SourceContact.java @@ -91,4 +91,4 @@ public ContactDetail getPreferredContactDetail( * @return the byte array of the image or null if no image is available */ public byte[] getImage(); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/fileaccess/FailSafeTransaction.java b/src/net/java/sip/communicator/service/fileaccess/FailSafeTransaction.java deleted file mode 100644 index b294c8c7e..000000000 --- a/src/net/java/sip/communicator/service/fileaccess/FailSafeTransaction.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.fileaccess; - -import java.io.*; - -/** - * A failsafe transaction interface. By failsafe we mean here that the file - * concerned always stays in a coherent state. - * - * @author Benoit Pradelle - */ -public interface FailSafeTransaction { - /** - * Ensure that the file accessed is in a coherent state. This function is - * useful to do a failsafe read without starting a transaction. - * - * @throws IllegalStateException if the file doesn't exists anymore - * @throws IOException if an IOException occurs during the file restoration - */ - public void restoreFile() - throws IllegalStateException, IOException; - - /** - * Begins a new transaction. If a transaction is already active, commits the - * changes and begin a new transaction. - * A transaction can be closed by a commit or rollback operation. - * When the transaction begins, the file is restored to a coherent state if - * needed. - * - * @throws IllegalStateException if the file doesn't exists anymore - * @throws IOException if an IOException occurs during the transaction - * creation - */ - public void beginTransaction() - throws IllegalStateException, IOException; - - /** - * Closes the transaction and commit the changes. Everything written in the - * file during the transaction is saved. - * - * @throws IllegalStateException if the file doesn't exists anymore - * @throws IOException if an IOException occurs during the operation - */ - public void commit() - throws IllegalStateException, IOException; - - /** - * Closes the transation and cancel the changes. Everything written in the - * file during the transaction is NOT saved. - * @throws IllegalStateException if the file doesn't exists anymore - * @throws IOException if an IOException occurs during the operation - */ - public void rollback() - throws IllegalStateException, IOException; -} diff --git a/src/net/java/sip/communicator/service/fileaccess/FileAccessService.java b/src/net/java/sip/communicator/service/fileaccess/FileAccessService.java deleted file mode 100644 index a68b03309..000000000 --- a/src/net/java/sip/communicator/service/fileaccess/FileAccessService.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.fileaccess; - -import java.io.*; - -/** - * A service used to provide the basic functionality required to access the - * underlying file system. - * - * Note: Never store unencrypted sensitive information, such as passwords, - * personal data, credit card numbers, etc.. - * - * @author Alexander Pelov - */ -public interface FileAccessService { - - /** - * The key of the configuration property containing the user home dir - if - * it is not defined the system property is used - */ - public static final String CONFPROPERTYKEY_USER_HOME - = "net.java.sip.communicator.fileaccess.USER_HOME"; - - /** - * This method returns a created temporary file. After you close this file - * it is not guaranteed that you will be able to open it again nor that it - * will contain any information. - * - * Note: DO NOT store unencrypted sensitive information in this file - * - * @return The created temporary file - * @throws IOException - * If the file cannot be created - */ - File getTemporaryFile() throws IOException; - - /** - * This method returns a created temporary directory. Any file you create in - * it will be a temporary file. - * - * Note: If there is no opened file in this directory it may be deleted at - * any time. Note: DO NOT store unencrypted sensitive information in this - * directory - * - * @return The created directory - * @throws IOException - * If the directory cannot be created - */ - File getTemporaryDirectory() throws IOException; - - /** - * This method returns a file specific to the current user. It may not - * exist, but it is guaranteed that you will have the sufficient rights to - * create it. - * - * This file should not be considered secure because the implementor may - * return a file accesible to everyone. Generaly it will reside in current - * user's homedir, but it may as well reside in a shared directory. - * - * Note: DO NOT store unencrypted sensitive information in this file - * - * @param fileName - * The name of the private file you wish to access - * @return The file - * @throws Exception - * Thrown if there is no suitable location for the persistent - * file - */ - File getPrivatePersistentFile(String fileName) throws Exception; - - /** - * This method creates a directory specific to the current user. - * - * This directory should not be considered secure because the implementor - * may return a directory accessible to everyone. Generally, it will reside - * in current user's homedir, but it may as well reside in a shared - * directory. - * - * It is guaranteed that you will be able to create files in it. - * - * Note: DO NOT store unencrypted sensitive information in this file - * - * @param dirName - * The name of the private directory you wish to access. - * @return The created directory. - * @throws Exception - * Thrown if there is no suitable location for the persistent - * directory. - */ - File getPrivatePersistentDirectory(String dirName) throws Exception; - - /** - * This method creates a directory specific to the current user. - * - * {@link #getPrivatePersistentDirectory(String)} - * - * @param dirNames - * The name of the private directory you wish to access. - * @return The created directory. - * @throws Exception - * Thrown if there is no suitable location for the persistent - * directory. - */ - File getPrivatePersistentDirectory(String[] dirNames) throws Exception; - - /** - * Returns the default download directory depending on the operating system. - * - * @return the default download directory depending on the operating system - * @throws IOException if it I/O error occurred - */ - File getDefaultDownloadDirectory() throws IOException; - - /** - * Creates a failsafe transaction which can be used to safely store - * informations into a file. - * - * @param file The file concerned by the transaction, null if file is null. - * - * @return A new failsafe transaction related to the given file. - */ - FailSafeTransaction createFailSafeTransaction(File file); -} diff --git a/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutService.java b/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutService.java index f9f2cf373..6eb8f5e51 100644 --- a/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutService.java +++ b/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutService.java @@ -66,4 +66,4 @@ public void setSpecialKeyDetection(boolean enable, * @param enable enable or not global shortcut */ public void setEnable(boolean enable); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/gui/Container.java b/src/net/java/sip/communicator/service/gui/Container.java index adb64e4e0..24ef7ab07 100644 --- a/src/net/java/sip/communicator/service/gui/Container.java +++ b/src/net/java/sip/communicator/service/gui/Container.java @@ -234,4 +234,4 @@ else if (obj instanceof String) else return false; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java b/src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java index 05ae8fb7d..15843033f 100644 --- a/src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java +++ b/src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java @@ -10,6 +10,8 @@ import net.java.sip.communicator.service.gui.internal.*; import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; + /** * @author Lubomir Marinov * @author Yana Stamcheva diff --git a/src/net/java/sip/communicator/service/gui/UIService.java b/src/net/java/sip/communicator/service/gui/UIService.java index e2818283e..f2a7b3bfd 100644 --- a/src/net/java/sip/communicator/service/gui/UIService.java +++ b/src/net/java/sip/communicator/service/gui/UIService.java @@ -455,4 +455,4 @@ public SecurityAuthority getDefaultSecurityAuthority( * participants to be included into the newly created Chat */ public void startChat(String[] participants); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/gui/event/ChatListener.java b/src/net/java/sip/communicator/service/gui/event/ChatListener.java index 07ca99af6..85b2909dc 100644 --- a/src/net/java/sip/communicator/service/gui/event/ChatListener.java +++ b/src/net/java/sip/communicator/service/gui/event/ChatListener.java @@ -29,4 +29,4 @@ public interface ChatListener * @param chat the new Chat which has been created */ public void chatCreated(Chat chat); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/gui/event/ChatMenuListener.java b/src/net/java/sip/communicator/service/gui/event/ChatMenuListener.java index 15a81d989..916d2aa6d 100644 --- a/src/net/java/sip/communicator/service/gui/event/ChatMenuListener.java +++ b/src/net/java/sip/communicator/service/gui/event/ChatMenuListener.java @@ -28,4 +28,4 @@ public interface ChatMenuListener * @return elements that should be added to the menu */ List getMenuElements(Chat source, MouseEvent event); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/gui/gui.manifest.mf b/src/net/java/sip/communicator/service/gui/gui.manifest.mf index 6203f68a9..ea6378091 100644 --- a/src/net/java/sip/communicator/service/gui/gui.manifest.mf +++ b/src/net/java/sip/communicator/service/gui/gui.manifest.mf @@ -5,7 +5,7 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util Export-Package: net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event, diff --git a/src/net/java/sip/communicator/service/gui/internal/GuiServiceActivator.java b/src/net/java/sip/communicator/service/gui/internal/GuiServiceActivator.java index 15a53c256..94fecfc36 100644 --- a/src/net/java/sip/communicator/service/gui/internal/GuiServiceActivator.java +++ b/src/net/java/sip/communicator/service/gui/internal/GuiServiceActivator.java @@ -5,9 +5,9 @@ */ package net.java.sip.communicator.service.gui.internal; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/service/httputil/HttpUtilActivator.java b/src/net/java/sip/communicator/service/httputil/HttpUtilActivator.java index 75b751c0a..9c923ec2c 100644 --- a/src/net/java/sip/communicator/service/httputil/HttpUtilActivator.java +++ b/src/net/java/sip/communicator/service/httputil/HttpUtilActivator.java @@ -1,10 +1,12 @@ package net.java.sip.communicator.service.httputil; import net.java.sip.communicator.service.certificate.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; + +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/service/httputil/httputil.manifest.mf b/src/net/java/sip/communicator/service/httputil/httputil.manifest.mf index b3850e91d..e3f77a7a2 100644 --- a/src/net/java/sip/communicator/service/httputil/httputil.manifest.mf +++ b/src/net/java/sip/communicator/service/httputil/httputil.manifest.mf @@ -28,13 +28,13 @@ Import-Package: org.xml.sax, net.java.sip.communicator.util.xml, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, - net.java.sip.communicator.service.resources, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.certificate, net.java.sip.communicator.service.credentialsstorage, net.java.sip.communicator.service.keybindings, net.java.sip.communicator.service.netaddr, net.java.sip.communicator.service.netaddr.event, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, sun.awt.shell, sun.net.util, diff --git a/src/net/java/sip/communicator/service/keybindings/KeybindingsService.java b/src/net/java/sip/communicator/service/keybindings/KeybindingsService.java index afc382565..07d589de7 100644 --- a/src/net/java/sip/communicator/service/keybindings/KeybindingsService.java +++ b/src/net/java/sip/communicator/service/keybindings/KeybindingsService.java @@ -44,4 +44,4 @@ public interface KeybindingsService * Save the configuration file. */ public void saveGlobalShortcutFromConfiguration(); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/ldap/ldap.manifest.mf b/src/net/java/sip/communicator/service/ldap/ldap.manifest.mf index 1289e0548..4007ce802 100644 --- a/src/net/java/sip/communicator/service/ldap/ldap.manifest.mf +++ b/src/net/java/sip/communicator/service/ldap/ldap.manifest.mf @@ -4,6 +4,6 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 Import-Package: org.osgi.framework, javax.naming.directory, - net.java.sip.communicator.service.configuration + org.jitsi.service.configuration Export-Package: net.java.sip.communicator.service.ldap, net.java.sip.communicator.service.ldap.event diff --git a/src/net/java/sip/communicator/service/neomedia/AbstractMediaStream.java b/src/net/java/sip/communicator/service/neomedia/AbstractMediaStream.java deleted file mode 100644 index 779441aa0..000000000 --- a/src/net/java/sip/communicator/service/neomedia/AbstractMediaStream.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.beans.*; -import java.util.*; - -import net.java.sip.communicator.service.neomedia.format.*; - -/** - * Abstract base implementation of MediaStream to ease the - * implementation of the interface. - * - * @author Lyubomir Marinov - */ -public abstract class AbstractMediaStream - implements MediaStream -{ - /** - * The name of this stream, that some protocols may use for diagnostic - * purposes. - */ - private String name; - - /** - * The delegate of this instance which implements support for property - * change notifications for its - * {@link #addPropertyChangeListener(PropertyChangeListener)} and - * {@link #removePropertyChangeListener(PropertyChangeListener)}. - */ - private final PropertyChangeSupport propertyChangeSupport - = new PropertyChangeSupport(this); - - /** - * Adds a PropertyChangelistener to this stream which is to be - * notified upon property changes such as a SSRC ID which becomes known. - * - * @param listener the PropertyChangeListener to register for - * PropertyChangeEvents - * @see MediaStream#addPropertyChangeListener(PropertyChangeListener) - */ - public void addPropertyChangeListener(PropertyChangeListener listener) - { - propertyChangeSupport.addPropertyChangeListener(listener); - } - - /** - * Fires a new PropertyChangeEvent to the - * PropertyChangeListeners registered with this instance in order - * to notify about a change in the value of a specific property which had - * its old value modified to a specific new value. - * - * @param property the name of the property of this instance which had its - * value changed - * @param oldValue the value of the property with the specified name before - * the change - * @param newValue the value of the property with the specified name after - * the change - */ - protected void firePropertyChange( - String property, - Object oldValue, - Object newValue) - { - propertyChangeSupport.firePropertyChange(property, oldValue, newValue); - } - - /** - * Returns the name of this stream or null if no name has been - * set. A stream name is used by some protocols, for diagnostic purposes - * mostly. In XMPP for example this is the name of the content element that - * describes a stream. - * - * @return the name of this stream or null if no name has been - * set. - */ - public String getName() - { - return name; - } - - /** - * Determines whether a specific MediaFormat has specific values - * for its properties mediaType, encoding, - * clockRate and channels for MediaFormats with - * mediaType equal to {@link MediaType#AUDIO}. - * - * @param format the {@link MediaFormat} whose properties we'd like to - * examine - * @param mediaType the type we expect {@link MediaFormat} to have - * @param encoding the encoding we are looking for. - * @param clockRate the clock rate that we'd like the format to have. - * @param channels the number of channels that expect to find in this format - * @param formatParameters the format parameters expected to match these of - * the specified format - * @return true if the specified format has specific - * values for its properties mediaType, encoding, - * clockRate and channels; otherwise, false - */ - public static boolean matches( - MediaFormat format, - MediaType mediaType, - String encoding, double clockRate, int channels, - Map formatParameters) - { - // mediaType - // encoding - if (!format.getMediaType().equals(mediaType) - || !format.getEncoding().equals(encoding)) - return false; - - // clockRate - if (clockRate != MediaFormatFactory.CLOCK_RATE_NOT_SPECIFIED) - { - double formatClockRate = format.getClockRate(); - - if ((formatClockRate != MediaFormatFactory.CLOCK_RATE_NOT_SPECIFIED) - && (formatClockRate != clockRate)) - return false; - } - - // channels - if (MediaType.AUDIO.equals(mediaType)) - { - if (channels == MediaFormatFactory.CHANNELS_NOT_SPECIFIED) - channels = 1; - - int formatChannels = ((AudioMediaFormat) format).getChannels(); - - if (formatChannels == MediaFormatFactory.CHANNELS_NOT_SPECIFIED) - formatChannels = 1; - if (formatChannels != channels) - return false; - } - - // formatParameters - return format.formatParametersMatch(formatParameters); - } - - /** - * Removes the specified PropertyChangeListener from this stream so - * that it won't receive further property change events. - * - * @param listener the PropertyChangeListener to remove - * @see MediaStream#removePropertyChangeListener(PropertyChangeListener) - */ - public void removePropertyChangeListener(PropertyChangeListener listener) - { - propertyChangeSupport.removePropertyChangeListener(listener); - } - - /** - * Sets the name of this stream. Stream names are used by some protocols, - * for diagnostic purposes mostly. In XMPP for example this is the name of - * the content element that describes a stream. - * - * @param name the name of this stream or null if no name has been - * set. - */ - public void setName(String name) - { - this.name = name; - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/AudioMediaStream.java b/src/net/java/sip/communicator/service/neomedia/AudioMediaStream.java deleted file mode 100644 index e09a879e0..000000000 --- a/src/net/java/sip/communicator/service/neomedia/AudioMediaStream.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import net.java.sip.communicator.service.neomedia.event.*; -import net.java.sip.communicator.service.protocol.*; - -/** - * Extends the MediaStream interface and adds methods specific to - * audio streaming. - * - * @author Emil Ivov - */ -public interface AudioMediaStream - extends MediaStream -{ - /** - * Sets listener as the SimpleAudioLevelListener - * registered to receive notifications for changes in the levels of the - * party that's at the other end of this stream. - * - * @param listener the SimpleAudioLevelListener that we'd like to - * register or null if we want to stop stream audio level - * measurements. - */ - public void setStreamAudioLevelListener(SimpleAudioLevelListener listener); - - /** - * Registers listener as the CsrcAudioLevelListener that - * will receive notifications for changes in the levels of conference - * participants that the remote party could be mixing. - * - * @param listener the CsrcAudioLevelListener that we'd like to - * register or null if we'd like to stop receiving notifications. - */ - public void setCsrcAudioLevelListener(CsrcAudioLevelListener listener); - - /** - * Sets listener as the SimpleAudioLevelListener - * registered to receive notifications for changes in the levels of the - * audio that this stream is sending out. - * - * @param listener the SimpleAudioLevelListener that we'd like to - * register or null if we want to stop local audio level - * measurements. - */ - public void setLocalUserAudioLevelListener( - SimpleAudioLevelListener listener); - - /** - * Starts sending the specified DTMFTone until the - * stopSendingDTMF() method is called (Excepts for INBAND DTMF, - * which stops by itself this is why where there is no need to call the - * stopSendingDTMF). Callers should keep in mind the fact that calling this - * method would most likely interrupt all audio transmission until the - * corresponding stop method is called. Also, calling this method - * successively without invoking the corresponding stop method between the - * calls will simply replace the DTMFTone from the first call with - * that from the second. - * - * @param tone the DTMFTone to start sending. - * @param dtmfMethod The kind of DTMF used (RTP, SIP-INOF or INBAND). - */ - public void startSendingDTMF(DTMFTone tone, DTMFMethod dtmfMethod); - - /** - * Interrupts transmission of a DTMFTone started with the - * startSendingDTMF method. This method has no effect if no tone - * is being currently sent. - * - * @param dtmfMethod the DTMFMethod to stop sending. - */ - public void stopSendingDTMF(DTMFMethod dtmfMethod); - - /** - * Registers a listener that would receive notification events if the - * remote party starts sending DTMF tones to us. - * - * @param listener the DTMFListener that we'd like to register. - */ - public void addDTMFListener(DTMFListener listener); - - /** - * Removes listener from the list of DTMFListeners - * registered to receive events for incoming DTMF tones. - * - * @param listener the listener that we'd like to unregister - */ - public void removeDTMFListener(DTMFListener listener); -} diff --git a/src/net/java/sip/communicator/service/neomedia/DTMFInbandTone.java b/src/net/java/sip/communicator/service/neomedia/DTMFInbandTone.java deleted file mode 100644 index 8956fc60e..000000000 --- a/src/net/java/sip/communicator/service/neomedia/DTMFInbandTone.java +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -/** - * Manages the generation of the inband DMTF signal. A signal is identified by a - * value (1, 2, 3, 4, 5, 6, 7, 8, 9, *, #, A, B, C and D) and each signal is - * produced by the composition of 2 frequencies (as defined below). - * (cf. ITU recommendation Q.23) - * - * +------------------------------------------------+ - * | | 1209 Hz | 1336 Hz | 1477 Hz | 1633 Hz | - * +------------------------------------------------+ - * | 697 Hz | 1 | 2 | 3 | A | - * | 770 Hz | 4 | 5 | 6 | B | - * | 852 Hz | 7 | 8 | 9 | C | - * | 941 Hz | * | 0 | # | D | - * +------------------------------------------------+ - * - * @author Vincent Lucas - */ -public class DTMFInbandTone -{ - /** - * The first set of frequencies in Hz which composes an inband DTMF. - */ - private static final double[] frequencyList1 = - new double[] - { - 697.0, 770.0, 852.0, 941.0 - }; - - /** - * The second set of frequencies in Hz which composes an inband DTMF. - */ - private static final double[] frequencyList2 = - new double[] - { - 1209.0, 1336.0, 1477.0, 1633.0 - }; - - /** - * The "0" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_0 = new DTMFInbandTone("0", - frequencyList1[3], - frequencyList2[1]); - - /** - * The "1" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_1 = new DTMFInbandTone("1", - frequencyList1[0], - frequencyList2[0]); - - /** - * The "2" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_2 = new DTMFInbandTone("2", - frequencyList1[0], - frequencyList2[1]); - - /** - * The "3" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_3 = new DTMFInbandTone("3", - frequencyList1[0], - frequencyList2[2]); - - /** - * The "4" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_4 = new DTMFInbandTone("4", - frequencyList1[1], - frequencyList2[0]); - - /** - * The "5" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_5 = new DTMFInbandTone("5", - frequencyList1[1], - frequencyList2[1]); - - /** - * The "6" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_6 = new DTMFInbandTone("6", - frequencyList1[1], - frequencyList2[2]); - - /** - * The "7" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_7 = new DTMFInbandTone("7", - frequencyList1[2], - frequencyList2[0]); - - /** - * The "8" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_8 = new DTMFInbandTone("8", - frequencyList1[2], - frequencyList2[1]); - - /** - * The "9" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_9 = new DTMFInbandTone("9", - frequencyList1[2], - frequencyList2[2]); - - /** - * The "*" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_STAR = - new DTMFInbandTone("*", - frequencyList1[3], - frequencyList2[0]); - - /** - * The "#" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_SHARP = - new DTMFInbandTone("#", - frequencyList1[3], - frequencyList2[2]); - - /** - * The "A" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_A = new DTMFInbandTone("A", - frequencyList1[0], - frequencyList2[3]); - - /** - * The "B" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_B = new DTMFInbandTone("B", - frequencyList1[1], - frequencyList2[3]); - - /** - * The "C" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_C = new DTMFInbandTone("C", - frequencyList1[2], - frequencyList2[3]); - - /** - * The "D" DTMF Inband Tone. - */ - public static final DTMFInbandTone DTMF_INBAND_D = new DTMFInbandTone("D", - frequencyList1[3], - frequencyList2[3]); - - /** - * The default duration of an inband DTMF tone in ms. - * 50 ms c.f. - * http://nemesis.lonestar.org/reference/telecom/signaling/dtmf.html - * which cites the norm ANSI T1.401-1988 (but unavailable to me). - * But when testing it at 50 ms, the asterisk servers miss some DTMF tone - * impulses. Thus, set it up 150 ms. - */ - private static final int toneDuration = 150; - - /** - * The default duration of an inband DTMF tone in ms. - * 45 ms c.f. - * http://nemesis.lonestar.org/reference/telecom/signaling/dtmf.html - * which cites the norm ANSI T1.401-1988 (but unavailable to me). - * Moreover the minimum duty cycle (signal tone + silence) for - * ANSI-compliance shall be greater or equal to 100 ms. - */ - private static final int interDigitInterval = 45; - - /** - * The value which identifies the current inband tone. Available values are - * (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, *, #, A, B, C and D). - */ - private String value; - - /** - * The first frequency which composes the current inband tone. - */ - private double frequency1; - - /** - * The second frequency which composes the current inband tone. - */ - private double frequency2; - - /** - * Creates a new instance of an inband tone. The value given is the main - * identifier which determines which are the two frequencies to used to - * generate this tone. - * - * @param value The identifier of the tone. Available values are (0, 1, 2, - * 3, 4, 5, 6, 7, 8, 9, *, #, A, B, C and D). - * @param frequency1 The first frequency which composes the tone. Available - * values corresponds to DTMFInbandTone.frequencyList1. - * @param frequency2 The second frequency which composes the tone. Available - * values corresponds to DTMFInbandTone.frequencyList2. - */ - public DTMFInbandTone(String value, double frequency1, double frequency2) - { - this.value = value; - this.frequency1 = frequency1; - this.frequency2 = frequency2; - } - - /** - * Returns this tone value as a string representation. - * - * @return this tone value. - */ - public String getValue() - { - return this.value; - } - - /** - * Returns the first frequency coded by this tone. - * - * @return the first frequency coded by this tone. - */ - public double getFrequency1() - { - return this.frequency1; - } - - /** - * Returns the second frequency coded by this tone. - * - * @return the second frequency coded by this tone. - */ - public double getFrequency2() - { - return this.frequency2; - } - - /** - * Generates a sample for the current tone signal. - * - * @param samplingFrequency The sampling frequency (codec clock rate) in Hz - * of the stream which will encapsulate this signal. - * @param sampleNumber The sample number of this signal to be produced. The - * sample number corresponds to the abscissa of the signal function. - * - * @return the sample generated. This sample corresponds to the ordinate of - * the signal function - */ - public double getAudioSampleContinuous( - double samplingFrequency, - int sampleNumber) - { - double u1 = 2.0 * Math.PI * this.frequency1 / samplingFrequency; - double u2 = 2.0 * Math.PI * this.frequency2 / samplingFrequency; - double audioSample; - - // The signal generated is composed of 2 sinusoidal signals, which - // ampltudes is between -1 and 1 (included). - audioSample = Math.sin(u1 * sampleNumber) * 0.5 + - Math.sin(u2 * sampleNumber) * 0.5; - - return audioSample; - } - - /** - * Generates a sample for the current tone signal converted into a discrete - * signal. - * - * @param samplingFrequency The sampling frequency (codec clock rate) in Hz - * of the stream which will encapsulate this signal. - * @param sampleNumber The sample number of this signal to be produced. The - * sample number corresponds to the abscissa of the signal function. - * @param sampleSizeInBits The size of each sample (8 for a byte, 16 for a - * short and 32 for an int) - * - * @return the sample generated. This sample corresponds to the ordinate of - * the signal function - */ - public int getAudioSampleDiscrete( - double samplingFrequency, - int sampleNumber, - int sampleSizeInBits) - { - // If the param sampleSizeInBits is equal to 8, then its corresponds to - // a Java byte which is 8 bits signed type which contains a number - // between -128 and 127. Thus, as the result of the continuous function - // is between -1 and 1, we multiply each audioSample by 127. This - // generates a signal between -127 and 127. - // Same operation if sampleSizeInBits is equal to 16, this function - // generates a signal between -32767 and 32767. - // As well as if sampleSizeInBits is equal to 32, this function - // generates a signal between -2147483647 and 2147483647. - double amplitudeCoefficient = Math.pow(2.0, sampleSizeInBits - 1) - 1.0; - double audioSampleContinuous; - int audioSampleDiscrete; - - audioSampleContinuous = this.getAudioSampleContinuous( - samplingFrequency, - sampleNumber); - audioSampleDiscrete = (int) - (audioSampleContinuous * amplitudeCoefficient); - - return audioSampleDiscrete; - } - - /** - * Generates a signal sample for the current tone signal and stores it into - * the byte data array. - * - * @param samplingFrequency The sampling frequency (codec clock rate) in Hz - * of the stream which will encapsulate this signal. - * @param sampleSizeInBits The size of each sample (8 for a byte, 16 for a - * short and 32 for an int) - * - * @return The data array containing the DTMF signal. - */ - public int[] getAudioSamples( - double samplingFrequency, - int sampleSizeInBits) - { - int sampleNumber = 0; - - int nbToneSamples = ((int) (samplingFrequency / 1000.0)) * - DTMFInbandTone.toneDuration; - int nbInterDigitSamples = ((int) (samplingFrequency / 1000.0)) * - DTMFInbandTone.interDigitInterval; - - int[] sampleData = - new int[nbInterDigitSamples + nbToneSamples + nbInterDigitSamples]; - - while(sampleNumber < nbInterDigitSamples) - { - sampleData[sampleNumber] = 0; - ++sampleNumber; - } - while(sampleNumber < nbInterDigitSamples + nbToneSamples) - { - sampleData[sampleNumber] = getAudioSampleDiscrete( - samplingFrequency, - sampleNumber, - sampleSizeInBits); - - ++sampleNumber; - } - while(sampleNumber < sampleData.length) - { - sampleData[sampleNumber] = 0; - ++sampleNumber; - } - - return sampleData; - } - - /** - * Maps between protocol and media inband DTMF objects. - * @param tone The DTMF tone as defined in the service protocol, which is - * only composed by a value as its identifier. - * - * @return the corresponding DTMF tone which contains a value as an - * identifier and two frequencies composing the inband tone. - */ - public static DTMFInbandTone - mapTone(net.java.sip.communicator.service.protocol.DTMFTone tone) - { - if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_0)) - return DTMFInbandTone.DTMF_INBAND_0; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_1)) - return DTMFInbandTone.DTMF_INBAND_1; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_2)) - return DTMFInbandTone.DTMF_INBAND_2; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_3)) - return DTMFInbandTone.DTMF_INBAND_3; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_4)) - return DTMFInbandTone.DTMF_INBAND_4; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_5)) - return DTMFInbandTone.DTMF_INBAND_5; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_6)) - return DTMFInbandTone.DTMF_INBAND_6; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_7)) - return DTMFInbandTone.DTMF_INBAND_7; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_8)) - return DTMFInbandTone.DTMF_INBAND_8; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_9)) - return DTMFInbandTone.DTMF_INBAND_9; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_A)) - return DTMFInbandTone.DTMF_INBAND_A; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_B)) - return DTMFInbandTone.DTMF_INBAND_B; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_C)) - return DTMFInbandTone.DTMF_INBAND_C; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_D)) - return DTMFInbandTone.DTMF_INBAND_D; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_SHARP)) - return DTMFInbandTone.DTMF_INBAND_SHARP; - else if(tone.equals( - net.java.sip.communicator.service.protocol.DTMFTone.DTMF_STAR)) - return DTMFInbandTone.DTMF_INBAND_STAR; - - return null; - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/DTMFMethod.java b/src/net/java/sip/communicator/service/neomedia/DTMFMethod.java deleted file mode 100644 index b589c0248..000000000 --- a/src/net/java/sip/communicator/service/neomedia/DTMFMethod.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -/** - * Enumerates all available DTMF methods. - * - * @author Vincent Lucas - */ -public enum DTMFMethod -{ - /** - * {@link #RTP_DTMF} if telephony-event are available; otherwise, - * {@link #INBAND_DTMF}. - */ - AUTO_DTMF, - - /** RTP DTMF as defined in RFC4733. */ - RTP_DTMF, - - /** SIP INFO DTMF. */ - SIP_INFO_DTMF, - - /** INBAND DTMF as defined in ITU-T recommendation Q.23. */ - INBAND_DTMF -} diff --git a/src/net/java/sip/communicator/service/neomedia/DTMFRtpTone.java b/src/net/java/sip/communicator/service/neomedia/DTMFRtpTone.java deleted file mode 100644 index 07bb772b9..000000000 --- a/src/net/java/sip/communicator/service/neomedia/DTMFRtpTone.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import net.java.sip.communicator.service.protocol.*; - -/** - * Represents all DTMF tones for RTP method (RFC4733). - * - * @author JM HEITZ - * @author Romain Philibert - * @author Emil Ivov - */ -public final class DTMFRtpTone -{ - /** - * The "0" DTMF Tone - */ - public static final DTMFRtpTone DTMF_0=new DTMFRtpTone("0", (byte)0); - - /** - * The "1" DTMF Tone - */ - public static final DTMFRtpTone DTMF_1=new DTMFRtpTone("1", (byte)1); - - /** - * The "2" DTMF Tone - */ - public static final DTMFRtpTone DTMF_2=new DTMFRtpTone("2", (byte)2); - - /** - * The "3" DTMF Tone - */ - public static final DTMFRtpTone DTMF_3=new DTMFRtpTone("3", (byte)3); - - /** - * The "4" DTMF Tone - */ - public static final DTMFRtpTone DTMF_4=new DTMFRtpTone("4", (byte)4); - - /** - * The "5" DTMF Tone - */ - public static final DTMFRtpTone DTMF_5=new DTMFRtpTone("5", (byte)5); - - /** - * The "6" DTMF Tone - */ - public static final DTMFRtpTone DTMF_6=new DTMFRtpTone("6", (byte)6); - - /** - * The "7" DTMF Tone - */ - public static final DTMFRtpTone DTMF_7=new DTMFRtpTone("7", (byte)7); - - /** - * The "8" DTMF Tone - */ - public static final DTMFRtpTone DTMF_8=new DTMFRtpTone("8", (byte)8); - - /** - * The "9" DTMF Tone - */ - public static final DTMFRtpTone DTMF_9=new DTMFRtpTone("9", (byte)9); - - /** - * The "*" DTMF Tone - */ - public static final DTMFRtpTone DTMF_STAR=new DTMFRtpTone("*", (byte)10); - - /** - * The "#" DTMF Tone - */ - public static final DTMFRtpTone DTMF_SHARP=new DTMFRtpTone("#", (byte)11); - - /** - * The "A" DTMF Tone - */ - public static final DTMFRtpTone DTMF_A=new DTMFRtpTone("A", (byte)12); - - /** - * The "B" DTMF Tone - */ - public static final DTMFRtpTone DTMF_B=new DTMFRtpTone("B", (byte)13); - - /** - * The "C" DTMF Tone - */ - public static final DTMFRtpTone DTMF_C=new DTMFRtpTone("C", (byte)14); - - /** - * The "D" DTMF Tone - */ - public static final DTMFRtpTone DTMF_D=new DTMFRtpTone("D", (byte)15); - - /** - * The value of the DTMF tone - */ - private final String value; - - /** - * The code of the tone, as specified by RFC 4733, and the we'll actually - * be sending over the wire. - */ - private final byte code; - - /** - * Creates a DTMF instance with the specified tone value. The method is - * private since one would only have to use predefined static instances. - * - * @param value one of the DTMF_XXX fields, indicating the value of the tone. - * @param code the of the DTMF tone that we'll actually be sending over the - * wire, as specified by RFC 4733. - */ - private DTMFRtpTone(String value, byte code) - { - this.value = value; - this.code = code; - } - - /** - * Returns the string representation of this DTMF tone. - * - * @return the String representation of this DTMF tone. - */ - public String getValue() - { - return this.value; - } - - /** - * Indicates whether some other object is "equal to" this tone. - * - * @param target the reference object with which to compare. - * - * @return true if target represents the same tone as this - * object. - */ - public boolean equals(Object target) - { - if(!(target instanceof DTMFRtpTone)) - { - return false; - } - DTMFRtpTone targetDTMFTone = (DTMFRtpTone)(target); - - return targetDTMFTone.value.equals(this.value); - } - - /** - * Returns a hash code value for the object. This method is - * supported for the benefit of hashtables such as those provided by - * java.util.Hashtable. The method would actually return the - * hashcode of the string representation of this DTMF tone. - * - * @return a hash code value for this object (same as calling - * getValue().hashCode()). - */ - public int hashCode() - { - return getValue().hashCode(); - } - - /** - * Returns the RFC 4733 code of this DTMF tone. - * - * @return the RFC 4733 code of this DTMF tone. - */ - public byte getCode() - { - return code; - } - - /** - * Maps between protocol and media DTMF objects. - * @param tone The DTMFTone to be mapped to an DTMFRtpTone. - * @return The DTMFRtpTone corresponding to the tone specified. - */ - public static DTMFRtpTone mapTone(DTMFTone tone) - { - if(tone.equals(DTMFTone.DTMF_0)) - return DTMFRtpTone.DTMF_0; - else if(tone.equals(DTMFTone.DTMF_1)) - return DTMFRtpTone.DTMF_1; - else if(tone.equals(DTMFTone.DTMF_2)) - return DTMFRtpTone.DTMF_2; - else if(tone.equals(DTMFTone.DTMF_3)) - return DTMFRtpTone.DTMF_3; - else if(tone.equals(DTMFTone.DTMF_4)) - return DTMFRtpTone.DTMF_4; - else if(tone.equals(DTMFTone.DTMF_5)) - return DTMFRtpTone.DTMF_5; - else if(tone.equals(DTMFTone.DTMF_6)) - return DTMFRtpTone.DTMF_6; - else if(tone.equals(DTMFTone.DTMF_7)) - return DTMFRtpTone.DTMF_7; - else if(tone.equals(DTMFTone.DTMF_8)) - return DTMFRtpTone.DTMF_8; - else if(tone.equals(DTMFTone.DTMF_9)) - return DTMFRtpTone.DTMF_9; - else if(tone.equals(DTMFTone.DTMF_A)) - return DTMFRtpTone.DTMF_A; - else if(tone.equals(DTMFTone.DTMF_B)) - return DTMFRtpTone.DTMF_B; - else if(tone.equals(DTMFTone.DTMF_C)) - return DTMFRtpTone.DTMF_C; - else if(tone.equals(DTMFTone.DTMF_D)) - return DTMFRtpTone.DTMF_D; - else if(tone.equals(DTMFTone.DTMF_SHARP)) - return DTMFRtpTone.DTMF_SHARP; - else if(tone.equals(DTMFTone.DTMF_STAR)) - return DTMFRtpTone.DTMF_STAR; - - return null; - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/DefaultStreamConnector.java b/src/net/java/sip/communicator/service/neomedia/DefaultStreamConnector.java deleted file mode 100644 index fc7096df1..000000000 --- a/src/net/java/sip/communicator/service/neomedia/DefaultStreamConnector.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.net.*; - -import net.java.sip.communicator.impl.neomedia.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.util.*; - -/** - * Represents a default implementation of StreamConnector which is - * initialized with a specific pair of control and data DatagramSockets - * and which closes them (if they exist) when its {@link #close()} is invoked. - * - * @author Lubomir Marinov - */ -public class DefaultStreamConnector - implements StreamConnector -{ - - /** - * The Logger used by the DefaultStreamConnector class and - * its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(DefaultStreamConnector.class); - - /** - * The default number of binds that a Media Service Implementation should - * execute in case a port is already bound to (each retry would be on a - * new random port). - */ - public static final int BIND_RETRIES_DEFAULT_VALUE = 50; - - /** - * The name of the property containing the number of binds that a Media - * Service Implementation should execute in case a port is already - * bound to (each retry would be on a new port in the allowed boundaries). - */ - public static final String BIND_RETRIES_PROPERTY_NAME - = "net.java.sip.communicator.service.media.BIND_RETRIES"; - - /** - * The name of the property that contains the maximum port number that we'd - * like our RTP managers to bind upon. - */ - public static final String MAX_PORT_NUMBER_PROPERTY_NAME - = "net.java.sip.communicator.service.media.MAX_PORT_NUMBER"; - - /** - * The maximum port number DefaultStreamConnector instances are to - * attempt to bind to. - */ - private static int maxPort = -1; - - /** - * The name of the property that contains the minimum port number that we'd - * like our RTP managers to bind upon. - */ - public static final String MIN_PORT_NUMBER_PROPERTY_NAME - = "net.java.sip.communicator.service.media.MIN_PORT_NUMBER"; - - /** - * The minimum port number DefaultStreamConnector instances are to - * attempt to bind to. - */ - private static int minPort = -1; - - /** - * The local InetAddress this StreamConnector attempts to - * bind to on demand. - */ - private final InetAddress bindAddr; - - /** - * The DatagramSocket that a stream should use for control data - * (e.g. RTCP) traffic. - */ - protected DatagramSocket controlSocket; - - /** - * The DatagramSocket that a stream should use for data (e.g. RTP) - * traffic. - */ - protected DatagramSocket dataSocket; - - /** - * Initializes a new DefaultStreamConnector instance with no - * control and data DatagramSockets. - *

- * Suitable for extenders willing to delay the creation of the control and - * data sockets. For example, they could override - * {@link #getControlSocket()} and/or {@link #getDataSocket()} and create - * them on demand. - */ - public DefaultStreamConnector() - { - this(null, null); - } - - /** - * Creates a new DatagramSocket instance which is bound to the - * specified local InetAddress and its port is within the range - * defined by the ConfigurationService properties - * {@link #MIN_PORT_NUMBER_PROPERTY_NAME} and - * {@link #MAX_PORT_NUMBER_PROPERTY_NAME}. Attempts at most - * {@link #BIND_RETRIES_PROPERTY_NAME} times to bind. - * - * @param bindAddr the local InetAddress the new - * DatagramSocket is to bind to - * @return a new DatagramSocket instance bound to the specified - * local InetAddress - */ - private static synchronized DatagramSocket createDatagramSocket( - InetAddress bindAddr) - { - ConfigurationService cfg = NeomediaActivator.getConfigurationService(); - int bindRetries = BIND_RETRIES_DEFAULT_VALUE; - - if (cfg != null) - bindRetries = cfg.getInt(BIND_RETRIES_PROPERTY_NAME, bindRetries); - if (maxPort < 0) - { - maxPort = 6000; - if (cfg != null) - maxPort = cfg.getInt(MAX_PORT_NUMBER_PROPERTY_NAME, maxPort); - } - - for (int i = 0; i < bindRetries; i++) - { - if ((minPort < 0) || (minPort > maxPort)) - { - minPort = 5000; - if (cfg != null) - { - minPort - = cfg.getInt(MIN_PORT_NUMBER_PROPERTY_NAME, minPort); - } - } - - int port = minPort++; - - try - { - return - (bindAddr == null) - ? new DatagramSocket(port) - : new DatagramSocket(port, bindAddr); - } - catch (SocketException se) - { - logger.warn( - "Retrying a bind because of a failure to bind to address " - + bindAddr - + " and port " - + port, - se); - } - } - return null; - } - - /** - * Initializes a new DefaultStreamConnector instance with a - * specific bind InetAddress. The new instance is to attempt to - * bind on demand to the specified InetAddress in the port range - * defined by the ConfigurationService properties - * {@link #MIN_PORT_NUMBER_PROPERTY_NAME} and - * {@link #MAX_PORT_NUMBER_PROPERTY_NAME} at most - * {@link #BIND_RETRIES_PROPERTY_NAME} times. - * - * @param bindAddr the local InetAddress the new instance is to - * attempt to bind to - */ - public DefaultStreamConnector(InetAddress bindAddr) - { - this.bindAddr = bindAddr; - } - - /** - * Initializes a new DefaultStreamConnector instance which is to - * represent a specific pair of control and data DatagramSockets. - * - * @param dataSocket the DatagramSocket to be used for data (e.g. - * RTP) traffic - * @param controlSocket the DatagramSocket to be used for control - * data (e.g. RTCP) traffic - */ - public DefaultStreamConnector( - DatagramSocket dataSocket, - DatagramSocket controlSocket) - { - this.controlSocket = controlSocket; - this.dataSocket = dataSocket; - this.bindAddr = null; - } - - /** - * Releases the resources allocated by this instance in the course of its - * execution and prepares it to be garbage collected. - * - * @see StreamConnector#close() - */ - public void close() - { - if (controlSocket != null) - controlSocket.close(); - if (dataSocket != null) - dataSocket.close(); - } - - /** - * Returns a reference to the DatagramSocket that a stream should - * use for control data (e.g. RTCP) traffic. - * - * @return a reference to the DatagramSocket that a stream should - * use for control data (e.g. RTCP) traffic - * @see StreamConnector#getControlSocket() - */ - public DatagramSocket getControlSocket() - { - if ((controlSocket == null) && (bindAddr != null)) - controlSocket = createDatagramSocket(bindAddr); - return controlSocket; - } - - /** - * Returns a reference to the DatagramSocket that a stream should - * use for data (e.g. RTP) traffic. - * - * @return a reference to the DatagramSocket that a stream should - * use for data (e.g. RTP) traffic - * @see StreamConnector#getDataSocket() - */ - public DatagramSocket getDataSocket() - { - if ((dataSocket == null) && (bindAddr != null)) - dataSocket = createDatagramSocket(bindAddr); - return dataSocket; - } - - /** - * Returns a reference to the Socket that a stream should - * use for data (e.g. RTP) traffic. - * - * @return a reference to the Socket that a stream should - * use for data (e.g. RTP) traffic. - */ - public Socket getDataTCPSocket() - { - return null; - } - - /** - * Returns a reference to the Socket that a stream should - * use for control data (e.g. RTCP). - * - * @return a reference to the Socket that a stream should - * use for control data (e.g. RTCP). - */ - public Socket getControlTCPSocket() - { - return null; - } - - /** - * Returns the protocol of this StreamConnector. - * - * @return the protocol of this StreamConnector - */ - public Protocol getProtocol() - { - return Protocol.UDP; - } - - /** - * Notifies this instance that utilization of its DatagramSockets - * for data and/or control traffic has started. - * - * @see StreamConnector#started() - */ - public void started() - { - } - - /** - * Notifies this instance that utilization of its DatagramSockets - * for data and/or control traffic has temporarily stopped. This instance - * should be prepared to be started at a later time again though. - * - * @see StreamConnector#stopped() - */ - public void stopped() - { - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/DefaultTCPStreamConnector.java b/src/net/java/sip/communicator/service/neomedia/DefaultTCPStreamConnector.java deleted file mode 100644 index 169ce2c25..000000000 --- a/src/net/java/sip/communicator/service/neomedia/DefaultTCPStreamConnector.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.io.*; -import java.net.*; - -import net.java.sip.communicator.util.*; - -/** - * Represents a default implementation of StreamConnector which is - * initialized with a specific pair of control and data Sockets - * and which closes them (if they exist) when its {@link #close()} is invoked. - * - * @author Lubomir Marinov - * @author Sebastien Vincent - */ -public class DefaultTCPStreamConnector - implements StreamConnector -{ - - /** - * The Logger used by the DefaultTCPStreamConnector class and - * its instances for logging output. - */ - private static final Logger logger - = Logger.getLogger(DefaultTCPStreamConnector.class); - - /** - * The Socket that a stream should use for control data - * (e.g. RTCP) traffic. - */ - protected Socket controlSocket; - - /** - * The Socket that a stream should use for data (e.g. RTP) - * traffic. - */ - protected Socket dataSocket; - - /** - * Initializes a new DefaultTCPStreamConnector instance with no - * control and data Sockets. - *

- * Suitable for extenders willing to delay the creation of the control and - * data sockets. For example, they could override - * {@link #getControlSocket()} and/or {@link #getDataSocket()} and create - * them on demand. - */ - public DefaultTCPStreamConnector() - { - this(null, null); - } - - /** - * Initializes a new DefaultTCPStreamConnector instance which is to - * represent a specific pair of control and data Sockets. - * - * @param dataSocket the Socket to be used for data (e.g. - * RTP) traffic - * @param controlSocket the Socket to be used for control - * data (e.g. RTCP) traffic - */ - public DefaultTCPStreamConnector( - Socket dataSocket, - Socket controlSocket) - { - this.controlSocket = controlSocket; - this.dataSocket = dataSocket; - } - - /** - * Releases the resources allocated by this instance in the course of its - * execution and prepares it to be garbage collected. - * - * @see StreamConnector#close() - */ - public void close() - { - try - { - if (controlSocket != null) - controlSocket.close(); - if (dataSocket != null) - dataSocket.close(); - } - catch(IOException ioe) - { - logger.debug("Failed to close TCP socket", ioe); - } - } - - /** - * Returns a reference to the DatagramSocket that a stream should - * use for control data (e.g. RTCP) traffic. - * - * @return a reference to the DatagramSocket that a stream should - * use for control data (e.g. RTCP) traffic - * @see StreamConnector#getControlSocket() - */ - public DatagramSocket getControlSocket() - { - return null; - } - - /** - * Returns a reference to the DatagramSocket that a stream should - * use for data (e.g. RTP) traffic. - * - * @return a reference to the DatagramSocket that a stream should - * use for data (e.g. RTP) traffic - * @see StreamConnector#getDataSocket() - */ - public DatagramSocket getDataSocket() - { - return null; - } - - /** - * Returns a reference to the Socket that a stream should - * use for data (e.g. RTP) traffic. - * - * @return a reference to the Socket that a stream should - * use for data (e.g. RTP) traffic. - */ - public Socket getDataTCPSocket() - { - return dataSocket; - } - - /** - * Returns a reference to the Socket that a stream should - * use for control data (e.g. RTCP). - * - * @return a reference to the Socket that a stream should - * use for control data (e.g. RTCP). - */ - public Socket getControlTCPSocket() - { - return controlSocket; - } - - /** - * Returns the protocol of this StreamConnector. - * - * @return the protocol of this StreamConnector - */ - public Protocol getProtocol() - { - return Protocol.TCP; - } - - /** - * Notifies this instance that utilization of its Sockets - * for data and/or control traffic has started. - * - * @see StreamConnector#started() - */ - public void started() - { - } - - /** - * Notifies this instance that utilization of its Sockets - * for data and/or control traffic has temporarily stopped. This instance - * should be prepared to be started at a later time again though. - * - * @see StreamConnector#stopped() - */ - public void stopped() - { - } -} \ No newline at end of file diff --git a/src/net/java/sip/communicator/service/neomedia/MediaDirection.java b/src/net/java/sip/communicator/service/neomedia/MediaDirection.java deleted file mode 100644 index 4d44fe7f8..000000000 --- a/src/net/java/sip/communicator/service/neomedia/MediaDirection.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -/** - * The MediaDirections enumeration contains a list of media directions - * that indicate read/write capabilities of different entities in this - * MediaService such as for example devices. - * - * @author Emil Ivov - */ -public enum MediaDirection -{ - /** - * Indicates that the related entity does not support neither input - * nor output (i.e. neither send nor receive) operations. - */ - INACTIVE("inactive"), - - /** - * Represents a direction from the entity that this direction pertains to - * to the outside. When applied to a MediaDevice the direction - * indicates that the device is a read-only one. In the case of a stream - * a SENDONLY direction indicates that the stream is only sending - * data to the remote party without receiving. - */ - SENDONLY("sendonly"), - - /** - * Represents a direction pointing to the entity that this object pertains - * to and from the outside. When applied to a MediaDevice the - * direction indicates that the device is a write-only one. In the case of a - * MediaStream a RECVONLY direction indicates that the - * stream is only receiving data from the remote party without sending - * any. - */ - RECVONLY("recvonly"), - - /** - * Indicates that the related entity supports both input and output (send - * and receive) operations. - */ - SENDRECV("sendrecv"); - - /** - * The name of this direction. - */ - private final String directionName; - - /** - * Creates a MediaDirection instance with the specified name. - * - * @param directionName the name of the MediaDirections we'd like - * to create. - */ - private MediaDirection(String directionName) - { - this.directionName = directionName; - } - - /** - * Returns the name of this MediaDirection (e.g. "sendonly" or - * "sendrecv"). The name returned by this method is meant for use by - * session description mechanisms such as SIP/SDP or XMPP/Jingle. - * - * @return the name of this MediaDirection (e.g. "sendonly", - * "recvonly", "sendrecv"). - */ - @Override - public String toString() - { - return directionName; - } - - /** - * Applies an extra direction constraint to this MediaDirection - * or in other words performs an and operation. This method is - * primarily meant for use by the - * getReverseMediaDirection(MediaDirection) method while working - * on Offer/Answer media negotiation.. - * - * @param direction that direction constraint that we'd like to apply to - * this MediaDirection - * - * @return the new MediaDirection obtained after applying the - * direction constraint to this MediaDirection. - */ - public MediaDirection and(MediaDirection direction) - { - if (this == SENDRECV) - { - return direction; - } - else if( this == SENDONLY) - { - if (direction == SENDONLY || direction == SENDRECV) - return SENDONLY; - else - return INACTIVE; - } - else if( this == RECVONLY) - { - if (direction == RECVONLY || direction == SENDRECV) - return RECVONLY; - else - return INACTIVE; - } - else - return INACTIVE; - } - - /** - * Reverses a direction constraint on this MediaDirection - * or in other words performs an or operation. This method is - * meant for use in cases like putting a stream off hold or in other words - * reversing the SENDONLY constraint. - * - * @param direction the direction that we'd like to enable (i.e. add) to - * this MediaDirection - * - * @return the new MediaDirection obtained after adding the - * specified direction this MediaDirection. - */ - public MediaDirection or(MediaDirection direction) - { - if (this == SENDRECV) - { - return this; - } - else if( this == SENDONLY) - { - if( direction.allowsReceiving()) - return SENDRECV; - else - return this; - } - else if( this == RECVONLY) - { - if( direction.allowsSending()) - return SENDRECV; - else - return this; - } - else // INACTIVE - return direction; - } - - /** - * Returns the MediaDirection value corresponding to a remote - * party's perspective of this MediaDirection. In other words, - * if I say I'll be sending only, for you this means that you'll be - * receiving only. If however, I say I'll be both sending and receiving - * (i.e. SENDRECV) then it means you'll be doing the same (i.e. - * again SENDRECV). - * - * @return the MediaDirection value corresponding to a remote - * party's perspective of this MediaDirection. - */ - public MediaDirection getReverseDirection() - { - if (this == SENDRECV) - { - return SENDRECV; - } - else if(this == SENDONLY) - { - return RECVONLY; - } - else if (this == RECVONLY) - { - return SENDONLY; - } - else - { - return INACTIVE; - } - } - - /** - * Returns the MediaDirection value corresponding to a remote - * party's perspective of this MediaDirection applying a remote - * party constraint. In other words, if I say I'll only be sending media - * (i.e. SENDONLY) and you know that you can both send and receive - * (i.e. SENDRECV) then to you this mean that you'll be only - * receiving media (i.e. RECVONLY). If however I say that I can - * only receive a particular media type (i.e. RECVONLY) and you - * are in the same situation then this means that neither of us would be - * sending nor receiving and the stream would appear INACTIVE to - * you (and me for that matter). The method is meant for use during - * Offer/Answer SDP negotiation. - * - * @param remotePartyDir the remote party MediaDirection constraint - * that we'd have to consider when trying to obtain a - * MediaDirection corresponding to remoteParty's constraint. - * - * @return the MediaDirection value corresponding to a remote - * party's perspective of this MediaDirection applying a remote - * party constraint. - */ - public MediaDirection getDirectionForAnswer(MediaDirection remotePartyDir) - { - return this.and(remotePartyDir.getReverseDirection()); - } - - /** - * Determines whether the directions specified by this - * MediaDirection instance allow for outgoing (i.e. sending) - * streams or in other words whether this is a SENDONLY or a - * SENDRECV instance - * - * @return true if this MediaDirection instance includes - * the possibility of sending and false otherwise. - */ - public boolean allowsSending() - { - return this == SENDONLY || this == SENDRECV; - } - - /** - * Determines whether the directions specified by this - * MediaDirection instance allow for incoming (i.e. receiving) - * streams or in other words whether this is a RECVONLY or a - * SENDRECV instance - * - * @return true if this MediaDirection instance includes - * the possibility of receiving and false otherwise. - */ - public boolean allowsReceiving() - { - return this == RECVONLY || this == SENDRECV; - } - - /** - * Returns a MediaDirection value corresponding to the specified - * mediaDirectionStr or in other words SENDONLY for - * "sendonly", RECVONLY for "recvonly", SENDRECV for - * "sendrecv", and INACTIVE for "inactive". - * - * @param mediaDirectionStr the direction String that we'd like to - * parse. - * @return a MediaDirection value corresponding to the specified - * mediaDirectionStr. - * - * @throws IllegalArgumentException in case mediaDirectionStr is - * not a valid media direction. - */ - public static MediaDirection parseString(String mediaDirectionStr) - throws IllegalArgumentException - { - for (MediaDirection value : values()) - if (value.toString().equals(mediaDirectionStr)) - return value; - - throw new IllegalArgumentException( - mediaDirectionStr + " is not a valid media direction"); - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/MediaException.java b/src/net/java/sip/communicator/service/neomedia/MediaException.java deleted file mode 100644 index f60c3aeeb..000000000 --- a/src/net/java/sip/communicator/service/neomedia/MediaException.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -/** - * Implements an Exception thrown by the neomedia service interfaces - * and their implementations. MediaException carries an error code in - * addition to the standard Exception properties which gives more - * information about the specifics of the particular MediaException. - * - * @author Lubomir Marinov - */ -public class MediaException - extends Exception -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * The error code value which specifies that the MediaException - * carrying it does not give more information about its specifics. - */ - public static final int GENERAL_ERROR = 1; - - /** - * The error code carried by this MediaException which gives more - * information about the specifics of this MediaException. - */ - private final int errorCode; - - /** - * Initializes a new MediaException instance with a specific - * detailed message and {@link #GENERAL_ERROR} error code. - * - * @param message the detailed message to initialize the new instance with - */ - public MediaException(String message) - { - this(message, GENERAL_ERROR); - } - - /** - * Initializes a new MediaException instance with a specific - * detailed message and a specific error code. - * - * @param message the detailed message to initialize the new instance with - * @param errorCode the error code which is to give more information about - * the specifics of the new instance - */ - public MediaException(String message, int errorCode) - { - super(message); - - this.errorCode = errorCode; - } - - /** - * Initializes a new MediaException instance with a specific - * detailed message, {@link #GENERAL_ERROR} error code and a specific - * Throwable cause. - * - * @param message the detailed message to initialize the new instance with - * @param cause the Throwable which is to be carried by the new - * instance and which is to be reported as the cause for throwing the new - * instance. If cause is null, the cause for throwing the - * new instance is considered to be unknown. - */ - public MediaException(String message, Throwable cause) - { - this(message, GENERAL_ERROR, cause); - } - - /** - * Initializes a new MediaException instance with a specific - * detailed message, a specific error code and a specific Throwable - * cause. - * - * @param message the detailed message to initialize the new instance with - * @param errorCode the error code which is to give more information about - * the specifics of the new instance - * @param cause the Throwable which is to be carried by the new - * instance and which is to be reported as the cause for throwing the new - * instance. If cause is null, the cause for throwing the - * new instance is considered to be unknown. - */ - public MediaException(String message, int errorCode, Throwable cause) - { - super(message, cause); - - this.errorCode = errorCode; - } - - /** - * Gets the error code carried by this MediaException which gives - * more information about the specifics of this MediaException. - * - * @return the error code carried by this MediaException which - * gives more information about the specifics of this - * MediaException - */ - public int getErrorCode() - { - return errorCode; - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/MediaService.java b/src/net/java/sip/communicator/service/neomedia/MediaService.java deleted file mode 100644 index a2269a965..000000000 --- a/src/net/java/sip/communicator/service/neomedia/MediaService.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.beans.*; -import java.util.*; - -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; - -/** - * The MediaService service is meant to be a wrapper of media libraries - * such as JMF, FMJ, FFMPEG, and/or others. It takes care of all media play and - * capture as well as media transport (e.g. over RTP). - * - * @author Emil Ivov - * @author Lyubomir Marinov - */ -public interface MediaService -{ - /** - * The name of the property of MediaService the value of which - * corresponds to the value returned by - * {@link #getDefaultDevice(MediaType, MediaUseCase)}. The oldValue - * and the newValue of the fired PropertyChangeEvent are - * not to be relied on and instead a call to getDefaultDevice is to - * be performed to retrieve the new value. - */ - public static final String DEFAULT_DEVICE = "defaultDevice"; - - /** - * Returns the default MediaDevice for the specified media - * type. - * - * @param mediaType a MediaType value indicating the kind of device - * that we are trying to obtain. - * @param useCase MediaUseCase value indicating for the use-case of - * device that we are trying to obtain. - * - * @return the currently default MediaDevice for the specified - * MediaType, or null if no such device exists. - */ - public MediaDevice getDefaultDevice( - MediaType mediaType, - MediaUseCase useCase); - - /** - * Returns a list containing all devices known to this service - * implementation and handling the specified MediaType. - * - * @param mediaType the media type (i.e. AUDIO or VIDEO) that we'd like - * to obtain the device list for. - * @param useCase MediaUseCase value indicating for the use-case of - * device that we are trying to obtain. - * - * @return the list of MediaDevices currently known to handle the - * specified mediaType. - */ - public List getDevices(MediaType mediaType, - MediaUseCase useCase); - - /** - * Create a MediaStream which will use a specific - * MediaDevice for capture and playback of media. The new instance - * will not have a StreamConnector at the time of its construction - * and a StreamConnector will be specified later on in order to - * enable the new instance to send and receive media. - * - * @param device the MediaDevice to be used by the new instance for - * capture and playback of media - * @return a newly-created MediaStream which will use the specified - * device for capture and playback of media - */ - public MediaStream createMediaStream(MediaDevice device); - - /** - * Creates a MediaStream that will be using the specified - * MediaDevice for both capture and playback of media exchanged - * via the specified StreamConnector. - * - * @param connector the StreamConnector the stream should use for - * sending and receiving media or null if the stream is to not have - * a StreamConnector configured at initialization time and a - * StreamConnector is to be specified later on - * @param device the device to be used for both capture and playback of - * media exchanged via the specified StreamConnector - * - * @return the newly created MediaStream. - */ - public MediaStream createMediaStream(StreamConnector connector, - MediaDevice device); - - /** - * Creates a MediaStream that will be using the specified - * MediaDevice for both capture and playback of media exchanged - * via the specified StreamConnector. - * - * @param connector the StreamConnector the stream should use for - * sending and receiving media or null if the stream is to not have - * a StreamConnector configured at initialization time and a - * StreamConnector is to be specified later on - * @param device the device to be used for both capture and playback of - * media exchanged via the specified StreamConnector - * @param zrtpControl a control which is already created, used to control - * the ZRTP operations. - * - * @return the newly created MediaStream. - */ - public MediaStream createMediaStream(StreamConnector connector, - MediaDevice device, - SrtpControl zrtpControl); - - /** - * Creates a new MediaDevice which uses a specific - * MediaDevice to capture and play back media and performs mixing - * of the captured media and the media played back by any other users of the - * returned MediaDevice. For the AUDIO MediaType, - * the returned device is commonly referred to as an audio mixer. The - * MediaType of the returned MediaDevice is the same as - * the MediaType of the specified device. - * - * @param device the MediaDevice which is to be used by the - * returned MediaDevice to actually capture and play back media - * @return a new MediaDevice instance which uses device to - * capture and play back media and performs mixing of the captured media and - * the media played back by any other users of the returned - * MediaDevice instance - */ - public MediaDevice createMixer(MediaDevice device); - - /** - * Gets the MediaFormatFactory through which MediaFormat - * instances may be created for the purposes of working with the - * MediaStreams created by this MediaService. - * - * @return the MediaFormatFactory through which - * MediaFormat instances may be created for the purposes of working - * with the MediaStreams created by this MediaService - */ - public MediaFormatFactory getFormatFactory(); - - /** - * Initializes a new ZrtpControl instance which is to control all - * ZRTP options. - * - * @return a new ZrtpControl instance which is to control all ZRTP - * options - */ - public ZrtpControl createZrtpControl(); - - /** - * Initializes a new SDesControl instance which is to control all - * SDes options. - * - * @return a new SDesControl instance which is to control all SDes - * options - */ - public SDesControl createSDesControl(); - - /** - * Gets the VolumeControl which controls the volume level of audio - * output/playback. - * - * @return the VolumeControl which controls the volume level of - * audio output/playback - */ - public VolumeControl getOutputVolumeControl(); - - /** - * Gets the VolumeControl which controls the volume level of audio - * input/capture. - * - * @return the VolumeControl which controls the volume level of - * audio input/capture - */ - public VolumeControl getInputVolumeControl(); - - /** - * Get available ScreenDevices. - * - * @return screens - */ - public List getAvailableScreenDevices(); - - /** - * Get default ScreenDevice device. - * - * @return default screen device - */ - public ScreenDevice getDefaultScreenDevice(); - - /** - * Creates a new Recorder instance that can be used to record a - * call which captures and plays back media using a specific - * MediaDevice. - * - * @param device the MediaDevice which is used for media capture - * and playback by the call to be recorded - * @return a new Recorder instance that can be used to record a - * call which captures and plays back media using the specified - * MediaDevice - */ - public Recorder createRecorder(MediaDevice device); - - /** - * Returns a {@link Map} that binds indicates whatever preferences the - * media service implementation may have for the RTP payload type numbers - * that get dynamically assigned to {@link MediaFormat}s with no static - * payload type. The method is useful for formats such as "telephone-event" - * for example that is statically assigned the 101 payload type by some - * legacy systems. Signalling protocol implementations such as SIP and XMPP - * should make sure that, whenever this is possible, they assign to formats - * the dynamic payload type returned in this {@link Map}. - * - * @return a {@link Map} binding some formats to a preferred dynamic RTP - * payload type number. - */ - public Map getDynamicPayloadTypePreferences(); - - /** - * Creates a preview component for the specified device(video device) used - * to show video preview from it. - * - * @param device the video device - * @param preferredWidth the width we prefer for the component - * @param preferredHeight the height we prefer for the component - * @return the preview component. - */ - public Object getVideoPreviewComponent( - MediaDevice device, int preferredWidth, int preferredHeight); - - /** - * Get a MediaDevice for a part of desktop streaming/sharing. - * - * @param width width of the part - * @param height height of the part - * @param x origin of the x coordinate (relative to the full desktop) - * @param y origin of the y coordinate (relative to the full desktop) - * @return MediaDevice representing the part of desktop or null - * if problem - */ - public MediaDevice getMediaDeviceForPartialDesktopStreaming( - int width, int height, int x, int y); - - /** - * If the MediaDevice corresponds to partial desktop streaming - * device. - * - * @param mediaDevice MediaDevice - * @return true if MediaDevice is a partial desktop streaming - * device, false otherwise - */ - public boolean isPartialStreaming(MediaDevice mediaDevice); - - /** - * Get origin for desktop streaming device. - * - * @param mediaDevice media device - * @return origin - */ - public java.awt.Point getOriginForDesktopStreamingDevice( - MediaDevice mediaDevice); - - /** - * Those interested in Recorder events add listener through MediaService. - * This way they don't need to have access to the Recorder instance. - * Adds a new Recorder.Listener to the list of listeners - * interested in notifications from a Recorder. - * - * @param listener the new Recorder.Listener to be added to the - * list of listeners interested in notifications from Recorders. - */ - public void addRecorderListener(Recorder.Listener listener); - - /** - * Removes an existing Recorder.Listener from the list of listeners - * interested in notifications from Recorders. - * - * @param listener the existing Listener to be removed from the - * list of listeners interested in notifications from Recorders - */ - public void removeRecorderListener(Recorder.Listener listener); - - /** - * Gives access to currently registered Recorder.Listeners. - * @return currently registered Recorder.Listeners. - */ - public Iterator getRecorderListeners(); - - /** - * Initializes a new RTPTranslator which is to forward RTP and RTCP - * traffic between multiple MediaStreams. - * - * @return a new RTPTranslator which is to forward RTP and RTCP - * traffic between multiple MediaStreams - */ - public RTPTranslator createRTPTranslator(); - - /** - * Adds a PropertyChangeListener to be notified about changes in - * the values of the properties of this instance. - * - * @param listener the PropertyChangeListener to be notified about - * changes in the values of the properties of this instance - */ - public void addPropertyChangeListener(PropertyChangeListener listener); - - /** - * Removes a PropertyChangeListener to no longer be notified about - * changes in the values of the properties of this instance. - * - * @param listener the PropertyChangeListener to no longer be - * notified about changes in the values of the properties of this instance - */ - public void removePropertyChangeListener(PropertyChangeListener listener); -} diff --git a/src/net/java/sip/communicator/service/neomedia/MediaStream.java b/src/net/java/sip/communicator/service/neomedia/MediaStream.java deleted file mode 100644 index 00dcc7617..000000000 --- a/src/net/java/sip/communicator/service/neomedia/MediaStream.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.net.*; -import java.util.*; -import java.beans.*; - -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.format.*; - -/** - * The MediaStream class represents a (generally) bidirectional RTP - * stream between exactly two parties. The class reflects one media stream, in - * the SDP sense of the word. MediaStream instances are created through - * the openMediaStream() method of the MediaService. - * - * @author Emil Ivov - * @author Lyubomir Marinov - */ -public interface MediaStream -{ - - /** - * The name of the property which indicates whether the remote SSRC is - * currently available. - */ - public static final String PNAME_LOCAL_SSRC = "localSSRCAvailable"; - - /** - * The name of the property which indicates whether the local SSRC is - * currently available. - */ - public static final String PNAME_REMOTE_SSRC = "remoteSSRCAvailable"; - - /** - * Starts capturing media from this stream's MediaDevice and then - * streaming it through the local StreamConnector toward the - * stream's target address and port. The method also puts the - * MediaStream in a listening state that would make it play all - * media received from the StreamConnector on the stream's - * MediaDevice. - */ - public void start(); - - /** - * Stops all streaming and capturing in this MediaStream and closes - * and releases all open/allocated devices/resources. This method has no - * effect on an already closed stream and is simply ignored. - */ - public void stop(); - - /** - * Releases the resources allocated by this instance in the course of its - * execution and prepares it to be garbage collected. - */ - public void close(); - - /** - * Sets the MediaFormat that this MediaStream should - * transmit in. - * - * @param format the MediaFormat that this MediaStream - * should transmit in. - */ - public void setFormat(MediaFormat format); - - /** - * Returns the MediaFormat that this stream is currently - * transmitting in. - * - * @return the MediaFormat that this stream is currently - * transmitting in. - */ - public MediaFormat getFormat(); - - /** - * Sets the StreamConnector to be used by this MediaStream - * for sending and receiving media. - * - * @param connector the StreamConnector to be used by this - * MediaStream for sending and receiving media - */ - public void setConnector(StreamConnector connector); - - /** - * Sets the device that this stream should use to play back and capture - * media. - * - * @param device the MediaDevice that this stream should use to - * play back and capture media. - */ - public void setDevice(MediaDevice device); - - /** - * Gets the device that this stream uses to play back and capture media. - * - * @return the MediaDevice that this stream uses to play back and - * capture media. - */ - public MediaDevice getDevice(); - - /** - * Returns the synchronization source (SSRC) identifier of the remote - * participant or -1 if that identifier is not yet known at this - * point. - * - * @return the synchronization source (SSRC) identifier of the remote - * participant or -1 if that identifier is not yet known at this - * point. - */ - public long getRemoteSourceID(); - - /** - * Gets the synchronization source (SSRC) identifiers of the remote peers. - * - * @return the synchronization source (SSRC) identifiers of the remote peers - * @see MediaStream#getRemoteSourceIDs() - */ - public List getRemoteSourceIDs(); - - /** - * Returns the synchronization source (SSRC) identifier of the local - * participant or -1 if that identifier is not yet known at this - * point. - * - * @return the synchronization source (SSRC) identifier of the local - * participant or -1 if that identifier is not yet known at this - * point. - */ - public long getLocalSourceID(); - - /** - * Returns the address that this stream is sending RTCP traffic to. - * - * @return an InetSocketAddress instance indicating the address - * that we are sending RTCP packets to. - */ - public InetSocketAddress getRemoteControlAddress(); - - /** - * Returns the address that this stream is sending RTP traffic to. - * - * @return an InetSocketAddress instance indicating the address - * that we are sending RTP packets to. - */ - public InetSocketAddress getRemoteDataAddress(); - - /** - * Returns the transport protocol used by the streams. - * - * @return the transport protocol (UDP or TCP) used by the streams. null if - * the stream connector is not instanciated. - */ - public StreamConnector.Protocol getTransportProtocol(); - - /** - * Adds a property change listener to this stream so that it would be - * notified upon property change events like for example an SSRC ID which - * becomes known. - * - * @param listener the listener that we'd like to register for - * PropertyChangeEvents - */ - public void addPropertyChangeListener(PropertyChangeListener listener); - - /** - * Removes the specified property change listener from this stream - * so that it won't receive further property change events. - * - * @param listener the listener that we'd like to remove. - */ - public void removePropertyChangeListener(PropertyChangeListener listener); - - /** - * Sets the target of this MediaStream to which it is to send and - * from which it is to receive data (e.g. RTP) and control data (e.g. RTCP). - * - * @param target the MediaStreamTarget describing the data - * (e.g. RTP) and the control data (e.g. RTCP) locations to which this - * MediaStream is to send and from which it is to receive - */ - public void setTarget(MediaStreamTarget target); - - /** - * Returns the target of this MediaStream to which it is to send - * and from which it is to receive data (e.g. RTP) and control data (e.g. - * RTCP). - * - * @return the MediaStreamTarget describing the data - * (e.g. RTP) and the control data (e.g. RTCP) locations to which this - * MediaStream is to send and from which it is to receive - * @see MediaStream#setTarget(MediaStreamTarget) - */ - public MediaStreamTarget getTarget(); - - /** - * Adds a new association in this MediaStream of the specified RTP - * payload type with the specified MediaFormat in order to allow it - * to report rtpPayloadType in RTP flows sending and receiving - * media in format. Usually, rtpPayloadType will be in the - * range of dynamic RTP payload types. - * - * @param rtpPayloadType the RTP payload type to be associated in this - * MediaStream with the specified MediaFormat - * @param format the MediaFormat to be associated in this - * MediaStream with rtpPayloadType - */ - public void addDynamicRTPPayloadType( - byte rtpPayloadType, - MediaFormat format); - - /** - * Gets the existing associations in this MediaStream of RTP - * payload types to MediaFormats. The returned Map - * only contains associations previously added in this instance with - * {@link #addDynamicRTPPayloadType(byte, MediaFormat)} and not globally or - * well-known associations reported by - * {@link MediaFormat#getRTPPayloadType()}. - * - * @return a Map of RTP payload type expressed as Byte to - * MediaFormat describing the existing (dynamic) associations in - * this instance of RTP payload types to MediaFormats. The - * Map represents a snapshot of the existing associations at the - * time of the getDynamicRTPPayloadTypes() method call and - * modifications to it are not reflected on the internal storage - */ - public Map getDynamicRTPPayloadTypes(); - - /** - * Adds or updates an association in this MediaStream mapping the - * specified extensionID to rtpExtension and enabling or - * disabling its use according to the direction attribute of - * rtpExtension. - * - * @param extensionID the ID that is mapped to rtpExtension for - * the lifetime of this MediaStream. - * @param rtpExtension the RTPExtension that we are mapping to - * extensionID. - */ - public void addRTPExtension(byte extensionID, RTPExtension rtpExtension); - - /** - * Returns a map containing all currently active RTPExtensions in - * use by this stream. - * - * @return a map containing all currently active RTPExtensions in - * use by this stream. - */ - public Map getActiveRTPExtensions(); - - /** - * Sets the direction in which media in this MediaStream is to be - * streamed. If this MediaStream is not currently started, calls to - * {@link #start()} later on will start it only in the specified - * direction. If it is currently started in a direction different - * than the specified, directions other than the specified will be stopped. - * - * @param direction the MediaDirection in which this - * MediaStream is to stream media when it is started - */ - public void setDirection(MediaDirection direction); - - /** - * Gets the direction in which this MediaStream is allowed to - * stream media. - * - * @return the MediaDirection in which this MediaStream is - * allowed to stream media - */ - public MediaDirection getDirection(); - - /** - * Determines whether {@link #start()} has been called on this - * MediaStream without {@link #stop()} or {@link #close()} - * afterwards. - * - * @return true if {@link #start()} has been called on this - * MediaStream without {@link #stop()} or {@link #close()} - * afterwards - */ - public boolean isStarted(); - - /** - * Causes this MediaStream to stop transmitting the media being fed - * from this stream's MediaDevice and transmit "silence" instead. - * "Silence" for video is understood as video data which is not the captured - * video data and may represent, for example, a black image. - * - * @param mute true if we are to start transmitting "silence" and - * false if we are to use media from this stream's - * MediaDevice again. - */ - public void setMute(boolean mute); - - /** - * Determines whether this MediaStream is set to transmit "silence" - * instead of the media being fed from its MediaDevice. "Silence" - * for video is understood as video data which is not the captured video - * data and may represent, for example, a black image. - * - * @return true if this MediaStream is set to transmit - * "silence" instead of the media fed from its MediaDevice; - * false, otherwise - */ - public boolean isMute(); - - /** - * Returns the name of this stream or null if no name has been - * set. A stream name is used by some protocols, for diagnostic purposes - * mostly. In XMPP for example this is the name of the content element that - * describes a stream. - * - * @return the name of this stream or null if no name has been - * set. - */ - public String getName(); - - /** - * Sets the name of this stream. Stream names are used by some protocols, - * for diagnostic purposes mostly. In XMPP for example this is the name of - * the content element that describes a stream. - * - * @param name the name of this stream or null if no name has been - * set. - */ - public void setName(String name); - - /** - * The ZrtpControl which controls the ZRTP for this stream. - * - * @return the ZrtpControl which controls the ZRTP for this stream - */ - public SrtpControl getSrtpControl(); - - /** - * Sets the RTPTranslator which is to forward RTP and RTCP traffic - * between this and other MediaStreams. - * - * @param rtpTranslator the RTPTranslator which is to forward RTP - * and RTCP traffic between this and other MediaStreams - */ - public void setRTPTranslator(RTPTranslator rtpTranslator); - - /** - * Returns a MediaStreamStats object used to get statistics about this - * MediaStream. - * - * @return the MediaStreamStats object used to compute the statistics about - * this MediaStream. - */ - public MediaStreamStats getMediaStreamStats(); -} diff --git a/src/net/java/sip/communicator/service/neomedia/MediaStreamStats.java b/src/net/java/sip/communicator/service/neomedia/MediaStreamStats.java deleted file mode 100644 index 3d1c68b69..000000000 --- a/src/net/java/sip/communicator/service/neomedia/MediaStreamStats.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.awt.*; -import net.sf.fmj.media.rtp.*; - -/** - * Class used to compute stats concerning a MediaStream. - * - * @author Vincent Lucas - */ -public interface MediaStreamStats -{ - /** - * Computes and updates information for a specific stream. - */ - public void updateStats(); - - /** - * Returns the MediaStream enconding. - * - * @return the encoding used by the stream. - */ - public String getEncoding(); - - /** - * Returns the MediaStream enconding rate (in Hz).. - * - * @return the encoding rate used by the stream. - */ - public String getEncodingClockRate(); - - /** - * Returns the upload video size if this stream uploads a video, or null if - * not. - * - * @return the upload video size if this stream uploads a video, or null if - * not. - */ - public Dimension getUploadVideoSize(); - - /** - * Returns the download video size if this stream downloads a video, or - * null if not. - * - * @return the download video size if this stream downloads a video, or null - * if not. - */ - public Dimension getDownloadVideoSize(); - - /** - * Returns the local IP address of the MediaStream. - * - * @return the local IP address of the stream. - */ - public String getLocalIPAddress(); - - /** - * Returns the local port of the MediaStream. - * - * @return the local port of the stream. - */ - public int getLocalPort(); - - /** - * Returns the remote IP address of the MediaStream. - * - * @return the remote IP address of the stream. - */ - public String getRemoteIPAddress(); - - /** - * Returns the remote port of the MediaStream. - * - * @return the remote port of the stream. - */ - public int getRemotePort(); - - /** - * Returns the percent loss of the download stream. - * - * @return the last loss rate computed (in %). - */ - public double getDownloadPercentLoss(); - - /** - * Returns the percent loss of the upload stream. - * - * @return the last loss rate computed (in %). - */ - public double getUploadPercentLoss(); - - /** - * Returns the bandwidth used by this download stream. - * - * @return the last used download bandwidth computed (in Kbit/s). - */ - public double getDownloadRateKiloBitPerSec(); - - /** - * Returns the bandwidth used by this download stream. - * - * @return the last used upload bandwidth computed (in Kbit/s). - */ - public double getUploadRateKiloBitPerSec(); - - /** - * Returns the jitter average of this download stream. - * - * @return the last jitter average computed (in ms). - */ - public double getDownloadJitterMs(); - - /** - * Returns the jitter average of this upload stream. - * - * @return the last jitter average computed (in ms). - */ - public double getUploadJitterMs(); - - /** - * Updates this stream stats with the new feedback sent. - * - * @param feedback The last RTCP feedback sent by the MediaStream. - */ - public void updateNewSentFeedback(RTCPFeedback feedback); - - /** - * Updates this stream stats with the new feedback received. - * - * @param feedback The last RTCP feedback received by the MediaStream. - */ - public void updateNewReceivedFeedback(RTCPFeedback feedback); -} diff --git a/src/net/java/sip/communicator/service/neomedia/MediaStreamTarget.java b/src/net/java/sip/communicator/service/neomedia/MediaStreamTarget.java deleted file mode 100644 index 64488e84f..000000000 --- a/src/net/java/sip/communicator/service/neomedia/MediaStreamTarget.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.net.*; - -/** - * The MediaStreamTarget contains a pair of host:port couples - * indicating data (RTP) and control (RTCP) locations. - * - * @author Emil Ivov - * @author Lyubomir Marinov - */ -public class MediaStreamTarget -{ - /** - * The data (RTP) address of the target. - */ - private final InetSocketAddress rtpTarget; - - /** - * The control (RTCP) address of the target. - */ - private final InetSocketAddress rtcpTarget; - - /** - * Creates an instance of this MediaStreamTarget containing the - * specified RTP and RTCP target host:port couples. - * - * @param rtpTarget the InetSocketAddress that this - * MediaStreamTarget is supposed to indicate as a data address. - * @param rtcpTarget the InetSocketAddress that this - * MediaStreamTarget is supposed to indicate as a control address. - */ - public MediaStreamTarget(InetSocketAddress rtpTarget, - InetSocketAddress rtcpTarget) - { - this.rtpTarget = rtpTarget; - this.rtcpTarget = rtcpTarget; - } - - /** - * Determines whether two specific InetSocketAddress instances are - * equal. - * - * @param addr1 one of the InetSocketAddress instances to be - * compared - * @param addr2 the other InetSocketAddress instance to be compared - * @return true if addr1 is equal to addr2; - * otherwise, false - */ - private boolean addressesAreEqual( - InetSocketAddress addr1, - InetSocketAddress addr2) - { - return (addr1 == null) ? (addr2 == null) : addr1.equals(addr2); - } - - /** - * Determines whether this MediaStreamTarget is equal to a specific - * Object. - * - * @param obj the Object to be compared to this - * MediaStreamTarget - * @return true if this MediaStreamTarget is equal to the - * specified obj; otherwise, false - */ - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - - if (!getClass().isInstance(obj)) - return false; - - MediaStreamTarget mediaStreamTarget = (MediaStreamTarget) obj; - - return - addressesAreEqual( - getControlAddress(), - mediaStreamTarget.getControlAddress()) - && addressesAreEqual( - getDataAddress(), - mediaStreamTarget.getDataAddress()); - } - - /** - * Returns the InetSocketAddress that this MediaTarget is - * pointing to for all media (RTP) traffic. - * - * @return the InetSocketAddress that this MediaTarget is - * pointing to for all media (RTP) traffic. - */ - public InetSocketAddress getDataAddress() - { - return rtpTarget; - } - - /** - * Returns the InetSocketAddress that this MediaTarget is - * pointing to for all media (RTP) traffic. - * - * @return the InetSocketAddress that this MediaTarget is - * pointing to for all media (RTP) traffic. - */ - public InetSocketAddress getControlAddress() - { - return rtcpTarget; - } - - /** - * Returns a hash code for this MediaStreamTarget instance which is - * suitable for use in hash tables. - * - * @return a hash code for this MediaStreamTarget instance which is - * suitable for use in hash tables - */ - @Override - public int hashCode() - { - int hashCode = 0; - - InetSocketAddress controlAddress = getControlAddress(); - if (controlAddress != null) - hashCode |= controlAddress.hashCode(); - - InetSocketAddress dataAddress = getDataAddress(); - if (dataAddress != null) - hashCode |= dataAddress.hashCode(); - - return hashCode; - } - - /** - * Returns a human-readable representation of this - * MediaStreamTarget instance in the form of a String - * value. - * - * @return a String value which gives a human-readable - * representation of this MediaStreamTarget instance - */ - @Override - public String toString() - { - return - getClass().getSimpleName() - + " with dataAddress " - + getDataAddress() - + " and controlAddress " - + getControlAddress(); - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/MediaType.java b/src/net/java/sip/communicator/service/neomedia/MediaType.java deleted file mode 100644 index 8720cdc1d..000000000 --- a/src/net/java/sip/communicator/service/neomedia/MediaType.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -/** - * The MediaType enumeration contains a list of media types - * currently known to and handled by the MediaService. - * - * @author Emil Ivov - */ -public enum MediaType -{ - /** - * Represents an AUDIO media type. - */ - AUDIO("audio"), - - /** - * Represents a VIDEO media type. - */ - VIDEO("video"); - - /** - * The name of this MediaType. - */ - private final String mediaTypeName; - - /** - * Creates a MediaType instance with the specified name. - * - * @param mediaTypeName the name of the MediaType we'd like to - * create. - */ - private MediaType(String mediaTypeName) - { - this.mediaTypeName = mediaTypeName; - } - - /** - * Returns the name of this MediaType (e.g. "audio" or "video"). The name - * returned by this method is meant for use by session description - * mechanisms such as SIP/SDP or XMPP/Jingle. - * - * @return the name of this MediaType (e.g. "audio" or "video"). - */ - @Override - public String toString() - { - return mediaTypeName; - } - - /** - * Returns a MediaType value corresponding to the specified - * mediaTypeName or in other words MediaType.AUDIO for - * "audio" and MediaType.VIDEO for "video". - * - * @param mediaTypeName the name that we'd like to parse. - * @return a MediaType value corresponding to the specified - * mediaTypeName. - * - * @throws IllegalArgumentException in case mediaTypeName is not a - * valid or currently supported media type. - */ - public static MediaType parseString(String mediaTypeName) - throws IllegalArgumentException - { - if(AUDIO.toString().equals(mediaTypeName)) - return AUDIO; - - if(VIDEO.toString().equals(mediaTypeName)) - return VIDEO; - - throw new IllegalArgumentException( - mediaTypeName + " is not a currently supported MediaType"); - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/MediaTypeSrtpControl.java b/src/net/java/sip/communicator/service/neomedia/MediaTypeSrtpControl.java deleted file mode 100644 index 0dd9a1eff..000000000 --- a/src/net/java/sip/communicator/service/neomedia/MediaTypeSrtpControl.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -/** - * Utility class to combine MediaType and SrtpControlType as a - * map key. - * - * @author Ingo Bauersachs - */ -public class MediaTypeSrtpControl implements Comparable -{ - /** - * The media type. - */ - public final MediaType mediaType; - - /** - * The SRTP control type. - */ - public final SrtpControlType srtpControlType; - - /** - * Creates a new instance of this class. - * @param mt The MediaType for this key. - * @param sct The SrtpControlType for this key. - */ - public MediaTypeSrtpControl(MediaType mt, SrtpControlType sct) - { - mediaType = mt; - srtpControlType = sct; - } - - @Override - public boolean equals(Object obj) - { - if(obj == null || obj.getClass() != MediaTypeSrtpControl.class) - return false; - - MediaTypeSrtpControl other = (MediaTypeSrtpControl)obj; - return mediaType == other.mediaType - && srtpControlType == other.srtpControlType; - } - - @Override - public int hashCode() - { - return mediaType.hashCode() ^ srtpControlType.hashCode(); - } - - public int compareTo(MediaTypeSrtpControl o) - { - return getWeight() == o.getWeight() ? - 0 : - getWeight() < o.getWeight() ? - -1 : 1; - } - - private int getWeight() - { - int mtWeight = 0; - switch(mediaType) - { - case AUDIO: - mtWeight = 1; - break; - case VIDEO: - mtWeight = 2; - break; - } - int stWeight = 0; - switch(srtpControlType) - { - case ZRTP: - stWeight = 1; - break; - case MIKEY: - stWeight = 2; - break; - case SDES: - stWeight = 3; - break; - } - return mtWeight * 10 + stWeight; - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/MediaUseCase.java b/src/net/java/sip/communicator/service/neomedia/MediaUseCase.java deleted file mode 100644 index b65158cff..000000000 --- a/src/net/java/sip/communicator/service/neomedia/MediaUseCase.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -/** - * The MediaUseCase enumeration contains a list of use-cases for media - * related. Typically it can be used to differentiate a video call (video comes - * from webcam) and desktop session (video comes from desktop). - * - * @author Sebastien Vincent - */ -public enum MediaUseCase -{ - /** - * Represents any usecase. - */ - ANY("any"), - - /** - * Represents a standard call (voice/video). - */ - CALL("call"), - - /** - * Represents a desktop streaming/sharing session. - */ - DESKTOP("desktop"); - - /** - * Name of this MediaUseCase. - */ - private final String mediaUseCase; - - /** - * Constructor. - * - * @param mediaUseCase type of MediaUseCase we'd like to create - */ - private MediaUseCase(String mediaUseCase) - { - this.mediaUseCase = mediaUseCase; - } - - /** - * Returns the name of this MediaUseCase. - * - * @return the name of this MediaUseCase. - */ - @Override - public String toString() - { - return mediaUseCase; - } - - /** - * Returns a MediaUseCase value corresponding to the specified - * mediaUseCase. - * - * @param mediaUseCase the name that we'd like to parse. - * @return a MediaUseCase value corresponding to the specified - * mediaUseCase. - * - * @throws IllegalArgumentException in case mediaUseCase is not a - * valid or currently supported media usecase. - */ - public static MediaUseCase parseString(String mediaUseCase) - throws IllegalArgumentException - { - if(CALL.toString().equals(mediaUseCase)) - return CALL; - if(ANY.toString().equals(mediaUseCase)) - return ANY; - if(DESKTOP.toString().equals(mediaUseCase)) - return DESKTOP; - - throw new IllegalArgumentException( - mediaUseCase + " is not a currently supported MediaUseCase"); - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/QualityControl.java b/src/net/java/sip/communicator/service/neomedia/QualityControl.java deleted file mode 100644 index a210f695e..000000000 --- a/src/net/java/sip/communicator/service/neomedia/QualityControl.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import net.java.sip.communicator.service.protocol.*; - -/** - * The quality controls we use to control other party video presets. - * @author Damian Minkov - */ -public interface QualityControl -{ - /** - * The currently used quality preset announced as receive by remote party. - * @return the current quality preset. - */ - public QualityPreset getRemoteReceivePreset(); - - /** - * The minimum preset that the remote party is sending and we are receiving. - * @return the minimum remote preset. - */ - public QualityPreset getRemoteSendMinPreset(); - - /** - * The maximum preset that the remote party is sending and we are receiving. - * @return the maximum preset announced from remote party as send. - */ - public QualityPreset getRemoteSendMaxPreset(); - - /** - * Changes remote send preset. This doesn't have impact of current stream. - * But will have on next media changes. - * With this we can try to change the resolution that the remote part - * is sending. - * @param preset the new preset value. - */ - public void setRemoteSendMaxPreset(QualityPreset preset); - - /** - * Changes remote send preset and protocols who can handle the changes - * will implement this for re-inviting the other party or just sending that - * media has changed. - * @param preset the new preset. - * @throws OperationFailedException - */ - public void setPreferredRemoteSendMaxPreset(QualityPreset preset) - throws OperationFailedException; -} diff --git a/src/net/java/sip/communicator/service/neomedia/QualityPreset.java b/src/net/java/sip/communicator/service/neomedia/QualityPreset.java deleted file mode 100644 index efd91d988..000000000 --- a/src/net/java/sip/communicator/service/neomedia/QualityPreset.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.awt.*; - -/** - * Predefined quality preset used to specify some video settings during an - * existing call or when starting a new call. - * - * @author Damian Minkov - * @author Lyubomir Marinov - */ -public class QualityPreset - implements Comparable -{ - /** - * 720p HD - */ - public static final QualityPreset HD_QUALITY - = new QualityPreset(new Dimension(1280, 720), 30); - - /** - * Low - */ - public static final QualityPreset LO_QUALITY - = new QualityPreset(new Dimension(320, 240), 15); - - /** - * SD - */ - public static final QualityPreset SD_QUALITY - = new QualityPreset(new Dimension(640, 480), 20); - - /** - * The frame rate to use. - */ - private final float frameRate; - - /** - * The resolution to use. - */ - private final Dimension resolution; - - /** - * Initializes a new quality preset with a specific resolution and - * a specific frameRate. - * - * @param resolution the resolution - * @param frameRate the frame rate - */ - public QualityPreset(Dimension resolution, float frameRate) - { - this.frameRate = frameRate; - this.resolution = resolution; - } - - /** - * Initializes a new quality preset with a specific resolution and - * an unspecified frameRate. - * - * @param resolution the resolution - */ - public QualityPreset(Dimension resolution) - { - this(resolution, -1 /* unspecified */); - } - - /** - * Returns this preset frame rate. - * @return the frame rate. - */ - public float getFameRate() - { - return frameRate; - } - - /** - * Returns this preset resolution. - * @return the resolution. - */ - public Dimension getResolution() - { - return resolution; - } - - /** - * Compares to presets and its dimensions. - * @param o object to compare to. - * @return a negative integer, zero, or a positive integer as this object is - * less than, equal to, or greater than the specified object. - */ - public int compareTo(QualityPreset o) - { - if(resolution == null) - return -1; - else if(o == null) - return 1; - else if(resolution.equals(o.resolution)) - return 0; - else if((resolution.height < o.resolution.height) - && (resolution.width < o.resolution.width)) - return -1; - else - return 1; - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/RTPExtension.java b/src/net/java/sip/communicator/service/neomedia/RTPExtension.java deleted file mode 100644 index 02fab5ab4..000000000 --- a/src/net/java/sip/communicator/service/neomedia/RTPExtension.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.net.*; - -/** - * RTP extensions are defined by RFC 5285 and they allow attaching additional - * information to some or all RTP packets of an RTP stream. This class describes - * RTP extensions in a way that makes them convenient for use in SDP - * generation/parsing. - * - * @author Emil Ivov - */ -public class RTPExtension -{ - /** - * The direction that this extension will be transmitted in. - */ - private MediaDirection direction = MediaDirection.SENDRECV; - - /** - * The URI identifier of this extension. - */ - private final URI extensionURI; - - /** - * Extension specific attributes. - */ - private String extensionAttributes = null; - - /** - * The URN identifying the RTP extension that allows mixers to send to - * conference participants the audio levels of all contributing sources. - */ - public static final String CSRC_AUDIO_LEVEL_URN - = "urn:ietf:params:rtp-hdrext:csrc-audio-level"; - - /** - * The URN identifying the RTP extension that allows clients to send to - * conference mixers the audio level of their packet payload. - */ - public static final String SSRC_AUDIO_LEVEL_URN - = "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; - - /** - * Creates an RTPExtension instance for the specified - * extensionURI using a default SENDRECV direction and no - * extension attributes. - * - * @param extensionURI the URI (possibly a URN) of the RTP - * extension that we'd like to create. - */ - public RTPExtension(URI extensionURI) - { - this(extensionURI, MediaDirection.SENDRECV); - } - - /** - * Creates an RTPExtension instance for the specified - * extensionURI and direction. - * - * @param extensionURI the URI (possibly a URN) of the RTP - * extension that we'd like to create. - * @param direction a MediaDirection instance indication how this - * extension will be transmitted. - */ - public RTPExtension(URI extensionURI, MediaDirection direction) - { - this(extensionURI, direction, null); - } - - /** - * Creates an RTPExtension instance for the specified - * extensionURI using a default SENDRECV direction and - * extensionAttributes. - * - * @param extensionURI the URI (possibly a URN) of the RTP - * extension that we'd like to create. - * @param extensionAttributes any attributes that we'd like to add to this - * extension. - */ - public RTPExtension(URI extensionURI, String extensionAttributes) - { - this(extensionURI, MediaDirection.SENDRECV, extensionAttributes); - } - - /** - * Creates an RTPExtension instance for the specified - * extensionURI and direction and sets the specified - * extensionAttributes. - * - * @param extensionURI the URI (possibly a URN) of the RTP - * extension that we'd like to create. - * @param direction a MediaDirection instance indication how this - * extension will be transmitted. - * @param extensionAttributes any attributes that we'd like to add to this - * extension. - */ - public RTPExtension(URI extensionURI, - MediaDirection direction, - String extensionAttributes) - { - this.extensionURI = extensionURI; - this.direction = direction; - this.extensionAttributes = extensionAttributes; - } - - /** - * Returns the direction that the corresponding MediaDevice - * supports for this extension. By default RTP extension headers inherit - * the direction of a stream. When explicitly specified SENDONLY - * direction indicates an ability to attach the extension in outgoing RTP - * packets; a RECVONLY direction indicates a desire to receive - * the extension in incoming packets; a SENDRECV direction - * indicates both. An INACTIVE direction indicates neither, but - * later re-negotiation may make an extension active. - * - * @return the direction that the corresponding MediaDevice - * supports for this extension. - */ - public MediaDirection getDirection() - { - return direction; - } - - /** - * Returns the URI that identifies the format and meaning of this - * extension. - * - * @return the URI (possibly a URN) that identifies the format and - * meaning of this extension. - */ - public URI getURI() - { - return extensionURI; - } - - /** - * Returns the extension attributes associated with this - * RTPExtension or null if this extension does not have - * any. - * - * @return A String containing the extension attributes associated - * with this RTPExtension or null if this extension does - * not have any. - */ - public String getExtensionAttributes() - { - return extensionAttributes; - } - - /** - * Returns a String representation of this RTPExtension's - * URI. - * - * @return a String representation of this RTPExtension's - * URI. - */ - @Override - public String toString() - { - return extensionURI.toString() + ";" + getDirection(); - } - - /** - * Returns true if and only if o is an instance of - * RTPExtension and o's URI is equal to this - * extension's URI. The method returns false otherwise. - * - * @param o the Object that we'd like to compare to this - * RTPExtension. - * - * @return true when o's URI is equal to this - * extension's URI and false otherwise. - */ - @Override - public boolean equals(Object o) - { - return (o instanceof RTPExtension) - && ((RTPExtension)o).getURI().equals(getURI()); - } - - /** - * Returns the hash code of this extension instance which is actually the - * hash code of the URI that this extension is encapsulating. - * - * @return the hash code of this extension instance which is actually the - * hash code of the URI that this extension is encapsulating. - */ - @Override - public int hashCode() - { - return getURI().hashCode(); - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/RTPTranslator.java b/src/net/java/sip/communicator/service/neomedia/RTPTranslator.java deleted file mode 100644 index 5313b36b9..000000000 --- a/src/net/java/sip/communicator/service/neomedia/RTPTranslator.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -/** - * Represents an RTP translator which forwards RTP and RTCP traffic between - * multiple MediaStreams. - * - * @author Lyubomir Marinov - */ -public interface RTPTranslator -{ - /** - * Releases the resources allocated by this instance in the course of its - * execution and prepares it to be garbage collected. - */ - public void dispose(); -} diff --git a/src/net/java/sip/communicator/service/neomedia/Recorder.java b/src/net/java/sip/communicator/service/neomedia/Recorder.java deleted file mode 100644 index b7d5862e2..000000000 --- a/src/net/java/sip/communicator/service/neomedia/Recorder.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.io.*; -import java.util.*; - -/** - * The call recording interface. Provides the capability to start and stop call - * recording. - * - * @author Dmitri Melnikov - * @author Lubomir Marinov - */ -public interface Recorder -{ - /** - * The name of the configuration property the value of which specifies the - * full path to the directory with media recorded by Recorder (e.g. - * the media being sent and received in a Call). - */ - public static final String SAVED_CALLS_PATH - = "net.java.sip.communicator.impl.neomedia.SAVED_CALLS_PATH"; - - /** - * The name of the configuration property the value of which specifies the - * format in which media is to be recorded by Recorder (e.g. the - * media being sent and received in a Call). - */ - public static final String FORMAT - = "net.java.sip.communicator.impl.neomedia.Recorder.FORMAT"; - - /** - * Adds a new Listener to the list of listeners interested in - * notifications from this Recorder. - * - * @param listener the new Listener to be added to the list of - * listeners interested in notifications from this Recorder - */ - public void addListener(Listener listener); - - /** - * Gets a list of the formats in which this Recorder supports - * recording media. - * - * @return a List of the formats in which this Recorder - * supports recording media - */ - public List getSupportedFormats(); - - /** - * Removes an existing Listener from the list of listeners - * interested in notifications from this Recorder. - * - * @param listener the existing Listener to be removed from the - * list of listeners interested in notifications from this Recorder - */ - public void removeListener(Listener listener); - - /** - * Starts the recording of the media associated with this Recorder - * (e.g. the media being sent and received in a Call) into a file - * with a specific name. - * - * @param format the format into which the media associated with this - * Recorder is to be recorded into the specified file - * @param filename the name of the file into which the media associated with - * this Recorder is to be recorded - * @throws IOException if anything goes wrong with the input and/or output - * performed by this Recorder - * @throws MediaException if anything else goes wrong while starting the - * recording of media performed by this Recorder - */ - public void start(String format, String filename) - throws IOException, - MediaException; - - /** - * Stops the recording of the media associated with this Recorder - * (e.g. the media being sent and received in a Call) if it has - * been started and prepares this Recorder for garbage collection. - */ - public void stop(); - - /** - * Represents a listener interested in notifications from a Recorder. - * - * @author Lubomir Marinov - */ - public interface Listener - { - /** - * Notifies this Listener that a specific Recorder has - * stopped recording the media associated with it. - * - * @param recorder the Recorder which has stopped recording its - * associated media - */ - public void recorderStopped(Recorder recorder); - } - - /** - * Put the recorder in mute state. It won't record the local input. - * This is used when the local call is muted and we don't won't to record - * the local input. - * @param mute the new value of the mute property - */ - public void setMute(boolean mute); - - /** - * Returns the filename we are last started or stopped recording to, - * null if not started. - * @return the filename we are last started or stopped recording to, - * null if not started. - */ - public String getFilename(); -} diff --git a/src/net/java/sip/communicator/service/neomedia/SDesControl.java b/src/net/java/sip/communicator/service/neomedia/SDesControl.java deleted file mode 100644 index a0559b8a3..000000000 --- a/src/net/java/sip/communicator/service/neomedia/SDesControl.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import ch.imvs.sdes4j.srtp.SrtpCryptoAttribute; - -/** - * SDES based SRTP MediaStream encryption control. - * - * @author Ingo Bauersachs - */ -public interface SDesControl - extends SrtpControl -{ - /** - * Name of the config setting that supplies the default enabled cipher - * suites. Cipher suites are comma-separated. - */ - public static final String SDES_CIPHER_SUITES = - "net.java.sip.communicator.service.neomedia.SDES_CIPHER_SUITES"; - - /** - * Set the enabled SDES ciphers. - * - * @param ciphers The list of enabled ciphers. - */ - public void setEnabledCiphers(Iterable ciphers); - - /** - * Gets all supported cipher suites. - * - * @return all supported cipher suites. - */ - public Iterable getSupportedCryptoSuites(); - - /** - * Gets the encoded SDES crypto-attributes for all enabled ciphers when the - * control is used as the initiator. - * - * @return the encoded SDES crypto-attributes for all enabled ciphers. - */ - public String[] getInitiatorCryptoAttributes(); - - /** - * Chooses a supported crypto attribute from the peer's list of supplied - * attributes and creates the local crypto attribute. Used when the control - * is running in the role as responder. - * - * @param peerAttributes The peer's crypto attribute offering. - * @return The local crypto attribute for the answer of the offer or null if - * no matching cipher suite could be found. - */ - public String responderSelectAttribute(Iterable peerAttributes); - - /** - * Select the local crypto attribute from the initial offering (@see - * {@link #getInitiatorCryptoAttributes()}) based on the peer's first - * matching cipher suite. - * - * @param peerAttributes The peer's crypto offers. - * @return True when a matching cipher suite was found, false otherwise. - */ - public boolean initiatorSelectAttribute(Iterable peerAttributes); - - /** - * Gets the crypto attribute of the incoming MediaStream. - * @return the crypto attribute of the incoming MediaStream. - */ - public SrtpCryptoAttribute getInAttribute(); - - /** - * Gets the crypto attribute of the outgoing MediaStream. - * @return the crypto attribute of the outgoing MediaStream. - */ - public SrtpCryptoAttribute getOutAttribute(); -} diff --git a/src/net/java/sip/communicator/service/neomedia/SrtpControl.java b/src/net/java/sip/communicator/service/neomedia/SrtpControl.java deleted file mode 100644 index 6d04d9251..000000000 --- a/src/net/java/sip/communicator/service/neomedia/SrtpControl.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import net.java.sip.communicator.impl.neomedia.AbstractRTPConnector; -import net.java.sip.communicator.impl.neomedia.transform.TransformEngine; -import net.java.sip.communicator.service.neomedia.event.*; - -/** - * Controls SRTP encryption in the MediaStream. - * - * @author Damian Minkov - */ -public interface SrtpControl -{ - /** - * Cleans up the current SRTP control and its engine. - */ - public void cleanup(); - - /** - * Sets a SrtpListener that will listen for security events. - * - * @param srtpListener the SrtpListener that will receive the - * events - */ - public void setSrtpListener(SrtpListener srtpListener); - - /** - * Returns the SrtpListener which listens for security events. - * - * @return the SrtpListener which listens for security events - */ - public SrtpListener getSrtpListener(); - - /** - * Gets the default secure/insecure communication status for the supported - * call sessions. - * - * @return default secure communication status for the supported - * call sessions. - */ - public boolean getSecureCommunicationStatus(); - - /** - * When in multistream mode, enables the master session. - * @param masterSession whether current control, controls the master session. - */ - public void setMasterSession(boolean masterSession); - - /** - * Starts and enables zrtp in the stream holding this control. - * @param mediaType the media type of the stream this control controls. - */ - public void start(MediaType mediaType); - - /** - * Sets the multistream data, which means that the master stream - * has successfully started and this will start all other streams - * in this session. - * @param master The security control of the master stream. - */ - public void setMultistream(SrtpControl master); - - /** - * Returns the transform engine currently used by this stream. - * - * @return the RTP stream transformation engine - */ - public TransformEngine getTransformEngine(); - - /** - * Sets the RTPConnector which is to use or uses this SRTP engine. - * - * @param connector the RTPConnector which is to use or uses this - * SRTP engine - */ - public void setConnector(AbstractRTPConnector connector); - - /** - * Indicates if the key exchange method is dependent on secure transport of - * the signaling channel. - * - * @return True when secure signaling is required to make the encryption - * secure, false otherwise. - */ - public boolean requiresSecureSignalingTransport(); -} diff --git a/src/net/java/sip/communicator/service/neomedia/SrtpControlType.java b/src/net/java/sip/communicator/service/neomedia/SrtpControlType.java deleted file mode 100644 index d015017ba..000000000 --- a/src/net/java/sip/communicator/service/neomedia/SrtpControlType.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -/** - * The SrtpControlType enumeration contains all currently known - * SrtpControl implementations. - * - * @author Ingo Bauersachs - */ -public enum SrtpControlType -{ - /** - * Session Description Protocol (SDP) Security Descriptions for Media - * Streams (RFC 4568) - */ - SDES, - - /** - * ZRTP: Media Path Key Agreement for Unicast Secure RTP (RFC 6189) - */ - ZRTP, - - /** - * Multimedia Internet KEYing (RFC 3830) - */ - MIKEY -} diff --git a/src/net/java/sip/communicator/service/neomedia/StreamConnector.java b/src/net/java/sip/communicator/service/neomedia/StreamConnector.java deleted file mode 100644 index 027bb2dfd..000000000 --- a/src/net/java/sip/communicator/service/neomedia/StreamConnector.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.net.*; - -/** - * The StreamConnector interface represents a pair of datagram sockets - * that a media stream could use for RTP and RTCP traffic. - *

- * The reason why this media service makes sockets visible through this - * StreamConnector is so that they could be shared among media - * and other libraries that may need to use them like an ICE implementation for - * example. - * - * @author Emil Ivov - */ -public interface StreamConnector -{ - /** - * Enumerates the protocols supported by StreamConnector. - */ - public enum Protocol - { - /** - * UDP protocol. - */ - UDP, - - /** - * TCP protocol. - */ - TCP - } - - /** - * Returns a reference to the DatagramSocket that a stream should - * use for data (e.g. RTP) traffic. - * - * @return a reference to the DatagramSocket that a stream should - * use for data (e.g. RTP) traffic or null if this - * StreamConnector does not handle UDP sockets. - */ - public DatagramSocket getDataSocket(); - - /** - * Returns a reference to the DatagramSocket that a stream should - * use for control data (e.g. RTCP). - * - * @return a reference to the DatagramSocket that a stream should - * use for control data (e.g. RTCP) or null if this - * StreamConnector does not handle UDP sockets. - */ - public DatagramSocket getControlSocket(); - - /** - * Returns a reference to the Socket that a stream should - * use for data (e.g. RTP) traffic. - * - * @return a reference to the Socket that a stream should - * use for data (e.g. RTP) traffic or null if this - * StreamConnector does not handle TCP sockets. - */ - public Socket getDataTCPSocket(); - - /** - * Returns a reference to the Socket that a stream should - * use for control data (e.g. RTCP). - * - * @return a reference to the Socket that a stream should - * use for control data (e.g. RTCP) or null if this - * StreamConnector does not handle TCP sockets. - */ - public Socket getControlTCPSocket(); - - /** - * Returns the protocol of this StreamConnector. - * - * @return the protocol of this StreamConnector - */ - public Protocol getProtocol(); - - /** - * Releases the resources allocated by this instance in the course of its - * execution and prepares it to be garbage collected. - */ - public void close(); - - /** - * Notifies this instance that utilization of its DatagramSockets - * for data and/or control traffic has started. - */ - public void started(); - - /** - * Notifies this instance that utilization of its DatagramSockets - * for data and/or control traffic has temporarily stopped. This instance - * should be prepared to be started at a later time again though. - */ - public void stopped(); -} diff --git a/src/net/java/sip/communicator/service/neomedia/StreamConnectorDelegate.java b/src/net/java/sip/communicator/service/neomedia/StreamConnectorDelegate.java deleted file mode 100644 index 111923122..000000000 --- a/src/net/java/sip/communicator/service/neomedia/StreamConnectorDelegate.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.net.*; - -/** - * Implements a {@link StreamConnector} which wraps a specific - * StreamConnector instance. - * - * @param the very type of the StreamConnector wrapped by - * StreamConnectorDelegate - * - * @author Lyubomir Marinov - */ -public class StreamConnectorDelegate - implements StreamConnector -{ - /** - * The StreamConnector wrapped by this instance. - */ - protected final T streamConnector; - - /** - * Initializes a new StreamConnectorDelegate which is to wrap a - * specific StreamConnector. - * - * @param streamConnector the StreamConnector to be wrapped by the - * new instance - */ - public StreamConnectorDelegate(T streamConnector) - { - if (streamConnector == null) - throw new NullPointerException("streamConnector"); - - this.streamConnector = streamConnector; - } - - /** - * Releases the resources allocated by this instance in the course of its - * execution and prepares it to be garbage collected. Calls - * {@link StreamConnector#close()} on the StreamConnector wrapped - * by this instance. - */ - public void close() - { - streamConnector.close(); - } - - public DatagramSocket getControlSocket() - { - return streamConnector.getControlSocket(); - } - - public Socket getControlTCPSocket() - { - return streamConnector.getControlTCPSocket(); - } - - public DatagramSocket getDataSocket() - { - return streamConnector.getDataSocket(); - } - - public Socket getDataTCPSocket() - { - return streamConnector.getDataTCPSocket(); - } - - public Protocol getProtocol() - { - return streamConnector.getProtocol(); - } - - public void started() - { - streamConnector.started(); - } - - public void stopped() - { - streamConnector.stopped(); - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/StreamConnectorFactory.java b/src/net/java/sip/communicator/service/neomedia/StreamConnectorFactory.java deleted file mode 100644 index 3a662f9ad..000000000 --- a/src/net/java/sip/communicator/service/neomedia/StreamConnectorFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -/** - * Represents a factory of StreamConnector instances. - * - * @author Lyubomir Marinov - */ -public interface StreamConnectorFactory -{ - /** - * Initializes a StreamConnector instance. - * - * @return a StreamConnector instance - */ - public StreamConnector createStreamConnector(); -} diff --git a/src/net/java/sip/communicator/service/neomedia/VideoMediaStream.java b/src/net/java/sip/communicator/service/neomedia/VideoMediaStream.java deleted file mode 100644 index 851ac9499..000000000 --- a/src/net/java/sip/communicator/service/neomedia/VideoMediaStream.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import java.awt.*; -import java.util.*; -import java.util.List; - -import net.java.sip.communicator.service.neomedia.control.*; -import net.java.sip.communicator.util.event.*; - -/** - * Extends the MediaStream interface and adds methods specific to - * video streaming. - * - * @author Emil Ivov - * @author Lyubomir Marinov - */ -public interface VideoMediaStream - extends MediaStream -{ - /** - * Gets local visual Component of the local peer. - * - * @param flipLocalVideoDisplay Tells to flip the local video display (true, - * in case of diplaying the webcam as a mirror), or not (false, for desktop - * streaming). - * - * @return visual Component - */ - public Component createLocalVisualComponent(boolean flipLocalVideoDisplay); - - /** - * Disposes of a specific local visual Component of the local peer. - * - * @param component the local visual Component of the local peer to - * dispose of - */ - public void disposeLocalVisualComponent(Component component); - - /** - * Gets the visual Component where video from the remote peer is - * being rendered or null if no video is currently being rendered. - * - * @return the visual Component where video from the remote peer is - * being rendered or null if no video is currently being rendered - */ - @Deprecated - public Component getVisualComponent(); - - /** - * Gets a list of the visual Components where video from the remote - * peer is being rendered. - * - * @return a list of the visual Components where video from the - * remote peer is being rendered - */ - public List getVisualComponents(); - - /** - * Gets the visual Components rendering the ReceiveStream - * corresponding to the given ssrc. - * - * @param ssrc the src-id of the receive stream, which visual - * Component we're looking for - * @return the visual Component rendering the - * ReceiveStream corresponding to the given ssrc - */ - public Component getVisualComponent(long ssrc); - - /** - * Adds a specific VideoListener to this VideoMediaStream - * in order to receive notifications when visual/video Components - * are being added and removed. - *

- * Adding a listener which has already been added does nothing i.e. it is - * not added more than once and thus does not receive one and the same - * VideoEvent multiple times - *

- * - * @param listener the VideoListener to be notified when - * visual/video Components are being added or removed in this - * VideoMediaStream - */ - public void addVideoListener(VideoListener listener); - - /** - * Removes a specific VideoListener from this - * VideoMediaStream in order to have to no longer receive - * notifications when visual/video Components are being added and - * removed. - * - * @param listener the VideoListener to no longer be notified when - * visual/video Components are being added or removed in this - * VideoMediaStream - */ - public void removeVideoListener(VideoListener listener); - - /** - * Gets the KeyFrameControl of this VideoMediaStream. - * - * @return the KeyFrameControl of this VideoMediaStream - */ - public KeyFrameControl getKeyFrameControl(); - - /** - * Gets the QualityControl of this VideoMediaStream. - * - * @return the QualityControl of this VideoMediaStream - */ - public QualityControl getQualityControl(); - - /** - * Updates the QualityControl of this VideoMediaStream. - * - * @param advancedParams parameters of advanced attributes that may affect - * quality control - */ - public void updateQualityControl( - Map advancedParams); - - /** - * Move origin of a partial desktop streaming MediaDevice. - * - * @param x new x coordinate origin - * @param y new y coordinate origin - */ - public void movePartialDesktopStreaming( - int x, int y); -} diff --git a/src/net/java/sip/communicator/service/neomedia/VolumeControl.java b/src/net/java/sip/communicator/service/neomedia/VolumeControl.java deleted file mode 100644 index 229456975..000000000 --- a/src/net/java/sip/communicator/service/neomedia/VolumeControl.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -import net.java.sip.communicator.service.neomedia.event.*; - -/** - * Control for volume level in media service. - * - * @author Damian Minkov - */ -public interface VolumeControl -{ - /** - * The name of the configuration property which specifies the volume level - * of audio input. - */ - public final static String CAPTURE_VOLUME_LEVEL_PROPERTY_NAME - = "net.java.sip.communicator.service.media.CAPTURE_VOLUME_LEVEL"; - - /** - * The name of the configuration property which specifies the volume level - * of audio output. - */ - public final static String PLAYBACK_VOLUME_LEVEL_PROPERTY_NAME - = "net.java.sip.communicator.service.media.PLAYBACK_VOLUME_LEVEL"; - - /** - * Current volume value. - * @return the current volume level. - */ - public float getVolume(); - - /** - * Returns the minimum allowed volume value. - * @return the minimum allowed volume value. - */ - public float getMinValue(); - - /** - * Returns the maximum allowed volume value. - * @return the maximum allowed volume value. - */ - public float getMaxValue(); - - /** - * Changes volume level. - * @param value the new level to set. - * @return the actual level which was set. - */ - public float setVolume(float value); - - /** - * Mutes current sound playback. - * @param mute mutes/unmutes playback. - */ - public void setMute(boolean mute); - - /** - * Get mute state of sound playback. - * @return mute state of sound playback. - */ - public boolean getMute(); - - /** - * Adds a VolumeChangeListener to be informed for any change - * in the volume levels. - * - * @param listener volume change listener. - */ - public void addVolumeChangeListener(VolumeChangeListener listener); - - /** - * Removes a VolumeChangeListener. - * @param listener the volume change listener to be removed. - */ - public void removeVolumeChangeListener(VolumeChangeListener listener); -} diff --git a/src/net/java/sip/communicator/service/neomedia/ZrtpControl.java b/src/net/java/sip/communicator/service/neomedia/ZrtpControl.java deleted file mode 100644 index c6b1efdc0..000000000 --- a/src/net/java/sip/communicator/service/neomedia/ZrtpControl.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia; - -/** - * ZRTP based SRTP MediaStream encryption control. - * - * @author Damian Minkov - */ -public interface ZrtpControl - extends SrtpControl -{ - /** - * Return the zrtp hello hash String. - * - * @return String the zrtp hello hash. - */ - public String getHelloHash(); - - /** - * Get the ZRTP Hello Hash data - separate strings. - * - * @return String array containing the version string at offset 0, the Hello - * hash value as hex-digits at offset 1. Hello hash is available - * immediately after class instantiation. Returns null - * if ZRTP is not available. - */ - public String[] getHelloHashSep(); - - /** - * Gets the SAS for the current media stream. - * - * @return the four character ZRTP SAS. - */ - public String getSecurityString(); - - /** - * Gets the cipher information for the current media stream. - * - * @return the cipher information string. - */ - public String getCipherString(); - - /** - * Gets the status of the SAS verification. - * - * @return true when the SAS has been verified. - */ - public boolean isSecurityVerified(); - - /** - * Sets the SAS verification - * - * @param verified the new SAS verification status - */ - public void setSASVerification(boolean verified); - - /** - * Returns the timeout value that will we will wait - * and fire timeout secure event if call is not secured. - * The value is in milliseconds. - * @return the timeout value that will we will wait - * and fire timeout secure event if call is not secured. - */ - public long getTimeoutValue(); - - /** - * Get other party's ZID (ZRTP Identifier) data - * - * This functions returns the other party's ZID that was receivied during - * ZRTP processing. - * - * The ZID data can be retrieved after ZRTP receive the first Hello packet - * from the other party. - * - * @return the ZID data as byte array. - */ - public byte[] getPeerZid(); - - /** - * Get other party's ZID (ZRTP Identifier) data as String - * - * This functions returns the other party's ZID that was receivied during - * ZRTP processing. - * - * The ZID data can be retrieved after ZRTP receive the first Hello packet - * from the other party. - * - * @return the ZID data as String. - */ - public String getPeerZidString(); -} diff --git a/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControl.java b/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControl.java deleted file mode 100644 index c3b4facd5..000000000 --- a/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControl.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.control; - -import java.util.*; - -/** - * Represents a control over the key frame-related logic of a - * VideoMediaStream. - * - * @author Lyubomir Marinov - */ -public interface KeyFrameControl -{ - /** - * Adds a KeyFrameRequestee to be made available through this - * KeyFrameControl. - * - * @param index the zero-based index at which keyFrameRequestee is - * to be added to the list of KeyFrameRequestees made available or - * -1 to have this KeyFrameControl choose at which index - * it is to be added in accord with its internal logic - * through this KeyFrameControl - * @param keyFrameRequestee the KeyFrameRequestee to be added to - * this KeyFrameControl so that it is made available through it - */ - public void addKeyFrameRequestee( - int index, - KeyFrameRequestee keyFrameRequestee); - - /** - * Adds a KeyFrameRequester to be made available through this - * KeyFrameControl. - * - * @param index the zero-based index at which keyFrameRequester is - * to be added to the list of KeyFrameRequesters made available or - * -1 to have this KeyFrameControl choose at which index - * it is to be added in accord with its internal logic - * through this KeyFrameControl - * @param keyFrameRequester the KeyFrameRequester to be added to - * this KeyFrameControl so that it is made available through it - */ - public void addKeyFrameRequester( - int index, - KeyFrameRequester keyFrameRequester); - - /** - * Gets the KeyFrameRequestees made available through this - * KeyFrameControl. - * - * @return an unmodifiable list of KeyFrameRequestees made - * available through this KeyFrameControl - */ - public List getKeyFrameRequestees(); - - /** - * Gets the KeyFrameRequesters made available through this - * KeyFrameControl. - * - * @return an unmodifiable list of KeyFrameRequesters made - * available through this KeyFrameControl - */ - public List getKeyFrameRequesters(); - - /** - * Notifies this KeyFrameControl that the remote peer of the - * associated VideoMediaStream has requested a key frame from the - * local peer. - * - * @return true if the local peer has honored the request from the - * remote peer for a key frame; otherwise, false - */ - public boolean keyFrameRequest(); - - /** - * Removes a KeyFrameRequestee to no longer be made available - * through this KeyFrameControl. - * - * @param keyFrameRequestee the KeyFrameRequestee to be removed - * from this KeyFrameControl so that it is no longer made available - * through it - * @return true if keyFrameRequestee was found in this - * KeyFrameControl; otherwise, false - */ - public boolean removeKeyFrameRequestee(KeyFrameRequestee keyFrameRequestee); - - /** - * Removes a KeyFrameRequester to no longer be made available - * through this KeyFrameControl. - * - * @param keyFrameRequester the KeyFrameRequester to be removed - * from this KeyFrameControl so that it is no longer made available - * through it - * @return true if keyFrameRequester was found in this - * KeyFrameControl; otherwise, false - */ - public boolean removeKeyFrameRequester(KeyFrameRequester keyFrameRequester); - - /** - * Requests a key frame from the remote peer of the associated - * VideoMediaStream. - * - * @param urgent true if the caller has determined that the need - * for a key frame is urgent and should not obey all constraints with - * respect to time between two subsequent requests for key frames - * @return true if a key frame was indeed requested from the remote - * peer of the associated VideoMediaStream in response to the call; - * otherwise, false - */ - public boolean requestKeyFrame(boolean urgent); - - /** - * Represents a way for the remote peer of a VideoMediaStream to - * request a key frame from its local peer. - * - * @author Lyubomir Marinov - */ - public interface KeyFrameRequestee - { - /** - * Notifies this KeyFrameRequestee that the remote peer of the - * associated VideoMediaStream requests a key frame from the - * local peer. - * - * @return true if this KeyFrameRequestee has honored - * the request for a key frame; otherwise, false - */ - public boolean keyFrameRequest(); - } - - /** - * Represents a way for a VideoMediaStream to request a key frame - * from its remote peer. - * - * @author Lyubomir Marinov - */ - public interface KeyFrameRequester - { - /** - * The name of the ConfigurationService property which - * specifies the preferred KeyFrameRequester to be used. - */ - public static final String PREFERRED_PNAME - = "net.java.sip.communicator.impl.neomedia.codec.video.h264." - + "preferredKeyFrameRequester"; - - /** - * The value of the {@link #PREFERRED_PNAME} - * ConfigurationService property which indicates that the - * RTCP KeyFrameRequester is preferred. - */ - public static final String RTCP = "rtcp"; - - /** - * The value of the {@link #PREFERRED_PNAME} - * ConfigurationService property which indicates that the - * signaling/protocol KeyFrameRequester is preferred. - */ - public static final String SIGNALING = "signaling"; - - /** - * The default value of the {@link #PREFERRED_PNAME} - * ConfigurationService property. - */ - public static final String DEFAULT_PREFERRED = RTCP; - - /** - * Requests a key frame from the remote peer of the associated - * VideoMediaStream. - * - * @return true if this KeyFrameRequester has - * indeed requested a key frame from the remote peer of the associated - * VideoMediaStream in response to the call; otherwise, - * false - */ - public boolean requestKeyFrame(); - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControlAdapter.java b/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControlAdapter.java deleted file mode 100644 index b6682d9a3..000000000 --- a/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControlAdapter.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.control; - -import java.util.*; - -/** - * Provides a default implementation of {@link KeyFrameControl}. - * - * @author Lyubomir Marinov - */ -public class KeyFrameControlAdapter - implements KeyFrameControl -{ - /** - * The KeyFrameRequestees made available by this - * KeyFrameControl. - */ - private List keyFrameRequestees - = new ArrayList(0); - - /** - * The KeyFrameRequesters made available by this - * KeyFrameControl. - */ - private List keyFrameRequesters - = new ArrayList(0); - - /** - * An unmodifiable view of {@link #keyFrameRequestees} appropriate to be - * returned by {@link #getKeyFrameRequestees()}. - */ - private List unmodifiableKeyFrameRequestees; - - /** - * An unmodifiable view of {@link #keyFrameRequesters} appropriate to be - * returned by {@link #getKeyFrameRequesters()}. - */ - private List unmodifiableKeyFrameRequesters; - - /** - * Implements - * {@link KeyFrameControl#addKeyFrameRequestee(int, KeyFrameRequestee)}. - * - * {@inheritDoc} - */ - public void addKeyFrameRequestee( - int index, - KeyFrameRequestee keyFrameRequestee) - { - if (keyFrameRequestee == null) - throw new NullPointerException("keyFrameRequestee"); - synchronized (this) - { - if (!keyFrameRequestees.contains(keyFrameRequestee)) - { - List newKeyFrameRequestees - = new ArrayList( - keyFrameRequestees.size() + 1); - - newKeyFrameRequestees.addAll(keyFrameRequestees); - /* - * If this KeyFrameControl is to determine the index at which - * keyFrameRequestee is to be added according to its own - * internal logic, then it will prefer KeyFrameRequestee - * implementations from outside of neomedia rather than from its - * inside. - */ - if (-1 == index) - { - if (keyFrameRequestee.getClass().getName().contains( - ".neomedia.")) - index = newKeyFrameRequestees.size(); - else - index = 0; - } - newKeyFrameRequestees.add(index, keyFrameRequestee); - - keyFrameRequestees = newKeyFrameRequestees; - unmodifiableKeyFrameRequestees = null; - } - } - } - - /** - * Implements - * {@link KeyFrameControl#addKeyFrameRequester(int, KeyFrameRequester)}. - * - * {@inheritDoc} - */ - public void addKeyFrameRequester( - int index, - KeyFrameRequester keyFrameRequester) - { - if (keyFrameRequester == null) - throw new NullPointerException("keyFrameRequester"); - synchronized (this) - { - if (!keyFrameRequesters.contains(keyFrameRequester)) - { - List newKeyFrameRequesters - = new ArrayList( - keyFrameRequesters.size() + 1); - - newKeyFrameRequesters.addAll(keyFrameRequesters); - /* - * If this KeyFrameControl is to determine the index at which - * keyFrameRequester is to be added according to its own - * internal logic, then it will prefer KeyFrameRequester - * implementations from outside of neomedia rather than from its - * inside. - */ - if (-1 == index) - { - if (keyFrameRequester.getClass().getName().contains( - ".neomedia.")) - index = newKeyFrameRequesters.size(); - else - index = 0; - } - newKeyFrameRequesters.add(index, keyFrameRequester); - - keyFrameRequesters = newKeyFrameRequesters; - unmodifiableKeyFrameRequesters = null; - } - } - } - - /** - * Implements {@link KeyFrameControl#getKeyFrameRequestees()}. - * - * {@inheritDoc} - */ - public List getKeyFrameRequestees() - { - synchronized (this) - { - if (unmodifiableKeyFrameRequestees == null) - { - unmodifiableKeyFrameRequestees - = Collections.unmodifiableList(keyFrameRequestees); - } - return unmodifiableKeyFrameRequestees; - } - } - - /** - * Implements {@link KeyFrameControl#getKeyFrameRequesters()}. - * - * {@inheritDoc} - */ - public List getKeyFrameRequesters() - { - synchronized (this) - { - if (unmodifiableKeyFrameRequesters == null) - { - unmodifiableKeyFrameRequesters - = Collections.unmodifiableList(keyFrameRequesters); - } - return unmodifiableKeyFrameRequesters; - } - } - - /** - * Implements {@link KeyFrameControl#keyFrameRequest()}. - * - * {@inheritDoc} - */ - public boolean keyFrameRequest() - { - for (KeyFrameRequestee keyFrameRequestee : getKeyFrameRequestees()) - { - try - { - if (keyFrameRequestee.keyFrameRequest()) - return true; - } - catch (Exception e) - { - /* - * A KeyFrameRequestee has malfunctioned, do not let it - * interfere with the others. - */ - } - } - return false; - } - - /** - * Implements - * {@link KeyFrameControl#removeKeyFrameRequestee(KeyFrameRequestee)}. - * - * {@inheritDoc} - */ - public boolean removeKeyFrameRequestee(KeyFrameRequestee keyFrameRequestee) - { - synchronized (this) - { - int index = keyFrameRequestees.indexOf(keyFrameRequestee); - - if (-1 != index) - { - List newKeyFrameRequestees - = new ArrayList(keyFrameRequestees); - - newKeyFrameRequestees.remove(index); - - keyFrameRequestees = newKeyFrameRequestees; - unmodifiableKeyFrameRequestees = null; - - return true; - } - else - return false; - } - } - - /** - * Implements - * {@link KeyFrameControl#removeKeyFrameRequester(KeyFrameRequester)}. - * - * {@inheritDoc} - */ - public boolean removeKeyFrameRequester(KeyFrameRequester keyFrameRequester) - { - synchronized (this) - { - int index = keyFrameRequesters.indexOf(keyFrameRequester); - - if (-1 != index) - { - List newKeyFrameRequesters - = new ArrayList(keyFrameRequesters); - - newKeyFrameRequesters.remove(index); - - keyFrameRequesters = newKeyFrameRequesters; - unmodifiableKeyFrameRequesters = null; - - return true; - } - else - return false; - } - } - - /** - * Implements {@link KeyFrameControl#requestKeyFrame(boolean)}. - * - * {@inheritDoc} - */ - public boolean requestKeyFrame(boolean urgent) - { - for (KeyFrameRequester keyFrameRequester : getKeyFrameRequesters()) - { - try - { - if (keyFrameRequester.requestKeyFrame()) - return true; - } - catch (Exception e) - { - /* - * A KeyFrameRequestee has malfunctioned, do not let it - * interfere with the others. - */ - } - } - return false; - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/device/MediaDevice.java b/src/net/java/sip/communicator/service/neomedia/device/MediaDevice.java deleted file mode 100644 index 96cb75447..000000000 --- a/src/net/java/sip/communicator/service/neomedia/device/MediaDevice.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.device; - -import java.util.*; - -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.format.*; - -/** - * The MediaDevice class represents capture and playback devices that - * can be used to grab or render media. Sound cards, USB phones and webcams are - * examples of such media devices. - * - * @author Emil Ivov - */ -public interface MediaDevice -{ - - /** - * Returns the MediaDirection supported by this device. - * - * @return MediaDirection.SENDONLY if this is a read-only device, - * MediaDirection.RECVONLY if this is a write-only device and - * MediaDirection.SENDRECV if this MediaDevice can both - * capture and render media. - */ - public MediaDirection getDirection(); - - /** - * Returns the MediaFormat that this device is currently set to use - * when capturing data. - * - * @return the MediaFormat that this device is currently set to - * provide media in. - */ - public MediaFormat getFormat(); - - /** - * Returns the MediaType that this device supports. - * - * @return MediaType.AUDIO if this is an audio device or - * MediaType.VIDEO in case of a video device. - */ - public MediaType getMediaType(); - - /** - * Returns the List of RTPExtensions that this device - * know how to handle. - * - * @return the List of RTPExtensions that this device - * know how to handle or null if the device does not support any - * RTP extensions. - */ - public List getSupportedExtensions(); - - /** - * Returns a list of MediaFormat instances representing the media - * formats supported by this MediaDevice. - * - * @return the list of MediaFormats supported by this device. - */ - public List getSupportedFormats(); - - /** - * Returns a list of MediaFormat instances representing the media - * formats supported by this MediaDevice. - * - * @param localPreset the preset used to set the send format parameters, - * used for video and settings. - * @param remotePreset the preset used to set the receive format parameters, - * used for video and settings. - * - * @return the list of MediaFormats supported by this device. - */ - public List getSupportedFormats( - QualityPreset localPreset, - QualityPreset remotePreset); -} diff --git a/src/net/java/sip/communicator/service/neomedia/device/MediaDeviceWrapper.java b/src/net/java/sip/communicator/service/neomedia/device/MediaDeviceWrapper.java deleted file mode 100644 index 2dee70ea6..000000000 --- a/src/net/java/sip/communicator/service/neomedia/device/MediaDeviceWrapper.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.device; - -/** - * Represents a special-purpose MediaDevice which is effectively built - * on top of and forwarding to another MediaDevice. - * - * @author Lyubomir Marinov - */ -public interface MediaDeviceWrapper - extends MediaDevice -{ - /** - * Gets the actual MediaDevice which this MediaDevice is - * effectively built on top of and forwarding to. - * - * @return the actual MediaDevice which this MediaDevice - * is effectively built on top of and forwarding to - */ - public MediaDevice getWrappedDevice(); -} diff --git a/src/net/java/sip/communicator/service/neomedia/device/ScreenDevice.java b/src/net/java/sip/communicator/service/neomedia/device/ScreenDevice.java deleted file mode 100644 index e481d345b..000000000 --- a/src/net/java/sip/communicator/service/neomedia/device/ScreenDevice.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.device; - -import java.awt.*; - -/** - * Represents a physical screen display. - * - * @author Sebastien Vincent - */ -public interface ScreenDevice -{ - - /** - * Determines whether this screen contains a specified point. - * - * @param p point coordinate - * @return true if point belongs to this screen; - * false, otherwise - */ - public boolean containsPoint(Point p); - - /** - * Gets this screen's index. - * - * @return this screen's index - */ - public int getIndex(); - - /** - * Gets the current resolution of this screen. - * - * @return the current resolution of this screen - */ - public Dimension getSize(); -} diff --git a/src/net/java/sip/communicator/service/neomedia/event/CsrcAudioLevelListener.java b/src/net/java/sip/communicator/service/neomedia/event/CsrcAudioLevelListener.java deleted file mode 100644 index 1644f5641..000000000 --- a/src/net/java/sip/communicator/service/neomedia/event/CsrcAudioLevelListener.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.event; - -/** - * The CsrcAudioLevelListener delivers audio level events reported by - * the remote party in cases where it (the remote party) is acting as a mixer, - * mixing flows from numerous contributors. It is up to upper layers such as - * SIP to define means of determining the exact members that the CSRC IDs and - * hence audio levels participants belong to. - * - * @author Emil Ivov - */ -public interface CsrcAudioLevelListener -{ - /** - * Called by the media service implementation after it has received audio - * levels for the various participants (Contributing SouRCes) that are - * taking part in a conference call. - * - * @param audioLevels a long array in which the elements at the - * even indices specify the CSRC IDs and the elements at the odd indices - * specify the respective audio levels - */ - public void audioLevelsReceived(long[] audioLevels); -} diff --git a/src/net/java/sip/communicator/service/neomedia/event/DTMFListener.java b/src/net/java/sip/communicator/service/neomedia/event/DTMFListener.java deleted file mode 100644 index 4a6156958..000000000 --- a/src/net/java/sip/communicator/service/neomedia/event/DTMFListener.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.event; - -/** - * The purpose of a DTMFListener is to notify implementors when new - * DMTF tones are received by this MediaService implementation. - * - * @author Emil Ivov - */ -public interface DTMFListener -{ - - /** - * Indicates that we have started receiving a DTMFTone. - * - * @param event the DTMFToneEvent instance containing the - * DTMFTone - */ - public void dtmfToneReceptionStarted(DTMFToneEvent event); - - /** - * Indicates that reception of a DTMF tone has stopped. - * - * @param event the DTMFToneEvent instance containing the - * DTMFTone - */ - public void dtmfToneReceptionEnded(DTMFToneEvent event); -} diff --git a/src/net/java/sip/communicator/service/neomedia/event/DTMFToneEvent.java b/src/net/java/sip/communicator/service/neomedia/event/DTMFToneEvent.java deleted file mode 100644 index 48b11b85a..000000000 --- a/src/net/java/sip/communicator/service/neomedia/event/DTMFToneEvent.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.event; - -import java.util.*; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * This event represents starting or ending reception of a specific - * DTMFRtpTone. - * - * @author Emil Ivov - */ -public class DTMFToneEvent - extends EventObject -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * The tone that this event is pertaining to. - */ - private final DTMFRtpTone dtmfTone; - - /** - * Creates an instance of this DTMFToneEvent with the specified - * source stream and DTMF tone. - * - * @param source the AudioMediaSteam instance that received the - * tone. - * @param dtmfTone the tone that we (started/stopped) receiving. - */ - public DTMFToneEvent(AudioMediaStream source, DTMFRtpTone dtmfTone) - { - super(source); - - this.dtmfTone = dtmfTone; - } - - /** - * Returns the DTMFTone instance that this event pertains to. - * - * @return the DTMFTone instance that this event pertains to. - */ - public DTMFRtpTone getDtmfTone() - { - return dtmfTone; - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/event/RTCPFeedbackEvent.java b/src/net/java/sip/communicator/service/neomedia/event/RTCPFeedbackEvent.java deleted file mode 100644 index 6db18ea8f..000000000 --- a/src/net/java/sip/communicator/service/neomedia/event/RTCPFeedbackEvent.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.event; - -import java.util.*; - -/** - * Represents an event coming from RTCP that meant to tell codec - * to do something (i.e send a keyframe, ...). - * - * @author Sebastien Vincent - */ -public class RTCPFeedbackEvent - extends EventObject -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * Transport layer type (payload type). - */ - public static final int PT_TL = 205; - - /** - * Payload-specific type (payload type). - */ - public static final int PT_PS = 206; - - /** - * Picture Loss Indication message type. - */ - public static final int FMT_PLI = 1; - - /** - * Full Intra-frame Request message type. - */ - public static final int FMT_FIR = 4; - - /** - * Feedback message type. - */ - private int feedbackMessageType = 0; - - /** - * Payload type. - */ - private int payloadType = 0; - - /** - * Constructor. - * - * @param src source - * @param feedbackMessageType FMT - * @param payloadType PT - */ - public RTCPFeedbackEvent(Object src, int feedbackMessageType, - int payloadType) - { - super(src); - - this.feedbackMessageType = feedbackMessageType; - this.payloadType = payloadType; - } - - /** - * Get feedback message type. - * - * @return message type - */ - public int getFeedbackMessageType() - { - return feedbackMessageType; - } - - /** - * Get payload type of RTCP packet. - * - * @return payload type - */ - public int getPayloadType() - { - return payloadType; - } -} - diff --git a/src/net/java/sip/communicator/service/neomedia/event/RTCPFeedbackListener.java b/src/net/java/sip/communicator/service/neomedia/event/RTCPFeedbackListener.java deleted file mode 100644 index c94e14744..000000000 --- a/src/net/java/sip/communicator/service/neomedia/event/RTCPFeedbackListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.event; - -/** - * RTCPFeedbackListener is used by codec to be notified - * by RTCP feedback event such as PLI (Picture Loss Indication) or - * FIR (Full Intra-frame Request). - * - * @author Sebastien Vincent - */ -public interface RTCPFeedbackListener -{ - /** - * Event fired when RTCP feedback message is received. - * - * @param event RTCPFeedbackEvent - */ - public void feedbackReceived(RTCPFeedbackEvent event); -} - diff --git a/src/net/java/sip/communicator/service/neomedia/event/SimpleAudioLevelListener.java b/src/net/java/sip/communicator/service/neomedia/event/SimpleAudioLevelListener.java deleted file mode 100644 index 0f33048b2..000000000 --- a/src/net/java/sip/communicator/service/neomedia/event/SimpleAudioLevelListener.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.event; - -/** - * A very simple listener that delivers int values every time the audio - * level of an audio source changes. - * - * @author Emil Ivov - */ -public interface SimpleAudioLevelListener -{ - /** - * The maximum level that can be reported for a participant in a conference. - * Level values should be distributed between MAX_LEVEL and - * {@link #MIN_LEVEL} in a way that would appear uniform to users. - *
- */ - public static final int MAX_LEVEL = 127; - - /** - * The maximum (zero) level that can be reported for a participant in a - * conference. Level values should be distributed among {@link #MAX_LEVEL} - * and MIN_LEVEL in a way that would appear uniform to users. - *

- * Note: The value of 127 is specifically chosen as the - * value of MAX_LEVEL because (1) we transport the levels within - * RTP and it gives us a signed byte for it, and (2) the range of - * [0, 127] is pretty good to directly express the sound pressure - * level decibels as heard by humans in Earth's atmosphere. - *

- * Note: The value of 0 is specifically chosen as the value - * of MIN_LEVEL because (1) we transport the levels within RTP and - * it gives us a signed byte for it, and (2) the range of - * [0, 127] is pretty good to directly express the sound pressure - * level decibels as heard by humans in Earth's atmosphere. - *

- */ - public static final int MIN_LEVEL = 0; - - /** - * Indicates a new audio level for the source that this listener was - * registered with. - * @param level the new/current level of the audio source that this - * listener is registered with. - */ - public void audioLevelChanged(int level); -} diff --git a/src/net/java/sip/communicator/service/neomedia/event/SrtpListener.java b/src/net/java/sip/communicator/service/neomedia/event/SrtpListener.java deleted file mode 100644 index 0e291123d..000000000 --- a/src/net/java/sip/communicator/service/neomedia/event/SrtpListener.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.event; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * The ZrtpListener is meant to be used by the media stream creator, as - * the name indicates in order to be notified when a security event has occurred - * that concerns ZRTP. - * - * @author Yana Stamcheva - */ -public interface SrtpListener -{ - /** - * Indicates that the security has been turned on. When we are in the case - * of using multistreams when the master stream ZRTP is initialized and - * established the param multiStreamData holds the data needed for the - * slave streams to establish their sessions. If this is a securityTurnedOn - * event on non master stream the multiStreamData is null. - * - * @param sessionType the type of the call session - audio or video. - * @param cipher the security cipher that encrypts the call - * @param sender the control that initiated the event. - */ - public void securityTurnedOn( int sessionType, - String cipher, - SrtpControl sender); - - /** - * Indicates that the security has been turned off. - * - * @param sessionType the type of the call session - audio or video. - */ - public void securityTurnedOff(int sessionType); - - /** - * Indicates that a security message has occurred associated with a - * failure/warning or information coming from the encryption protocol. - * - * @param message the message. - * @param i18nMessage the internationalized message - * @param severity severity level - */ - public void securityMessageReceived(String message, - String i18nMessage, - int severity); - - /** - * Indicates that the other party has timed out replying to our - * offer to secure the connection. - * - * @param sessionType the type of the call session - audio or video. - */ - public void securityTimeout(int sessionType); - - /** - * Indicates that we started the process of securing the the connection. - * - * @param sessionType the type of the call session - audio or video. - * @param sender the control that initiated the event. - */ - public void securityNegotiationStarted(int sessionType, SrtpControl sender); -} diff --git a/src/net/java/sip/communicator/service/neomedia/event/VolumeChangeEvent.java b/src/net/java/sip/communicator/service/neomedia/event/VolumeChangeEvent.java deleted file mode 100644 index 9347d3dbb..000000000 --- a/src/net/java/sip/communicator/service/neomedia/event/VolumeChangeEvent.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.event; - -import java.util.*; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * Represents the event fired when playback volume value has changed. - * - * @author Damian Minkov - */ -public class VolumeChangeEvent - extends EventObject -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * The volume level. - */ - private final float level; - - /** - * The indicator which determines whether the volume is muted. - */ - private final boolean mute; - - /** - * Initializes a new VolumeChangeEvent which is to notify about a - * specific volume level and its mute state. - * - * @param source the VolumeControl which is the source of the - * change - * @param level the volume level - * @param mute true if the volume is muted; otherwise, - * false - * @throws IllegalArgumentException if source is null - */ - public VolumeChangeEvent(VolumeControl source, float level, boolean mute) - { - super(source); - - this.level = level; - this.mute = mute; - } - - /** - * Gets the VolumeControl which is the source of the change - * notified about by this VolumeChangeEvent. - * - * @return the VolumeControl which is the source of the change - * notified about by this VolumeChangeEvent - */ - public VolumeControl getSourceVolumeControl() - { - return (VolumeControl) getSource(); - } - - /** - * Gets the volume level notified about by this VolumeChangeEvent. - * - * @return the volume level notified about by this - * VolumeChangeEvent - */ - public float getLevel() - { - return level; - } - - /** - * Gets the indicator which determines whether the volume is muted. - * - * @return true if the volume is muted; otherwise, false - */ - public boolean getMute() - { - return mute; - } -} diff --git a/src/net/java/sip/communicator/service/neomedia/event/VolumeChangeListener.java b/src/net/java/sip/communicator/service/neomedia/event/VolumeChangeListener.java deleted file mode 100644 index 7db9568dd..000000000 --- a/src/net/java/sip/communicator/service/neomedia/event/VolumeChangeListener.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.event; - -/** - * VolumeChangeListener used to notify for changes in the - * playback volume. - * - * @author Damian Minkov - */ -public interface VolumeChangeListener -{ - /** - * Event fired when volume has changed. - * @param volumeChangeEvent the volume change event. - */ - public void volumeChange(VolumeChangeEvent volumeChangeEvent); -} diff --git a/src/net/java/sip/communicator/service/neomedia/format/AudioMediaFormat.java b/src/net/java/sip/communicator/service/neomedia/format/AudioMediaFormat.java deleted file mode 100644 index 46a64c75c..000000000 --- a/src/net/java/sip/communicator/service/neomedia/format/AudioMediaFormat.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.format; - -/** - * The interface represents an audio format. Audio formats characterize audio - * streams and the AudioMediaFormat interface gives access to some of its - * properties such as encoding, clock rate, and number of channels. - * - * @author Emil Ivov - */ -public interface AudioMediaFormat - extends MediaFormat -{ - /** - * Returns the number of audio channels associated with this - * AudioMediaFormat. - * - * @return the number of audio channels associated with this - * AudioMediaFormat. - */ - public int getChannels(); -} diff --git a/src/net/java/sip/communicator/service/neomedia/format/MediaFormat.java b/src/net/java/sip/communicator/service/neomedia/format/MediaFormat.java deleted file mode 100644 index 1ffab4868..000000000 --- a/src/net/java/sip/communicator/service/neomedia/format/MediaFormat.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.format; - -import java.util.*; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * The MediaFormat interface represents a generic (i.e. audio/video or - * other) format used to represent media represent a media stream. - *

- * The interface contains utility methods for extracting common media format - * properties such as the name of the underlying encoding, or clock rate or in - * order comparing to compare formats. Extending interfaces representing audio - * or video formats are likely to add other methods. - * - * @author Emil Ivov - * @author Lyubomir Marinov - */ -public interface MediaFormat -{ - - /** - * The constant returned by {@link #getRTPPayloadType()} when the - * MediaFormat instance describes a format without an RTP payload - * type (number) known in RFC 3551 "RTP Profile for Audio and Video - * Conferences with Minimal Control". - */ - public static final byte RTP_PAYLOAD_TYPE_UNKNOWN = -1; - - /** - * The minimum integer that is allowed for use in dynamic payload type - * assignment. - */ - public static final int MIN_DYNAMIC_PAYLOAD_TYPE = 96; - - /** - * The maximum integer that is allowed for use in dynamic payload type - * assignment. - */ - public static final int MAX_DYNAMIC_PAYLOAD_TYPE = 127; - - /** - * Returns the type of this MediaFormat (e.g. audio or video). - * - * @return the MediaType that this format represents (e.g. audio - * or video). - */ - public MediaType getMediaType(); - - /** - * Returns the name of the encoding (i.e. codec) used by this - * MediaFormat. - * - * @return The name of the encoding that this MediaFormat is using. - */ - public String getEncoding(); - - /** - * Returns the clock rate associated with this MediaFormat. - * - * @return The clock rate associated with this format. - */ - public double getClockRate(); - - /** - * Returns a String representation of the clock rate associated - * with this MediaFormat making sure that the value appears as - * an integer (i.e. contains no decimal point) unless it is actually a non - * integer. - * - * @return a String representation of the clock rate associated - * with this MediaFormat. - */ - public String getClockRateString(); - - /** - * Returns a String representation of the real used clock rate - * associated with this MediaFormat making sure that the value - * appears as an integer (i.e. contains no decimal point) unless it is - * actually a non integer. - * This function corrects the problem of the G.722 codec which advertises - * its clock rate to be 8 kHz while 16 kHz is really used to encode the - * stream (that's an error noted in the respective RFC and kept for the sake - * of compatibility.). - * - * @return a String representation of the real used clock rate - * associated with this MediaFormat. - */ - public String getRealUsedClockRateString(); - - /** - * Determines whether this MediaFormat is equal to - * mediaFormat i.e. they have the same encoding, clock rate, format - * parameters, advanced attributes, etc. - * - * @param mediaFormat the MediaFormat to compare to this instance - * @return true if mediaFormat is equal to this format and - * false otherwise. - */ - @Override - public boolean equals(Object mediaFormat); - - /** - * Determines whether the format parameters of this MediaFormat - * match a specific set of format parameters. - * - * @param fmtps the set of format parameters to match to the format - * parameters of this MediaFormat - * @return true if this MediaFormat considers - * fmtps matching its format parameters; otherwise, false - */ - public boolean formatParametersMatch(Map fmtps); - - /** - * Returns a Map containing advanced parameters specific to this - * particular MediaFormat. The parameters returned here are meant - * for use in SIP/SDP or XMPP session descriptions. - * - * @return a Map containing advanced parameters specific to this - * particular MediaFormat - */ - public Map getAdvancedAttributes(); - - /** - * Returns a Map containing parameters specific to this particular - * MediaFormat. The parameters returned here are meant for use in - * SIP/SDP or XMPP session descriptions where they get transported through - * the "fmtp:" attribute or tag respectively. - * - * @return a Map containing parameters specific to this particular - * MediaFormat. - */ - public Map getFormatParameters(); - - /** - * Gets the RTP payload type (number) of this MediaFormat as it is - * known in RFC 3551 "RTP Profile for Audio and Video Conferences with - * Minimal Control". - * - * @return the RTP payload type of this MediaFormat if it is known - * in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal - * Control"; otherwise, {@link #RTP_PAYLOAD_TYPE_UNKNOWN} - */ - public byte getRTPPayloadType(); - - /** - * Sets additional codec settings. - * - * @param settings additional settings represented by a map. - */ - public void setAdditionalCodecSettings(Map settings); - - /** - * Returns additional codec settings. - * - * @return additional settings represented by a map. - */ - public Map getAdditionalCodecSettings(); - - /** - * Returns a String representation of this MediaFormat - * containing important format attributes such as the encoding for example. - * - * @return a String representation of this MediaFormat. - */ - @Override - public String toString(); -} diff --git a/src/net/java/sip/communicator/service/neomedia/format/MediaFormatFactory.java b/src/net/java/sip/communicator/service/neomedia/format/MediaFormatFactory.java deleted file mode 100644 index 068e69292..000000000 --- a/src/net/java/sip/communicator/service/neomedia/format/MediaFormatFactory.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.format; - -import java.util.*; - -import net.java.sip.communicator.service.neomedia.*; - -/** - * Allows the creation of audio and video MediaFormat instances. - * - * @author Emil Ivov - * @author Lubomir Marinov - */ -public interface MediaFormatFactory -{ - - /** - * The constant to be used as an argument representing number of channels to - * denote that a specific number of channels is not specified. - */ - public static final int CHANNELS_NOT_SPECIFIED = -1; - - /** - * The constant to be used as an argument representing a clock rate to - * denote that a specific clock rate is not specified. - */ - public static final double CLOCK_RATE_NOT_SPECIFIED = -1; - - /** - * Creates an unknown MediaFormat. - * - * @param type MediaType - * @return unknown MediaFormat - */ - public MediaFormat createUnknownMediaFormat(MediaType type); - - /** - * Creates a MediaFormat for the specified encoding with - * default clock rate and set of format parameters. If encoding is - * known to this MediaFormatFactory, returns a - * MediaFormat which is either an AudioMediaFormat or a - * VideoMediaFormat instance. Otherwise, returns null. - * - * @param encoding the well-known encoding (name) to create a - * MediaFormat for - * @return a MediaFormat with the specified encoding which - * is either an AudioMediaFormat or a VideoMediaFormat - * instance if encoding is known to this - * MediaFormatFactory; otherwise, null - */ - public MediaFormat createMediaFormat(String encoding); - - /** - * Creates a MediaFormat for the specified RTP payload type with - * default clock rate and set of format parameters. If - * rtpPayloadType is known to this MediaFormatFactory, - * returns a MediaFormat which is either an - * AudioMediaFormat or a VideoMediaFormat instance. - * Otherwise, returns null. - * - * @param rtpPayloadType the RTP payload type of the MediaFormat to - * create - * @return a MediaFormat with the specified rtpPayloadType - * which is either an AudioMediaFormat or a - * VideoMediaFormat instance if rtpPayloadType is known to - * this MediaFormatFactory; otherwise, null - */ - public MediaFormat createMediaFormat(byte rtpPayloadType); - - /** - * Creates a MediaFormat for the specified encoding with - * the specified clockRate and a default set of format parameters. - * If encoding is known to this MediaFormatFactory, - * returns a MediaFormat which is either an - * AudioMediaFormat or a VideoMediaFormat instance. - * Otherwise, returns null. - * - * @param encoding the well-known encoding (name) to create a - * MediaFormat for - * @param clockRate the clock rate in Hz to create a MediaFormat - * for - * @return a MediaFormat with the specified encoding and - * clockRate which is either an AudioMediaFormat or a - * VideoMediaFormat instance if encoding is known to this - * MediaFormatFactory; otherwise, null - */ - public MediaFormat createMediaFormat( - String encoding, - double clockRate); - - /** - * Creates a MediaFormat for the specified encoding, - * clockRate and channels and a default set of format - * parameters. If encoding is known to this - * MediaFormatFactory, returns a MediaFormat which is - * either an AudioMediaFormat or a VideoMediaFormat - * instance. Otherwise, returns null. - * - * @param encoding the well-known encoding (name) to create a - * MediaFormat for - * @param clockRate the clock rate in Hz to create a MediaFormat - * for - * @param channels the number of available channels (1 for mono, 2 for - * stereo) if it makes sense for the MediaFormat with the specified - * encoding; otherwise, ignored - * @return a MediaFormat with the specified encoding, - * clockRate and channels and a default set of format - * parameters which is either an AudioMediaFormat or a - * VideoMediaFormat instance if encoding is known to this - * MediaFormatFactory; otherwise, null - */ - public MediaFormat createMediaFormat( - String encoding, - double clockRate, - int channels); - - /** - * Creates a MediaFormat for the specified encoding, - * clockRate and set of format parameters. If encoding is - * known to this MediaFormatFactory, returns a MediaFormat - * which is either an AudioMediaFormat or a - * VideoMediaFormat instance. Otherwise, returns null. - * - * @param encoding the well-known encoding (name) to create a - * MediaFormat for - * @param clockRate the clock rate in Hz to create a MediaFormat - * for - * @param formatParams any codec specific parameters which have been - * received via SIP/SDP or XMPP/Jingle - * @param advancedAttrs advanced attributes received via SIP/SDP or - * XMPP/Jingle - * @return a MediaFormat with the specified encoding, - * clockRate and set of format parameters which is either an - * AudioMediaFormat or a VideoMediaFormat instance if - * encoding is known to this MediaFormatFactory; - * otherwise, null - */ - public MediaFormat createMediaFormat( - String encoding, - double clockRate, - Map formatParams, - Map advancedAttrs); - - /** - * Creates a MediaFormat for the specified encoding, - * clockRate, channels and set of format parameters. If - * encoding is known to this MediaFormatFactory, returns a - * MediaFormat which is either an AudioMediaFormat or a - * VideoMediaFormat instance. Otherwise, returns null. - * - * @param encoding the well-known encoding (name) to create a - * MediaFormat for - * @param clockRate the clock rate in Hz to create a MediaFormat - * for - * @param frameRate the frame rate in number of frames per second to - * create a MediaFormat for - * @param channels the number of available channels (1 for mono, 2 for - * stereo) if it makes sense for the MediaFormat with the specified - * encoding; otherwise, ignored - * @param formatParams any codec specific parameters which have been - * received via SIP/SDP or XMPP/Jingle - * @param advancedAttrs advanced attributes received via SIP/SDP or - * XMPP/Jingle - * @return a MediaFormat with the specified encoding, - * clockRate, channels and set of format parameters which - * is either an AudioMediaFormat or a VideoMediaFormat - * instance if encoding is known to this - * MediaFormatFactory; otherwise, null - */ - public MediaFormat createMediaFormat( - String encoding, - double clockRate, - int channels, - float frameRate, - Map formatParams, - Map advancedAttrs); - - /** - * Creates a MediaFormat either for the specified - * rtpPayloadType or for the specified encoding, - * clockRate, channels and set of format parameters. If - * encoding is known to this MediaFormatFactory, ignores - * rtpPayloadType and returns a MediaFormat which is - * either an AudioMediaFormat or a VideoMediaFormat - * instance. If rtpPayloadType is not - * {@link MediaFormat#RTP_PAYLOAD_TYPE_UNKNOWN} and encoding is - * null, uses the encoding associated with rtpPayloadType. - * - * @param rtpPayloadType the RTP payload type to create a - * MediaFormat for; {@link MediaFormat#RTP_PAYLOAD_TYPE_UNKNOWN} if - * encoding is not null. If rtpPayloadType is not - * MediaFormat#RTP_PAYLOAD_TYPE_UNKNOWN and encoding is - * not null, rtpPayloadType is ignored - * @param encoding the well-known encoding (name) to create a - * MediaFormat for; null - * @param clockRate the clock rate in Hz to create a MediaFormat - * for - * @param frameRate the frame rate in number of frames per second to - * create a MediaFormat for - * @param channels the number of available channels (1 for mono, 2 for - * stereo) if it makes sense for the MediaFormat with the specified - * encoding; otherwise, ignored - * @param formatParams any codec specific parameters which have been - * received via SIP/SDP or XMPP/Jingle - * @param advancedAttrs advanced attributes received via SIP/SDP or - * XMPP/Jingle - * @return a MediaFormat with the specified encoding, - * clockRate, channels and set of format parameters which - * is either an AudioMediaFormat or a VideoMediaFormat - * instance if encoding is known to this - * MediaFormatFactory; otherwise, null - */ - public MediaFormat createMediaFormat( - byte rtpPayloadType, - String encoding, - double clockRate, - int channels, - float frameRate, - Map formatParams, - Map advancedAttrs); -} diff --git a/src/net/java/sip/communicator/service/neomedia/format/VideoMediaFormat.java b/src/net/java/sip/communicator/service/neomedia/format/VideoMediaFormat.java deleted file mode 100644 index af32e6fef..000000000 --- a/src/net/java/sip/communicator/service/neomedia/format/VideoMediaFormat.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.neomedia.format; - -import java.awt.*; - -/** - * The interface represents a video format. Video formats characterize video - * streams and the VideoMediaFormat interface gives access to some of - * their properties such as encoding and clock rate. - * - * @author Emil Ivov - */ -public interface VideoMediaFormat - extends MediaFormat -{ - /** - * Returns the size of the image that this VideoMediaFormat - * describes. - * - * @return a java.awt.Dimension instance indicating the image size - * (in pixels) of this VideoMediaFormat. - */ - public Dimension getSize(); - - /** - * Returns the frame rate associated with this MediaFormat. - * - * @return The frame rate associated with this format. - */ - public float getFrameRate(); -} diff --git a/src/net/java/sip/communicator/service/notification/NotificationAction.java b/src/net/java/sip/communicator/service/notification/NotificationAction.java index ae67047dd..c97c740b6 100644 --- a/src/net/java/sip/communicator/service/notification/NotificationAction.java +++ b/src/net/java/sip/communicator/service/notification/NotificationAction.java @@ -97,4 +97,4 @@ public void setEnabled(boolean isEnabled) { this.isEnabled = isEnabled; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/notification/NotificationServiceActivator.java b/src/net/java/sip/communicator/service/notification/NotificationServiceActivator.java index 6599a168a..a2f6932c1 100644 --- a/src/net/java/sip/communicator/service/notification/NotificationServiceActivator.java +++ b/src/net/java/sip/communicator/service/notification/NotificationServiceActivator.java @@ -6,7 +6,7 @@ */ package net.java.sip.communicator.service.notification; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.*; import org.osgi.framework.*; diff --git a/src/net/java/sip/communicator/service/notification/NotificationServiceImpl.java b/src/net/java/sip/communicator/service/notification/NotificationServiceImpl.java index e9fb33200..b16e8e563 100644 --- a/src/net/java/sip/communicator/service/notification/NotificationServiceImpl.java +++ b/src/net/java/sip/communicator/service/notification/NotificationServiceImpl.java @@ -8,7 +8,7 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.notification.event.*; import net.java.sip.communicator.util.*; import static net.java.sip.communicator.service.notification.NotificationAction.*; diff --git a/src/net/java/sip/communicator/service/notification/SoundNotificationHandler.java b/src/net/java/sip/communicator/service/notification/SoundNotificationHandler.java index affc26864..46cab32d8 100644 --- a/src/net/java/sip/communicator/service/notification/SoundNotificationHandler.java +++ b/src/net/java/sip/communicator/service/notification/SoundNotificationHandler.java @@ -31,4 +31,4 @@ public interface SoundNotificationHandler * @param data Additional data for the event. */ public void stop(NotificationData data); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/notification/notification.manifest.mf b/src/net/java/sip/communicator/service/notification/notification.manifest.mf index 8a0240d20..6c52f21b5 100644 --- a/src/net/java/sip/communicator/service/notification/notification.manifest.mf +++ b/src/net/java/sip/communicator/service/notification/notification.manifest.mf @@ -8,4 +8,4 @@ Export-Package: net.java.sip.communicator.service.notification, net.java.sip.communicator.service.notification.event Import-Package: org.osgi.framework, net.java.sip.communicator.util, - net.java.sip.communicator.service.configuration + org.jitsi.service.configuration diff --git a/src/net/java/sip/communicator/service/packetlogging/PacketLoggingConfiguration.java b/src/net/java/sip/communicator/service/packetlogging/PacketLoggingConfiguration.java deleted file mode 100644 index 45a4e7168..000000000 --- a/src/net/java/sip/communicator/service/packetlogging/PacketLoggingConfiguration.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.packetlogging; - -/** - * Stores the configuration used by Packet Logging Service. - * - * @author Damian Minkov - */ -public class PacketLoggingConfiguration -{ - /** - * Configuration property for packet logging enabled/disabled. - */ - public final static String PACKET_LOGGING_ENABLED_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_ENABLED"; - - /** - * Configuration property for packet logging for - * sip protocol enabled/disabled. - */ - public final static String PACKET_LOGGING_SIP_ENABLED_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_SIP_ENABLED"; - - /** - * Configuration property for packet logging for - * jabber protocol enabled/disabled. - */ - public final static String PACKET_LOGGING_JABBER_ENABLED_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_JABBER_ENABLED"; - - /** - * Configuration property for packet logging for - * RTP enabled/disabled. - */ - public final static String PACKET_LOGGING_RTP_ENABLED_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_RTP_ENABLED"; - - /** - * Configuration property for packet logging for - * ICE4J enabled/disabled. - */ - public final static String PACKET_LOGGING_ICE4J_ENABLED_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_ICE4J_ENABLED"; - - /** - * Configuration property for packet logging file count. - */ - public final static String PACKET_LOGGING_FILE_COUNT_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_FILE_COUNT"; - - /** - * Configuration property for packet logging file size. - */ - public final static String PACKET_LOGGING_FILE_SIZE_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_FILE_SIZE"; - - /** - * Is Packet Logging Service enabled. - */ - private boolean globalLoggingEnabled = true; - - /** - * Is Packet Logging Service enabled for sip protocol. - */ - private boolean sipLoggingEnabled = true; - - /** - * Is Packet Logging Service enabled for jabber protocol. - */ - private boolean jabberLoggingEnabled = true; - - /** - * Is Packet Logging Service enabled for rtp. - */ - private boolean rtpLoggingEnabled = true; - - /** - * Is Packet Logging Service enabled for ice4j. - */ - private boolean ice4jLoggingEnabled = true; - - /** - * The limit for the file size. - * 0 means no limit. - */ - private long limit = 5000000; - - /** - * The counter for number of files. - */ - private int logfileCount = 3; - - /** - * Checks whether packet logging is enabled in the configuration. - * @return true if packet logging is enabled. - */ - public boolean isGlobalLoggingEnabled() - { - return this.globalLoggingEnabled; - } - - /** - * Checks whether packet logging is enabled in the configuration - * for sip protocol. - * @return true if packet logging is enabled for sip protocol. - */ - public boolean isSipLoggingEnabled() - { - return this.sipLoggingEnabled; - } - - /** - * Checks whether packet logging is enabled in the configuration - * for jabber protocol. - * @return true if packet logging is enabled for jabber protocol. - */ - public boolean isJabberLoggingEnabled() - { - return this.jabberLoggingEnabled; - } - - /** - * Checks whether packet logging is enabled in the configuration - * for RTP. - * @return true if packet logging is enabled for RTP. - */ - public boolean isRTPLoggingEnabled() - { - return this.rtpLoggingEnabled; - } - - /** - * Checks whether packet logging is enabled in the configuration - * for Ice4J. - * @return true if packet logging is enabled for RTP. - */ - public boolean isIce4JLoggingEnabled() - { - return this.ice4jLoggingEnabled; - } - - /** - * The limit for the file size. 0 means no limit. - * @return the file size limit. - */ - public long getLimit() - { - return this.limit; - } - - /** - * The counter for number of files. - * @return the number of file counts. - */ - public int getLogfileCount() - { - return this.logfileCount; - } - - /** - * Change whether packet logging is enabled. - * @param enabled true if we enable it. - */ - public void setGlobalLoggingEnabled(boolean enabled) - { - if(!enabled) - { - // as we are globally off, set it and to services - this.sipLoggingEnabled = false; - this.jabberLoggingEnabled = false; - this.rtpLoggingEnabled = false; - this.ice4jLoggingEnabled = false; - } - - this.globalLoggingEnabled = enabled; - } - - /** - * Change whether packet logging for sip protocol is enabled. - * @param enabled true if we enable it. - */ - public void setSipLoggingEnabled(boolean enabled) - { - this.sipLoggingEnabled = enabled; - } - - /** - * Change whether packet logging for jabber protocol is enabled. - * @param enabled true if we enable it. - */ - public void setJabberLoggingEnabled(boolean enabled) - { - this.jabberLoggingEnabled = enabled; - } - - /** - * Change whether packet logging for RTP is enabled. - * @param enabled true if we enable it. - */ - public void setRTPLoggingEnabled(boolean enabled) - { - this.rtpLoggingEnabled = true; - } - - /** - * Change whether packet logging for Ice4J is enabled. - * @param enabled true if we enable it. - */ - public void setIce4JLoggingEnabled(boolean enabled) - { - this.ice4jLoggingEnabled = true; - } - - /** - * Changes the file size limit. - * @param limit the new limit size. - */ - public void setLimit(long limit) - { - this.limit = limit; - } - - /** - * Changes file count. - * @param logfileCount the new file count. - */ - public void setLogfileCount(int logfileCount) - { - this.logfileCount = logfileCount; - } - -} diff --git a/src/net/java/sip/communicator/service/packetlogging/PacketLoggingService.java b/src/net/java/sip/communicator/service/packetlogging/PacketLoggingService.java deleted file mode 100644 index 537e6448f..000000000 --- a/src/net/java/sip/communicator/service/packetlogging/PacketLoggingService.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.packetlogging; - -/** - * A Packet Logging Service to log packets that were send/received - * by protocols or any other network related services in various formats. - * Its for debugging purposes. - * - * @author Damian Minkov - */ -public interface PacketLoggingService -{ - /** - * These are the services that this packet logging service - * cab handle. - */ - public enum ProtocolName - { - /** - * SIP protocol name. - */ - SIP, - - /** - * Jabber protocol name. - */ - JABBER, - - /** - * RTP protocol name. - */ - RTP, - - /** - * ICE protocol name. - */ - ICE4J - } - - /** - * The transport names. - */ - public enum TransportName - { - /** - * UDP transport name. - */ - UDP, - - /** - * TCP transport name. - */ - TCP - } - - /** - * Checks is logging globally enabled for the service. - * @return is logging enabled. - */ - public boolean isLoggingEnabled(); - - /** - * Checks is logging globally enabled for and is it currently - * available fo the given protocol. - *. - * @param protocol that is checked. - * @return is logging enabled. - */ - public boolean isLoggingEnabled(ProtocolName protocol); - - /** - * Log a packet with all the required information. - * - * @param protocol the source protocol that logs this packet. - * @param sourceAddress the source address of the packet. - * @param sourcePort the source port of the packet. - * @param destinationAddress the destination address. - * @param destinationPort the destination port. - * @param transport the transport this packet uses. - * @param sender are we the sender of the packet or not. - * @param packetContent the packet content. - */ - public void logPacket( - ProtocolName protocol, - byte[] sourceAddress, - int sourcePort, - byte[] destinationAddress, - int destinationPort, - TransportName transport, - boolean sender, - byte[] packetContent); - - /** - * Log a packet with all the required information. - * - * @param protocol the source protocol that logs this packet. - * @param sourceAddress the source address of the packet. - * @param sourcePort the source port of the packet. - * @param destinationAddress the destination address. - * @param destinationPort the destination port. - * @param transport the transport this packet uses. - * @param sender are we the sender of the packet or not. - * @param packetContent the packet content. - * @param packetOffset the packet content offset. - * @param packetLength the packet content length. - */ - public void logPacket( - ProtocolName protocol, - byte[] sourceAddress, - int sourcePort, - byte[] destinationAddress, - int destinationPort, - TransportName transport, - boolean sender, - byte[] packetContent, - int packetOffset, - int packetLength); - - /** - * Returns the current Packet Logging Configuration. - * - * @return the Packet Logging Configuration. - */ - public PacketLoggingConfiguration getConfiguration(); -} diff --git a/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java b/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java index 7eb43a882..74538938c 100644 --- a/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java +++ b/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java @@ -11,7 +11,9 @@ import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.event.*; + +import org.jitsi.service.protocol.event.*; +import org.jitsi.util.event.*; /** * Provides a default implementation for most of the CallPeer methods diff --git a/src/net/java/sip/communicator/service/protocol/AbstractConferenceMember.java b/src/net/java/sip/communicator/service/protocol/AbstractConferenceMember.java index 739a03a56..eafc2b0d0 100644 --- a/src/net/java/sip/communicator/service/protocol/AbstractConferenceMember.java +++ b/src/net/java/sip/communicator/service/protocol/AbstractConferenceMember.java @@ -6,7 +6,7 @@ */ package net.java.sip.communicator.service.protocol; -import net.java.sip.communicator.util.event.*; +import org.jitsi.util.event.*; /** * Provides the default implementation of the ConferenceMember diff --git a/src/net/java/sip/communicator/service/protocol/AccountManager.java b/src/net/java/sip/communicator/service/protocol/AccountManager.java index 4aa3a426a..14b9aa653 100644 --- a/src/net/java/sip/communicator/service/protocol/AccountManager.java +++ b/src/net/java/sip/communicator/service/protocol/AccountManager.java @@ -8,11 +8,11 @@ import java.util.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.configuration.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/service/protocol/CallPeer.java b/src/net/java/sip/communicator/service/protocol/CallPeer.java index 855dd68ea..8ecec6e7c 100644 --- a/src/net/java/sip/communicator/service/protocol/CallPeer.java +++ b/src/net/java/sip/communicator/service/protocol/CallPeer.java @@ -6,11 +6,13 @@ */ package net.java.sip.communicator.service.protocol; -import java.net.*; import java.beans.*; +import java.net.*; import net.java.sip.communicator.service.protocol.event.*; +import org.jitsi.service.protocol.event.*; + /** * The CallPeer is an interface that represents peers in a call. * Users of the UIService need to implement this interface (or one of its diff --git a/src/net/java/sip/communicator/service/protocol/DTMFTone.java b/src/net/java/sip/communicator/service/protocol/DTMFTone.java deleted file mode 100644 index 9a1a69c16..000000000 --- a/src/net/java/sip/communicator/service/protocol/DTMFTone.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.protocol; - -/** - * Class for representing all the different DTMF tones. - * - * @author JM HEITZ - */ -public final class DTMFTone -{ - /** - * The "A" DTMF Tone - */ - public static final DTMFTone DTMF_A=new DTMFTone("A"); - - /** - * The "B" DTMF Tone - */ - public static final DTMFTone DTMF_B=new DTMFTone("B"); - - /** - * The "C" DTMF Tone - */ - public static final DTMFTone DTMF_C=new DTMFTone("C"); - - /** - * The "D" DTMF Tone - */ - public static final DTMFTone DTMF_D=new DTMFTone("D"); - - /** - * The "0" DTMF Tone - */ - public static final DTMFTone DTMF_0=new DTMFTone("0"); - - /** - * The "1" DTMF Tone - */ - public static final DTMFTone DTMF_1=new DTMFTone("1"); - - /** - * The "2" DTMF Tone - */ - public static final DTMFTone DTMF_2=new DTMFTone("2"); - - /** - * The "3" DTMF Tone - */ - public static final DTMFTone DTMF_3=new DTMFTone("3"); - - /** - * The "4" DTMF Tone - */ - public static final DTMFTone DTMF_4=new DTMFTone("4"); - - /** - * The "5" DTMF Tone - */ - public static final DTMFTone DTMF_5=new DTMFTone("5"); - - /** - * The "6" DTMF Tone - */ - public static final DTMFTone DTMF_6=new DTMFTone("6"); - - /** - * The "7" DTMF Tone - */ - public static final DTMFTone DTMF_7=new DTMFTone("7"); - - /** - * The "8" DTMF Tone - */ - public static final DTMFTone DTMF_8=new DTMFTone("8"); - - /** - * The "9" DTMF Tone - */ - public static final DTMFTone DTMF_9=new DTMFTone("9"); - - /** - * The "*" DTMF Tone - */ - public static final DTMFTone DTMF_STAR=new DTMFTone("*"); - - /** - * The "#" DTMF Tone - */ - public static final DTMFTone DTMF_SHARP=new DTMFTone("#"); - - /** - * The value of the DTMF tone - */ - private final String value; - - /** - * Creates a DTMF instance with the specified tone value. The method is - * private since one would only have to use predefined static instances. - * - * @param value one of te DTMF_XXX fields, indicating the value of the tone. - */ - private DTMFTone(String value) - { - this.value = value; - } - - /** - * Returns the string representation of this DTMF tone. - * - * @return the String representation of this DTMF tone. - */ - public String getValue() - { - return this.value; - } - - /** - * Indicates whether some other object is "equal to" this tone. - *

- * @param target the reference object with which to compare. - * - * @return true if target represents the same tone as this - * object. - */ - public boolean equals(Object target) - { - if(!(target instanceof DTMFTone)) - { - return false; - } - DTMFTone targetDTMFTone = (DTMFTone)(target); - - return targetDTMFTone.value.equals(this.value); - } - - /** - * Returns a hash code value for the object. This method is - * supported for the benefit of hashtables such as those provided by - * java.util.Hashtable. The method would actually return the - * hashcode of the string representation of this DTMF tone. - *

- * - * @return a hash code value for this object (same as calling - * getValue().hashCode()). - */ - public int hashCode() - { - return getValue().hashCode(); - } - - /** - * Parses input value and return the corresponding tone. - * If unknown will return null; - * @param value the input value. - * @return the corresponding tone, null for unknown. - */ - public static DTMFTone getDTMFTone(String value) - { - if(value == null) - return null; - else if(value.equals(DTMF_0.getValue())) - return DTMF_0; - else if(value.equals(DTMF_1.getValue())) - return DTMF_1; - else if(value.equals(DTMF_2.getValue())) - return DTMF_2; - else if(value.equals(DTMF_3.getValue())) - return DTMF_3; - else if(value.equals(DTMF_4.getValue())) - return DTMF_4; - else if(value.equals(DTMF_5.getValue())) - return DTMF_5; - else if(value.equals(DTMF_6.getValue())) - return DTMF_6; - else if(value.equals(DTMF_7.getValue())) - return DTMF_7; - else if(value.equals(DTMF_8.getValue())) - return DTMF_8; - else if(value.equals(DTMF_9.getValue())) - return DTMF_9; - else if(value.equals(DTMF_A.getValue())) - return DTMF_A; - else if(value.equals(DTMF_B.getValue())) - return DTMF_B; - else if(value.equals(DTMF_C.getValue())) - return DTMF_C; - else if(value.equals(DTMF_D.getValue())) - return DTMF_D; - else if(value.equals(DTMF_SHARP.getValue())) - return DTMF_SHARP; - else if(value.equals(DTMF_STAR.getValue())) - return DTMF_STAR; - else - return null; - } -} diff --git a/src/net/java/sip/communicator/service/protocol/OperationSetBasicTelephony.java b/src/net/java/sip/communicator/service/protocol/OperationSetBasicTelephony.java index 12b7c7be1..e73229d3f 100644 --- a/src/net/java/sip/communicator/service/protocol/OperationSetBasicTelephony.java +++ b/src/net/java/sip/communicator/service/protocol/OperationSetBasicTelephony.java @@ -9,9 +9,10 @@ import java.text.*; import java.util.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.event.*; +import org.jitsi.service.neomedia.*; + /** * An Operation Set defining all basic telephony operations such as conducting * simple calls and etc. Note that video is not considered as a part of a diff --git a/src/net/java/sip/communicator/service/protocol/OperationSetDTMF.java b/src/net/java/sip/communicator/service/protocol/OperationSetDTMF.java index cd1ab2bf1..d39449b72 100644 --- a/src/net/java/sip/communicator/service/protocol/OperationSetDTMF.java +++ b/src/net/java/sip/communicator/service/protocol/OperationSetDTMF.java @@ -6,6 +6,8 @@ */ package net.java.sip.communicator.service.protocol; +import org.jitsi.service.protocol.*; + /** * An OperationSet that allows other modules to send DMF tones through * this protocol provider. diff --git a/src/net/java/sip/communicator/service/protocol/OperationSetDesktopStreaming.java b/src/net/java/sip/communicator/service/protocol/OperationSetDesktopStreaming.java index 6377622f3..11b8e6f6b 100644 --- a/src/net/java/sip/communicator/service/protocol/OperationSetDesktopStreaming.java +++ b/src/net/java/sip/communicator/service/protocol/OperationSetDesktopStreaming.java @@ -8,7 +8,7 @@ import java.text.*; -import net.java.sip.communicator.service.neomedia.device.*; +import org.jitsi.service.neomedia.device.*; /** * Represents an OperationSet giving access to desktop streaming @@ -95,4 +95,4 @@ public void setLocalVideoAllowed( Call call, */ public void movePartialDesktopStreaming(Call call, int x, int y); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/OperationSetVideoTelephony.java b/src/net/java/sip/communicator/service/protocol/OperationSetVideoTelephony.java index a6119bd1b..c9f56d33c 100644 --- a/src/net/java/sip/communicator/service/protocol/OperationSetVideoTelephony.java +++ b/src/net/java/sip/communicator/service/protocol/OperationSetVideoTelephony.java @@ -11,9 +11,10 @@ import java.text.*; import java.util.List; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.event.*; + +import org.jitsi.service.neomedia.*; +import org.jitsi.util.event.*; /** * Represents an OperationSet giving access to video-specific diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolProviderActivator.java b/src/net/java/sip/communicator/service/protocol/ProtocolProviderActivator.java index eec179916..39186773f 100644 --- a/src/net/java/sip/communicator/service/protocol/ProtocolProviderActivator.java +++ b/src/net/java/sip/communicator/service/protocol/ProtocolProviderActivator.java @@ -6,12 +6,12 @@ */ package net.java.sip.communicator.service.protocol; -import org.osgi.framework.*; - -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; + /** * Implements BundleActivator for the purposes of * protocol.jar/protocol.provider.manifest.mf and in order to register and start diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java b/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java index 8e8560a4a..e3a1a45f9 100644 --- a/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java +++ b/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java @@ -9,7 +9,7 @@ import java.lang.reflect.*; import java.util.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.util.*; diff --git a/src/net/java/sip/communicator/service/protocol/event/AdHocChatRoomParticipantPresenceListener.java b/src/net/java/sip/communicator/service/protocol/event/AdHocChatRoomParticipantPresenceListener.java index 560398174..32ae1190c 100644 --- a/src/net/java/sip/communicator/service/protocol/event/AdHocChatRoomParticipantPresenceListener.java +++ b/src/net/java/sip/communicator/service/protocol/event/AdHocChatRoomParticipantPresenceListener.java @@ -29,4 +29,4 @@ public interface AdHocChatRoomParticipantPresenceListener */ public void participantPresenceChanged( AdHocChatRoomParticipantPresenceChangeEvent evt); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/event/CallEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallEvent.java index f5639617b..c059349ed 100644 --- a/src/net/java/sip/communicator/service/protocol/event/CallEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/CallEvent.java @@ -8,9 +8,10 @@ import java.util.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; +import org.jitsi.service.neomedia.*; + /** * An event class representing that an incoming or an outgoing call has been * created. The event id indicates the exact reason for this event. diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityListener.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityListener.java index db07b48f1..a7c2d7c54 100755 --- a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityListener.java +++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityListener.java @@ -8,6 +8,8 @@ import java.util.*; +import org.jitsi.service.protocol.event.*; + /** * CallPeerSecurityListener interface extends EventListener. This is the * listener interface used to handle an event related with a change in security diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityMessageEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityMessageEvent.java deleted file mode 100644 index 8543dc880..000000000 --- a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityMessageEvent.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.protocol.event; - -import java.util.*; - -/** - * The CallPeerSecurityFailedEvent is triggered whenever - * a problem has occurred during call security process. - * - * @author Yana Stamcheva - * @author Werner Dittmann - */ -public class CallPeerSecurityMessageEvent - extends EventObject -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * This is a information message. Security will be established. - */ - public static final int INFORMATION = 0; - - /** - * This is a warning message. Security will not be established. - */ - public static final int WARNING = 1; - - /** - * This is a severe error. Security will not be established. - */ - public static final int SEVERE = 2; - - /** - * This is a ZRTP error message. Security will not be established. - */ - public static final int ERROR = 3; - - /** - * The internationalized message associated with this event. - */ - private final String eventI18nMessage; - - /** - * The message associated with this event. - */ - private final String eventMessage; - - /** - * The severity of the security message event. - */ - private final int eventSeverity; - - /** - * Creates a CallPeerSecurityFailedEvent by specifying the - * call peer, event type and message associated with this event. - * - * @param source the object on which the event initially occurred - * @param eventMessage the message associated with this event. - * @param i18nMessage the internationalized message associated with this - * event that could be shown to the user. - * @param eventSeverity severity level. - */ - public CallPeerSecurityMessageEvent( - Object source, - String eventMessage, - String i18nMessage, - int eventSeverity) - { - super(source); - - this.eventMessage = eventMessage; - this.eventI18nMessage = i18nMessage; - this.eventSeverity = eventSeverity; - } - - /** - * Returns the message associated with this event. - * - * @return the message associated with this event. - */ - public String getMessage() - { - return eventMessage; - } - - /** - * Returns the internationalized message associated with this event. - * - * @return the internationalized message associated with this event. - */ - public String getI18nMessage() - { - return eventI18nMessage; - } - - /** - * Returns the event severity. - * - * @return the eventSeverity - */ - public int getEventSeverity() { - return eventSeverity; - } -} diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityNegotiationStartedEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityNegotiationStartedEvent.java index 61009b39b..9a86e8759 100644 --- a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityNegotiationStartedEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityNegotiationStartedEvent.java @@ -6,9 +6,11 @@ */ package net.java.sip.communicator.service.protocol.event; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.protocol.event.*; + /** * The CallPeerSecurityNegotiationStartedEvent is triggered whenever a * communication with a given peer is established, diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOffEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOffEvent.java index 1e247aa34..73c713e94 100644 --- a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOffEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOffEvent.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.protocol.*; +import org.jitsi.service.protocol.event.*; + /** * The CallPeerSecurityAuthenticationEvent is triggered whenever * a the security strings are received in a secure call. diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOnEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOnEvent.java index 976952f8d..210a53629 100644 --- a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOnEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityOnEvent.java @@ -6,9 +6,11 @@ */ package net.java.sip.communicator.service.protocol.event; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.protocol.event.*; + /** * The CallPeerSecurityOnEvent is triggered whenever a * communication with a given peer is going secure. diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityStatusEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityStatusEvent.java deleted file mode 100644 index 6720f4bd4..000000000 --- a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityStatusEvent.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.protocol.event; - -import java.util.*; - -/** - * Parent class for SecurityOn and SecurityOff events. - * - * @author Yana Stamcheva - */ -public abstract class CallPeerSecurityStatusEvent - extends EventObject -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * Constant value defining that security is enabled. - */ - public static final int AUDIO_SESSION = 1; - - /** - * Constant value defining that security is disabled. - */ - public static final int VIDEO_SESSION = 2; - - /** - * Session type of the event {@link #AUDIO_SESSION} or - * {@link #VIDEO_SESSION}. - */ - private final int sessionType; - - /** - * Constructor required by the EventObject. - * - * @param source the source object for this event. - * @param sessionType either AUDIO_SESSION or - * VIDEO_SESSION to indicate the type of the - * session - */ - public CallPeerSecurityStatusEvent(Object source, int sessionType) - { - super(source); - - this.sessionType = sessionType; - } - - /** - * Returns the type of the session, either AUDIO_SESSION or VIDEO_SESSION. - * - * @return the type of the session, either AUDIO_SESSION or VIDEO_SESSION. - */ - public int getSessionType() - { - return sessionType; - } -} diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityTimeoutEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityTimeoutEvent.java index 63f546e05..5014a8966 100644 --- a/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityTimeoutEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerSecurityTimeoutEvent.java @@ -8,6 +8,8 @@ import net.java.sip.communicator.service.protocol.*; +import org.jitsi.service.protocol.event.*; + /** * The CallPeerSecurityTimeoutEvent is triggered whenever a * communication with a given peer cannot be established, the peer diff --git a/src/net/java/sip/communicator/service/protocol/event/DTMFReceivedEvent.java b/src/net/java/sip/communicator/service/protocol/event/DTMFReceivedEvent.java index 319eac660..84cac5eaa 100644 --- a/src/net/java/sip/communicator/service/protocol/event/DTMFReceivedEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/DTMFReceivedEvent.java @@ -6,9 +6,11 @@ */ package net.java.sip.communicator.service.protocol.event; +import java.util.*; + import net.java.sip.communicator.service.protocol.*; -import java.util.*; +import org.jitsi.service.protocol.*; /** * DTMFReceivedEvents indicate reception of a DTMF tone. diff --git a/src/net/java/sip/communicator/service/protocol/event/WhiteboardInvitationReceivedEvent.java b/src/net/java/sip/communicator/service/protocol/event/WhiteboardInvitationReceivedEvent.java index 724d479d8..d92c7d360 100644 --- a/src/net/java/sip/communicator/service/protocol/event/WhiteboardInvitationReceivedEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/WhiteboardInvitationReceivedEvent.java @@ -84,4 +84,4 @@ public Date getTimestamp() { return timestamp; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/event/WhiteboardInvitationRejectedEvent.java b/src/net/java/sip/communicator/service/protocol/event/WhiteboardInvitationRejectedEvent.java index afed27a3b..b7d096157 100644 --- a/src/net/java/sip/communicator/service/protocol/event/WhiteboardInvitationRejectedEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/WhiteboardInvitationRejectedEvent.java @@ -122,4 +122,4 @@ public Date getTimestamp() return timestamp; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/event/WhiteboardObjectDeletedEvent.java b/src/net/java/sip/communicator/service/protocol/event/WhiteboardObjectDeletedEvent.java index ac9457fd4..8daeb8586 100644 --- a/src/net/java/sip/communicator/service/protocol/event/WhiteboardObjectDeletedEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/WhiteboardObjectDeletedEvent.java @@ -105,4 +105,4 @@ public Date getTimestamp () { return timestamp; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/event/WhiteboardSessionPresenceChangeEvent.java b/src/net/java/sip/communicator/service/protocol/event/WhiteboardSessionPresenceChangeEvent.java index 6234dc14b..960ce72f5 100644 --- a/src/net/java/sip/communicator/service/protocol/event/WhiteboardSessionPresenceChangeEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/WhiteboardSessionPresenceChangeEvent.java @@ -150,4 +150,4 @@ public String toString() + getWhiteboardSession() + "]"; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetBasicTelephony.java b/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetBasicTelephony.java index c1a7ca850..96e41b44d 100644 --- a/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetBasicTelephony.java +++ b/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetBasicTelephony.java @@ -8,11 +8,12 @@ import java.util.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; + /** * Represents a default implementation of OperationSetBasicTelephony in * order to make it easier for implementers to provide complete solutions while diff --git a/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetVideoTelephony.java b/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetVideoTelephony.java index 9e9074ee4..f2f033bdf 100644 --- a/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetVideoTelephony.java +++ b/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetVideoTelephony.java @@ -11,10 +11,11 @@ import java.text.*; import java.util.List; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.event.*; + +import org.jitsi.service.neomedia.*; +import org.jitsi.util.event.*; /** * Represents a default implementation of OperationSetVideoTelephony in diff --git a/src/net/java/sip/communicator/service/protocol/media/AbstractQualityControlWrapper.java b/src/net/java/sip/communicator/service/protocol/media/AbstractQualityControlWrapper.java index c8114e9de..60d1b4497 100644 --- a/src/net/java/sip/communicator/service/protocol/media/AbstractQualityControlWrapper.java +++ b/src/net/java/sip/communicator/service/protocol/media/AbstractQualityControlWrapper.java @@ -6,8 +6,8 @@ */ package net.java.sip.communicator.service.protocol.media; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.protocol.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.protocol.*; /** * A wrapper of media quality control. @@ -146,4 +146,4 @@ public void setRemoteSendMaxPreset(QualityPreset preset) */ public abstract void setPreferredRemoteSendMaxPreset(QualityPreset preset) throws OperationFailedException; -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java b/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java index 3affd164f..314a4d262 100644 --- a/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java +++ b/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java @@ -11,14 +11,15 @@ import java.util.*; import java.util.List; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.control.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.event.*; -import net.java.sip.communicator.service.neomedia.format.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.event.*; + +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.control.*; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.service.neomedia.event.*; +import org.jitsi.service.neomedia.format.*; +import org.jitsi.util.event.*; /** * A utility class implementing media control code shared between current diff --git a/src/net/java/sip/communicator/service/protocol/media/DynamicPayloadTypeRegistry.java b/src/net/java/sip/communicator/service/protocol/media/DynamicPayloadTypeRegistry.java index 57ab34408..794ff412b 100644 --- a/src/net/java/sip/communicator/service/protocol/media/DynamicPayloadTypeRegistry.java +++ b/src/net/java/sip/communicator/service/protocol/media/DynamicPayloadTypeRegistry.java @@ -8,8 +8,8 @@ import java.util.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.format.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.format.*; /** * The RTP Audio/Video Profile [RFC 3551] specifies a number of static payload diff --git a/src/net/java/sip/communicator/service/protocol/media/DynamicRTPExtensionsRegistry.java b/src/net/java/sip/communicator/service/protocol/media/DynamicRTPExtensionsRegistry.java index 18c817533..9a9e6541d 100644 --- a/src/net/java/sip/communicator/service/protocol/media/DynamicRTPExtensionsRegistry.java +++ b/src/net/java/sip/communicator/service/protocol/media/DynamicRTPExtensionsRegistry.java @@ -8,7 +8,7 @@ import java.util.*; -import net.java.sip.communicator.service.neomedia.*; +import org.jitsi.service.neomedia.*; /** * RFC [RFC 5285] defines a mechanism for attaching multiple extensions to diff --git a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java index 2a05646a6..81b661998 100644 --- a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java +++ b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java @@ -9,12 +9,13 @@ import java.beans.*; import java.util.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.event.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.*; + +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.service.neomedia.event.*; +import org.jitsi.util.*; /** * A utility class implementing media control code shared between current diff --git a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java index 545cf2013..95a7afae6 100644 --- a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java +++ b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java @@ -9,12 +9,13 @@ import java.beans.*; import java.util.*; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.event.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.event.*; + /** * A utility class implementing media control code shared between current * telephony implementations. This class is only meant for use by protocol diff --git a/src/net/java/sip/communicator/service/protocol/media/MediaHandler.java b/src/net/java/sip/communicator/service/protocol/media/MediaHandler.java index f1df1265f..d51cee4b0 100644 --- a/src/net/java/sip/communicator/service/protocol/media/MediaHandler.java +++ b/src/net/java/sip/communicator/service/protocol/media/MediaHandler.java @@ -11,14 +11,15 @@ import java.util.*; import java.util.List; -import net.java.sip.communicator.service.neomedia.*; -import net.java.sip.communicator.service.neomedia.control.*; -import net.java.sip.communicator.service.neomedia.device.*; -import net.java.sip.communicator.service.neomedia.event.*; -import net.java.sip.communicator.service.neomedia.format.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.event.*; + +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.control.*; +import org.jitsi.service.neomedia.device.*; +import org.jitsi.service.neomedia.event.*; +import org.jitsi.service.neomedia.format.*; +import org.jitsi.util.event.*; /** * Implements media control code which allows state sharing among multiple diff --git a/src/net/java/sip/communicator/service/protocol/media/ProtocolMediaActivator.java b/src/net/java/sip/communicator/service/protocol/media/ProtocolMediaActivator.java index 3f7f406cd..a6f95f945 100644 --- a/src/net/java/sip/communicator/service/protocol/media/ProtocolMediaActivator.java +++ b/src/net/java/sip/communicator/service/protocol/media/ProtocolMediaActivator.java @@ -6,11 +6,11 @@ */ package net.java.sip.communicator.service.protocol.media; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.neomedia.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/service/protocol/media/TransportManager.java b/src/net/java/sip/communicator/service/protocol/media/TransportManager.java index 40eac4868..6a3cd6a22 100644 --- a/src/net/java/sip/communicator/service/protocol/media/TransportManager.java +++ b/src/net/java/sip/communicator/service/protocol/media/TransportManager.java @@ -9,13 +9,13 @@ import java.net.*; import java.util.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; import org.ice4j.ice.*; +import org.jitsi.service.configuration.*; +import org.jitsi.service.neomedia.*; /** * TransportManagers are responsible for allocating ports, gathering diff --git a/src/net/java/sip/communicator/service/protocol/media/protocol.media.manifest.mf b/src/net/java/sip/communicator/service/protocol/media/protocol.media.manifest.mf index 8f640cb77..7955aad67 100644 --- a/src/net/java/sip/communicator/service/protocol/media/protocol.media.manifest.mf +++ b/src/net/java/sip/communicator/service/protocol/media/protocol.media.manifest.mf @@ -5,15 +5,16 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, - net.java.sip.communicator.service.neomedia, - net.java.sip.communicator.service.neomedia.control, - net.java.sip.communicator.service.neomedia.device, - net.java.sip.communicator.service.neomedia.event, - net.java.sip.communicator.service.neomedia.format, + org.jitsi.service.configuration, + org.jitsi.service.neomedia, + org.jitsi.service.neomedia.control, + org.jitsi.service.neomedia.device, + org.jitsi.service.neomedia.event, + org.jitsi.service.neomedia.format, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.netaddr, + org.jitsi.util, net.java.sip.communicator.util, net.java.sip.communicator.util.event, org.ice4j.ice diff --git a/src/net/java/sip/communicator/service/protocol/protocol.provider.manifest.mf b/src/net/java/sip/communicator/service/protocol/protocol.provider.manifest.mf index 00a5c7409..7da2c040b 100644 --- a/src/net/java/sip/communicator/service/protocol/protocol.provider.manifest.mf +++ b/src/net/java/sip/communicator/service/protocol/protocol.provider.manifest.mf @@ -5,10 +5,10 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.credentialsstorage, - net.java.sip.communicator.service.neomedia, - net.java.sip.communicator.service.resources, + org.jitsi.service.neomedia, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.event Export-Package: net.java.sip.communicator.service.protocol, diff --git a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObject.java b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObject.java index 73e44910e..9f291e4b8 100644 --- a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObject.java +++ b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObject.java @@ -69,4 +69,4 @@ public interface WhiteboardObject public void setColor(int color); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectCircle.java b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectCircle.java index 080897593..8f3c7d697 100644 --- a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectCircle.java +++ b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectCircle.java @@ -83,4 +83,4 @@ public interface WhiteboardObjectCircle extends WhiteboardObject * @return the RGB value of the background color of this object. */ public int getBackgroundColor (); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectEllipse.java b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectEllipse.java index f612e595e..2aae1ef35 100644 --- a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectEllipse.java +++ b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectEllipse.java @@ -97,4 +97,4 @@ public interface WhiteboardObjectEllipse extends WhiteboardObject * @return the RGB value of the background color of this object. */ public int getBackgroundColor (); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectImage.java b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectImage.java index 4c4ee6f92..7a51fddf3 100644 --- a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectImage.java +++ b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectImage.java @@ -81,4 +81,4 @@ public interface WhiteboardObjectImage extends WhiteboardObject * the object background. */ public byte[] getBackgroundImage(); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectLine.java b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectLine.java index fa7a22389..8c3a4ed36 100644 --- a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectLine.java +++ b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectLine.java @@ -49,4 +49,4 @@ public interface WhiteboardObjectLine extends WhiteboardObject * @param whiteboardPointEnd the new end coordinates for this line. */ public void setWhiteboardPointEnd(WhiteboardPoint whiteboardPointEnd); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectRect.java b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectRect.java index fe3c2f656..e9e3dcbbf 100644 --- a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectRect.java +++ b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectRect.java @@ -97,4 +97,4 @@ public interface WhiteboardObjectRect extends WhiteboardObject * @return the RGB value of the background color of this object. */ public int getBackgroundColor (); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectText.java b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectText.java index 443e35c28..5d8cec565 100644 --- a/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectText.java +++ b/src/net/java/sip/communicator/service/protocol/whiteboardobjects/WhiteboardObjectText.java @@ -78,4 +78,4 @@ public interface WhiteboardObjectText extends WhiteboardObject * @param fontName the new WhiteboardObjectText's font name. */ public void setFontName(String fontName); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/provdisc/provdisc.manifest.mf b/src/net/java/sip/communicator/service/provdisc/provdisc.manifest.mf index 8790e7d2e..ac539c081 100644 --- a/src/net/java/sip/communicator/service/provdisc/provdisc.manifest.mf +++ b/src/net/java/sip/communicator/service/provdisc/provdisc.manifest.mf @@ -4,4 +4,4 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Export-Package: net.java.sip.communicator.service.provdisc, - net.java.sip.communicator.service.provdisc.event \ No newline at end of file + net.java.sip.communicator.service.provdisc.event diff --git a/src/net/java/sip/communicator/service/replacement/ReplacementProperty.java b/src/net/java/sip/communicator/service/replacement/ReplacementProperty.java index f92fe684a..179dbf791 100644 --- a/src/net/java/sip/communicator/service/replacement/ReplacementProperty.java +++ b/src/net/java/sip/communicator/service/replacement/ReplacementProperty.java @@ -31,4 +31,4 @@ public static String getPropertyName(String source) + source + ".enable"; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/replacement/ReplacementService.java b/src/net/java/sip/communicator/service/replacement/ReplacementService.java index ca42b6b7a..f932eed73 100644 --- a/src/net/java/sip/communicator/service/replacement/ReplacementService.java +++ b/src/net/java/sip/communicator/service/replacement/ReplacementService.java @@ -41,4 +41,4 @@ public interface ReplacementService * @return the pattern of the source */ public String getPattern(); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/replacement/replacement.manifest.mf b/src/net/java/sip/communicator/service/replacement/replacement.manifest.mf index c580e7ef8..27b81e381 100644 --- a/src/net/java/sip/communicator/service/replacement/replacement.manifest.mf +++ b/src/net/java/sip/communicator/service/replacement/replacement.manifest.mf @@ -4,4 +4,4 @@ Bundle-Vendor: jitsi.org Bundle-Version: 0.0.1 System-Bundle: yes Export-Package: net.java.sip.communicator.service.replacement, - net.java.sip.communicator.service.replacement.smilies \ No newline at end of file + net.java.sip.communicator.service.replacement.smilies diff --git a/src/net/java/sip/communicator/service/replacement/smilies/Smiley.java b/src/net/java/sip/communicator/service/replacement/smilies/Smiley.java index 5354f5b0c..8aad5b5fd 100644 --- a/src/net/java/sip/communicator/service/replacement/smilies/Smiley.java +++ b/src/net/java/sip/communicator/service/replacement/smilies/Smiley.java @@ -46,4 +46,4 @@ public interface Smiley * @return the path of the image corresponding to this smiley. */ public String getImagePath(); -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/service/resources/ResourceManagementService.java b/src/net/java/sip/communicator/service/resources/ResourceManagementService.java deleted file mode 100644 index a3842df8b..000000000 --- a/src/net/java/sip/communicator/service/resources/ResourceManagementService.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.resources; - -import java.io.*; -import java.net.*; -import java.util.*; - -import javax.swing.*; - -/** - * The Resource Management Service gives easy access to - * common resources for the application including texts, images, sounds and - * some configurations. - * - * @author Damian Minkov - * @author Adam Netocny - */ -public interface ResourceManagementService -{ - // Color pack methods - /** - * Returns the int representation of the color corresponding to the - * given key. - * - * @param key The key of the color in the colors properties file. - * @return the int representation of the color corresponding to the - * given key. - */ - public int getColor(String key); - - /** - * Returns the string representation of the color corresponding to the - * given key. - * - * @param key The key of the color in the colors properties file. - * @return the string representation of the color corresponding to the - * given key. - */ - public String getColorString(String key); - - /** - * Returns the InputStream of the image corresponding to the given - * path. - * - * @param path The path to the image file. - * @return the InputStream of the image corresponding to the given - * path. - */ - public InputStream getImageInputStreamForPath(String path); - - /** - * Returns the InputStream of the image corresponding to the given - * key. - * - * @param streamKey The identifier of the image in the resource properties - * file. - * @return the InputStream of the image corresponding to the given - * key. - */ - public InputStream getImageInputStream(String streamKey); - - /** - * Returns the URL of the image corresponding to the given key. - * - * @param urlKey The identifier of the image in the resource properties file. - * @return the URL of the image corresponding to the given key - */ - public URL getImageURL(String urlKey); - - /** - * Returns the URL of the image corresponding to the given path. - * - * @param path The path to the given image file. - * @return the URL of the image corresponding to the given path. - */ - public URL getImageURLForPath(String path); - - /** - * Returns the image path corresponding to the given key. - * - * @param key The identifier of the image in the resource properties file. - * @return the image path corresponding to the given key. - */ - public String getImagePath(String key); - - // Language pack methods - /** - * Default Locale config string. - */ - public final static String DEFAULT_LOCALE_CONFIG = - "net.java.sip.communicator.service.resources.DefaultLocale"; - - /** - * All the locales in the language pack. - * @return all the locales this Language pack contains. - */ - public Iterator getAvailableLocales(); - - /** - * Returns an internationalized string corresponding to the given key. - * - * @param key The identifier of the string in the resources properties file. - * @return An internationalized string corresponding to the given key. - */ - public String getI18NString(String key); - - /** - * Returns an internationalized string corresponding to the given key. - * - * @param key The identifier of the string in the resources properties file. - * @param locale The locale. - * @return An internationalized string corresponding to the given key and - * given locale. - */ - public String getI18NString(String key, Locale locale); - - /** - * Returns an internationalized string corresponding to the given key. - * - * @param key The identifier of the string in the resources properties file. - * @param params An array of parameters to be replaced in the returned - * string. - * @return An internationalized string corresponding to the given key and - * given locale. - */ - public String getI18NString(String key, String[] params); - - /** - * Returns an internationalized string corresponding to the given key. - * - * @param key The identifier of the string in the resources properties file. - * @param params An array of parameters to be replaced in the returned - * string. - * @param locale The locale. - * @return An internationalized string corresponding to the given key. - */ - public String getI18NString(String key, String[] params, Locale locale); - - /** - * Returns an internationalized string corresponding to the given key. - * - * @param key The identifier of the string in the resources properties file. - * @return An internationalized string corresponding to the given key. - */ - public char getI18nMnemonic(String key); - - /** - * Returns an internationalized string corresponding to the given key. - * - * @param key The key of the string. - * @param l The locale. - * @return An internationalized string corresponding to the given key. - */ - public char getI18nMnemonic(String key, Locale l); - - // Settings pack methods - /** - * Returns an url for the setting corresponding to the given key. - * Used when the setting is an actual file. - * - * @param urlKey The key of the setting. - * @return Url to the corresponding resource. - */ - public URL getSettingsURL(String urlKey); - - /** - * Returns an InputStream for the setting corresponding to the given key. - * Used when the setting is an actual file. - * - * @param streamKey The key of the setting. - * @return InputStream to the corresponding resource. - */ - public InputStream getSettingsInputStream(String streamKey); - - /** - * Returns a stream from a given identifier, obtained through the class - * loader of the given resourceClass. - * - * @param streamKey The identifier of the stream. - * @param resourceClass the resource class through which the resource would - * be obtained - * @return The stream for the given identifier. - */ - public InputStream getSettingsInputStream( String streamKey, - Class resourceClass); - - /** - * Returns the int value of the corresponding configuration key. - * - * @param key The identifier of the string in the resources properties file. - * @return the int value of the corresponding configuration key. - */ - public String getSettingsString(String key); - - /** - * Returns the int value of the corresponding configuration key. - * - * @param key The identifier of the string in the resources properties file. - * @return the int value of the corresponding configuration key. - */ - public int getSettingsInt(String key); - - // Sound pack methods - /** - * Returns an url for the sound resource corresponding to the given key. - * - * @param urlKey The key of the setting. - * @return Url to the corresponding resource. - */ - public URL getSoundURL(String urlKey); - - /** - * Returns an url for the sound resource corresponding to the given path. - * - * @param path The path to the sound resource. - * @return Url to the corresponding resource. - */ - public URL getSoundURLForPath(String path); - - /** - * Returns the path of the sound corresponding to the given - * property key. - * - * @param soundKey The key of the sound. - * @return the path of the sound corresponding to the given - * property key. - */ - public String getSoundPath(String soundKey); - - /** - * Constructs an ImageIcon from the specified image ID and returns - * it. - * - * @param imageID The identifier of the image. - * @return An ImageIcon containing the image with the given - * identifier. - */ - public ImageIcon getImage(String imageID); - - /** - * Loads the image with the specified ID and returns a byte array - * containing it. - * - * @param imageID The identifier of the image. - * @return A byte array containing the image with the given identifier. - */ - public byte[] getImageInBytes(String imageID); - - /** - * Builds a new skin bundle from the zip file content. - * @param zipFile Zip file with skin information. - * @return File for the bundle. - * @throws Exception When something goes wrong. - */ - public File prepareSkinBundleFromZip(File zipFile) throws Exception; -} diff --git a/src/net/java/sip/communicator/service/resources/ResourceManagementServiceUtils.java b/src/net/java/sip/communicator/service/resources/ResourceManagementServiceUtils.java index 695ddf30f..04aa05676 100644 --- a/src/net/java/sip/communicator/service/resources/ResourceManagementServiceUtils.java +++ b/src/net/java/sip/communicator/service/resources/ResourceManagementServiceUtils.java @@ -10,6 +10,7 @@ import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/service/version/Version.java b/src/net/java/sip/communicator/service/version/Version.java deleted file mode 100644 index be58c57d5..000000000 --- a/src/net/java/sip/communicator/service/version/Version.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.version; - -/** - * Contains version information of the SIP Communicator instance that we're - * currently running. - * - * @author Emil Ivov - * @author Lyubomir Marinov - */ -public interface Version - extends Comparable -{ - /** - * The name of the System property the value of which is equal to - * the value of {@link #getApplicationName()}. Expected to be set by - * implementers of the VersionService and Version - * interfaces. - */ - public static final String PNAME_APPLICATION_NAME - = "sip-communicator.application.name"; - - /** - * The name of the System property the value of which is equal to - * the value of {@link #toString()}. Expected to be set by - * implementers of the VersionService and Version - * interfaces. - */ - public static final String PNAME_APPLICATION_VERSION - = "sip-communicator.version"; - - /** - * Returns the version major of the current SIP Communicator version. In an - * example 2.3.1 version string 2 is the version major. The version major - * number changes when a relatively extensive set of new features and - * possibly rearchitecturing have been applied to the SIP Communicator. - * - * @return the version major integer. - */ - public int getVersionMajor(); - - /** - * Returns the version minor of the current SIP Communicator version. In an - * example 2.3.1 version string 3 is the version minor. The version minor - * number changes after adding enhancements and possibly new features to a - * given SIP Communicator version. - * - * @return the version minor integer. - */ - public int getVersionMinor(); - - /** - * Returns the version revision number of the current SIP Communicator - * version. In an example 2.3.1 version string 1 is the revision number. - * The version revision number number changes after applying bug fixes and - * possible some small enhancements to a given SIP Communicator version. - * - * @return the version revision number. - */ - public int getVersionRevision(); - - /** - * Indicates if this SIP Communicator version corresponds to a nightly build - * of a repository snapshot or to an official SIP Communicator release. - * - * @return true if this is a build of a nightly repository snapshot and - * false if this is an official SIP Communicator release. - */ - public boolean isNightly(); - - /** - * If this is a nightly build, returns the build identifies (e.g. - * nightly-2007.12.07-06.45.17). If this is not a nightly build SIP - * Communicator version, the method returns null. - * - * @return a String containing a nightly build identifier or null if - */ - public String getNightlyBuildID(); - - /** - * Indicates whether this version represents a prerelease (i.e. a - * non-complete release like an alpha, beta or release candidate version). - * @return true if this version represents a prerelease and false otherwise. - */ - public boolean isPreRelease(); - - /** - * Returns the version prerelease ID of the current SIP Communicator version - * and null if this version is not a prerelease. Version pre-release id-s - * and version revisions are exclusive, so in case this version is a pre- - * release the revision will bereturn null - * - * @return a String containing the version prerelease ID. - */ - public String getPreReleaseID(); - - /** - * Compares another Version object to this one and returns a - * negative, zero or a positive integer if this version instance represents - * respectively an earlier, same, or later version as the one indicated - * by the version parameter. - * - * @param version the Version instance that we'd like to compare - * to this one. - * - * @return a negative integer, zero, or a positive integer as this object - * represents a version that is earlier, same, or more recent than the one - * referenced by the version parameter. - */ - public int compareTo(Version version); - - /** - * Compares the version parameter to this version and returns true - * if and only if both reference the same SIP Communicator version and - * false otherwise. - * - * @param version the version instance that we'd like to compare with this - * one. - * @return true if and only the version param references the same - * SIP Communicator version as this Version instance and false otherwise. - */ - public boolean equals(Object version); - - /** - * Returns the name of the application that we're currently running. Default - * MUST be SIP Communicator. - * - * @return the name of the application that we're currently running. Default - * MUST be SIP Communicator. - */ - public String getApplicationName(); - - /** - * Returns a String representation of this Version instance. If you'd just - * like to obtain the version of SIP Communicator so that you could display - * it (e.g. in a Help->About dialog) then all you need is calling this - * method. - * - * @return a major.minor.revision[.build] String containing the complete - * SIP Communicator version. - */ - public String toString(); -} diff --git a/src/net/java/sip/communicator/service/version/VersionService.java b/src/net/java/sip/communicator/service/version/VersionService.java deleted file mode 100644 index da53cae5c..000000000 --- a/src/net/java/sip/communicator/service/version/VersionService.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.version; - -/** - * The version service keeps track of the SIP Communicator version that we are - * currently running. Other modules (such as a Help->About dialog) query and - * use this service in order to show the current application version. - * - * @author Emil Ivov - */ -public interface VersionService -{ - /** - * Returns a Version object containing version details of the SIP - * Communicator version that we're currently running. - * - * @return a Version object containing version details of the SIP - * Communicator version that we're currently running. - */ - public Version getCurrentVersion(); - - /** - * Returns a Version instance corresponding to the version string. - * - * @param version a version String that we have obtained by calling a - * Version.toString() method. - * - * @return the Version object corresponding to the version - * string. - */ - public Version parseVersionString(String version); -} diff --git a/src/net/java/sip/communicator/service/version/version.manifest.mf b/src/net/java/sip/communicator/service/version/version.manifest.mf deleted file mode 100755 index 6183ebf3f..000000000 --- a/src/net/java/sip/communicator/service/version/version.manifest.mf +++ /dev/null @@ -1,6 +0,0 @@ -Bundle-Name: Version Service Implementation -Bundle-Description: Version Service Implementation. -Bundle-Vendor: jitsi.org -Bundle-Version: 0.0.1 -System-Bundle: yes -Export-Package: net.java.sip.communicator.service.version diff --git a/src/net/java/sip/communicator/util/FileHandler.java b/src/net/java/sip/communicator/util/FileHandler.java index 2f6e3a576..49b2ecb21 100644 --- a/src/net/java/sip/communicator/util/FileHandler.java +++ b/src/net/java/sip/communicator/util/FileHandler.java @@ -4,7 +4,6 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ - package net.java.sip.communicator.util; import java.io.*; diff --git a/src/net/java/sip/communicator/util/OSUtils.java b/src/net/java/sip/communicator/util/OSUtils.java deleted file mode 100644 index f79efa384..000000000 --- a/src/net/java/sip/communicator/util/OSUtils.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.util; - -/** - * Utility fields for OS detection. - * - * @author Sebastien Vincent - * @author Lubomir Marinov - */ -public class OSUtils -{ - - /** true if architecture is 32 bit. */ - public static final boolean IS_32_BIT; - - /** true if architecture is 64 bit. */ - public static final boolean IS_64_BIT; - - /** true if OS is Android */ - public static final boolean IS_ANDROID; - - /** true if OS is Linux. */ - public static final boolean IS_LINUX; - - /** true if OS is Linux 32-bit. */ - public static final boolean IS_LINUX32; - - /** true if OS is Linux 64-bit. */ - public static final boolean IS_LINUX64; - - /** true if OS is MacOSX. */ - public static final boolean IS_MAC; - - /** true if OS is MacOSX 32-bit. */ - public static final boolean IS_MAC32; - - /** true if OS is MacOSX 64-bit. */ - public static final boolean IS_MAC64; - - /** true if OS is Windows. */ - public static final boolean IS_WINDOWS; - - /** true if OS is Windows 32-bit. */ - public static final boolean IS_WINDOWS32; - - /** true if OS is Windows 64-bit. */ - public static final boolean IS_WINDOWS64; - - /** true if OS is Windows Vista. */ - public static final boolean IS_WINDOWS_VISTA; - - /** true if OS is Windows 7. */ - public static final boolean IS_WINDOWS_7; - - /** true if OS is FreeBSD. */ - public static final boolean IS_FREEBSD; - - static - { - // OS - String osName = System.getProperty("os.name"); - - if (osName == null) - { - IS_ANDROID = false; - IS_LINUX = false; - IS_MAC = false; - IS_WINDOWS = false; - IS_WINDOWS_VISTA = false; - IS_WINDOWS_7 = false; - IS_FREEBSD = false; - } - else if (osName.startsWith("Linux")) - { - String javaVmName = System.getProperty("java.vm.name"); - - if ((javaVmName != null) && javaVmName.equalsIgnoreCase("Dalvik")) - { - IS_ANDROID = true; - IS_LINUX = false; - } - else - { - IS_ANDROID = false; - IS_LINUX = true; - } - IS_MAC = false; - IS_WINDOWS = false; - IS_WINDOWS_VISTA = false; - IS_WINDOWS_7 = false; - IS_FREEBSD = false; - } - else if (osName.startsWith("Mac")) - { - IS_ANDROID = false; - IS_LINUX = false; - IS_MAC = true; - IS_WINDOWS = false; - IS_WINDOWS_VISTA = false; - IS_WINDOWS_7 = false; - IS_FREEBSD = false; - } - else if (osName.startsWith("Windows")) - { - IS_ANDROID = false; - IS_LINUX = false; - IS_MAC = false; - IS_WINDOWS = true; - IS_WINDOWS_VISTA = (osName.indexOf("Vista") != -1); - IS_WINDOWS_7 = (osName.indexOf("7") != -1); - IS_FREEBSD = false; - } - else if (osName.startsWith("FreeBSD")) - { - IS_ANDROID = false; - IS_LINUX = false; - IS_MAC = false; - IS_WINDOWS = false; - IS_WINDOWS_VISTA = false; - IS_WINDOWS_7 = false; - IS_FREEBSD = true; - } - else - { - IS_ANDROID = false; - IS_LINUX = false; - IS_MAC = false; - IS_WINDOWS = false; - IS_WINDOWS_VISTA = false; - IS_WINDOWS_7 = false; - IS_FREEBSD = false; - } - - // arch i.e. x86, amd64 - String osArch = System.getProperty("sun.arch.data.model"); - - if(osArch == null) - { - IS_32_BIT = true; - IS_64_BIT = false; - } - else if (osArch.indexOf("32") != -1) - { - IS_32_BIT = true; - IS_64_BIT = false; - } - else if (osArch.indexOf("64") != -1) - { - IS_32_BIT = false; - IS_64_BIT = true; - } - else - { - IS_32_BIT = false; - IS_64_BIT = false; - } - - // OS && arch - IS_LINUX32 = IS_LINUX && IS_32_BIT; - IS_LINUX64 = IS_LINUX && IS_64_BIT; - IS_MAC32 = IS_MAC && IS_32_BIT; - IS_MAC64 = IS_MAC && IS_64_BIT; - IS_WINDOWS32 = IS_WINDOWS && IS_32_BIT; - IS_WINDOWS64 = IS_WINDOWS && IS_64_BIT; - } -} diff --git a/src/net/java/sip/communicator/util/OrderedProperties.java b/src/net/java/sip/communicator/util/OrderedProperties.java index 369fcda2e..a0010a92e 100644 --- a/src/net/java/sip/communicator/util/OrderedProperties.java +++ b/src/net/java/sip/communicator/util/OrderedProperties.java @@ -114,4 +114,4 @@ public int size() { return linkedMap.size(); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/util/SoundFileUtils.java b/src/net/java/sip/communicator/util/SoundFileUtils.java deleted file mode 100644 index 136085ec7..000000000 --- a/src/net/java/sip/communicator/util/SoundFileUtils.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.util; - -import java.io.*; -import java.util.*; - -/** - * Defines the different permit extension file. - * - * @author Alexandre Maillard - * @author Dmitri Melnikov - * @author Vincent Lucas - */ -public class SoundFileUtils -{ - /** - * Different extension of a sound file - */ - public final static String wav = "wav"; - public final static String mid = "midi"; - public final static String mp2 = "mp2"; - public final static String mp3 = "mp3"; - public final static String mod = "mod"; - public final static String ram = "ram"; - public final static String wma = "wma"; - public final static String ogg = "ogg"; - public final static String gsm = "gsm"; - public final static String aif = "aiff"; - public final static String au = "au"; - - /** - * The file extension and the format of call recording to be used by - * default. - */ - public static final String DEFAULT_CALL_RECORDING_FORMAT = mp3; - - /** - * Checks whether this file is a sound file. - * - * @param f File to check - * @return true if it's a sound file, false otherwise - */ - public static boolean isSoundFile(File f) - { - String ext = getExtension(f); - - if (ext != null) - { - return - ext.equals(wma) - || ext.equals(wav) - || ext.equals(ram) - || ext.equals(ogg) - || ext.equals(mp3) - || ext.equals(mp2) - || ext.equals(mod) - || ext.equals(mid) - || ext.equals(gsm) - || ext.equals(au); - } - return false; - } - - /** - * Checks whether this file is a sound file. - * - * @param f File to check - * @param soundFormats The sound formats to restrict the file name - * extension. If soundFormats is null, then every sound format defined by - * SoundFileUtils is correct. - * - * @return true if it's a sound file conforming to the format given - * in parameters (if soundFormats is null, then every sound format defined - * by SoundFileUtils is correct), false otherwise. - */ - public static boolean isSoundFile(File f, String[] soundFormats) - { - // If there is no specific filters, then compare the file to all sound - // extension available. - if(soundFormats == null) - { - return SoundFileUtils.isSoundFile(f); - } - // Compare the file extension to the sound formats provided in - // parameter. - else - { - String ext = getExtension(f); - - // If the file has an extension - if (ext != null) - { - return (Arrays.binarySearch( - soundFormats, - ext, - String.CASE_INSENSITIVE_ORDER) != -1); - } - } - return false; - } - - /** - * Gets the file extension. - * TODO: There are at least 2 other methods like this scattered around - * the SC code, we should move them all to util package. - * - * @param f which wants the extension - * @return Return the extension as a String - */ - public static String getExtension(File f) - { - String s = f.getName(); - int i = s.lastIndexOf('.'); - String ext = null; - - if ((i > 0) && (i < s.length() - 1)) - ext = s.substring(i+1).toLowerCase(); - return ext; - } -} diff --git a/src/net/java/sip/communicator/util/UtilActivator.java b/src/net/java/sip/communicator/util/UtilActivator.java index 27bb1768c..852f2f8f3 100644 --- a/src/net/java/sip/communicator/util/UtilActivator.java +++ b/src/net/java/sip/communicator/util/UtilActivator.java @@ -11,11 +11,12 @@ import javax.imageio.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.keybindings.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.resources.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/util/dns/ConfigurableDnssecResolver.java b/src/net/java/sip/communicator/util/dns/ConfigurableDnssecResolver.java index 77aa37860..6733d6192 100644 --- a/src/net/java/sip/communicator/util/dns/ConfigurableDnssecResolver.java +++ b/src/net/java/sip/communicator/util/dns/ConfigurableDnssecResolver.java @@ -12,12 +12,12 @@ import javax.swing.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.notification.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.jitsi.service.resources.*; import org.xbill.DNS.*; /** diff --git a/src/net/java/sip/communicator/util/dns/DnsUtilActivator.java b/src/net/java/sip/communicator/util/dns/DnsUtilActivator.java index 49983531b..853adfc6a 100644 --- a/src/net/java/sip/communicator/util/dns/DnsUtilActivator.java +++ b/src/net/java/sip/communicator/util/dns/DnsUtilActivator.java @@ -6,11 +6,12 @@ */ package net.java.sip.communicator.util.dns; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.notification.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; import org.osgi.framework.*; import org.xbill.DNS.*; diff --git a/src/net/java/sip/communicator/util/dns/util.dns.manifest.mf b/src/net/java/sip/communicator/util/dns/util.dns.manifest.mf index dbbdaec4d..5c6b82142 100644 --- a/src/net/java/sip/communicator/util/dns/util.dns.manifest.mf +++ b/src/net/java/sip/communicator/util/dns/util.dns.manifest.mf @@ -9,8 +9,8 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, - net.java.sip.communicator.service.resources, - net.java.sip.communicator.service.configuration, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, + org.jitsi.service.configuration, net.java.sip.communicator.service.notification, sun.net.dns, org.xbill.DNS, diff --git a/src/net/java/sip/communicator/util/event/PropertyChangeNotifier.java b/src/net/java/sip/communicator/util/event/PropertyChangeNotifier.java deleted file mode 100644 index a5f683f24..000000000 --- a/src/net/java/sip/communicator/util/event/PropertyChangeNotifier.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.util.event; - -import java.util.*; -import java.beans.*; - -/** - * Represents a source of PropertyChangeEvents which notifies - * PropertyChangeListeners about changes in the values of properties. - * - * @author Lyubomir Marinov - */ -public class PropertyChangeNotifier -{ - - /** - * The list of PropertyChangeListeners interested in and notified - * about changes in the values of the properties of this - * PropertyChangeNotifier. - */ - private final List listeners - = new Vector(); - - /** - * Adds a specific PropertyChangeListener to the list of listeners - * interested in and notified about changes in the values of the properties - * of this PropertyChangeNotifier. - * - * @param listener a PropertyChangeListener to be notified about - * changes in the values of the properties of this - * PropertyChangeNotifier. If the specified listener is already in - * the list of interested listeners (i.e. it has been previously added), it - * is not added again. - */ - public void addPropertyChangeListener(PropertyChangeListener listener) - { - if (listener != null) - synchronized (listeners) - { - if (!listeners.contains(listener)) - listeners.add(listener); - } - } - - /** - * Removes a specific PropertyChangeListener from the list of - * listeners interested in and notified about changes in the values of the - * properties of this PropertyChangeNotifer. - * - * @param listener a PropertyChangeListener to no longer be - * notified about changes in the values of the properties of this - * PropertyChangeNotifier - */ - public void removePropertyChangeListener(PropertyChangeListener listener) - { - if (listener != null) - synchronized (listeners) - { - listeners.remove(listener); - } - } - - /** - * Fires a new PropertyChangeEvent to the - * PropertyChangeListeners registered with this - * PropertyChangeNotifier in order to notify about a change in the - * value of a specific property which had its old value modified to a - * specific new value. - * - * @param property the name of the property of this - * PropertyChangeNotifier which had its value changed - * @param oldValue the value of the property with the specified name before - * the change - * @param newValue the value of the property with the specified name after - * the change - */ - protected void firePropertyChange( - String property, - Object oldValue, - Object newValue) - { - PropertyChangeListener[] listeners; - synchronized (this.listeners) - { - listeners - = this.listeners - .toArray( - new PropertyChangeListener[this.listeners.size()]); - } - - PropertyChangeEvent event - = new PropertyChangeEvent( - getPropertyChangeSource(property, oldValue, newValue), - property, - oldValue, - newValue); - - for (PropertyChangeListener listener : listeners) - listener.propertyChange(event); - } - - /** - * Gets the Object to be reported as the source of a new - * PropertyChangeEvent which is to notify the - * PropertyChangeListeners registered with this - * PropertyChangeNotifier about the change in the value of a - * property with a specific name from a specific old value to a specific new - * value. - * - * @param property the name of the property which had its value changed from - * the specified old value to the specified new value - * @param oldValue the value of the property with the specified name before - * the change - * @param newValue the value of the property with the specified name after - * the change - * @return the Object to be reported as the source of the new - * PropertyChangeEvent which is to notify the - * PropertyChangeListeners registered with this - * PropertyChangeNotifier about the change in the value of the - * property with the specified name from the specified old value to the - * specified new value - */ - protected Object getPropertyChangeSource( - String property, - Object oldValue, - Object newValue) - { - return this; - } -} diff --git a/src/net/java/sip/communicator/util/event/SizeChangeVideoEvent.java b/src/net/java/sip/communicator/util/event/SizeChangeVideoEvent.java deleted file mode 100644 index e4982bb28..000000000 --- a/src/net/java/sip/communicator/util/event/SizeChangeVideoEvent.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.util.event; - -import java.awt.*; - -/** - * Represents a VideoEvent which notifies about an update to the size - * of a specific visual Component depicting video. - * - * @author Lyubomir Marinov - */ -public class SizeChangeVideoEvent - extends VideoEvent -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * The type of a VideoEvent which notifies about an update to the - * size of a specific visual Component depicting video. - */ - public static final int VIDEO_SIZE_CHANGE = 3; - - /** - * The new height of the associated visual Component. - */ - private final int height; - - /** - * The new width of the associated visual Component. - */ - private final int width; - - /** - * Initializes a new SizeChangeVideoEvent which is to notify about - * an update to the size of a specific visual Component depicting - * video. - * - * @param source the source of the new SizeChangeVideoEvent - * @param visualComponent the visual Component depicting video - * with the updated size - * @param origin the origin of the video the new - * SizeChangeVideoEvent is to notify about - * @param width the new width of visualComponent - * @param height the new height of visualComponent - */ - public SizeChangeVideoEvent( - Object source, - Component visualComponent, - int origin, - int width, - int height) - { - super(source, VIDEO_SIZE_CHANGE, visualComponent, origin); - - this.width = width; - this.height = height; - } - - @Override - public VideoEvent clone(Object source) - { - return - new SizeChangeVideoEvent( - source, - getVisualComponent(), getOrigin(), - getWidth(), getHeight()); - } - - /** - * Gets the new height of the associated visual Component. - * - * @return the new height of the associated visual Component - */ - public int getHeight() - { - return height; - } - - /** - * Gets the new width of the associated visual Component. - * - * @return the new width of the associated visual Component - */ - public int getWidth() - { - return width; - } -} diff --git a/src/net/java/sip/communicator/util/event/VideoEvent.java b/src/net/java/sip/communicator/util/event/VideoEvent.java deleted file mode 100644 index 695e0048f..000000000 --- a/src/net/java/sip/communicator/util/event/VideoEvent.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.util.event; - -import java.awt.*; -import java.util.*; - -/** - * Represents an event fired by providers of visual Components - * depicting video to notify about changes in the availability of such - * Components. - * - * @author Lyubomir Marinov - */ -public class VideoEvent - extends EventObject -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * The video origin of a VideoEvent which is local to the executing - * client such as a local video capture device. - */ - public static final int LOCAL = 1; - - /** - * The video origin of a VideoEvent which is remote to the - * executing client such as a video being remotely streamed from a - * CallPeer. - */ - public static final int REMOTE = 2; - - /** - * The type of a VideoEvent which notifies about a specific visual - * Component depicting video being made available by the firing - * provider. - */ - public static final int VIDEO_ADDED = 1; - - /** - * The type of a VideoEvent which notifies about a specific visual - * Component depicting video no longer being made available by the - * firing provider. - */ - public static final int VIDEO_REMOVED = 2; - - /** - * The indicator which determines whether this event and, more specifically, - * the visual Component it describes have been consumed and should - * be considered owned, referenced (which is important because - * Components belong to a single Container at a time). - */ - private boolean consumed; - - /** - * The origin of the video this VideoEvent notifies about which is - * one of {@link #LOCAL} and {@link #REMOTE}. - */ - private final int origin; - - /** - * The type of availability change this VideoEvent notifies about - * which is one of {@link #VIDEO_ADDED} and {@link #VIDEO_REMOVED}. - */ - private final int type; - - /** - * The visual Component depicting video which had its availability - * changed and which this VideoEvent notifies about. - */ - private final Component visualComponent; - - /** - * Initializes a new VideoEvent which is to notify about a specific - * change in the availability of a specific visual Component - * depicting video and being provided by a specific source. - * - * @param source the source of the new VideoEvent and the provider - * of the visual Component depicting video - * @param type the type of the availability change which has caused the new - * VideoEvent to be fired - * @param visualComponent the visual Component depicting video - * which had its availability in the source provider changed - * @param origin the origin of the video the new VideoEvent is to - * notify about - */ - public VideoEvent( - Object source, - int type, - Component visualComponent, - int origin) - { - super(source); - - this.type = type; - this.visualComponent = visualComponent; - this.origin = origin; - } - - public VideoEvent clone(Object source) - { - return - new VideoEvent( - source, - getType(), getVisualComponent(), getOrigin()); - } - - /** - * Consumes this event and, more specifically, marks the Component - * it describes as owned, referenced in order to let other potential - * consumers know about its current ownership status (which is important - * because Components belong to a single Container at a - * time). - */ - public void consume() - { - consumed = true; - } - - /** - * Gets the origin of the video this VideoEvent notifies about - * which is one of {@link #LOCAL} and {@link #REMOTE}. - * - * @return one of {@link #LOCAL} and {@link #REMOTE} which specifies the - * origin of the video this VideoEvent notifies about - */ - public int getOrigin() - { - return origin; - } - - /** - * Gets the type of availability change this VideoEvent notifies - * about which is one of {@link #VIDEO_ADDED} and {@link #VIDEO_REMOVED}. - * - * @return one of {@link #VIDEO_ADDED} and {@link #VIDEO_REMOVED} which - * describes the type of availability change this VideoEvent - * notifies about - */ - public int getType() - { - return type; - } - - /** - * Gets the visual Component depicting video which had its - * availability changed and which this VideoEvent notifies about. - * - * @return the visual Component depicting video which had its - * availability changed and which this VideoEvent notifies about - */ - public Component getVisualComponent() - { - return visualComponent; - } - - /** - * Determines whether this event and, more specifically, the visual - * Component it describes have been consumed and should be - * considered owned, referenced (which is important because - * Components belong to a single Container at a time). - * - * @return true if this event and, more specifically, the visual - * Component it describes have been consumed and should be - * considered owned, referenced (which is important because - * Components belong to a single Container at a time); - * otherwise, false - */ - public boolean isConsumed() - { - return consumed; - } - - /** - * Returns a human-readable representation of a specific VideoEvent - * origin constant in the form of a String value. - * - * @param origin one of the VideoEvent origin constants such as - * {@link #LOCAL} or {@link #REMOTE} - * @return a String value which gives a human-readable - * representation of the specified VideoEvent origin - * constant - */ - public static String originToString(int origin) - { - switch (origin) - { - case VideoEvent.LOCAL: - return "LOCAL"; - case VideoEvent.REMOTE: - return "REMOTE"; - default: - throw new IllegalArgumentException("origin"); - } - } - - /** - * Returns a human-readable representation of a specific VideoEvent - * type constant in the form of a String value. - * - * @param type one of the VideoEvent type constants such as - * {@link #VIDEO_ADDED} or {@link #VIDEO_REMOVED} - * @return a String value which gives a human-readable - * representation of the specified VideoEvent type - * constant - */ - public static String typeToString(int type) - { - switch (type) - { - case VideoEvent.VIDEO_ADDED: - return "VIDEO_ADDED"; - case VideoEvent.VIDEO_REMOVED: - return "VIDEO_REMOVED"; - default: - throw new IllegalArgumentException("type"); - } - } -} diff --git a/src/net/java/sip/communicator/util/event/VideoListener.java b/src/net/java/sip/communicator/util/event/VideoListener.java deleted file mode 100644 index 25266a7a2..000000000 --- a/src/net/java/sip/communicator/util/event/VideoListener.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.util.event; - -import java.util.*; - -/** - * Defines the notification support informing about changes in the availability - * of visual Components representing video such as adding and - * removing. - * - * @author Lyubomir Marinov - */ -public interface VideoListener - extends EventListener -{ - - /** - * Notifies that a visual Component representing video has been - * added to the provider this listener has been added to. - * - * @param event a VideoEvent describing the added visual - * Component representing video and the provider it was added into - */ - void videoAdded(VideoEvent event); - - /** - * Notifies that a visual Component representing video has been - * removed from the provider this listener has been added to. - * - * @param event a VideoEvent describing the removed visual - * Component representing video and the provider it was removed - * from - */ - void videoRemoved(VideoEvent event); - - /** - * Notifies about an update to a visual Component representing - * video. - * - * @param event a VideoEvent describing the visual - * Component related to the update and the details of the specific - * update - */ - void videoUpdate(VideoEvent event); -} diff --git a/src/net/java/sip/communicator/util/event/VideoNotifierSupport.java b/src/net/java/sip/communicator/util/event/VideoNotifierSupport.java deleted file mode 100644 index af30eafc9..000000000 --- a/src/net/java/sip/communicator/util/event/VideoNotifierSupport.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.util.event; - -import java.awt.*; -import java.util.*; -import java.util.List; // disambiguation - -/** - * Represents a mechanism to easily add to a specific Object by means - * of composition support for firing VideoEvents to - * VideoListeners. - * - * @author Lyubomir Marinov - */ -public class VideoNotifierSupport -{ - private static final long THREAD_TIMEOUT = 5000; - - /** - * The list of VideoEvents which are to be delivered to the - * {@link #listeners} registered with this instance when - * {@link #synchronous} is equal to false. - */ - private final List events; - - /** - * The list of VideoListeners interested in changes in the - * availability of visual Components depicting video. - */ - private final List listeners - = new ArrayList(); - - /** - * The Object which is to be reported as the source of the - * VideoEvents fired by this instance. - */ - private final Object source; - - /** - * The indicator which determines whether this instance delivers the - * VideoEvents to the {@link #listeners} synchronously. - */ - private final boolean synchronous; - - /** - * The Thread in which {@link #events} are delivered to the - * {@link #listeners} when {@link #synchronous} is equal to false. - */ - private Thread thread; - - /** - * Initializes a new VideoNotifierSupport instance which is to - * facilitate the management of VideoListeners and firing - * VideoEvents to them for a specific Object. - * - * @param source the Object which is to be reported as the source - * of the VideoEvents fired by the new instance - */ - public VideoNotifierSupport(Object source) - { - this(source, true); - } - - /** - * Initializes a new VideoNotifierSupport instance which is to - * facilitate the management of VideoListeners and firing - * VideoEvents to them for a specific Object. - * - * @param source the Object which is to be reported as the source - * of the VideoEvents fired by the new instance - * @param synchronous true if the new instance is to deliver the - * VideoEvents synchronously; otherwise, false - */ - public VideoNotifierSupport(Object source, boolean synchronous) - { - this.source = source; - this.synchronous = synchronous; - - events = this.synchronous ? null : new LinkedList(); - } - - /** - * Adds a specific VideoListener to this - * VideoNotifierSupport in order to receive notifications when - * visual/video Components are being added and removed. - *

- * Adding a listener which has already been added does nothing i.e. it is - * not added more than once and thus does not receive one and the same - * VideoEvent multiple times. - *

- * - * @param listener the VideoListener to be notified when - * visual/video Components are being added or removed in this - * VideoNotifierSupport - */ - public void addVideoListener(VideoListener listener) - { - if (listener == null) - throw new NullPointerException("listener"); - - synchronized (listeners) - { - if (!listeners.contains(listener)) - listeners.add(listener); - } - } - - protected void doFireVideoEvent(VideoEvent event) - { - VideoListener[] listeners; - - synchronized (this.listeners) - { - listeners - = this.listeners.toArray( - new VideoListener[this.listeners.size()]); - } - - for (VideoListener listener : listeners) - switch (event.getType()) - { - case VideoEvent.VIDEO_ADDED: - listener.videoAdded(event); - break; - case VideoEvent.VIDEO_REMOVED: - listener.videoRemoved(event); - break; - default: - listener.videoUpdate(event); - break; - } - } - - /** - * Notifies the VideoListeners registered with this - * VideoMediaStream about a specific type of change in the - * availability of a specific visual Component depicting video. - * - * @param type the type of change as defined by VideoEvent in the - * availability of the specified visual Component depicting video - * @param visualComponent the visual Component depicting video - * which has been added or removed - * @param origin {@link VideoEvent#LOCAL} if the origin of the video is - * local (e.g. it is being locally captured); {@link VideoEvent#REMOTE} if - * the origin of the video is remote (e.g. a remote peer is streaming it) - * @param wait true if the call is to wait till the specified - * VideoEvent has been delivered to the VideoListeners; - * otherwise, false - * @return true if this event and, more specifically, the visual - * Component it describes have been consumed and should be - * considered owned, referenced (which is important because - * Components belong to a single Container at a time); - * otherwise, false - */ - public boolean fireVideoEvent( - int type, Component visualComponent, int origin, - boolean wait) - { - VideoEvent event - = new VideoEvent(source, type, visualComponent, origin); - - fireVideoEvent(event, wait); - return event.isConsumed(); - } - - /** - * Notifies the VideoListeners registered with this instance about - * a specific VideoEvent. - * - * @param event the VideoEvent to be fired to the - * VideoListeners registered with this instance - * @param wait true if the call is to wait till the specified - * VideoEvent has been delivered to the VideoListeners; - * otherwise, false - */ - public void fireVideoEvent(VideoEvent event, boolean wait) - { - if (synchronous) - doFireVideoEvent(event); - else - { - synchronized (events) - { - events.add(event); - - if (thread == null) - startThread(); - else - events.notify(); - - if (wait) - { - boolean interrupted = false; - - while (events.contains(event) && (thread != null)) - { - try - { - events.wait(); - } - catch (InterruptedException ie) - { - interrupted = true; - } - } - if (interrupted) - Thread.currentThread().interrupt(); - } - } - } - } - - /** - * Removes a specific VideoListener from this - * VideoNotifierSupport in order to have to no longer receive - * notifications when visual/video Components are being added and - * removed. - * - * @param listener the VideoListener to no longer be notified when - * visual/video Components are being added or removed - */ - public void removeVideoListener(VideoListener listener) - { - synchronized (listeners) - { - listeners.remove(listener); - } - } - - private void runInThread() - { - while (true) - { - VideoEvent event = null; - - synchronized (events) - { - long emptyTime = -1; - boolean interrupted = false; - - while (events.isEmpty()) - { - if (emptyTime == -1) - emptyTime = System.currentTimeMillis(); - else - { - long newEmptyTime = System.currentTimeMillis(); - - if ((newEmptyTime - emptyTime) >= THREAD_TIMEOUT) - { - events.notify(); - return; - } - } - - try - { - events.wait(THREAD_TIMEOUT); - } - catch (InterruptedException ie) - { - interrupted = true; - } - } - if (interrupted) - Thread.currentThread().interrupt(); - - event = events.remove(0); - } - - if (event != null) - { - try - { - doFireVideoEvent(event); - } - catch (Throwable t) - { - if (t instanceof ThreadDeath) - throw (ThreadDeath) t; - } - - synchronized (events) - { - events.notify(); - } - } - } - } - - private void startThread() - { - thread - = new Thread("VideoNotifierSupportThread") - { - @Override - public void run() - { - try - { - runInThread(); - } - finally - { - synchronized (events) - { - if (Thread.currentThread().equals(thread)) - { - thread = null; - if (events.isEmpty()) - events.notify(); - else - startThread(); - } - } - } - } - }; - thread.setDaemon(true); - thread.start(); - } -} diff --git a/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java b/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java index 844da5681..9ecda900c 100644 --- a/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java +++ b/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java @@ -12,6 +12,8 @@ import net.java.sip.communicator.util.*; +import org.jitsi.util.*; + /** * The LauncherArgHandler class handles invocation arguments that have * been passed to us when running SIP Communicator. The class supports a fixed diff --git a/src/net/java/sip/communicator/util/swing/AuthenticationWindow.java b/src/net/java/sip/communicator/util/swing/AuthenticationWindow.java index 539331cc5..e95cf74c0 100644 --- a/src/net/java/sip/communicator/util/swing/AuthenticationWindow.java +++ b/src/net/java/sip/communicator/util/swing/AuthenticationWindow.java @@ -13,6 +13,8 @@ import net.java.sip.communicator.util.*; +import org.jitsi.util.*; + /** * The AuthenticationWindow is the window where the user should type * his user identifier and password to login. diff --git a/src/net/java/sip/communicator/util/swing/EmphasizedLabel.java b/src/net/java/sip/communicator/util/swing/EmphasizedLabel.java index b63af6133..b99e68cef 100644 --- a/src/net/java/sip/communicator/util/swing/EmphasizedLabel.java +++ b/src/net/java/sip/communicator/util/swing/EmphasizedLabel.java @@ -101,4 +101,4 @@ protected void paintComponent(Graphics g) fUseEmphasisColor = false; super.paintComponent(g); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/util/swing/FitLayout.java b/src/net/java/sip/communicator/util/swing/FitLayout.java deleted file mode 100644 index 384824887..000000000 --- a/src/net/java/sip/communicator/util/swing/FitLayout.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.util.swing; - -import java.awt.*; - -/** - * Represents a LayoutManager which centers the first - * Component within its Container and, if the - * preferred size of the Component is larger than the size of the - * Container, scales the former within the bounds of the latter - * while preserving the aspect ratio. FitLayout is appropriate for - * Containers which display a single image or video - * Component in its entirety for which preserving the aspect ratio - * is important. - * - * @author Lyubomir Marinov - */ -public class FitLayout - implements LayoutManager -{ - - /* - * Does nothing because this LayoutManager lays out only the first Component - * of the parent Container and thus doesn't need String associations. - */ - public void addLayoutComponent(String name, Component comp) - { - } - - /** - * Gets the first Component of a specific - * Container if there is such a Component. - * - * @param parent the Container to retrieve the first - * Component of - * @return the first Component of a specific - * Container if there is such a Component; - * otherwise, null - */ - protected Component getComponent(Container parent) - { - Component[] components = parent.getComponents(); - - return (components.length > 0) ? components[0] : null; - } - - protected void layoutComponent(Component component, Rectangle bounds, - float alignmentX, float alignmentY) - { - Dimension componentSize = component.getPreferredSize(); - boolean scale = false; - double widthRatio; - double heightRatio; - - if ((componentSize.width != bounds.width) && (componentSize.width > 0)) - { - scale = true; - widthRatio = bounds.width / (double) componentSize.width; - } - else - widthRatio = 1; - if ((componentSize.height != bounds.height) - && (componentSize.height > 0)) - { - scale = true; - heightRatio = bounds.height / (double) componentSize.height; - } - else - heightRatio = 1; - if (scale) - { - double ratio = Math.min(widthRatio, heightRatio); - - componentSize.width = (int) (componentSize.width * ratio); - componentSize.height = (int) (componentSize.height * ratio); - - // Respect the maximumSize of the component. - if (component.isMaximumSizeSet()) - { - Dimension maximumSize = component.getMaximumSize(); - - if (componentSize.width > maximumSize.width) - componentSize.width = maximumSize.width; - if (componentSize.height > maximumSize.height) - componentSize.height = maximumSize.height; - } - } - - /* - * Why would one fit a Component into a rectangle with zero width and - * height? - */ - if (componentSize.height < 1) - componentSize.height = 1; - if (componentSize.width < 1) - componentSize.width = 1; - - component.setBounds( - bounds.x - + Math.round( - (bounds.width - componentSize.width) * alignmentX), - bounds.y - + Math.round( - (bounds.height - componentSize.height) * alignmentY), - componentSize.width, - componentSize.height); - } - - /* - * Scales the first Component if its preferred size is larger than the size - * of its parent Container in order to display the Component in its entirety - * and then centers it within the display area of the parent. - */ - public void layoutContainer(Container parent) - { - layoutContainer(parent, Component.CENTER_ALIGNMENT); - } - - protected void layoutContainer(Container parent, float componentAlignmentX) - { - Component component = getComponent(parent); - - if (component != null) - layoutComponent(component, new Rectangle(parent.getSize()), - componentAlignmentX, Component.CENTER_ALIGNMENT); - } - - /* - * Since this LayoutManager lays out only the first Component of the - * specified parent Container, the minimum size of the Container is the - * minimum size of the mentioned Component. - */ - public Dimension minimumLayoutSize(Container parent) - { - Component component = getComponent(parent); - - return (component != null) ? component.getMinimumSize() - : new Dimension(0, 0); - } - - /* - * Since this LayoutManager lays out only the first Component of the - * specified parent Container, the preferred size of the Container is the - * preferred size of the mentioned Component. - */ - public Dimension preferredLayoutSize(Container parent) - { - Component component = getComponent(parent); - - return (component != null) ? component.getPreferredSize() - : new Dimension(0, 0); - } - - /* - * Does nothing because this LayoutManager lays out only the first Component - * of the parent Container and thus doesn't need String associations. - */ - public void removeLayoutComponent(Component comp) - { - } -} diff --git a/src/net/java/sip/communicator/util/swing/FramedImage.java b/src/net/java/sip/communicator/util/swing/FramedImage.java index f1945aca6..60d741043 100644 --- a/src/net/java/sip/communicator/util/swing/FramedImage.java +++ b/src/net/java/sip/communicator/util/swing/FramedImage.java @@ -186,4 +186,4 @@ private ImageIcon getScaledImage(byte[] image) { return ImageUtils.getScaledRoundedIcon(image, width - 2, height - 2); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/util/swing/GenericFileDialog.java b/src/net/java/sip/communicator/util/swing/GenericFileDialog.java index 03309218c..86ec57cf5 100644 --- a/src/net/java/sip/communicator/util/swing/GenericFileDialog.java +++ b/src/net/java/sip/communicator/util/swing/GenericFileDialog.java @@ -8,9 +8,9 @@ import java.awt.*; -import javax.swing.JFileChooser; +import javax.swing.*; -import net.java.sip.communicator.util.*; +import org.jitsi.util.*; /** diff --git a/src/net/java/sip/communicator/util/swing/MasterPasswordInputDialog.java b/src/net/java/sip/communicator/util/swing/MasterPasswordInputDialog.java index a33c3771d..59a46ef80 100644 --- a/src/net/java/sip/communicator/util/swing/MasterPasswordInputDialog.java +++ b/src/net/java/sip/communicator/util/swing/MasterPasswordInputDialog.java @@ -10,9 +10,10 @@ import javax.swing.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; + /** * The master password input dialog. * diff --git a/src/net/java/sip/communicator/util/swing/SIPCommCheckBox.java b/src/net/java/sip/communicator/util/swing/SIPCommCheckBox.java index 1e0bcf3f8..7ddf98f7e 100644 --- a/src/net/java/sip/communicator/util/swing/SIPCommCheckBox.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommCheckBox.java @@ -8,7 +8,7 @@ import javax.swing.*; -import net.java.sip.communicator.util.*; +import org.jitsi.util.*; /** * @author Lubomir Marinov diff --git a/src/net/java/sip/communicator/util/swing/SIPCommDialog.java b/src/net/java/sip/communicator/util/swing/SIPCommDialog.java index 282d4a4a4..8279e94f9 100644 --- a/src/net/java/sip/communicator/util/swing/SIPCommDialog.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommDialog.java @@ -11,8 +11,11 @@ import javax.swing.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; + +import org.jitsi.service.configuration.*; +import org.jitsi.util.*; /** * @author Yana Stamcheva diff --git a/src/net/java/sip/communicator/util/swing/SIPCommFrame.java b/src/net/java/sip/communicator/util/swing/SIPCommFrame.java index e00420420..158760ee4 100644 --- a/src/net/java/sip/communicator/util/swing/SIPCommFrame.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommFrame.java @@ -16,10 +16,13 @@ import javax.swing.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.keybindings.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; + +import org.jitsi.service.configuration.*; +import org.jitsi.service.resources.*; +import org.jitsi.util.*; /** * A custom frame that remembers its size and location and could have a diff --git a/src/net/java/sip/communicator/util/swing/SIPCommRadioButton.java b/src/net/java/sip/communicator/util/swing/SIPCommRadioButton.java index 6e9ad5893..42a7f5d31 100644 --- a/src/net/java/sip/communicator/util/swing/SIPCommRadioButton.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommRadioButton.java @@ -8,7 +8,7 @@ import javax.swing.*; -import net.java.sip.communicator.util.*; +import org.jitsi.util.*; /** * @author Ingo Bauersachs diff --git a/src/net/java/sip/communicator/util/swing/SIPCommTextField.java b/src/net/java/sip/communicator/util/swing/SIPCommTextField.java index 151dc7c4c..54c04f6ed 100644 --- a/src/net/java/sip/communicator/util/swing/SIPCommTextField.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommTextField.java @@ -283,4 +283,4 @@ private void fireTextFieldChangeListener(int eventType) case 1: l.textRemoved(); break; } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/util/swing/SipCommFileDialogImpl.java b/src/net/java/sip/communicator/util/swing/SipCommFileDialogImpl.java index 8c5cc1e0e..c61735b68 100644 --- a/src/net/java/sip/communicator/util/swing/SipCommFileDialogImpl.java +++ b/src/net/java/sip/communicator/util/swing/SipCommFileDialogImpl.java @@ -6,11 +6,11 @@ */ package net.java.sip.communicator.util.swing; -import net.java.sip.communicator.util.*; - import java.awt.*; import java.io.*; +import org.jitsi.util.*; + /** * Implements SipCommFileChooser for AWT's FileDialog. * diff --git a/src/net/java/sip/communicator/util/swing/SoundLevelIndicator.java b/src/net/java/sip/communicator/util/swing/SoundLevelIndicator.java index 81894bb64..92b65dd2d 100644 --- a/src/net/java/sip/communicator/util/swing/SoundLevelIndicator.java +++ b/src/net/java/sip/communicator/util/swing/SoundLevelIndicator.java @@ -10,10 +10,11 @@ import javax.swing.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; +import org.jitsi.service.resources.*; + /** * Represents the sound level indicator for a particular peer. * diff --git a/src/net/java/sip/communicator/util/swing/SwingWorker.java b/src/net/java/sip/communicator/util/swing/SwingWorker.java index 9b193a102..aa2d90693 100644 --- a/src/net/java/sip/communicator/util/swing/SwingWorker.java +++ b/src/net/java/sip/communicator/util/swing/SwingWorker.java @@ -216,4 +216,4 @@ public void run() }); } } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/util/swing/TransparentPanel.java b/src/net/java/sip/communicator/util/swing/TransparentPanel.java index ba7600f67..d2b6cfb11 100644 --- a/src/net/java/sip/communicator/util/swing/TransparentPanel.java +++ b/src/net/java/sip/communicator/util/swing/TransparentPanel.java @@ -8,25 +8,23 @@ import java.awt.*; -import javax.swing.*; - /** - * @author Yana Stamcheva + * Provides compatibility with source code written prior to the inception of + * libjitsi. + * + * @author Lyubomir Marinov */ public class TransparentPanel - extends JPanel + extends org.jitsi.util.swing.TransparentPanel { private static final long serialVersionUID = 0L; public TransparentPanel() { - this.setOpaque(false); } public TransparentPanel(LayoutManager layout) { super(layout); - - this.setOpaque(false); } } diff --git a/src/net/java/sip/communicator/util/swing/VideoContainer.java b/src/net/java/sip/communicator/util/swing/VideoContainer.java deleted file mode 100644 index aed90a1b3..000000000 --- a/src/net/java/sip/communicator/util/swing/VideoContainer.java +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.util.swing; - -import java.awt.*; -import java.awt.event.*; -import java.lang.reflect.*; - -import net.java.sip.communicator.util.*; - -/** - * Implements a Container for video/visual Components. - * VideoContainer uses {@link VideoLayout} to layout the video/visual - * Components it contains. A specific Component can be - * displayed by default at {@link VideoLayout#CENTER_REMOTE}. - * - * @author Lyubomir Marinov - * @author Yana Stamcheva - */ -public class VideoContainer - extends TransparentPanel -{ - /** - * Serial version UID. - */ - private static final long serialVersionUID = 0L; - - /** - * The Logger used by the VideoContainer class and its - * instances for logging output. - */ - private static final Logger logger = Logger.getLogger(VideoContainer.class); - - /** - * The default background color. - */ - public static final Color DEFAULT_BACKGROUND_COLOR - = OSUtils.IS_MAC ? Color.BLACK : null; - - /** - * The name of the instance method of Components added to - * VideoContainer which creates a new Component acting as - * a canvas in which the other Components contained in the - * VideoContainer are painted. - */ - private static final String VIDEO_CANVAS_FACTORY_METHOD_NAME - = "createCanvas"; - - /** - * The Component which is the canvas, if any, in which the other - * Components contained in this VideoContainer are - * painted. - */ - private Component canvas; - - /** - * The Component to be displayed by this VideoContainer - * at {@link VideoLayout#CENTER_REMOTE} when no other Component has - * been added to it to be displayed there. For example, the avatar of the - * remote peer may be displayed in place of the remote video when the remote - * video is not available. - */ - private final Component noVideoComponent; - - /** - * Initializes a new VideoContainer with a specific - * Component to be displayed when no remote video is available. - * - * @param noVideoComponent the component to be displayed when no remote - * video is available - * @param isConference indicates if this VideoLayout is dedicated - * to a conference interface. - */ - public VideoContainer(Component noVideoComponent, boolean isConference) - { - setLayout(new VideoLayout(isConference)); - - this.noVideoComponent = noVideoComponent; - - /* - * JAWTRenderer on Mac OS X will by default occupy the whole video - * container and will, consequently, draw a black background. In certain - * problematic cases which it will try to provide a workaround, it will - * not occupy the whole video container. To make the experience - * relatively the same, always use a black background. - */ - if (DEFAULT_BACKGROUND_COLOR != null) - { - setBackground(DEFAULT_BACKGROUND_COLOR); - addContainerListener( - new ContainerListener() - { - public void componentAdded(ContainerEvent e) - { - int componentCount = getComponentCount(); - - if ((componentCount == 1) - && (getComponent(0) - == VideoContainer.this.noVideoComponent)) - componentCount = 0; - - setOpaque(componentCount > 0); - } - - public void componentRemoved(ContainerEvent e) - { - /* - * It's all the same with respect to the purpose of this - * ContainerListener. - */ - componentAdded(e); - } - }); - } - - if (this.noVideoComponent != null) - { - add(this.noVideoComponent, VideoLayout.CENTER_REMOTE, -1); - validate(); - } - } - - /** - * Adds the given component at the {@link VideoLayout#CENTER_REMOTE} - * position in the default video layout. - * - * @param comp the component to add - * @return the added component - */ - @Override - public Component add(Component comp) - { - add(comp, VideoLayout.CENTER_REMOTE); - return comp; - } - - @Override - public Component add(Component comp, int index) - { - add(comp, null, index); - return comp; - } - - @Override - public void add(Component comp, Object constraints) - { - add(comp, constraints, -1); - } - - /** - * Overrides the default behavior of add in order to be sure to remove the - * default "no video" component when a remote video component is added. - * - * @param comp the component to add - * @param constraints - * @param index - */ - @Override - public void add(Component comp, Object constraints, int index) - { - if (VideoLayout.CENTER_REMOTE.equals(constraints) - && (noVideoComponent != null) - && !noVideoComponent.equals(comp) - || (comp.equals(noVideoComponent) - && noVideoComponent.getParent() != null)) - { - remove(noVideoComponent); - validate(); - } - - if ((canvas == null) || (canvas.getParent() != this)) - { - if (OSUtils.IS_MAC && (comp != canvas)) - { - /* - * Unless the comp has a createCanvas() method, it makes no - * sense to consider any exception a problem. - */ - boolean ignoreException; - Throwable exception; - - ignoreException = true; - exception = null; - canvas = null; - - try - { - Method m - = comp.getClass().getMethod( - VIDEO_CANVAS_FACTORY_METHOD_NAME); - - if (m != null) - { - ignoreException = false; - - Object c = m.invoke(comp); - - if (c instanceof Component) - canvas = (Component) c; - } - } - catch (ClassCastException cce) - { - exception = cce; - } - catch (ExceptionInInitializerError eiie) - { - exception = eiie; - } - catch (IllegalAccessException illegalAccessException) - { - exception = illegalAccessException; - } - catch (IllegalArgumentException illegalArgumentException) - { - exception = illegalArgumentException; - } - catch (InvocationTargetException ita) - { - exception = ita; - } - catch (NoSuchMethodException nsme) - { - exception = nsme; - } - catch (NullPointerException npe) - { - exception = npe; - } - catch (SecurityException se) - { - exception = se; - } - if (canvas != null) - add(canvas, VideoLayout.CANVAS, 0); - else if ((exception != null) && !ignoreException) - logger.error("Failed to create video canvas.", exception); - } - } - if ((canvas != null) - && (canvas.getParent() == this) - && OSUtils.IS_MAC - && (comp != canvas)) - { - /* - * The canvas in which the other components are to be painted should - * always be at index 0. And the order of adding is important so no - * index should be specified - */ - index = -1; - } - - /* - * XXX Do not call #remove(Component) beyond this point and before - * #add(Component, Object, int) because #removeCanvasIfNecessary() will - * remove the canvas. - */ - - super.add(comp, constraints, index); - } - - /** - * Overrides the default remove behavior in order to add the default no - * video component when the remote video is removed. - * - * @param comp the component to remove - */ - @Override - public void remove(Component comp) - { - super.remove(comp); - - if ((comp == canvas) - && (canvas != null) - && (canvas.getParent() != this)) - { - canvas = null; - validate(); - } - - Component[] components = getComponents(); - VideoLayout videoLayout = (VideoLayout) getLayout(); - boolean hasComponentsAtCenterRemote = false; - - for (Component c : components) - { - if (!c.equals(noVideoComponent) - && VideoLayout.CENTER_REMOTE.equals( - videoLayout.getComponentConstraints(c))) - { - hasComponentsAtCenterRemote = true; - break; - } - } - - if (!hasComponentsAtCenterRemote - && (noVideoComponent != null) - && !noVideoComponent.equals(comp)) - { - add(noVideoComponent, VideoLayout.CENTER_REMOTE); - validate(); - } - - removeCanvasIfNecessary(); - } - - /** - * Ensures noVideoComponent is displayed even when the clients of the - * videoContainer invoke its #removeAll() to remove their previous visual - * Components representing video. Just adding noVideoComponent upon - * ContainerEvent#COMPONENT_REMOVED when there is no other Component left in - * the Container will cause an infinite loop because Container#removeAll() - * will detect that a new Component has been added while dispatching the - * event and will then try to remove the new Component. - */ - @Override - public void removeAll() - { - super.removeAll(); - - if ((canvas != null) && (canvas.getParent() != this)) - canvas = null; - - if (noVideoComponent != null) - { - add(noVideoComponent, VideoLayout.CENTER_REMOTE); - validate(); - } - } - - /** - * Removes {@link #canvas} from this VideoContainer if no sibling - * Component needs it. - */ - public void removeCanvasIfNecessary() - { - if ((canvas == null) || !OSUtils.IS_MAC) - return; - - boolean removeCanvas = true; - - for (Component component : getComponents()) - { - if (component == canvas) - continue; - try - { - component.getClass().getMethod( - VIDEO_CANVAS_FACTORY_METHOD_NAME); - removeCanvas = false; - break; - } - catch (NoSuchMethodException nsme) - { - /* - * Ignore it because we already presume that component does not - * need the canvas. - */ - } - } - if (removeCanvas) - remove(canvas); - } -} diff --git a/src/net/java/sip/communicator/util/swing/VideoLayout.java b/src/net/java/sip/communicator/util/swing/VideoLayout.java deleted file mode 100644 index fb7ba7c87..000000000 --- a/src/net/java/sip/communicator/util/swing/VideoLayout.java +++ /dev/null @@ -1,470 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.util.swing; - -import java.awt.*; -import java.util.*; -import java.util.List; - -import javax.swing.*; - -/** - * Implements the LayoutManager which lays out the local and remote - * videos in a video Call. - * - * @author Lyubomir Marinov - * @author Yana Stamcheva - */ -public class VideoLayout extends FitLayout -{ - /** - * The video canvas constraint. - */ - public static final String CANVAS = "CANVAS"; - - /** - * The center remote video constraint. - */ - public static final String CENTER_REMOTE = "CENTER_REMOTE"; - - /** - * The close local video constraint. - */ - public static final String CLOSE_LOCAL_BUTTON = "CLOSE_LOCAL_BUTTON"; - - /** - * The east remote video constraint. - */ - public static final String EAST_REMOTE = "EAST_REMOTE"; - - /** - * The local video constraint. - */ - public static final String LOCAL = "LOCAL"; - - /** - * The ration between the local and the remote video. - */ - private static final float LOCAL_TO_REMOTE_RATIO = 0.30f; - - /** - * The video canvas. - */ - private Component canvas; - - /** - * The close local video button component. - */ - private Component closeButton; - - /** - * The map of component constraints. - */ - private final HashMap constraints - = new HashMap(); - - /** - * The component containing the local video. - */ - private Component local; - - /** - * The list of Components depicting remote videos. - */ - private final List remotes = new LinkedList(); - - /** - * The x coordinate alignment of the remote video. - */ - private float remoteAlignmentX = Component.CENTER_ALIGNMENT; - - /** - * Indicates if this VideoLayout is dedicated to a conference - * interface. - */ - private final boolean isConference; - - /** - * Creates an instance of VideoLayout by also indicating if this - * video layout is dedicated to a conference interface. - * - * @param isConference indicates if this VideoLayout is dedicated - * to a conference interface. - */ - public VideoLayout(boolean isConference) - { - super(); - - this.isConference = isConference; - } - - /** - * Adds the given component in this layout on the specified by name - * position. - * - * @param name the constraint giving the position of the component in this - * layout - * @param comp the component to add - */ - @Override - public void addLayoutComponent(String name, Component comp) - { - super.addLayoutComponent(name, comp); - - synchronized (constraints) - { - this.constraints.put(comp, name); - } - - if ((name == null) || name.equals(CENTER_REMOTE)) - { - remotes.add(comp); - remoteAlignmentX = Component.CENTER_ALIGNMENT; - } - else if (name.equals(EAST_REMOTE)) - { - remotes.add(comp); - remoteAlignmentX = Component.RIGHT_ALIGNMENT; - } - else if (name.equals(LOCAL)) - local = comp; - else if (name.equals(CLOSE_LOCAL_BUTTON)) - closeButton = comp; - else if (name.equals(CANVAS)) - canvas = comp; - } - - /** - * Determines how may columns to use for the grid display of specific remote - * visual/video Components. - * - * @param remotes the remote visual/video Components to be - * displayed in a grid - * @return the number of columns to use for the grid display of the - * specified remote visual/video Components - */ - private int calculateColumnCount(List remotes) - { - int remotesCount = remotes.size(); - - if (remotesCount == 1) - return 1; - else if (remotesCount == 2 || remotesCount == 4) - return 2; - else - return 3; - } - - /** - * Returns the remote video component. - * - * @return the remote video component - */ - @Override - protected Component getComponent(Container parent) - { - return (remotes.size() == 1) ? remotes.get(0) : null; - } - - /** - * Returns the constraints for the given component. - * - * @param c the component for which constraints we're looking for - * @return the constraints for the given component - */ - public Object getComponentConstraints(Component c) - { - synchronized (constraints) - { - return constraints.get(c); - } - } - - /** - * Returns the local video component. - * - * @return the local video component - */ - public Component getLocal() - { - return local; - } - - /** - * Returns the local video close button. - * - * @return the local video close button - */ - public Component getLocalCloseButton() - { - return closeButton; - } - - /** - * Lays out this given container. - * - * @param parent the container to lay out - */ - @Override - public void layoutContainer(Container parent) - { - List remotes; - Component local = getLocal(); - - /* - * When there are multiple remote visual/video Components, the local one - * will be displayed as if it is a remote one i.e. in the same grid, not - * on top of a remote one. - */ - if ((this.remotes.size() > 1) && (local != null)) - { - remotes = new ArrayList(); - remotes.addAll(this.remotes); - remotes.add(local); - } - else - remotes = this.remotes; - - int remoteCount = remotes.size(); - - // We need to reduce parent size in order to fit also the space we've - // left between videos. - Dimension parentSize = parent.getSize(); - parentSize.width -= remoteCount*10; - - if (remoteCount == 1 && !isConference) - { - super.layoutContainer(parent, - (local == null) - ? Component.CENTER_ALIGNMENT - : remoteAlignmentX); - } - else if (remoteCount > 0) - { - int columns = calculateColumnCount(remotes); - int rows = (remoteCount + columns - 1) / columns; - Rectangle bounds - = new Rectangle( - 0, - 0, - parentSize.width / columns, - parentSize.height / rows); - int columnsMinus1 = columns - 1; - int i = 0; - - for (Component remote : remotes) - { - /* - * We want the remote videos ordered from right to left so that - * the local video does not cover a remote video when possible. - */ - bounds.x = (columnsMinus1 - (i % columns)) * bounds.width; - bounds.y = (i / columns) * bounds.height; - - if (bounds.x > 0) - bounds.x += ((columns - (i%columns))*10); - - super.layoutComponent( - remote, - bounds, - Component.CENTER_ALIGNMENT, - Component.CENTER_ALIGNMENT); - - i++; - if (i >= remoteCount) - break; - } - } - - if (local != null) - { - /* - * If the local visual/video Component is not displayed as if it is - * a remote one, it will be placed on top of a remote one. - */ - if (!remotes.contains(local) && !isConference) - { - Component remote0 = remotes.isEmpty() ? null : remotes.get(0); - int localX; - int localY; - int height - = Math.round(parentSize.height * LOCAL_TO_REMOTE_RATIO); - int width - = Math.round(parentSize.width * LOCAL_TO_REMOTE_RATIO); - - /* - * XXX The remote Component being a JLabel is meant to signal - * that there is no remote video and the remote is the - * photoLabel. - */ - if ((remotes.size() == 1) && (remote0 instanceof JLabel)) - { - localX = parentSize.width/2 - width/2; - localY = parentSize.height - height; - super.layoutComponent( - local, - new Rectangle(localX, localY, width, height), - Component.CENTER_ALIGNMENT, - Component.BOTTOM_ALIGNMENT); - } - else - { - localX = ((remote0 == null) ? 0 : remote0.getX()) + 5; - localY = parentSize.height - height - 5; - - super.layoutComponent( - local, - new Rectangle(localX, localY, width, height), - Component.LEFT_ALIGNMENT, - Component.BOTTOM_ALIGNMENT); - } - } - - if (closeButton != null) - { - super.layoutComponent( - closeButton, - new Rectangle( - local.getX() + local.getWidth() - - closeButton.getWidth(), - local.getY(), - closeButton.getWidth(), - closeButton.getHeight()), - Component.CENTER_ALIGNMENT, - Component.CENTER_ALIGNMENT); - } - } - - if (canvas != null) - { - /* - * The video canvas will get the locations of the other components - * to paint so it has to cover the parent completely. - */ - canvas.setBounds(0, 0, parentSize.width, parentSize.height); - } - } - - /** - * Returns the minimum layout size for the given container. - * - * @param parent the container which minimum layout size we're looking for - * @return a Dimension containing, the minimum layout size for the given - * container - */ - @Override - public Dimension minimumLayoutSize(Container parent) - { - // TODO Auto-generated method stub - return super.minimumLayoutSize(parent); - } - - /** - * Returns the preferred layout size for the given container. - * - * @param parent the container which preferred layout size we're looking for - * @return a Dimension containing, the preferred layout size for the given - * container - */ - @Override - public Dimension preferredLayoutSize(Container parent) - { - List remotes; - Component local = getLocal(); - - /* - * When there are multiple remote visual/video Components, the local one - * will be displayed as if it is a remote one i.e. in the same grid, not - * on top of a remote one. - */ - if ((this.remotes.size() > 1) && (local != null)) - { - remotes = new ArrayList(); - remotes.addAll(this.remotes); - remotes.add(local); - } - else - remotes = this.remotes; - - int remoteCount = remotes.size(); - - if (remoteCount == 0) - { - /* - * If there is no remote visual/video Component, the local one will - * serve the preferredSize of the Container. - */ - if (local != null) - { - Dimension preferredSize = local.getPreferredSize(); - - if (preferredSize != null) - return preferredSize; - } - } - else if (remoteCount == 1) - { - /* - * If there is a single remote visual/video Component, the local one - * will be on top of it so the remote one will serve the - * preferredSize of the Container. - */ - Dimension preferredSize = remotes.get(0).getPreferredSize(); - - if (preferredSize != null) - return preferredSize; - } - else if (remoteCount > 1) - { - int maxWidth = 0; - int maxHeight = 0; - - for (Component remote : remotes) - { - Dimension preferredSize = remote.getPreferredSize(); - - if (preferredSize != null) - { - if (maxWidth < preferredSize.width) - maxWidth = preferredSize.width; - if (maxHeight < preferredSize.height) - maxHeight = preferredSize.height; - } - } - - if ((maxWidth > 0) && (maxHeight > 0)) - { - int columns = calculateColumnCount(remotes); - int rows = (remoteCount + columns - 1) / columns; - - return new Dimension(maxWidth * columns, maxHeight * rows); - } - } - - return super.preferredLayoutSize(parent); - } - - /** - * Removes the given component from this layout. - * - * @param comp the component to remove from the layout - */ - @Override - public void removeLayoutComponent(Component comp) - { - super.removeLayoutComponent(comp); - - if (local == comp) - local = null; - else if (closeButton == comp) - closeButton = null; - else if (canvas == comp) - canvas = null; - else - remotes.remove(comp); - } -} diff --git a/src/net/java/sip/communicator/util/swing/X509CertificatePanel.java b/src/net/java/sip/communicator/util/swing/X509CertificatePanel.java index fbab15478..4673cb6d4 100644 --- a/src/net/java/sip/communicator/util/swing/X509CertificatePanel.java +++ b/src/net/java/sip/communicator/util/swing/X509CertificatePanel.java @@ -18,9 +18,10 @@ import javax.security.auth.x500.*; import javax.swing.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.resources.*; + /** * Panel that shows the content of an X509Certificate. */ diff --git a/src/net/java/sip/communicator/util/swing/plaf/SIPCommTextFieldUI.java b/src/net/java/sip/communicator/util/swing/plaf/SIPCommTextFieldUI.java index fb303ed49..5b6819746 100644 --- a/src/net/java/sip/communicator/util/swing/plaf/SIPCommTextFieldUI.java +++ b/src/net/java/sip/communicator/util/swing/plaf/SIPCommTextFieldUI.java @@ -468,4 +468,4 @@ public static ComponentUI createUI(JComponent c) { return new SIPCommTextFieldUI(); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/util/swing/transparent/AWTUtilitiesWrapper.java b/src/net/java/sip/communicator/util/swing/transparent/AWTUtilitiesWrapper.java index e247c3d73..e72c385d3 100644 --- a/src/net/java/sip/communicator/util/swing/transparent/AWTUtilitiesWrapper.java +++ b/src/net/java/sip/communicator/util/swing/transparent/AWTUtilitiesWrapper.java @@ -161,4 +161,4 @@ public static void setWindowOpaque(Window window, boolean opaque) { set(mSetWindowOpaque, window, Boolean.valueOf(opaque)); } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/util/util.manifest.mf b/src/net/java/sip/communicator/util/util.manifest.mf index 2189026dc..9b27cfc7e 100644 --- a/src/net/java/sip/communicator/util/util.manifest.mf +++ b/src/net/java/sip/communicator/util/util.manifest.mf @@ -27,14 +27,17 @@ Import-Package: org.xml.sax, javax.naming.ldap, javax.imageio, javax.security.auth.x500, - net.java.sip.communicator.util.xml, + org.jitsi.util, + org.jitsi.util.swing, net.java.sip.communicator.util, net.java.sip.communicator.util.dns, + net.java.sip.communicator.util.xml, + org.jitsi.service.resources, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.keybindings, net.java.sip.communicator.service.netaddr, net.java.sip.communicator.service.netaddr.event, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.contactlist, sun.awt.shell, sun.net.util, diff --git a/test/net/java/sip/communicator/slick/configuration/ConfigurationServiceLick.java b/test/net/java/sip/communicator/slick/configuration/ConfigurationServiceLick.java index 0c096d377..c16a9a384 100644 --- a/test/net/java/sip/communicator/slick/configuration/ConfigurationServiceLick.java +++ b/test/net/java/sip/communicator/slick/configuration/ConfigurationServiceLick.java @@ -10,7 +10,7 @@ import org.osgi.framework.*; import junit.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.*; /** diff --git a/test/net/java/sip/communicator/slick/configuration/TestConfigurationService.java b/test/net/java/sip/communicator/slick/configuration/TestConfigurationService.java index 1713aca7b..f1bc8e24e 100644 --- a/test/net/java/sip/communicator/slick/configuration/TestConfigurationService.java +++ b/test/net/java/sip/communicator/slick/configuration/TestConfigurationService.java @@ -6,12 +6,12 @@ */ package net.java.sip.communicator.slick.configuration; -import java.util.*; import java.beans.*; +import java.util.*; import junit.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import org.osgi.framework.*; /** diff --git a/test/net/java/sip/communicator/slick/configuration/TestConfigurationServicePersistency.java b/test/net/java/sip/communicator/slick/configuration/TestConfigurationServicePersistency.java index 67b56e8d6..4b91299e3 100644 --- a/test/net/java/sip/communicator/slick/configuration/TestConfigurationServicePersistency.java +++ b/test/net/java/sip/communicator/slick/configuration/TestConfigurationServicePersistency.java @@ -12,7 +12,7 @@ import org.osgi.framework.*; import org.w3c.dom.*; import junit.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.util.xml.*; /** diff --git a/test/net/java/sip/communicator/slick/configuration/TestConfigurationSlickFinalizer.java b/test/net/java/sip/communicator/slick/configuration/TestConfigurationSlickFinalizer.java index 5cd3a7e11..ee4449c7d 100644 --- a/test/net/java/sip/communicator/slick/configuration/TestConfigurationSlickFinalizer.java +++ b/test/net/java/sip/communicator/slick/configuration/TestConfigurationSlickFinalizer.java @@ -9,7 +9,7 @@ import java.util.*; import junit.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import org.osgi.framework.*; diff --git a/test/net/java/sip/communicator/slick/configuration/configuration.slick.manifest.mf b/test/net/java/sip/communicator/slick/configuration/configuration.slick.manifest.mf index 8814bbef4..91b33e7fe 100644 --- a/test/net/java/sip/communicator/slick/configuration/configuration.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/configuration/configuration.slick.manifest.mf @@ -5,7 +5,7 @@ Bundle-Vendor: sip-communicator.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: junit.framework, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, org.osgi.framework, org.w3c.dom, javax.xml.parsers, diff --git a/test/net/java/sip/communicator/slick/contactlist/meta.cl.slick.manifest.mf b/test/net/java/sip/communicator/slick/contactlist/meta.cl.slick.manifest.mf index 685edc2a5..2987fdc5c 100644 --- a/test/net/java/sip/communicator/slick/contactlist/meta.cl.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/contactlist/meta.cl.slick.manifest.mf @@ -10,7 +10,7 @@ Import-Package: net.java.sip.communicator.service.contactlist, junit.framework, net.java.sip.communicator.util, net.java.sip.communicator.util.dns, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.icqconstants, net.java.sip.communicator.service.protocol.event, diff --git a/test/net/java/sip/communicator/slick/fileaccess/FileAccessServiceLick.java b/test/net/java/sip/communicator/slick/fileaccess/FileAccessServiceLick.java index 14220b1fb..62668d767 100644 --- a/test/net/java/sip/communicator/slick/fileaccess/FileAccessServiceLick.java +++ b/test/net/java/sip/communicator/slick/fileaccess/FileAccessServiceLick.java @@ -2,11 +2,12 @@ import java.util.*; -import org.osgi.framework.*; import junit.framework.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.fileaccess.*; +import org.osgi.framework.*; + /** * This class launches the bundle which tests the fileaccess bundle. This bundle * is a set of (j)unit tests. It should be launched by the cruisecontrol module. diff --git a/test/net/java/sip/communicator/slick/fileaccess/TestFailSafeTransaction.java b/test/net/java/sip/communicator/slick/fileaccess/TestFailSafeTransaction.java index 89d542d6d..36872879b 100644 --- a/test/net/java/sip/communicator/slick/fileaccess/TestFailSafeTransaction.java +++ b/test/net/java/sip/communicator/slick/fileaccess/TestFailSafeTransaction.java @@ -9,12 +9,11 @@ import java.io.*; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -import net.java.sip.communicator.service.fileaccess.*; import junit.framework.*; +import org.jitsi.service.fileaccess.*; +import org.osgi.framework.*; + /** * Tests for the fail safe transactions * diff --git a/test/net/java/sip/communicator/slick/fileaccess/TestFileAccessService.java b/test/net/java/sip/communicator/slick/fileaccess/TestFileAccessService.java index f16e69b10..923eeb8c0 100644 --- a/test/net/java/sip/communicator/slick/fileaccess/TestFileAccessService.java +++ b/test/net/java/sip/communicator/slick/fileaccess/TestFileAccessService.java @@ -3,9 +3,10 @@ import java.io.*; import java.util.*; -import org.osgi.framework.*; import junit.framework.*; -import net.java.sip.communicator.service.fileaccess.*; + +import org.jitsi.service.fileaccess.*; +import org.osgi.framework.*; public class TestFileAccessService extends TestCase { diff --git a/test/net/java/sip/communicator/slick/fileaccess/fileaccess.slick.manifest.mf b/test/net/java/sip/communicator/slick/fileaccess/fileaccess.slick.manifest.mf index 6c9ac4cc3..f0e45ae61 100644 --- a/test/net/java/sip/communicator/slick/fileaccess/fileaccess.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/fileaccess/fileaccess.slick.manifest.mf @@ -6,8 +6,8 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: junit.framework, net.java.sip.communicator.slick.fileaccess, - net.java.sip.communicator.service.fileaccess, - net.java.sip.communicator.service.configuration, + org.jitsi.service.fileaccess, + org.jitsi.service.configuration, org.osgi.framework, org.w3c.dom, javax.xml.parsers, diff --git a/test/net/java/sip/communicator/slick/history/history.slick.manifest.mf b/test/net/java/sip/communicator/slick/history/history.slick.manifest.mf index f9d62a859..a52a32526 100644 --- a/test/net/java/sip/communicator/slick/history/history.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/history/history.slick.manifest.mf @@ -8,7 +8,7 @@ Import-Package: junit.framework, net.java.sip.communicator.slick.history, net.java.sip.communicator.service.history.records, net.java.sip.communicator.service.history, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, org.osgi.framework, org.w3c.dom, javax.xml.parsers, diff --git a/test/net/java/sip/communicator/slick/netaddr/TestNetworkAddressManagerService.java b/test/net/java/sip/communicator/slick/netaddr/TestNetworkAddressManagerService.java index fd6b10c94..18b98cf9b 100644 --- a/test/net/java/sip/communicator/slick/netaddr/TestNetworkAddressManagerService.java +++ b/test/net/java/sip/communicator/slick/netaddr/TestNetworkAddressManagerService.java @@ -5,7 +5,7 @@ import org.osgi.framework.*; import junit.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.util.*; diff --git a/test/net/java/sip/communicator/slick/netaddr/netaddr.slick.manifest.mf b/test/net/java/sip/communicator/slick/netaddr/netaddr.slick.manifest.mf index 5d9f631bf..ead38fdfe 100644 --- a/test/net/java/sip/communicator/slick/netaddr/netaddr.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/netaddr/netaddr.slick.manifest.mf @@ -7,7 +7,7 @@ System-Bundle: yes Import-Package: net.java.sip.communicator.util, net.java.sip.communicator.util.dns, net.java.sip.communicator.service.netaddr, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, junit, junit.framework, junit.textui, diff --git a/test/net/java/sip/communicator/slick/protocol/generic/AuthHandler.java b/test/net/java/sip/communicator/slick/protocol/generic/AuthHandler.java index ce3551dd9..63f75492a 100644 --- a/test/net/java/sip/communicator/slick/protocol/generic/AuthHandler.java +++ b/test/net/java/sip/communicator/slick/protocol/generic/AuthHandler.java @@ -41,4 +41,4 @@ public void processAuthorizationResponse( sourceContact.getAddress() + " " + response.getResponseCode().getCode()); } -} \ No newline at end of file +} diff --git a/test/net/java/sip/communicator/slick/protocol/generic/ImEventCollector.java b/test/net/java/sip/communicator/slick/protocol/generic/ImEventCollector.java index eb6a5574b..0c0d50cf3 100644 --- a/test/net/java/sip/communicator/slick/protocol/generic/ImEventCollector.java +++ b/test/net/java/sip/communicator/slick/protocol/generic/ImEventCollector.java @@ -101,4 +101,4 @@ public void waitForEvent(long waitFor) } } } -} \ No newline at end of file +} diff --git a/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java b/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java index 398d1107b..e846e6270 100644 --- a/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java +++ b/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java @@ -8,11 +8,13 @@ import java.io.*; import java.util.*; + import junit.framework.*; -import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; + +import org.jitsi.service.fileaccess.*; import org.osgi.framework.*; /** diff --git a/test/net/java/sip/communicator/slick/protocol/gibberish/TestAccountUninstallationPersistence.java b/test/net/java/sip/communicator/slick/protocol/gibberish/TestAccountUninstallationPersistence.java index 4f385464c..3159c7892 100644 --- a/test/net/java/sip/communicator/slick/protocol/gibberish/TestAccountUninstallationPersistence.java +++ b/test/net/java/sip/communicator/slick/protocol/gibberish/TestAccountUninstallationPersistence.java @@ -8,7 +8,7 @@ import org.osgi.framework.*; import junit.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; /** diff --git a/test/net/java/sip/communicator/slick/protocol/gibberish/gibberish.provider.slick.manifest.mf b/test/net/java/sip/communicator/slick/protocol/gibberish/gibberish.provider.slick.manifest.mf index f2b9cf294..4fe98514a 100644 --- a/test/net/java/sip/communicator/slick/protocol/gibberish/gibberish.provider.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/protocol/gibberish/gibberish.provider.slick.manifest.mf @@ -4,7 +4,7 @@ Bundle-Description: A Service Leveraging Implementation Compatibility Kit for th Bundle-Vendor: sip-communicator.org Bundle-Version: 0.0.1 System-Bundle: yes -Import-Package: net.java.sip.communicator.service.configuration, +Import-Package: org.jitsi.service.configuration, junit.framework, org.osgi.framework, net.java.sip.communicator.util, diff --git a/test/net/java/sip/communicator/slick/protocol/icq/TestAccountUninstallationPersistence.java b/test/net/java/sip/communicator/slick/protocol/icq/TestAccountUninstallationPersistence.java index b77db43ec..64508d3af 100644 --- a/test/net/java/sip/communicator/slick/protocol/icq/TestAccountUninstallationPersistence.java +++ b/test/net/java/sip/communicator/slick/protocol/icq/TestAccountUninstallationPersistence.java @@ -8,7 +8,7 @@ import org.osgi.framework.*; import junit.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; /** diff --git a/test/net/java/sip/communicator/slick/protocol/icq/icq.provider.slick.manifest.mf b/test/net/java/sip/communicator/slick/protocol/icq/icq.provider.slick.manifest.mf index 9ef5144a5..057dd7475 100644 --- a/test/net/java/sip/communicator/slick/protocol/icq/icq.provider.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/protocol/icq/icq.provider.slick.manifest.mf @@ -6,7 +6,7 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: junit.framework, javax.net, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, org.osgi.framework, net.java.sip.communicator.util, net.java.sip.communicator.util.dns, @@ -14,4 +14,4 @@ Import-Package: junit.framework, net.java.sip.communicator.service.protocol.icqconstants, net.java.sip.communicator.service.protocol.aimconstants, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.fileaccess + org.jitsi.service.fileaccess diff --git a/test/net/java/sip/communicator/slick/protocol/jabber/TestAccountInstallation.java b/test/net/java/sip/communicator/slick/protocol/jabber/TestAccountInstallation.java index 7cc7635ed..72d32ee43 100644 --- a/test/net/java/sip/communicator/slick/protocol/jabber/TestAccountInstallation.java +++ b/test/net/java/sip/communicator/slick/protocol/jabber/TestAccountInstallation.java @@ -11,7 +11,7 @@ import org.osgi.framework.*; import junit.framework.*; import net.java.sip.communicator.service.certificate.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; /** diff --git a/test/net/java/sip/communicator/slick/protocol/jabber/TestAccountUninstallationPersistence.java b/test/net/java/sip/communicator/slick/protocol/jabber/TestAccountUninstallationPersistence.java index 6d41f6255..9cbaa5813 100644 --- a/test/net/java/sip/communicator/slick/protocol/jabber/TestAccountUninstallationPersistence.java +++ b/test/net/java/sip/communicator/slick/protocol/jabber/TestAccountUninstallationPersistence.java @@ -8,7 +8,7 @@ import org.osgi.framework.*; import junit.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; /** diff --git a/test/net/java/sip/communicator/slick/protocol/jabber/jabber.provider.slick.manifest.mf b/test/net/java/sip/communicator/slick/protocol/jabber/jabber.provider.slick.manifest.mf index 4bcdd72b9..ab122392a 100644 --- a/test/net/java/sip/communicator/slick/protocol/jabber/jabber.provider.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/protocol/jabber/jabber.provider.slick.manifest.mf @@ -4,7 +4,7 @@ Bundle-Description: A Service Leveraging Implementation Compatibility Kit for th Bundle-Vendor: sip-communicator.org Bundle-Version: 0.0.1 System-Bundle: yes -Import-Package: net.java.sip.communicator.service.configuration, +Import-Package: org.jitsi.service.configuration, net.java.sip.communicator.service.certificate, junit.framework, org.osgi.framework, @@ -16,4 +16,4 @@ Import-Package: net.java.sip.communicator.service.configuration, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.jabberconstants, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.fileaccess + org.jitsi.service.fileaccess diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestAccountUninstallationPersistence.java b/test/net/java/sip/communicator/slick/protocol/msn/TestAccountUninstallationPersistence.java index 1b2a3655b..b3f1e7f04 100644 --- a/test/net/java/sip/communicator/slick/protocol/msn/TestAccountUninstallationPersistence.java +++ b/test/net/java/sip/communicator/slick/protocol/msn/TestAccountUninstallationPersistence.java @@ -8,7 +8,7 @@ import org.osgi.framework.*; import junit.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; /** diff --git a/test/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf b/test/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf index 4e657f2c9..40b4cd5ff 100644 --- a/test/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf @@ -8,10 +8,10 @@ Import-Package: junit.framework, org.osgi.framework, javax.net.ssl, javax.xml.parsers, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.protocol.msnconstants, net.java.sip.communicator.util, net.java.sip.communicator.util.dns, - net.java.sip.communicator.service.fileaccess + org.jitsi.service.fileaccess diff --git a/test/net/java/sip/communicator/slick/protocol/rss/TestAccountUninstallationPersistence.java b/test/net/java/sip/communicator/slick/protocol/rss/TestAccountUninstallationPersistence.java index b4fef1fa2..743b37848 100755 --- a/test/net/java/sip/communicator/slick/protocol/rss/TestAccountUninstallationPersistence.java +++ b/test/net/java/sip/communicator/slick/protocol/rss/TestAccountUninstallationPersistence.java @@ -8,7 +8,7 @@ import junit.framework.*; import org.osgi.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; /** diff --git a/test/net/java/sip/communicator/slick/protocol/rss/rss.provider.slick.manifest.mf b/test/net/java/sip/communicator/slick/protocol/rss/rss.provider.slick.manifest.mf index dd5adad0e..bc3e56e74 100644 --- a/test/net/java/sip/communicator/slick/protocol/rss/rss.provider.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/protocol/rss/rss.provider.slick.manifest.mf @@ -4,7 +4,7 @@ Bundle-Description: A Service Leveraging Implementation Compatibility Kit for th Bundle-Vendor: sip-communicator.org Bundle-Version: 0.0.1 System-Bundle: yes -Import-Package: net.java.sip.communicator.service.configuration, +Import-Package: org.jitsi.service.configuration, junit.framework, org.osgi.framework, net.java.sip.communicator.util, diff --git a/test/net/java/sip/communicator/slick/protocol/sip/TestAccountUninstallationPersistence.java b/test/net/java/sip/communicator/slick/protocol/sip/TestAccountUninstallationPersistence.java index dcfd1cffc..680a77587 100644 --- a/test/net/java/sip/communicator/slick/protocol/sip/TestAccountUninstallationPersistence.java +++ b/test/net/java/sip/communicator/slick/protocol/sip/TestAccountUninstallationPersistence.java @@ -8,7 +8,7 @@ import org.osgi.framework.*; import junit.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; /** diff --git a/test/net/java/sip/communicator/slick/protocol/sip/sip.provider.slick.manifest.mf b/test/net/java/sip/communicator/slick/protocol/sip/sip.provider.slick.manifest.mf index d52a38b1e..b40410b96 100644 --- a/test/net/java/sip/communicator/slick/protocol/sip/sip.provider.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/protocol/sip/sip.provider.slick.manifest.mf @@ -4,7 +4,7 @@ Bundle-Description: A bundle that contains all tests for the SIP implementation Bundle-Vendor: sip-communicator.org Bundle-Version: 0.0.1 System-Bundle: yes -Import-Package: net.java.sip.communicator.service.configuration, +Import-Package: org.jitsi.service.configuration, junit.framework, org.osgi.framework, org.w3c.dom, diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountUninstallationPersistence.java b/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountUninstallationPersistence.java index 6e6f21c2c..8aec8ca9e 100644 --- a/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountUninstallationPersistence.java +++ b/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountUninstallationPersistence.java @@ -8,7 +8,7 @@ import org.osgi.framework.*; import junit.framework.*; -import net.java.sip.communicator.service.configuration.*; +import org.jitsi.service.configuration.*; import net.java.sip.communicator.service.protocol.*; /** diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/yahoo.provider.slick.manifest.mf b/test/net/java/sip/communicator/slick/protocol/yahoo/yahoo.provider.slick.manifest.mf index f0b6b35c2..26b7ac0b6 100644 --- a/test/net/java/sip/communicator/slick/protocol/yahoo/yahoo.provider.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/protocol/yahoo/yahoo.provider.slick.manifest.mf @@ -4,7 +4,7 @@ Bundle-Description: A Service Leveraging Implementation Compatibility Kit for th Bundle-Vendor: sip-communicator.org Bundle-Version: 0.0.1 System-Bundle: yes -Import-Package: net.java.sip.communicator.service.configuration, +Import-Package: org.jitsi.service.configuration, junit.framework, org.osgi.framework, javax.net.ssl, @@ -14,4 +14,4 @@ Import-Package: net.java.sip.communicator.service.configuration, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.yahooconstants, net.java.sip.communicator.service.protocol.event, - net.java.sip.communicator.service.fileaccess + org.jitsi.service.fileaccess diff --git a/test/net/java/sip/communicator/slick/runner/slick-runner.manifest.mf b/test/net/java/sip/communicator/slick/runner/slick-runner.manifest.mf index 467e1a9a2..6de663587 100644 --- a/test/net/java/sip/communicator/slick/runner/slick-runner.manifest.mf +++ b/test/net/java/sip/communicator/slick/runner/slick-runner.manifest.mf @@ -4,7 +4,7 @@ Bundle-Description: A bundle that runs all SLICKs declared in the corresponding Bundle-Vendor: sip-communicator.org Bundle-Version: 0.0.1 System-Bundle: yes -Import-Package: net.java.sip.communicator.service.configuration, +Import-Package: org.jitsi.service.configuration, junit, junit.framework, junit.swingui, diff --git a/test/net/java/sip/communicator/slick/slickless/slickless.manifest.mf b/test/net/java/sip/communicator/slick/slickless/slickless.manifest.mf index 07a79ec71..0544e77ea 100644 --- a/test/net/java/sip/communicator/slick/slickless/slickless.manifest.mf +++ b/test/net/java/sip/communicator/slick/slickless/slickless.manifest.mf @@ -4,7 +4,7 @@ Bundle-Description: Unit testing for classes not belonging to any service implem Bundle-Vendor: sip-communicator.org Bundle-Version: 0.0.1 System-Bundle: yes -Import-Package: net.java.sip.communicator.service.configuration, +Import-Package: org.jitsi.service.configuration, junit, junit.framework, junit.swingui, diff --git a/test/net/java/sip/communicator/slick/version/version.slick.manifest.mf b/test/net/java/sip/communicator/slick/version/version.slick.manifest.mf index 9788fdf88..d9b7ee15a 100644 --- a/test/net/java/sip/communicator/slick/version/version.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/version/version.slick.manifest.mf @@ -7,7 +7,7 @@ System-Bundle: yes Import-Package: org.osgi.framework, net.java.sip.communicator.util, net.java.sip.communicator.util.dns, - net.java.sip.communicator.service.configuration, + org.jitsi.service.configuration, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.icqconstants, net.java.sip.communicator.service.protocol.event,