Commit 5c2cadd9 authored by Petri Hintukainen's avatar Petri Hintukainen

BD-J: implement audio mixing controls

parent 88eaaa0d
......@@ -240,6 +240,18 @@ public abstract class BDHandler implements Player, ServiceContentHandler {
return rate;
}
public static final int GAIN_OVERALL = 1;
public static final int GAIN_PRIMARY = 2;
public static final int GAIN_SECONDARY = 3;
public void setGain(int mixer, boolean mute, float level) {
Logger.unimplemented("BDHandler", "setGain");
}
public void setPanning(float x, float y) {
Logger.unimplemented("BDHandler", "setPanning");
}
public Locator[] getServiceContentLocators() {
if (locator == null)
return new Locator[0];
......
......@@ -37,8 +37,8 @@ public class Handler extends BDHandler {
public Handler() {
controls = new Control[3];
controls[0] = new MediaTimePositionControlImpl(this);
controls[1] = new OverallGainControlImpl();
controls[2] = new PanningControlImpl();
controls[1] = new OverallGainControlImpl(this);
controls[2] = new PanningControlImpl(this);
}
public void setSource(DataSource source) throws IOException, IncompatibleSourceException {
......
/*
* This file is part of libbluray
* Copyright (C) 2015 Petri Hintukainen
*
* 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, see
* <http://www.gnu.org/licenses/>.
*/
package org.videolan.media.content.playlist;
import java.awt.Component;
import javax.media.GainControl;
import javax.media.GainChangeEvent;
import javax.media.GainChangeListener;
/*
http://docs.oracle.com/cd/E17802_01/j2se/javase/technologies/desktop/media/jmf/2.1.1/apidocs/javax/media/GainControl.html
*/
import org.videolan.BDJListeners;
abstract class GainControlImpl {
public void setMute(boolean mute) {
this.mute = mute;
setGain(this.mute, this.level);
}
public boolean getMute() {
return this.mute;
}
public float setDB(float gain) {
this.level = Math.max(1.0f, Math.min(0.0f, (float)Math.pow(10.0f, gain / 10.0f)));
this.gain = gain;
setGain(this.mute, this.level);
return this.gain;
}
public float getDB() {
return gain;
}
public float setLevel(float level) {
this.level = Math.max(1.0f, Math.min(0.0f, level));
this.gain = 10.0f * (float)(Math.log(this.level) / Math.log(10.0f));
setGain(this.mute, this.level);
return this.level;
}
public float getLevel() {
return level;
}
public void addGainChangeListener(GainChangeListener listener) {
listeners.add(listener);
}
public void removeGainChangeListener(GainChangeListener listener) {
listeners.remove(listener);
}
protected abstract void setGain(boolean mute, float level);
protected void valueChanged() {
listeners.putCallback(new GainChangeEvent((GainControl)this, mute, gain, level));
}
public Component getControlComponent() {
return null;
}
private boolean mute = false;
private float gain = 0.0f;
private float level = 1.0f;
private BDJListeners listeners = new BDJListeners();
}
......@@ -53,15 +53,15 @@ public class Handler extends BDHandler {
controls[3] = new DVBMediaSelectControlImpl(this);
controls[4] = new MediaTimeEventControlImpl();
controls[5] = new MediaTimePositionControlImpl(this);
controls[6] = new OverallGainControlImpl();
controls[7] = new PanningControlImpl();
controls[6] = new OverallGainControlImpl(this);
controls[7] = new PanningControlImpl(this);
controls[8] = new PiPControlImpl(this);
controls[9] = new PlaybackControlImpl(this);
controls[10] = new PlayListChangeControlImpl(this);
controls[11] = new PrimaryAudioControlImpl(this);
controls[12] = new PrimaryGainControlImpl();
controls[12] = new PrimaryGainControlImpl(this);
controls[13] = new SecondaryAudioControlImpl(this);
controls[14] = new SecondaryGainControlImpl();
controls[14] = new SecondaryGainControlImpl(this);
controls[15] = new SubtitlingControlImpl(this);
controls[16] = new UOMaskTableControlImpl(this);
controls[17] = new VideoFormatControlImpl(this);
......
/*
* This file is part of libbluray
* Copyright (C) 2010 William Hahne
* Copyright (C) 2015 Petri Hintukainen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -20,56 +21,19 @@
package org.videolan.media.content.playlist;
import java.awt.Component;
import javax.media.GainChangeListener;
import org.bluray.media.OverallGainControl;
public class OverallGainControlImpl implements OverallGainControl {
public void setMute(boolean mute) {
org.videolan.Logger.unimplemented("OverallGainControlImpl", "setMute");
this.mute = mute;
}
public boolean getMute() {
org.videolan.Logger.unimplemented("OverallGainControlImpl", "getMute");
return this.mute;
}
public float setDB(float gain) {
org.videolan.Logger.unimplemented("OverallGainControlImpl", "setDB");
this.gain = gain;
return this.gain;
}
public float getDB() {
org.videolan.Logger.unimplemented("OverallGainControlImpl", "getDB");
return gain;
}
public float setLevel(float level) {
org.videolan.Logger.unimplemented("OverallGainControlImpl", "setLevel");
this.level = level;
return this.level;
}
public float getLevel() {
org.videolan.Logger.unimplemented("OverallGainControlImpl", "getLevel");
return level;
}
public void addGainChangeListener(GainChangeListener listener) {
// TODO Not implemented
org.videolan.Logger.unimplemented("OverallGainControlImpl", "addGainChangeListener");
}
import org.videolan.media.content.BDHandler;
public void removeGainChangeListener(GainChangeListener listener) {
// TODO Not implemented
public class OverallGainControlImpl extends GainControlImpl implements OverallGainControl {
public OverallGainControlImpl(BDHandler player) {
this.player = player;
}
public Component getControlComponent() {
return null;
protected void setGain(boolean mute, float level) {
player.setGain(BDHandler.GAIN_OVERALL, mute, level);
super.valueChanged();
}
private boolean mute = false;
private float level = 0.0f;
private float gain = 0.0f;
private BDHandler player;
}
/*
* This file is part of libbluray
* Copyright (C) 2010 William Hahne
* Copyright (C) 2015 Petri Hintukainen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -21,47 +22,66 @@ package org.videolan.media.content.playlist;
import java.awt.Component;
import org.bluray.media.PanningChangeEvent;
import org.bluray.media.PanningChangeListener;
import org.bluray.media.PanningControl;
// TODO Figure out why the hell this is needed
import org.videolan.BDJListeners;
import org.videolan.media.content.BDHandler;
/*
set audio source location in 2D space
*/
public class PanningControlImpl implements PanningControl {
public PanningControlImpl(BDHandler player) {
this.player = player;
}
public Component getControlComponent() {
return null;
}
public void addPanningChangeListener(PanningChangeListener listener) {
org.videolan.Logger.unimplemented("PanningControlImpl", "addPanningChangeListener");
// TODO Not implemented
listeners.add(listener);
}
public void removePanningChangeListener(PanningChangeListener listener) {
// TODO Not implemented
listeners.remove(listener);
}
public float getLeftRight() {
org.videolan.Logger.unimplemented("PanningControlImpl", "getLeftRight");
return 0; // TODO Not implemented
return balance;
}
public float getFrontRear() {
org.videolan.Logger.unimplemented("PanningControlImpl", "getFrontRear");
return 0; // TODO Not implemented
return fading;
}
public void setLeftRight(float balance) {
org.videolan.Logger.unimplemented("PanningControlImpl", "setLeftRight");
// TODO Not implemented
setPosition(balance, this.fading);
}
public void setFrontRear(float fade) {
org.videolan.Logger.unimplemented("PanningControlImpl", "setFrontRear");
// TODO Not implemented
public void setFrontRear(float panning) {
setPosition(this.balance, panning);
}
public void setPosition(float x, float y) {
org.videolan.Logger.unimplemented("PanningControlImpl", "setPosition");
// TODO Not implemented
this.balance = clip(x);
this.fading = clip(y);
player.setPanning(balance, fading);
listeners.putCallback(new PanningChangeEvent(this, this.balance, this.fading));
}
private float clip(float val) {
if (val != val) /* NaN */
return 0.0f;
return Math.min(-1.0f, Math.max(1.0f, val));
}
private BDHandler player;
private BDJListeners listeners = new BDJListeners();
private float fading = 0.0f;
private float balance = 0.0f;
}
/*
* This file is part of libbluray
* Copyright (C) 2010 William Hahne
* Copyright (C) 2015 Petri Hintukainen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -20,59 +21,19 @@
package org.videolan.media.content.playlist;
import java.awt.Component;
import javax.media.GainChangeListener;
import org.bluray.media.PrimaryGainControl;
public class PrimaryGainControlImpl implements PrimaryGainControl {
public void setMute(boolean mute) {
org.videolan.Logger.unimplemented("PrimaryGainControlImpl", "setMute");
this.mute = mute;
// TODO Not implemented
}
public boolean getMute() {
org.videolan.Logger.unimplemented("PrimaryGainControlImpl", "getMute");
return this.mute; // TODO Not implemented
}
public float setDB(float gain) {
org.videolan.Logger.unimplemented("PrimaryGainControlImpl", "setDB");
this.gain = gain;
return this.gain;
}
public float getDB() {
org.videolan.Logger.unimplemented("PrimaryGainControlImpl", "getDB");
return gain;
}
public float setLevel(float level) {
org.videolan.Logger.unimplemented("PrimaryGainControlImpl", "setLevel");
this.level = level;
return this.level;
}
public float getLevel() {
org.videolan.Logger.unimplemented("PrimaryGainControlImpl", "getLevel");
return level;
}
public void addGainChangeListener(GainChangeListener listener) {
// TODO Not implemented
org.videolan.Logger.unimplemented("PrimaryGainControlImpl", "addGainChangeListener");
}
import org.videolan.media.content.BDHandler;
public void removeGainChangeListener(GainChangeListener listener) {
// TODO Not implemented
public class PrimaryGainControlImpl extends GainControlImpl implements PrimaryGainControl {
PrimaryGainControlImpl(BDHandler player) {
this.player = player;
}
public Component getControlComponent() {
return null;
protected void setGain(boolean mute, float level) {
player.setGain(BDHandler.GAIN_PRIMARY, mute, level);
super.valueChanged();
}
private boolean mute = false;
private float gain = 0.0f;
private float level = 0.0f;
private BDHandler player;
}
/*
* This file is part of libbluray
* Copyright (C) 2010 William Hahne
* Copyright (C) 2015 Petri Hintukainen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -20,58 +21,19 @@
package org.videolan.media.content.playlist;
import java.awt.Component;
import javax.media.GainChangeListener;
import org.bluray.media.SecondaryGainControl;
public class SecondaryGainControlImpl implements SecondaryGainControl {
public void setMute(boolean mute) {
org.videolan.Logger.unimplemented("SecondaryGainControlImpl", "setMute");
this.mute = mute;
}
public boolean getMute() {
org.videolan.Logger.unimplemented("SecondaryGainControlImpl", "getMute");
return this.mute;
}
public float setDB(float gain) {
org.videolan.Logger.unimplemented("SecondaryGainControlImpl", "setDB");
this.gain = gain;
return this.gain;
}
public float getDB() {
org.videolan.Logger.unimplemented("SecondaryGainControlImpl", "getDB");
return gain;
}
public float setLevel(float level) {
org.videolan.Logger.unimplemented("SecondaryGainControlImpl", "setLevel");
this.level = level;
return this.level;
}
public float getLevel() {
org.videolan.Logger.unimplemented("SecondaryGainControlImpl", "getLevel");
return level;
}
public void addGainChangeListener(GainChangeListener listener) {
// TODO Not implemented
org.videolan.Logger.unimplemented("SecondaryGainControlImpl", "addGainChangeListener");
}
import org.videolan.media.content.BDHandler;
public void removeGainChangeListener(GainChangeListener listener) {
// TODO Not implemented
public class SecondaryGainControlImpl extends GainControlImpl implements SecondaryGainControl {
SecondaryGainControlImpl(BDHandler player) {
this.player = player;
}
public Component getControlComponent() {
return null;
protected void setGain(boolean mute, float level) {
player.setGain(BDHandler.GAIN_SECONDARY, mute, level);
super.valueChanged();
}
private boolean mute = false;
private float level = 0.0f;
private float gain = 0.0f;
BDHandler player;
}
......@@ -49,8 +49,8 @@ public class Handler extends BDHandler {
public Handler() {
controls = new Control[3];
controls[0] = new MediaTimePositionControlImpl(this);
controls[1] = new OverallGainControlImpl();
controls[2] = new PanningControlImpl();
controls[1] = new OverallGainControlImpl(this);
controls[2] = new PanningControlImpl(this);
}
public void setSource(DataSource source) throws IOException, IncompatibleSourceException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment