| 1 |
/* |
| 2 |
* Copyright (C) 2000, 2001 Håkan Hjort |
| 3 |
* Copyright (C) 2001 Rich Wareham <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of libdvdnav, a DVD navigation library. It is modified |
| 6 |
* from a file originally part of the Ogle DVD player. |
| 7 |
* |
| 8 |
* libdvdnav is free software; you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation; either version 2 of the License, or |
| 11 |
* (at your option) any later version. |
| 12 |
* |
| 13 |
* libdvdnav is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU General Public License along |
| 19 |
* with libdvdnav; if not, write to the Free Software Foundation, Inc., |
| 20 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef LIBDVDNAV_VM_H |
| 24 |
#define LIBDVDNAV_VM_H |
| 25 |
|
| 26 |
/** |
| 27 |
* State: SPRM, GPRM, Domain, pgc, pgN, cellN, ? |
| 28 |
*/ |
| 29 |
typedef struct { |
| 30 |
registers_t registers; |
| 31 |
|
| 32 |
DVDDomain_t domain; |
| 33 |
int vtsN; /* 0 is vmgm? */ |
| 34 |
const pgc_t *pgc; /* either this or 'int pgcN' is enough? */ |
| 35 |
int pgcN; /* but provide pgcN for quick lookup */ |
| 36 |
int pgN; /* is this needed? can always fid pgN from cellN? */ |
| 37 |
int cellN; |
| 38 |
int32_t cell_restart; /* get cell to restart */ |
| 39 |
int blockN; |
| 40 |
|
| 41 |
/* Resume info */ |
| 42 |
int rsm_vtsN; |
| 43 |
int rsm_blockN; /* of nav_packet */ |
| 44 |
uint16_t rsm_regs[5]; /* system registers 4-8 */ |
| 45 |
int rsm_pgcN; |
| 46 |
int rsm_cellN; |
| 47 |
} dvd_state_t; |
| 48 |
|
| 49 |
typedef struct vm_position_s { |
| 50 |
int16_t button; /* Button highlighted */ |
| 51 |
int32_t vts; /* vts number to use */ |
| 52 |
DVDDomain_t domain; /* domain to use */ |
| 53 |
int32_t spu_channel; /* spu channel to use */ |
| 54 |
int32_t angle_channel; /* angle channel to use */ |
| 55 |
int32_t audio_channel; /* audio channel to use */ |
| 56 |
int32_t hop_channel; /* channel hopping. E.g menu button pressed */ |
| 57 |
#if 0 |
| 58 |
/* currently unused */ |
| 59 |
int32_t title; /* title number */ |
| 60 |
int32_t chapter; /* chapter number */ |
| 61 |
#endif |
| 62 |
int32_t cell; /* cell number */ |
| 63 |
int32_t cell_restart; /* get cell to restart */ |
| 64 |
int32_t cell_start; /* sector number of start of current cell in use */ |
| 65 |
int32_t still; /* is cell still */ |
| 66 |
int32_t block; /* block number within cell in use */ |
| 67 |
} vm_position_t; |
| 68 |
|
| 69 |
typedef struct { |
| 70 |
void *priv; |
| 71 |
dvdnav_logger_cb logcb; |
| 72 |
dvdnav_stream_cb streamcb; |
| 73 |
dvd_reader_t *dvd; |
| 74 |
dvd_reader_stream_cb dvdstreamcb; |
| 75 |
ifo_handle_t *vmgi; |
| 76 |
ifo_handle_t *vtsi; |
| 77 |
dvd_state_t state; |
| 78 |
int32_t hop_channel; |
| 79 |
char dvd_name[50]; |
| 80 |
char dvd_serial[15]; |
| 81 |
int stopped; |
| 82 |
} vm_t; |
| 83 |
|
| 84 |
/* magic number for seeking hops */ |
| 85 |
#define HOP_SEEK 0x1000 |
| 86 |
|
| 87 |
|
| 88 |
/* Audio stream number */ |
| 89 |
#define AST_REG registers.SPRM[1] |
| 90 |
/* Subpicture stream number */ |
| 91 |
#define SPST_REG registers.SPRM[2] |
| 92 |
/* Angle number */ |
| 93 |
#define AGL_REG registers.SPRM[3] |
| 94 |
/* Title Track Number */ |
| 95 |
#define TTN_REG registers.SPRM[4] |
| 96 |
/* VTS Title Track Number */ |
| 97 |
#define VTS_TTN_REG registers.SPRM[5] |
| 98 |
/* PGC Number for this Title Track */ |
| 99 |
#define TT_PGCN_REG registers.SPRM[6] |
| 100 |
/* Current Part of Title (PTT) number for (One_Sequential_PGC_Title) */ |
| 101 |
#define PTTN_REG registers.SPRM[7] |
| 102 |
/* Highlighted Button Number (btn nr 1 == value 1024) */ |
| 103 |
#define HL_BTNN_REG registers.SPRM[8] |
| 104 |
/* Parental Level */ |
| 105 |
#define PTL_REG registers.SPRM[13] |
| 106 |
|
| 107 |
/* Initialisation & destruction */ |
| 108 |
vm_t *vm_new_vm(void *, const dvdnav_logger_cb *); |
| 109 |
void vm_free_vm(vm_t *vm); |
| 110 |
|
| 111 |
/* IFO access */ |
| 112 |
ifo_handle_t *vm_get_vmgi(vm_t *vm); |
| 113 |
ifo_handle_t *vm_get_vtsi(vm_t *vm); |
| 114 |
|
| 115 |
/* Reader Access */ |
| 116 |
dvd_reader_t *vm_get_dvd_reader(vm_t *vm); |
| 117 |
|
| 118 |
/* Basic Handling */ |
| 119 |
int vm_start(vm_t *vm); |
| 120 |
void vm_stop(vm_t *vm); |
| 121 |
int vm_reset(vm_t *vm, const char *dvdroot, void *priv, |
| 122 |
dvdnav_stream_cb *stream_cb); |
| 123 |
|
| 124 |
/* copying and merging - useful for try-running an operation */ |
| 125 |
vm_t *vm_new_copy(vm_t *vm); |
| 126 |
void vm_merge(vm_t *target, vm_t *source); |
| 127 |
void vm_free_copy(vm_t *vm); |
| 128 |
|
| 129 |
/* regular playback */ |
| 130 |
void vm_position_get(vm_t *vm, vm_position_t *position); |
| 131 |
void vm_get_next_cell(vm_t *vm); |
| 132 |
|
| 133 |
/* Jumping - all these return 1, if a hop has been performed */ |
| 134 |
int vm_jump_pg(vm_t *vm, int pg); |
| 135 |
int vm_jump_cell_block(vm_t *vm, int cell, int block); |
| 136 |
int vm_jump_title_part(vm_t *vm, int title, int part); |
| 137 |
int vm_jump_title_program(vm_t *vm, int title, int pgcn, int pgn); |
| 138 |
int vm_jump_top_pg(vm_t *vm); |
| 139 |
int vm_jump_next_pg(vm_t *vm); |
| 140 |
int vm_jump_prev_pg(vm_t *vm); |
| 141 |
int vm_jump_up(vm_t *vm); |
| 142 |
int vm_jump_menu(vm_t *vm, DVDMenuID_t menuid); |
| 143 |
int vm_jump_resume(vm_t *vm); |
| 144 |
int vm_exec_cmd(vm_t *vm, const vm_cmd_t *cmd); |
| 145 |
|
| 146 |
/* getting information */ |
| 147 |
int vm_get_current_menu(vm_t *vm, int *menuid); |
| 148 |
int vm_get_current_title_part(vm_t *vm, int *title_result, int *part_result); |
| 149 |
int vm_get_audio_stream(vm_t *vm, int audioN); |
| 150 |
int vm_get_subp_stream(vm_t *vm, int subpN, int mode); |
| 151 |
int vm_get_audio_active_stream(vm_t *vm); |
| 152 |
int vm_get_subp_active_stream(vm_t *vm, int mode); |
| 153 |
void vm_get_angle_info(vm_t *vm, int *current, int *num_avail); |
| 154 |
#if 0 |
| 155 |
/* currently unused */ |
| 156 |
void vm_get_audio_info(vm_t *vm, int *current, int *num_avail); |
| 157 |
void vm_get_subp_info(vm_t *vm, int *current, int *num_avail); |
| 158 |
#endif |
| 159 |
void vm_get_video_res(vm_t *vm, int *width, int *height); |
| 160 |
int vm_get_video_aspect(vm_t *vm); |
| 161 |
int vm_get_video_scale_permission(vm_t *vm); |
| 162 |
video_attr_t vm_get_video_attr(vm_t *vm); |
| 163 |
audio_attr_t vm_get_audio_attr(vm_t *vm, int streamN); |
| 164 |
subp_attr_t vm_get_subp_attr(vm_t *vm, int streamN); |
| 165 |
ifo_handle_t *vm_get_title_ifo(vm_t *vm, uint32_t title); |
| 166 |
void vm_ifo_close(ifo_handle_t *ifo); |
| 167 |
|
| 168 |
/* Uncomment for VM command tracing */ |
| 169 |
/* #define TRACE */ |
| 170 |
#ifdef TRACE |
| 171 |
/* Debug */ |
| 172 |
void vm_position_print(vm_t *vm, vm_position_t *position); |
| 173 |
#endif |
| 174 |
|
| 175 |
int ifoOpenNewVTSI(vm_t *vm, dvd_reader_t *dvd, int vtsN); |
| 176 |
|
| 177 |
|
| 178 |
#endif /* LIBDVDNAV_VM_H */ |