Skip to content

Commit de8f41c

Browse files
committed
Ensure native libraries are loaded properly if running on OSGi
System.loadLibrary works properly in a real OSGi context in combination with Bundle-NativeCode manifest headers. The hacky JNIUtils with reflection and absolute paths is broken on newer Java versions unless add-opens is added. We don't need that.
1 parent 70dbb5c commit de8f41c

File tree

19 files changed

+47
-187
lines changed

19 files changed

+47
-187
lines changed

src/main/java/org/jitsi/impl/neomedia/MediaUtils.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,6 @@ public class MediaUtils
105105
AudioFormat.ULAW_RTP,
106106
8000);
107107

108-
/*
109-
* Some codecs depend on JMF native libraries which are only available
110-
* on 32-bit Linux and 32-bit Windows.
111-
*/
112-
if (OSUtils.IS_LINUX32 || OSUtils.IS_WINDOWS32)
113-
{
114-
Map<String, String> g723FormatParams = new HashMap<>();
115-
g723FormatParams.put("annexa", "no");
116-
g723FormatParams.put("bitrate", "6.3");
117-
addMediaFormats(
118-
(byte) SdpConstants.G723,
119-
"G723",
120-
MediaType.AUDIO,
121-
AudioFormat.G723_RTP,
122-
g723FormatParams,
123-
null,
124-
8000);
125-
}
126-
127108
addMediaFormats(
128109
(byte) SdpConstants.GSM,
129110
"GSM",
@@ -1041,10 +1022,6 @@ else if (jmfEncoding.equals(AudioFormat.GSM))
10411022
{
10421023
return SdpConstants.GSM;
10431024
}
1044-
else if (jmfEncoding.equals(AudioFormat.GSM_RTP))
1045-
{
1046-
return SdpConstants.GSM;
1047-
}
10481025
else if (jmfEncoding.equals(AudioFormat.G728_RTP))
10491026
{
10501027
return SdpConstants.G728;

src/main/java/org/jitsi/impl/neomedia/codec/audio/opus/Opus.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.jitsi.impl.neomedia.codec.audio.opus;
1717

18-
import org.jitsi.utils.*;
18+
import org.jitsi.util.*;
1919

2020
/**
2121
* Defines the API of the native opus library to be utilized by the libjitsi
@@ -78,7 +78,7 @@ public class Opus
7878
*/
7979
static
8080
{
81-
JNIUtils.loadLibrary("jnopus", Opus.class);
81+
OSUtils.loadLibrary("jnopus", Opus.class);
8282
}
8383

8484
/**

src/main/java/org/jitsi/impl/neomedia/codec/audio/speex/Speex.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.jitsi.impl.neomedia.codec.audio.speex;
1717

18-
import org.jitsi.utils.*;
18+
import org.jitsi.util.*;
1919

2020
/**
2121
* Provides the interface to the native Speex library.
@@ -42,7 +42,7 @@ public final class Speex
4242

4343
static
4444
{
45-
JNIUtils.loadLibrary("jnspeex", Speex.class);
45+
OSUtils.loadLibrary("jnspeex", Speex.class);
4646
}
4747

4848
public static void assertSpeexIsFunctional()

src/main/java/org/jitsi/impl/neomedia/codec/video/VPX.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.jitsi.impl.neomedia.codec.video;
1717

18-
import org.jitsi.utils.*;
18+
import org.jitsi.util.*;
1919

2020
/**
2121
* A wrapper for the libvpx native library.
@@ -902,7 +902,7 @@ public static String codec_err_to_string(int err)
902902

903903
static
904904
{
905-
JNIUtils.loadLibrary("jnvpx", VPX.class);
905+
OSUtils.loadLibrary("jnvpx", VPX.class);
906906
}
907907

908908
/**

src/main/java/org/jitsi/impl/neomedia/device/CoreAudioDevice.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ else if (OSUtils.IS_WINDOWS)
6161
}
6262
if (libname != null)
6363
{
64-
JNIUtils.loadLibrary(libname, CoreAudioDevice.class);
64+
OSUtils.loadLibrary(libname, CoreAudioDevice.class);
6565
isLoaded = true;
6666
}
6767
}

src/main/java/org/jitsi/impl/neomedia/device/DeviceConfiguration.java

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -238,52 +238,6 @@ private static void fixRenderers()
238238
PlugInManager.removePlugIn(
239239
"com.sun.media.renderer.audio.JavaSoundRenderer",
240240
PlugInManager.RENDERER);
241-
242-
if (OSUtils.IS_WINDOWS)
243-
{
244-
if (OSUtils.IS_WINDOWS32)
245-
{
246-
/*
247-
* DDRenderer will cause 32-bit Windows Vista/7 to switch its
248-
* theme from Aero to Vista Basic so try to pick up a different
249-
* Renderer.
250-
*/
251-
if (renderers.contains(
252-
"com.sun.media.renderer.video.GDIRenderer"))
253-
{
254-
PlugInManager.removePlugIn(
255-
"com.sun.media.renderer.video.DDRenderer",
256-
PlugInManager.RENDERER);
257-
}
258-
}
259-
else if (OSUtils.IS_WINDOWS64)
260-
{
261-
/*
262-
* Remove the native Renderers for 64-bit Windows because native
263-
* JMF libs are not available for 64-bit machines.
264-
*/
265-
PlugInManager.removePlugIn(
266-
"com.sun.media.renderer.video.GDIRenderer",
267-
PlugInManager.RENDERER);
268-
PlugInManager.removePlugIn(
269-
"com.sun.media.renderer.video.DDRenderer",
270-
PlugInManager.RENDERER);
271-
}
272-
}
273-
else if (!OSUtils.IS_LINUX32)
274-
{
275-
if (renderers.contains(
276-
"com.sun.media.renderer.video.LightWeightRenderer")
277-
|| renderers.contains(
278-
"com.sun.media.renderer.video.AWTRenderer"))
279-
{
280-
// Remove XLibRenderer because it is native and JMF is supported
281-
// on 32-bit machines only.
282-
PlugInManager.removePlugIn(
283-
"com.sun.media.renderer.video.XLibRenderer",
284-
PlugInManager.RENDERER);
285-
}
286-
}
287241
}
288242

289243
/**

src/main/java/org/jitsi/impl/neomedia/imgstreaming/ScreenCapture.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.jitsi.impl.neomedia.imgstreaming;
1717

18-
import org.jitsi.utils.*;
18+
import org.jitsi.util.*;
1919
import org.jitsi.utils.logging.*;
2020

2121
/**
@@ -36,7 +36,7 @@ public class ScreenCapture
3636

3737
try
3838
{
39-
JNIUtils.loadLibrary(lib, ScreenCapture.class);
39+
OSUtils.loadLibrary(lib, ScreenCapture.class);
4040
}
4141
catch (Throwable t)
4242
{

src/main/java/org/jitsi/impl/neomedia/jmfext/media/protocol/directshow/DSFormat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.jitsi.impl.neomedia.jmfext.media.protocol.directshow;
1717

1818
import javax.media.*;
19-
import org.jitsi.utils.*;
19+
import org.jitsi.util.*;
2020

2121
/**
2222
* DirectShow video format.
@@ -79,7 +79,7 @@ public class DSFormat
7979

8080
static
8181
{
82-
JNIUtils.loadLibrary("jndirectshow", DSFormat.class);
82+
OSUtils.loadLibrary("jndirectshow", DSFormat.class);
8383

8484
ARGB32 = ARGB32();
8585
I420 = I420();

src/main/java/org/jitsi/impl/neomedia/jmfext/media/protocol/directshow/DSManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.jitsi.impl.neomedia.jmfext.media.protocol.directshow;
1717

18-
import org.jitsi.utils.*;
18+
import org.jitsi.util.*;
1919

2020
/**
2121
* DirectShow capture device manager.
@@ -44,7 +44,7 @@ public class DSManager
4444

4545
static
4646
{
47-
JNIUtils.loadLibrary("jndirectshow", DSManager.class);
47+
OSUtils.loadLibrary("jndirectshow", DSManager.class);
4848
}
4949

5050
/**

src/main/java/org/jitsi/impl/neomedia/jmfext/media/protocol/video4linux2/Video4Linux2.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.jitsi.impl.neomedia.jmfext.media.protocol.video4linux2;
1717

18-
import org.jitsi.utils.*;
18+
import org.jitsi.util.*;
1919

2020
/**
2121
* Provides the interface to the native Video for Linux Two API Specification
@@ -95,7 +95,7 @@ public class Video4Linux2
9595

9696
static
9797
{
98-
JNIUtils.loadLibrary("jnvideo4linux2", Video4Linux2.class);
98+
OSUtils.loadLibrary("jnvideo4linux2", Video4Linux2.class);
9999

100100
VIDIOC_DQBUF = VIDIOC_DQBUF();
101101
VIDIOC_G_FMT = VIDIOC_G_FMT();

0 commit comments

Comments
 (0)