Commit 012fd330 authored by Petri Hintukainen's avatar Petri Hintukainen

BD-J: simplify playback status events handling

parent 2a815e68
...@@ -478,25 +478,17 @@ public class Libbluray { ...@@ -478,25 +478,17 @@ public class Libbluray {
return stopTitle(false); return stopTitle(false);
case BDJ_EVENT_CHAPTER: case BDJ_EVENT_CHAPTER:
PlayerManager.getInstance().onChapterReach(param);
break;
case BDJ_EVENT_MARK: case BDJ_EVENT_MARK:
PlayerManager.getInstance().onMarkReach(param);
break;
case BDJ_EVENT_PLAYITEM: case BDJ_EVENT_PLAYITEM:
PlayerManager.getInstance().onPlayItemReach(param);
break;
case BDJ_EVENT_PLAYLIST: case BDJ_EVENT_PLAYLIST:
PlayerManager.getInstance().onPlaylistStart(param);
break;
case BDJ_EVENT_ANGLE: case BDJ_EVENT_ANGLE:
PlayerManager.getInstance().onAngleChange(param);
break;
case BDJ_EVENT_SUBTITLE: case BDJ_EVENT_SUBTITLE:
PlayerManager.getInstance().onSubtitleChange(param);
break;
case BDJ_EVENT_PIP: case BDJ_EVENT_PIP:
PlayerManager.getInstance().onPiPChange(param); case BDJ_EVENT_AUDIO_STREAM:
case BDJ_EVENT_SECONDARY_STREAM:
case BDJ_EVENT_END_OF_PLAYLIST:
case BDJ_EVENT_PTS:
PlayerManager.getInstance().onEvent(event, param);
break; break;
case BDJ_EVENT_RATE: case BDJ_EVENT_RATE:
float rate = (float)param / 90000.0f; float rate = (float)param / 90000.0f;
...@@ -505,15 +497,11 @@ public class Libbluray { ...@@ -505,15 +497,11 @@ public class Libbluray {
if (rate > 0.99f && rate < 1.01f) rate = 1.0f; if (rate > 0.99f && rate < 1.01f) rate = 1.0f;
PlayerManager.getInstance().onRateChange(rate); PlayerManager.getInstance().onRateChange(rate);
break; break;
case BDJ_EVENT_END_OF_PLAYLIST:
PlayerManager.getInstance().onPlaylistEnd(param);
break;
case BDJ_EVENT_PSR102: case BDJ_EVENT_PSR102:
org.bluray.bdplus.Status.getInstance().receive(param); org.bluray.bdplus.Status.getInstance().receive(param);
break; break;
case BDJ_EVENT_PTS:
PlayerManager.getInstance().onPlaylistTime(param);
break;
case BDJ_EVENT_VK_KEY: case BDJ_EVENT_VK_KEY:
switch (param) { switch (param) {
case 0: key = KeyEvent.VK_0; break; case 0: key = KeyEvent.VK_0; break;
...@@ -549,28 +537,29 @@ public class Libbluray { ...@@ -549,28 +537,29 @@ public class Libbluray {
} }
break; break;
default: default:
System.err.println("Unknown event %d.%d\n", event, param);
result = false; result = false;
} }
return result; return result;
} }
private static final int BDJ_EVENT_CHAPTER = 1; public static final int BDJ_EVENT_CHAPTER = 1;
private static final int BDJ_EVENT_PLAYITEM = 2; public static final int BDJ_EVENT_PLAYITEM = 2;
private static final int BDJ_EVENT_ANGLE = 3; public static final int BDJ_EVENT_ANGLE = 3;
private static final int BDJ_EVENT_SUBTITLE = 4; public static final int BDJ_EVENT_SUBTITLE = 4;
private static final int BDJ_EVENT_PIP = 5; public static final int BDJ_EVENT_PIP = 5;
private static final int BDJ_EVENT_END_OF_PLAYLIST = 6; public static final int BDJ_EVENT_END_OF_PLAYLIST = 6;
private static final int BDJ_EVENT_PTS = 7; public static final int BDJ_EVENT_PTS = 7;
private static final int BDJ_EVENT_VK_KEY = 8; private static final int BDJ_EVENT_VK_KEY = 8;
private static final int BDJ_EVENT_MARK = 9; public static final int BDJ_EVENT_MARK = 9;
private static final int BDJ_EVENT_PSR102 = 10; private static final int BDJ_EVENT_PSR102 = 10;
private static final int BDJ_EVENT_PLAYLIST = 11; public static final int BDJ_EVENT_PLAYLIST = 11;
private static final int BDJ_EVENT_START = 12; private static final int BDJ_EVENT_START = 12;
private static final int BDJ_EVENT_STOP = 13; private static final int BDJ_EVENT_STOP = 13;
private static final int BDJ_EVENT_RATE = 14; public static final int BDJ_EVENT_RATE = 14;
/* TODO: use org/bluray/system/RegisterAccess instead */ /* TODO: use org/bluray/system/RegisterAccess instead */
public static final int PSR_IG_STREAM_ID = 0; public static final int PSR_IG_STREAM_ID = 0;
......
...@@ -60,6 +60,7 @@ import org.videolan.BDJActionManager; ...@@ -60,6 +60,7 @@ import org.videolan.BDJActionManager;
import org.videolan.BDJActionQueue; import org.videolan.BDJActionQueue;
import org.videolan.BDJListeners; import org.videolan.BDJListeners;
import org.videolan.BDJXletContext; import org.videolan.BDJXletContext;
import org.videolan.Libbluray;
import org.videolan.Logger; import org.videolan.Logger;
public abstract class BDHandler implements Player, ServiceContentHandler { public abstract class BDHandler implements Player, ServiceContentHandler {
...@@ -330,16 +331,9 @@ public abstract class BDHandler implements Player, ServiceContentHandler { ...@@ -330,16 +331,9 @@ public abstract class BDHandler implements Player, ServiceContentHandler {
* notifications from app * notifications from app
*/ */
protected void timeChanged(int time) { protected void statusEvent(int event, int param) {
if (isClosed) return; if (isClosed) return;
PlayerAction action = new PlayerAction(this, PlayerAction.ACTION_TIME_CHANGED, new Integer(time)); commandQueue.put(new PlayerAction(this, PlayerAction.ACTION_STATUS, new Integer(event), param));
commandQueue.put(action);
}
protected void playlistEndReached(int playlist) {
if (isClosed) return;
PlayerAction action = new PlayerAction(this, PlayerAction.ACTION_END_OF_MEDIA_REACHED, new Integer(playlist));
commandQueue.put(action);
} }
protected void rateChanged(float rate) { protected void rateChanged(float rate) {
...@@ -348,48 +342,6 @@ public abstract class BDHandler implements Player, ServiceContentHandler { ...@@ -348,48 +342,6 @@ public abstract class BDHandler implements Player, ServiceContentHandler {
commandQueue.put(action); commandQueue.put(action);
} }
protected void playlistStarted(int param) {
if (isClosed) return;
PlayerAction action = new PlayerAction(this, PlayerAction.ACTION_PLAYLIST_STARTED, new Integer(param));
commandQueue.put(action);
}
protected void chapterReached(int param) {
if (isClosed) return;
PlayerAction action = new PlayerAction(this, PlayerAction.ACTION_CHAPTER_REACHED, new Integer(param));
commandQueue.put(action);
}
protected void markReached(int param) {
if (isClosed) return;
PlayerAction action = new PlayerAction(this, PlayerAction.ACTION_MARK_REACHED, new Integer(param));
commandQueue.put(action);
}
protected void playItemReached(int param) {
if (isClosed) return;
PlayerAction action = new PlayerAction(this, PlayerAction.ACTION_PLAYITEM_REACHED, new Integer(param));
commandQueue.put(action);
}
protected void angleChanged(int param) {
if (isClosed) return;
PlayerAction action = new PlayerAction(this, PlayerAction.ACTION_ANGLE_CHANGED, new Integer(param));
commandQueue.put(action);
}
protected void subtitleChanged(int param) {
if (isClosed) return;
PlayerAction action = new PlayerAction(this, PlayerAction.ACTION_SUBTITLE_CHANGED, new Integer(param));
commandQueue.put(action);
}
protected void pipChanged(int param) {
if (isClosed) return;
PlayerAction action = new PlayerAction(this, PlayerAction.ACTION_PIP_CHANGED, new Integer(param));
commandQueue.put(action);
}
/* /*
* handling of notifications from app * handling of notifications from app
*/ */
...@@ -620,9 +572,13 @@ public abstract class BDHandler implements Player, ServiceContentHandler { ...@@ -620,9 +572,13 @@ public abstract class BDHandler implements Player, ServiceContentHandler {
private class PlayerAction extends BDJAction { private class PlayerAction extends BDJAction {
private PlayerAction(BDHandler player, int action, Object param) { private PlayerAction(BDHandler player, int action, Object param) {
this(player, action, param, -1);
}
private PlayerAction(BDHandler player, int action, Object param, int param2) {
this.player = player; this.player = player;
this.action = action; this.action = action;
this.param = param; this.param = param;
this.param2 = param2;
} }
protected void doAction() { protected void doAction() {
...@@ -656,35 +612,45 @@ public abstract class BDHandler implements Player, ServiceContentHandler { ...@@ -656,35 +612,45 @@ public abstract class BDHandler implements Player, ServiceContentHandler {
player.doSetRate((Float)param); player.doSetRate((Float)param);
break; break;
case ACTION_END_OF_MEDIA_REACHED:
player.doEndOfMediaReached(((Integer)param).intValue());
break;
case ACTION_TIME_CHANGED:
player.doTimeChanged(((Integer)param).intValue());
break;
case ACTION_RATE_CHANGED: case ACTION_RATE_CHANGED:
player.doRateChanged(((Float)param).floatValue()); player.doRateChanged(((Float)param).floatValue());
break; break;
case ACTION_PLAYLIST_STARTED: case ACTION_STATUS:
player.doPlaylistStarted(((Integer)param).intValue()); switch (((Integer)param).intValue()) {
break; case Libbluray.BDJ_EVENT_CHAPTER:
case ACTION_PLAYITEM_REACHED: player.doChapterReached(param2);
player.doPlayItemReached(((Integer)param).intValue()); break;
break; case Libbluray.BDJ_EVENT_MARK:
case ACTION_CHAPTER_REACHED: player.doMarkReached(param2);
player.doChapterReached(((Integer)param).intValue()); break;
break; case Libbluray.BDJ_EVENT_PLAYITEM:
case ACTION_MARK_REACHED: player.doPlayItemReached(param2);
player.doMarkReached(((Integer)param).intValue()); break;
break; case Libbluray.BDJ_EVENT_PLAYLIST:
case ACTION_ANGLE_CHANGED: player.doPlaylistStarted(param2);
player.doAngleChanged(((Integer)param).intValue()); break;
break; case Libbluray.BDJ_EVENT_ANGLE:
case ACTION_SUBTITLE_CHANGED: player.doAngleChanged(param2);
player.doSubtitleChanged(((Integer)param).intValue()); break;
case Libbluray.BDJ_EVENT_SUBTITLE:
player.doSubtitleChanged(param2);
break;
case Libbluray.BDJ_EVENT_PIP:
player.doPiPChanged(param2);
break;
case Libbluray.BDJ_EVENT_END_OF_PLAYLIST:
player.doEndOfMediaReached(param2);
break;
case Libbluray.BDJ_EVENT_PTS:
player.doTimeChanged(param2);
break;
default:
System.err.println("Unknown ACTION_STATUS: id " + param + ", value " + param2);
break;
}
break; break;
case ACTION_PIP_CHANGED: default:
player.doPiPChanged(((Integer)param).intValue()); System.err.println("Unknown action " + action);
break; break;
} }
} }
...@@ -692,6 +658,7 @@ public abstract class BDHandler implements Player, ServiceContentHandler { ...@@ -692,6 +658,7 @@ public abstract class BDHandler implements Player, ServiceContentHandler {
private BDHandler player; private BDHandler player;
private int action; private int action;
private Object param; private Object param;
private int param2;
public static final int ACTION_INIT = 1; public static final int ACTION_INIT = 1;
public static final int ACTION_REALIZE = 2; public static final int ACTION_REALIZE = 2;
...@@ -704,16 +671,8 @@ public abstract class BDHandler implements Player, ServiceContentHandler { ...@@ -704,16 +671,8 @@ public abstract class BDHandler implements Player, ServiceContentHandler {
public static final int ACTION_SEEK_TIME = 8; public static final int ACTION_SEEK_TIME = 8;
public static final int ACTION_SET_RATE = 9; public static final int ACTION_SET_RATE = 9;
public static final int ACTION_END_OF_MEDIA_REACHED = 10; public static final int ACTION_STATUS = 10;
public static final int ACTION_RATE_CHANGED = 11; public static final int ACTION_RATE_CHANGED = 11;
public static final int ACTION_TIME_CHANGED = 12;
public static final int ACTION_PLAYLIST_STARTED = 13;
public static final int ACTION_PLAYITEM_REACHED = 14;
public static final int ACTION_CHAPTER_REACHED = 15;
public static final int ACTION_MARK_REACHED = 16;
public static final int ACTION_ANGLE_CHANGED = 17;
public static final int ACTION_SUBTITLE_CHANGED = 18;
public static final int ACTION_PIP_CHANGED = 19;
} }
protected int state = Unrealized; protected int state = Unrealized;
......
...@@ -134,73 +134,13 @@ public class PlayerManager { ...@@ -134,73 +134,13 @@ public class PlayerManager {
* *
*/ */
public void onPlaylistEnd(int playlist) { public void onEvent(int event, int param) {
synchronized (stoppingLock) { synchronized (stoppingLock) {
if (stopping) return; if (stopping) return;
synchronized (playlistPlayerLock) { synchronized (playlistPlayerLock) {
if (playlistPlayer != null) if (playlistPlayer != null)
playlistPlayer.playlistEndReached(playlist); playlistPlayer.statusEvent(event, param);
} }
}
}
public void onPlaylistTime(int pts) {
synchronized (stoppingLock) {
if (stopping) return;
synchronized (playlistPlayerLock) {
if (playlistPlayer != null)
playlistPlayer.timeChanged(pts);
}
}
}
public void onChapterReach(int param) {
synchronized (stoppingLock) {
if (stopping) return;
synchronized (playlistPlayerLock) {
if (playlistPlayer != null)
playlistPlayer.chapterReached(param);
}
}
}
public void onMarkReach(int param) {
synchronized (stoppingLock) {
if (stopping) return;
synchronized (playlistPlayerLock) {
if (playlistPlayer != null)
playlistPlayer.markReached(param);
}
}
}
public void onPlaylistStart(int param) {
synchronized (stoppingLock) {
if (stopping) return;
synchronized (playlistPlayerLock) {
if (playlistPlayer != null)
playlistPlayer.playlistStarted(param);
}
}
}
public void onPlayItemReach(int param) {
synchronized (stoppingLock) {
if (stopping) return;
synchronized (playlistPlayerLock) {
if (playlistPlayer != null)
playlistPlayer.playItemReached(param);
}
}
}
public void onAngleChange(int param) {
synchronized (stoppingLock) {
if (stopping) return;
synchronized (playlistPlayerLock) {
if (playlistPlayer != null)
playlistPlayer.angleChanged(param);
}
} }
} }
...@@ -213,24 +153,4 @@ public class PlayerManager { ...@@ -213,24 +153,4 @@ public class PlayerManager {
} }
} }
} }
public void onSubtitleChange(int param) {
synchronized (stoppingLock) {
if (stopping) return;
synchronized (playlistPlayerLock) {
if (playlistPlayer != null)
playlistPlayer.subtitleChanged(param);
}
}
}
public void onPiPChange(int param) {
synchronized (stoppingLock) {
if (stopping) return;
synchronized (playlistPlayerLock) {
if (playlistPlayer != null)
playlistPlayer.pipChanged(param);
}
}
}
} }
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