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