aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java15
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java8
3 files changed, 29 insertions, 1 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
index 3832a7c51..51724d240 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
@@ -35,6 +35,7 @@ import jogamp.opengl.Debug;
import java.util.List;
+import com.jogamp.common.av.AudioFormat;
import com.jogamp.common.av.AudioSink;
import com.jogamp.common.av.TimeFrameI;
import com.jogamp.common.net.Uri;
@@ -419,6 +420,20 @@ public interface GLMediaPlayer extends TextureSequence {
public void setTextureWrapST(int[] wrapST);
/**
+ * Limit maximum supported audio channels by user.
+ * <p>
+ * Must be set before {@link #playStream(Uri, int, int, int)}
+ * </p>
+ * <p>
+ * May be utilized to enforce 1 channel (mono) downsampling
+ * in combination with JOAL/OpenAL to experience spatial 3D position effects.
+ * </p>
+ * @param cc maximum supported audio channels, will be clipped [1..x], with x being the underlying audio subsystem's maximum
+ * @see #playStream(Uri, int, int, int)
+ */
+ public void setAudioChannelLimit(final int cc);
+
+ /**
* Issues asynchronous stream initialization.
* <p>
* <a href="#lifecycle">Lifecycle</a>: {@link State#Uninitialized} -> {@link State#Initialized}<sup><a href="#streamworker">1</a></sup> or {@link State#Uninitialized}
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
index 9e390319a..eb4ef5713 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
@@ -96,6 +96,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
private int textureInternalFormat;
private int textureType;
private int texUnit;
+ private int userMaxChannels = -1; // not set
private int textureFragmentShaderHashCode;
@@ -248,6 +249,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
public final int[] getTextureWrapST() { return texWrapST; }
@Override
+ public final void setAudioChannelLimit(final int cc) {
+ userMaxChannels = Math.min(8, Math.max(1, cc));
+ }
+ protected int getAudioChannelLimit() { return userMaxChannels; }
+
+ @Override
public String getRequiredExtensionsShaderStub() {
if(GLES2.GL_TEXTURE_EXTERNAL_OES == textureTarget) {
return ShaderCode.createExtensionDirective(GLExtensions.OES_EGL_image_external, ShaderCode.ENABLE);
diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
index d6bbbdc5d..7b86b012d 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
@@ -346,6 +346,12 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
} else {
audioSink = AudioSinkFactory.createDefault(FFMPEGMediaPlayer.class.getClassLoader());
}
+ {
+ final int audioChannelLimit = getAudioChannelLimit();
+ if( audioChannelLimit >= 1 ) {
+ audioSink.setChannelLimit(audioChannelLimit);
+ }
+ }
final AudioFormat preferredAudioFormat = audioSink.getPreferredFormat();
if(DEBUG) {
System.err.println("initStream: p2 aid "+aid+", preferred "+preferredAudioFormat+" on "+audioSink+", "+this);
@@ -385,7 +391,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
} else {
resStreamLocS = streamLocS;
}
- final int aMaxChannelCount = audioSink.getMaxSupportedChannels();
+ final int aMaxChannelCount = preferredAudioFormat.channelCount;
final int aPrefSampleRate = preferredAudioFormat.sampleRate;
// setStream(..) issues updateAttributes*(..), and defines avChosenAudioFormat, vid, aid, .. etc
if(DEBUG) {