Commit 4f9f8667 authored by hpi1's avatar hpi1

Hooked up HDMV VM

parent c340ac88
......@@ -30,6 +30,7 @@
#include "util/strutl.h"
#include "bdnav/navigation.h"
#include "bdnav/index_parse.h"
#include "hdmv/hdmv_vm.h"
#include "file/file.h"
#ifdef DLOPEN_CRYPTO_LIBS
#include "file/dl.h"
......@@ -112,6 +113,9 @@ struct bluray {
BD_EVENT_QUEUE *event_queue; // navigation mode event queue
BD_TITLE_TYPE title_type; // type of current title (in navigation mode)
HDMV_VM *hdmv_vm;
uint8_t hdmv_suspended;
void *bdjava;
};
......@@ -394,6 +398,7 @@ void bd_close(BLURAY *bd)
nav_title_close(bd->title);
}
hdmv_vm_free(bd->hdmv_vm);
indx_free(bd->index);
bd_registers_free(bd->regs);
......@@ -1162,9 +1167,12 @@ static int _play_hdmv(BLURAY *bd, unsigned id_ref)
bd_stop_bdj(bd);
#endif
DEBUG(DBG_BLURAY|DBG_CRIT, "_hdmv_play(%u) not implemented (%p)\n", id_ref, bd);
if (!bd->hdmv_vm) {
bd->hdmv_vm = hdmv_vm_init(bd->device_path, bd->regs);
}
bd->hdmv_suspended = 0;
return -1;
return hdmv_vm_select_object(bd->hdmv_vm, id_ref, NULL);
}
#define TITLE_FIRST_PLAY 0xffff /* 10.4.3.2 (E) */
......@@ -1196,6 +1204,7 @@ int bd_play_title(BLURAY *bd, unsigned title)
/* bd_play not called ? */
if (bd->title_type == title_undef) {
DEBUG(DBG_BLURAY|DBG_CRIT, "bd_call_title(): bd_play() not called !\n");
return -1;
}
......@@ -1239,8 +1248,16 @@ int bd_play_title(BLURAY *bd, unsigned title)
int bd_play(BLURAY *bd)
{
/* reset player state */
bd->title_type = title_undef;
if (bd->hdmv_vm) {
hdmv_vm_free(bd->hdmv_vm);
bd->hdmv_vm = NULL;
bd->hdmv_suspended = 1;
}
_init_event_queue(bd);
bd_psr_register_cb(bd->regs, _process_psr_event, bd);
......@@ -1258,12 +1275,86 @@ int bd_menu_call(BLURAY *bd)
return bd_play_title(bd, TITLE_TOP_MENU);
}
static void _process_hdmv_vm_event(BLURAY *bd, HDMV_EVENT *hev)
{
DEBUG(DBG_BLURAY, "HDMV event: %d %d\n", hev->event, hev->param);
switch (hev->event) {
case HDMV_EVENT_TITLE:
bd_play_title(bd, hev->param);
break;
case HDMV_EVENT_PLAY_PL:
bd_select_playlist(bd, hev->param);
bd->hdmv_suspended = 1;
break;
case HDMV_EVENT_PLAY_PI:
//bd_seek_pi(bd, hev->param);
DEBUG(DBG_BLURAY|DBG_CRIT, "HDMV_EVENT_PLAY_PI: not implemented\n");
break;
case HDMV_EVENT_PLAY_PM:
bd_seek_mark(bd, hev->param);
break;
case HDMV_EVENT_PLAY_STOP:
DEBUG(DBG_BLURAY|DBG_CRIT, "HDMV_EVENT_PLAY_STOP: not tested !\n");
// stop current playlist
bd_seek(bd, bd->s_size - 1);
bd->clip = NULL;
// resume suspended movie object
bd->hdmv_suspended = 0;
break;
case HDMV_EVENT_END:
case HDMV_EVENT_NONE:
default:
break;
}
}
static int _run_hdmv(BLURAY *bd)
{
HDMV_EVENT hdmv_ev;
/* run VM */
if (hdmv_vm_run(bd->hdmv_vm, &hdmv_ev) < 0) {
_queue_event(bd, (BD_EVENT){BD_EVENT_ERROR, 0});
return -1;
}
/* process all events */
do {
_process_hdmv_vm_event(bd, &hdmv_ev);
} while (!hdmv_vm_get_event(bd->hdmv_vm, &hdmv_ev));
return 0;
}
int bd_read_ext(BLURAY *bd, unsigned char *buf, int len, BD_EVENT *event)
{
if (_get_event(bd, event)) {
return 0;
}
/* run HDMV VM ? */
if (bd->title_type == title_hdmv) {
while (!bd->hdmv_suspended) {
if (_run_hdmv(bd) < 0) {
DEBUG(DBG_BLURAY|DBG_CRIT, "bd_read_ext(): HDMV VM error\n");
bd->title_type = title_undef;
return -1;
}
if (_get_event(bd, event)) {
return 0;
}
}
}
if (len < 1) {
/* just polled events ? */
return 0;
......@@ -1271,6 +1362,13 @@ int bd_read_ext(BLURAY *bd, unsigned char *buf, int len, BD_EVENT *event)
int bytes = bd_read(bd, buf, len);
if (bytes == 0) {
if (bd->title_type == title_hdmv) {
DEBUG(DBG_BLURAY, "bd_read_ext(): reached end of playlist. hdmv_suspended=%d\n", bd->hdmv_suspended);
bd->hdmv_suspended = 0;
}
}
_get_event(bd, event);
return bytes;
......
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