Mercurial > mplayer.hg
annotate stream/stream_dvdnav.c @ 29790:f23da710dc29
dvdnav: print ID_SID_..._LANG, just like dvd://
author | reimar |
---|---|
date | Thu, 05 Nov 2009 21:29:14 +0000 |
parents | 9fbb75fb4e2d |
children | 94bde7a3ac51 |
rev | line source |
---|---|
19302 | 1 #include "config.h" |
2 | |
3 #include <stdlib.h> | |
4 #include <stdio.h> | |
5 #include <unistd.h> | |
6 #include <string.h> | |
25031
5e1e61012a05
report why the dvd couldn't be opened. Patch by Jan Knutar jknutar+nic+fi
nicodvb
parents:
25025
diff
changeset
|
7 #include <errno.h> |
19302 | 8 #include "mp_msg.h" |
9 #include "osdep/timer.h" | |
10 #include "input/input.h" | |
11 #include "stream.h" | |
19312
ab8d6b6deb63
proper inclusion of demuxer.h (including libmpdemux in Makefile only was to make previous split easier)
ben
parents:
19302
diff
changeset
|
12 #include "libmpdemux/demuxer.h" |
25539
47f2a9304623
include dvdnav.h from its installation directory rather than appending
nicodvb
parents:
25536
diff
changeset
|
13 #include <dvdnav/dvdnav.h> |
19302 | 14 #include "stream_dvdnav.h" |
15 #include "libvo/video_out.h" | |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
16 #include "libavutil/common.h" |
19302 | 17 #include "spudec.h" |
18 #include "m_option.h" | |
19 #include "m_struct.h" | |
20 #include "help_mp.h" | |
25824 | 21 #include "stream_dvd_common.h" |
22 | |
23 /* state flags */ | |
24 typedef enum { | |
25 NAV_FLAG_EOF = 1 << 0, /* end of stream has been reached */ | |
26 NAV_FLAG_WAIT = 1 << 1, /* wait event */ | |
27 NAV_FLAG_WAIT_SKIP = 1 << 2, /* wait skip disable */ | |
26985 | 28 NAV_FLAG_CELL_CHANGE = 1 << 3, /* cell change event */ |
25824 | 29 NAV_FLAG_WAIT_READ_AUTO = 1 << 4, /* wait read auto mode */ |
30 NAV_FLAG_WAIT_READ = 1 << 5, /* suspend read from stream */ | |
31 NAV_FLAG_VTS_DOMAIN = 1 << 6, /* vts domain */ | |
25827 | 32 NAV_FLAG_SPU_SET = 1 << 7, /* spu_clut is valid */ |
25830 | 33 NAV_FLAG_STREAM_CHANGE = 1 << 8, /* title, chapter, audio or SPU */ |
26983
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
34 NAV_FLAG_AUDIO_CHANGE = 1 << 9, /* audio stream change event */ |
26984
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
35 NAV_FLAG_SPU_CHANGE = 1 << 10, /* spu stream change event */ |
25824 | 36 } dvdnav_state_t; |
19302 | 37 |
25536
a7eec00ebb9c
private structures belong to the C file using them, not to header files included somewhere else
nicodvb
parents:
25296
diff
changeset
|
38 typedef struct { |
a7eec00ebb9c
private structures belong to the C file using them, not to header files included somewhere else
nicodvb
parents:
25296
diff
changeset
|
39 dvdnav_t * dvdnav; /* handle to libdvdnav stuff */ |
a7eec00ebb9c
private structures belong to the C file using them, not to header files included somewhere else
nicodvb
parents:
25296
diff
changeset
|
40 char * filename; /* path */ |
a7eec00ebb9c
private structures belong to the C file using them, not to header files included somewhere else
nicodvb
parents:
25296
diff
changeset
|
41 unsigned int duration; /* in milliseconds */ |
a7eec00ebb9c
private structures belong to the C file using them, not to header files included somewhere else
nicodvb
parents:
25296
diff
changeset
|
42 int mousex, mousey; |
a7eec00ebb9c
private structures belong to the C file using them, not to header files included somewhere else
nicodvb
parents:
25296
diff
changeset
|
43 int title; |
25827 | 44 unsigned int spu_clut[16]; |
25536
a7eec00ebb9c
private structures belong to the C file using them, not to header files included somewhere else
nicodvb
parents:
25296
diff
changeset
|
45 dvdnav_highlight_event_t hlev; |
25824 | 46 int still_length; /* still frame duration */ |
47 unsigned int state; | |
25536
a7eec00ebb9c
private structures belong to the C file using them, not to header files included somewhere else
nicodvb
parents:
25296
diff
changeset
|
48 } dvdnav_priv_t; |
a7eec00ebb9c
private structures belong to the C file using them, not to header files included somewhere else
nicodvb
parents:
25296
diff
changeset
|
49 |
19302 | 50 extern char *dvd_device; |
51 extern char *audio_lang, *dvdsub_lang; | |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
52 extern char *dvd_audio_stream_channels[6], *dvd_audio_stream_types[8]; |
19302 | 53 |
54 static struct stream_priv_s { | |
55 int track; | |
56 char* device; | |
57 } stream_priv_dflts = { | |
19764
499e5525d706
if no track number specified play the whole disc, or the menus can't be shown at start
nicodvb
parents:
19477
diff
changeset
|
58 0, |
19302 | 59 NULL |
60 }; | |
61 | |
62 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f) | |
63 /// URL definition | |
25242 | 64 static const m_option_t stream_opts_fields[] = { |
19302 | 65 {"filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, |
27235
ea35e46aa7af
in dvd streams the title part ranges from 1 to 99
nicodvb
parents:
26990
diff
changeset
|
66 {"hostname", ST_OFF(track), CONF_TYPE_INT, M_OPT_RANGE, 1, 99, NULL}, |
19302 | 67 { NULL, NULL, 0, 0, 0, 0, NULL } |
68 }; | |
25691 | 69 static const struct m_struct_st stream_opts = { |
19302 | 70 "dvd", |
71 sizeof(struct stream_priv_s), | |
72 &stream_priv_dflts, | |
73 stream_opts_fields | |
74 }; | |
75 | |
19892
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
76 static int seek(stream_t *s, off_t newpos); |
29130
33956c5f5005
Reemit the ID_AID_x_LANG for the track. This allows the identification of the
diego
parents:
29116
diff
changeset
|
77 static void show_audio_subs_languages(dvdnav_t *nav); |
19892
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
78 |
19914
dfd1bb3fc7c0
made file-static new_dvdnav_stream() and dvdnav_stream_read()
nicodvb
parents:
19912
diff
changeset
|
79 static dvdnav_priv_t * new_dvdnav_stream(char * filename) { |
25819 | 80 const char * title_str; |
20809 | 81 dvdnav_priv_t *priv; |
19302 | 82 |
83 if (!filename) | |
84 return NULL; | |
85 | |
20809 | 86 if (!(priv=calloc(1,sizeof(dvdnav_priv_t)))) |
19302 | 87 return NULL; |
88 | |
20809 | 89 if (!(priv->filename=strdup(filename))) { |
90 free(priv); | |
19302 | 91 return NULL; |
92 } | |
93 | |
20809 | 94 if(dvdnav_open(&(priv->dvdnav),priv->filename)!=DVDNAV_STATUS_OK) |
19302 | 95 { |
20809 | 96 free(priv->filename); |
97 free(priv); | |
19302 | 98 return NULL; |
99 } | |
100 | |
20809 | 101 if (!priv->dvdnav) { |
102 free(priv); | |
19302 | 103 return NULL; |
104 } | |
105 | |
106 if(1) //from vlc: if not used dvdnav from cvs will fail | |
107 { | |
108 int len, event; | |
109 char buf[2048]; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
110 |
20809 | 111 dvdnav_get_next_block(priv->dvdnav,buf,&event,&len); |
112 dvdnav_sector_search(priv->dvdnav, 0, SEEK_SET); | |
19302 | 113 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
114 |
19454 | 115 /* turn off dvdnav caching */ |
20809 | 116 dvdnav_set_readahead_flag(priv->dvdnav, 0); |
117 if(dvdnav_set_PGC_positioning_flag(priv->dvdnav, 1) != DVDNAV_STATUS_OK) | |
19302 | 118 mp_msg(MSGT_OPEN,MSGL_ERR,"stream_dvdnav, failed to set PGC positioning\n"); |
119 #if 1 | |
120 /* report the title?! */ | |
20809 | 121 if (dvdnav_get_title_string(priv->dvdnav,&title_str)==DVDNAV_STATUS_OK) { |
19302 | 122 mp_msg(MSGT_IDENTIFY, MSGL_INFO,"Title: '%s'\n",title_str); |
123 } | |
124 #endif | |
125 | |
20809 | 126 //dvdnav_event_clear(priv); |
19302 | 127 |
20809 | 128 return priv; |
19302 | 129 } |
130 | |
21219 | 131 static void dvdnav_get_highlight (dvdnav_priv_t *priv, int display_mode) { |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
132 pci_t *pnavpci = NULL; |
21219 | 133 dvdnav_highlight_event_t *hlev = &(priv->hlev); |
134 int btnum; | |
21198
fbe50a67612a
COSMETICS: consistently reformatted after ben's mess
nicodvb
parents:
21197
diff
changeset
|
135 |
21219 | 136 if (!priv || !priv->dvdnav) |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
137 return; |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
138 |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
139 pnavpci = dvdnav_get_current_nav_pci (priv->dvdnav); |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
140 if (!pnavpci) |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
141 return; |
21198
fbe50a67612a
COSMETICS: consistently reformatted after ben's mess
nicodvb
parents:
21197
diff
changeset
|
142 |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
143 dvdnav_get_current_highlight (priv->dvdnav, &(hlev->buttonN)); |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
144 hlev->display = display_mode; /* show */ |
21198
fbe50a67612a
COSMETICS: consistently reformatted after ben's mess
nicodvb
parents:
21197
diff
changeset
|
145 |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
146 if (hlev->buttonN > 0 && pnavpci->hli.hl_gi.btn_ns > 0 && hlev->display) { |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
147 for (btnum = 0; btnum < pnavpci->hli.hl_gi.btn_ns; btnum++) { |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
148 btni_t *btni = &(pnavpci->hli.btnit[btnum]); |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
149 |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
150 if (hlev->buttonN == btnum + 1) { |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
151 hlev->sx = FFMIN (btni->x_start, btni->x_end); |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
152 hlev->ex = FFMAX (btni->x_start, btni->x_end); |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
153 hlev->sy = FFMIN (btni->y_start, btni->y_end); |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
154 hlev->ey = FFMAX (btni->y_start, btni->y_end); |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
155 |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
156 hlev->palette = (btni->btn_coln == 0) ? 0 : |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
157 pnavpci->hli.btn_colit.btn_coli[btni->btn_coln - 1][0]; |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
158 break; |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
159 } |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
160 } |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
161 } else { /* hide button or no button */ |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
162 hlev->sx = hlev->ex = 0; |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
163 hlev->sy = hlev->ey = 0; |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
164 hlev->palette = hlev->buttonN = 0; |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
165 } |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
166 } |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
167 |
25824 | 168 static inline int dvdnav_get_duration (int length) { |
169 return (length == 255) ? 0 : length * 1000; | |
170 } | |
171 | |
20809 | 172 static int dvdnav_stream_read(dvdnav_priv_t * priv, unsigned char *buf, int *len) { |
19302 | 173 int event = DVDNAV_NOP; |
174 | |
175 *len=-1; | |
20809 | 176 if (dvdnav_get_next_block(priv->dvdnav,buf,&event,len)!=DVDNAV_STATUS_OK) { |
177 mp_msg(MSGT_OPEN,MSGL_V, "Error getting next block from DVD %d (%s)\n",event, dvdnav_err_to_string(priv->dvdnav) ); | |
19302 | 178 *len=-1; |
179 } | |
180 else if (event!=DVDNAV_BLOCK_OK) { | |
181 // need to handle certain events internally (like skipping stills) | |
182 switch (event) { | |
21332 | 183 case DVDNAV_NAV_PACKET: |
184 return event; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
185 case DVDNAV_STILL_FRAME: { |
25824 | 186 dvdnav_still_event_t *still_event = (dvdnav_still_event_t *) buf; |
187 priv->still_length = still_event->length; | |
188 /* set still frame duration */ | |
189 priv->duration = dvdnav_get_duration (priv->still_length); | |
190 if (priv->still_length <= 1) { | |
191 pci_t *pnavpci = dvdnav_get_current_nav_pci (priv->dvdnav); | |
192 priv->duration = mp_dvdtimetomsec (&pnavpci->pci_gi.e_eltm); | |
193 } | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
194 break; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
195 } |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
196 case DVDNAV_HIGHLIGHT: { |
21219 | 197 dvdnav_get_highlight (priv, 1); |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
198 break; |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
199 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
200 case DVDNAV_CELL_CHANGE: { |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
201 dvdnav_cell_change_event_t *ev = (dvdnav_cell_change_event_t*)buf; |
25824 | 202 uint32_t nextstill; |
203 | |
204 priv->state &= ~NAV_FLAG_WAIT_SKIP; | |
25830 | 205 priv->state |= NAV_FLAG_STREAM_CHANGE; |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
206 if(ev->pgc_length) |
20809 | 207 priv->duration = ev->pgc_length/90; |
25824 | 208 |
29116
2cd8c5f81281
Add a -indentify message that indicates if the current DVDNAV title is
reimar
parents:
28576
diff
changeset
|
209 if (dvdnav_is_domain_vts(priv->dvdnav)) { |
2cd8c5f81281
Add a -indentify message that indicates if the current DVDNAV title is
reimar
parents:
28576
diff
changeset
|
210 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "DVDNAV_TITLE_IS_MOVIE\n"); |
25824 | 211 priv->state &= ~NAV_FLAG_VTS_DOMAIN; |
29116
2cd8c5f81281
Add a -indentify message that indicates if the current DVDNAV title is
reimar
parents:
28576
diff
changeset
|
212 } else { |
2cd8c5f81281
Add a -indentify message that indicates if the current DVDNAV title is
reimar
parents:
28576
diff
changeset
|
213 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "DVDNAV_TITLE_IS_MENU\n"); |
25824 | 214 priv->state |= NAV_FLAG_VTS_DOMAIN; |
29116
2cd8c5f81281
Add a -indentify message that indicates if the current DVDNAV title is
reimar
parents:
28576
diff
changeset
|
215 } |
25824 | 216 |
217 nextstill = dvdnav_get_next_still_flag (priv->dvdnav); | |
218 if (nextstill) { | |
219 priv->duration = dvdnav_get_duration (nextstill); | |
220 priv->still_length = nextstill; | |
221 if (priv->still_length <= 1) { | |
222 pci_t *pnavpci = dvdnav_get_current_nav_pci (priv->dvdnav); | |
223 priv->duration = mp_dvdtimetomsec (&pnavpci->pci_gi.e_eltm); | |
224 } | |
225 } | |
226 | |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
227 break; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
228 } |
21538
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
229 case DVDNAV_SPU_CLUT_CHANGE: { |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
230 memcpy(priv->spu_clut, buf, 16*sizeof(unsigned int)); |
25827 | 231 priv->state |= NAV_FLAG_SPU_SET; |
21538
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
232 break; |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
233 } |
25824 | 234 case DVDNAV_WAIT: { |
235 if ((priv->state & NAV_FLAG_WAIT_SKIP) && | |
236 !(priv->state & NAV_FLAG_WAIT)) | |
237 dvdnav_wait_skip (priv->dvdnav); | |
238 else | |
239 priv->state |= NAV_FLAG_WAIT; | |
19302 | 240 break; |
25824 | 241 } |
242 case DVDNAV_VTS_CHANGE: { | |
243 priv->state &= ~NAV_FLAG_WAIT_SKIP; | |
25830 | 244 priv->state |= NAV_FLAG_STREAM_CHANGE; |
245 break; | |
246 } | |
247 case DVDNAV_SPU_STREAM_CHANGE: { | |
248 priv->state |= NAV_FLAG_STREAM_CHANGE; | |
25824 | 249 break; |
250 } | |
19302 | 251 } |
252 | |
253 *len=0; | |
254 } | |
255 return event; | |
256 } | |
257 | |
258 static void update_title_len(stream_t *stream) { | |
259 dvdnav_priv_t *priv = stream->priv; | |
260 dvdnav_status_t status; | |
261 uint32_t pos = 0, len = 0; | |
262 | |
263 status = dvdnav_get_position(priv->dvdnav, &pos, &len); | |
19892
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
264 if(status == DVDNAV_STATUS_OK && len) { |
19302 | 265 stream->end_pos = (off_t) len * 2048; |
19892
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
266 stream->seek = seek; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
267 } else { |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
268 stream->seek = NULL; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
269 stream->end_pos = 0; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
270 } |
19302 | 271 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
272 |
19302 | 273 |
274 static int seek(stream_t *s, off_t newpos) { | |
23990 | 275 uint32_t sector = 0; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
276 dvdnav_priv_t *priv = s->priv; |
19302 | 277 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29130
diff
changeset
|
278 if(s->end_pos && newpos > s->end_pos) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
279 newpos = s->end_pos; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
280 sector = newpos / 2048ULL; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
281 if(dvdnav_sector_search(priv->dvdnav, (uint64_t) sector, SEEK_SET) != DVDNAV_STATUS_OK) |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
282 goto fail; |
19302 | 283 |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
284 s->pos = newpos; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
285 |
19302 | 286 return 1; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
287 |
19302 | 288 fail: |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
289 mp_msg(MSGT_STREAM,MSGL_INFO,"dvdnav_stream, seeking to %"PRIu64" failed: %s\n", newpos, dvdnav_err_to_string(priv->dvdnav)); |
19302 | 290 |
291 return 1; | |
292 } | |
293 | |
294 static void stream_dvdnav_close(stream_t *s) { | |
295 dvdnav_priv_t *priv = s->priv; | |
296 dvdnav_close(priv->dvdnav); | |
297 priv->dvdnav = NULL; | |
298 free(priv); | |
299 } | |
300 | |
301 | |
302 static int fill_buffer(stream_t *s, char *but, int len) | |
303 { | |
304 int event; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
305 |
20809 | 306 dvdnav_priv_t* priv=s->priv; |
25824 | 307 if (priv->state & NAV_FLAG_WAIT_READ) /* read is suspended */ |
308 return -1; | |
19302 | 309 len=0; |
310 if(!s->end_pos) | |
311 update_title_len(s); | |
312 while(!len) /* grab all event until DVDNAV_BLOCK_OK (len=2048), DVDNAV_STOP or DVDNAV_STILL_FRAME */ | |
313 { | |
20810 | 314 event=dvdnav_stream_read(priv, s->buffer, &len); |
315 if(event==-1 || len==-1) | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
316 { |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
317 mp_msg(MSGT_CPLAYER,MSGL_ERR, "DVDNAV stream read error!\n"); |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
318 return 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
319 } |
25825
4c17a62383a4
automatically set spu button highlight when nav cell has changed
ben
parents:
25824
diff
changeset
|
320 if (event != DVDNAV_BLOCK_OK) |
4c17a62383a4
automatically set spu button highlight when nav cell has changed
ben
parents:
25824
diff
changeset
|
321 dvdnav_get_highlight (priv, 1); |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
322 switch (event) { |
25824 | 323 case DVDNAV_STOP: { |
324 priv->state |= NAV_FLAG_EOF; | |
325 return len; | |
326 } | |
21333 | 327 case DVDNAV_BLOCK_OK: |
328 case DVDNAV_NAV_PACKET: | |
25824 | 329 case DVDNAV_STILL_FRAME: |
21333 | 330 return len; |
25824 | 331 case DVDNAV_WAIT: { |
332 if (priv->state & NAV_FLAG_WAIT) | |
333 return len; | |
334 break; | |
335 } | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
336 case DVDNAV_VTS_CHANGE: { |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
337 int tit = 0, part = 0; |
23043
4038852b041e
after a DVDNAV_VTS_CHANGE event report the title being played
nicodvb
parents:
22936
diff
changeset
|
338 dvdnav_vts_change_event_t *vts_event = (dvdnav_vts_change_event_t *)s->buffer; |
4038852b041e
after a DVDNAV_VTS_CHANGE event report the title being played
nicodvb
parents:
22936
diff
changeset
|
339 mp_msg(MSGT_CPLAYER,MSGL_INFO, "DVDNAV, switched to title: %d\r\n", vts_event->new_vtsN); |
26985 | 340 priv->state |= NAV_FLAG_CELL_CHANGE; |
26983
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
341 priv->state |= NAV_FLAG_AUDIO_CHANGE; |
26984
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
342 priv->state |= NAV_FLAG_SPU_CHANGE; |
25824 | 343 priv->state &= ~NAV_FLAG_WAIT_SKIP; |
344 priv->state &= ~NAV_FLAG_WAIT; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
345 s->end_pos = 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
346 update_title_len(s); |
29130
33956c5f5005
Reemit the ID_AID_x_LANG for the track. This allows the identification of the
diego
parents:
29116
diff
changeset
|
347 show_audio_subs_languages(priv->dvdnav); |
25824 | 348 if (priv->state & NAV_FLAG_WAIT_READ_AUTO) |
349 priv->state |= NAV_FLAG_WAIT_READ; | |
20809 | 350 if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) == DVDNAV_STATUS_OK) { |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
351 mp_msg(MSGT_CPLAYER,MSGL_V, "\r\nDVDNAV, NEW TITLE %d\r\n", tit); |
21219 | 352 dvdnav_get_highlight (priv, 0); |
20809 | 353 if(priv->title > 0 && tit != priv->title) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
354 return 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
355 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
356 break; |
19302 | 357 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
358 case DVDNAV_CELL_CHANGE: { |
26985 | 359 priv->state |= NAV_FLAG_CELL_CHANGE; |
26983
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
360 priv->state |= NAV_FLAG_AUDIO_CHANGE; |
26984
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
361 priv->state |= NAV_FLAG_SPU_CHANGE; |
25824 | 362 priv->state &= ~NAV_FLAG_WAIT_SKIP; |
363 priv->state &= ~NAV_FLAG_WAIT; | |
364 if (priv->state & NAV_FLAG_WAIT_READ_AUTO) | |
365 priv->state |= NAV_FLAG_WAIT_READ; | |
20809 | 366 if(priv->title > 0 && dvd_last_chapter > 0) { |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
367 int tit=0, part=0; |
20809 | 368 if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) == DVDNAV_STATUS_OK && part > dvd_last_chapter) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
369 return 0; |
25826 | 370 } |
25825
4c17a62383a4
automatically set spu button highlight when nav cell has changed
ben
parents:
25824
diff
changeset
|
371 dvdnav_get_highlight (priv, 1); |
19302 | 372 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
373 break; |
26983
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
374 case DVDNAV_AUDIO_STREAM_CHANGE: |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
375 priv->state |= NAV_FLAG_AUDIO_CHANGE; |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
376 break; |
26984
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
377 case DVDNAV_SPU_STREAM_CHANGE: |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
378 priv->state |= NAV_FLAG_SPU_CHANGE; |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
379 break; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
380 } |
19302 | 381 } |
382 mp_msg(MSGT_STREAM,MSGL_DBG2,"DVDNAV fill_buffer len: %d\n",len); | |
383 return len; | |
384 } | |
385 | |
19443 | 386 static int control(stream_t *stream, int cmd, void* arg) { |
20809 | 387 dvdnav_priv_t* priv=stream->priv; |
19443 | 388 int tit, part; |
389 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29130
diff
changeset
|
390 switch(cmd) |
19443 | 391 { |
392 case STREAM_CTRL_SEEK_TO_CHAPTER: | |
393 { | |
394 int chap = *((unsigned int *)arg)+1; | |
395 | |
20809 | 396 if(chap < 1 || dvdnav_current_title_info(priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) |
19443 | 397 break; |
20809 | 398 if(dvdnav_part_play(priv->dvdnav, tit, chap) != DVDNAV_STATUS_OK) |
19443 | 399 break; |
400 return 1; | |
401 } | |
19477 | 402 case STREAM_CTRL_GET_NUM_CHAPTERS: |
403 { | |
20809 | 404 if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) |
19477 | 405 break; |
20809 | 406 if(dvdnav_get_number_of_parts(priv->dvdnav, tit, &part) != DVDNAV_STATUS_OK) |
19477 | 407 break; |
408 if(!part) | |
409 break; | |
410 *((unsigned int *)arg) = part; | |
411 return 1; | |
412 } | |
19443 | 413 case STREAM_CTRL_GET_CURRENT_CHAPTER: |
414 { | |
20809 | 415 if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) |
19443 | 416 break; |
417 *((unsigned int *)arg) = part - 1; | |
418 return 1; | |
419 } | |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
420 case STREAM_CTRL_GET_TIME_LENGTH: |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
421 { |
25824 | 422 if(priv->duration || priv->still_length) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
423 { |
20851
6602a90a06ec
consistency fix: STREAM_CTRL_GET_TIME_LENGTH and STREAM_CTRL_GET_CURRENT_TIME now return time in (double) seconds
nicodvb
parents:
20810
diff
changeset
|
424 *((double *)arg) = (double)priv->duration / 1000.0; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
425 return 1; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
426 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
427 break; |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
428 } |
24303 | 429 case STREAM_CTRL_GET_ASPECT_RATIO: |
430 { | |
431 uint8_t ar = dvdnav_get_video_aspect(priv->dvdnav); | |
432 *((double *)arg) = !ar ? 4.0/3.0 : 16.0/9.0; | |
433 return 1; | |
434 } | |
22936
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
435 case STREAM_CTRL_GET_CURRENT_TIME: |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
436 { |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
437 double tm; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
438 tm = dvdnav_get_current_time(priv->dvdnav)/90000.0f; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
439 if(tm != -1) |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
440 { |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
441 *((double *)arg) = tm; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
442 return 1; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
443 } |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
444 break; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
445 } |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
446 case STREAM_CTRL_SEEK_TO_TIME: |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
447 { |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
448 uint64_t tm = (uint64_t) (*((double*)arg) * 90000); |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
449 if(dvdnav_time_search(priv->dvdnav, tm) == DVDNAV_STATUS_OK) |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
450 return 1; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
451 break; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
452 } |
25574
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
453 case STREAM_CTRL_GET_NUM_ANGLES: |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
454 { |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
455 uint32_t curr, angles; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
456 if(dvdnav_get_angle_info(priv->dvdnav, &curr, &angles) != DVDNAV_STATUS_OK) |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
457 break; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
458 *((int *)arg) = angles; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
459 return 1; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
460 } |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
461 case STREAM_CTRL_GET_ANGLE: |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
462 { |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
463 uint32_t curr, angles; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
464 if(dvdnav_get_angle_info(priv->dvdnav, &curr, &angles) != DVDNAV_STATUS_OK) |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
465 break; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
466 *((int *)arg) = curr; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
467 return 1; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
468 } |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
469 case STREAM_CTRL_SET_ANGLE: |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
470 { |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
471 uint32_t curr, angles; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
472 int new_angle = *((int *)arg); |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
473 if(dvdnav_get_angle_info(priv->dvdnav, &curr, &angles) != DVDNAV_STATUS_OK) |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
474 break; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
475 if(new_angle>angles || new_angle<1) |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
476 break; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
477 if(dvdnav_angle_change(priv->dvdnav, new_angle) != DVDNAV_STATUS_OK) |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
478 return 1; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
479 } |
19443 | 480 } |
481 | |
24257 | 482 return STREAM_UNSUPPORTED; |
19443 | 483 } |
484 | |
25165 | 485 static void identify_chapters(dvdnav_t *nav, uint32_t title) |
486 { | |
25177
a43d99a80f4a
-identify also shows the duration(s) of the title(s)
nicodvb
parents:
25176
diff
changeset
|
487 uint64_t *parts=NULL, duration=0; |
25165 | 488 uint32_t n, i, t; |
25177
a43d99a80f4a
-identify also shows the duration(s) of the title(s)
nicodvb
parents:
25176
diff
changeset
|
489 n = dvdnav_describe_title_chapters(nav, title, &parts, &duration); |
25165 | 490 if(parts) { |
25177
a43d99a80f4a
-identify also shows the duration(s) of the title(s)
nicodvb
parents:
25176
diff
changeset
|
491 t = duration / 90; |
a43d99a80f4a
-identify also shows the duration(s) of the title(s)
nicodvb
parents:
25176
diff
changeset
|
492 mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_DVD_TITLE_%d_LENGTH=%d.%03d\n", title, t / 1000, t % 1000); |
25167 | 493 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "TITLE %u, CHAPTERS: ", title); |
25165 | 494 for(i=0; i<n; i++) { |
495 t = parts[i] / 90000; | |
496 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "%02d:%02d:%02d,", t/3600, (t/60)%60, t%60); | |
497 } | |
498 free(parts); | |
499 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "\n"); | |
500 } | |
501 } | |
502 | |
25176
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
503 static void identify(dvdnav_priv_t *priv, struct stream_priv_s *p) |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
504 { |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
505 uint32_t titles=0, i; |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
506 if(p->track <= 0) { |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
507 dvdnav_get_number_of_titles(priv->dvdnav, &titles); |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
508 for(i=0; i<titles; i++) |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
509 identify_chapters(priv->dvdnav, i); |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
510 } |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
511 else |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
512 identify_chapters(priv->dvdnav, p->track); |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
513 } |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
514 |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
515 static void show_audio_subs_languages(dvdnav_t *nav) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
516 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
517 uint8_t lg; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
518 uint16_t i, lang, format, id, channels; |
25820
b43eaaa94dd3
array was defined for 6 elements while 7 were declared
ben
parents:
25819
diff
changeset
|
519 int base[7] = {128, 0, 0, 0, 160, 136, 0}; |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
520 for(i=0; i<8; i++) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
521 { |
29787
efe4987aac4d
Make the dvdnav stream language information output more similar to the dvd one.
reimar
parents:
29786
diff
changeset
|
522 char tmp[] = "unknown"; |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
523 lg = dvdnav_get_audio_logical_stream(nav, i); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
524 if(lg == 0xff) continue; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
525 channels = dvdnav_audio_stream_channels(nav, lg); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
526 if(channels == 0xFFFF) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
527 channels = 2; //unknown |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
528 else |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
529 channels--; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
530 lang = dvdnav_audio_stream_to_lang(nav, lg); |
29787
efe4987aac4d
Make the dvdnav stream language information output more similar to the dvd one.
reimar
parents:
29786
diff
changeset
|
531 if(lang != 0xFFFF) |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
532 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
533 tmp[0] = lang >> 8; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
534 tmp[1] = lang & 0xFF; |
29787
efe4987aac4d
Make the dvdnav stream language information output more similar to the dvd one.
reimar
parents:
29786
diff
changeset
|
535 tmp[2] = 0; |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
536 } |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
537 format = dvdnav_audio_stream_format(nav, lg); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
538 if(format == 0xFFFF || format > 6) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
539 format = 1; //unknown |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
540 id = i + base[format]; |
29789
9fbb75fb4e2d
Cosmetics: indentation, merge two consecutive ifs.
reimar
parents:
29788
diff
changeset
|
541 mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDaudioStreamInfo, i, |
9fbb75fb4e2d
Cosmetics: indentation, merge two consecutive ifs.
reimar
parents:
29788
diff
changeset
|
542 dvd_audio_stream_types[format], dvd_audio_stream_channels[channels], tmp, id); |
9fbb75fb4e2d
Cosmetics: indentation, merge two consecutive ifs.
reimar
parents:
29788
diff
changeset
|
543 if (lang != 0xFFFF && lang && tmp[0]) |
29130
33956c5f5005
Reemit the ID_AID_x_LANG for the track. This allows the identification of the
diego
parents:
29116
diff
changeset
|
544 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", id, tmp); |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
545 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29130
diff
changeset
|
546 |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
547 for(i=0; i<32; i++) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
548 { |
29787
efe4987aac4d
Make the dvdnav stream language information output more similar to the dvd one.
reimar
parents:
29786
diff
changeset
|
549 char tmp[] = "unknown"; |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
550 lg = dvdnav_get_spu_logical_stream(nav, i); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
551 if(lg == 0xff) continue; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
552 lang = dvdnav_spu_stream_to_lang(nav, lg); |
29787
efe4987aac4d
Make the dvdnav stream language information output more similar to the dvd one.
reimar
parents:
29786
diff
changeset
|
553 if(lang != 0xFFFF) |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
554 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
555 tmp[0] = lang >> 8; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
556 tmp[1] = lang & 0xFF; |
29787
efe4987aac4d
Make the dvdnav stream language information output more similar to the dvd one.
reimar
parents:
29786
diff
changeset
|
557 tmp[2] = 0; |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
558 } |
29789
9fbb75fb4e2d
Cosmetics: indentation, merge two consecutive ifs.
reimar
parents:
29788
diff
changeset
|
559 mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDsubtitleLanguage, i, tmp); |
29790 | 560 if (lang != 0xFFFF && lang && tmp[0]) |
561 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n", i, tmp); | |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
562 } |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
563 } |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
564 |
19302 | 565 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { |
566 struct stream_priv_s* p = (struct stream_priv_s*)opts; | |
567 char *filename; | |
20809 | 568 dvdnav_priv_t *priv; |
19302 | 569 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29130
diff
changeset
|
570 if(p->device) filename = p->device; |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29130
diff
changeset
|
571 else if(dvd_device) filename= dvd_device; |
19302 | 572 else filename = DEFAULT_DVD_DEVICE; |
20809 | 573 if(!(priv=new_dvdnav_stream(filename))) { |
25031
5e1e61012a05
report why the dvd couldn't be opened. Patch by Jan Knutar jknutar+nic+fi
nicodvb
parents:
25025
diff
changeset
|
574 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename, strerror(errno)); |
24257 | 575 return STREAM_UNSUPPORTED; |
19302 | 576 } |
577 | |
19764
499e5525d706
if no track number specified play the whole disc, or the menus can't be shown at start
nicodvb
parents:
19477
diff
changeset
|
578 if(p->track > 0) { |
20809 | 579 priv->title = p->track; |
580 if(dvdnav_title_play(priv->dvdnav, p->track) != DVDNAV_STATUS_OK) { | |
581 mp_msg(MSGT_OPEN,MSGL_FATAL,"dvdnav_stream, couldn't select title %d, error '%s'\n", p->track, dvdnav_err_to_string(priv->dvdnav)); | |
24257 | 582 return STREAM_UNSUPPORTED; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
583 } |
25824 | 584 } else if (p->track == 0) { |
585 if(dvdnav_menu_call(priv->dvdnav, DVD_MENU_Root) != DVDNAV_STATUS_OK) | |
586 dvdnav_menu_call(priv->dvdnav, DVD_MENU_Title); | |
19842
a43fa4ad378e
at start, when not playing a specific titleset, try to call the Title menu (as is common practice among players)
nicodvb
parents:
19840
diff
changeset
|
587 } |
25176
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
588 if(mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
589 identify(priv, p); |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
590 if(p->track > 0) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
591 show_audio_subs_languages(priv->dvdnav); |
20754 | 592 if(dvd_angle > 1) |
20809 | 593 dvdnav_angle_change(priv->dvdnav, dvd_angle); |
19302 | 594 |
595 stream->sector_size = 2048; | |
596 stream->flags = STREAM_READ | STREAM_SEEK; | |
597 stream->fill_buffer = fill_buffer; | |
598 stream->seek = seek; | |
19443 | 599 stream->control = control; |
19302 | 600 stream->close = stream_dvdnav_close; |
601 stream->type = STREAMTYPE_DVDNAV; | |
20809 | 602 stream->priv=(void*)priv; |
19302 | 603 *file_format = DEMUXER_TYPE_MPEG_PS; |
604 | |
605 update_title_len(stream); | |
25824 | 606 if(!stream->pos && p->track > 0) |
24109 | 607 mp_msg(MSGT_OPEN,MSGL_ERR, "INIT ERROR: couldn't get init pos %s\r\n", dvdnav_err_to_string(priv->dvdnav)); |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
608 |
20406 | 609 mp_msg(MSGT_OPEN,MSGL_INFO, "Remember to disable MPlayer's cache when playing dvdnav:// streams (adding -nocache to your command line)\r\n"); |
19302 | 610 |
611 return STREAM_OK; | |
612 } | |
613 | |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
614 |
25824 | 615 void mp_dvdnav_handle_input(stream_t *stream, int cmd, int *button) { |
25829 | 616 dvdnav_priv_t * priv = stream->priv; |
20809 | 617 dvdnav_t *nav = priv->dvdnav; |
19908
b6aa47caeb72
§Ænitial button value is -1. Only (button>0) is a correct button selection.
jonas
parents:
19895
diff
changeset
|
618 dvdnav_status_t status=DVDNAV_STATUS_ERR; |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
619 pci_t *pci = dvdnav_get_current_nav_pci(nav); |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
620 |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
621 if(cmd != MP_CMD_DVDNAV_SELECT && !pci) |
25824 | 622 return; |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
623 |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
624 switch(cmd) { |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
625 case MP_CMD_DVDNAV_UP: |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
626 status = dvdnav_upper_button_select(nav, pci); |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
627 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
628 case MP_CMD_DVDNAV_DOWN: |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
629 status = dvdnav_lower_button_select(nav, pci); |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
630 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
631 case MP_CMD_DVDNAV_LEFT: |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
632 status = dvdnav_left_button_select(nav, pci); |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
633 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
634 case MP_CMD_DVDNAV_RIGHT: |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
635 status = dvdnav_right_button_select(nav, pci); |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
636 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
637 case MP_CMD_DVDNAV_MENU: |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
638 status = dvdnav_menu_call(nav,DVD_MENU_Root); |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
639 break; |
19777
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
640 case MP_CMD_DVDNAV_PREVMENU: { |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
641 int title=0, part=0; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
642 |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
643 dvdnav_current_title_info(nav, &title, &part); |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
644 if(title) { |
25824 | 645 if((status=dvdnav_menu_call(nav, DVD_MENU_Part)) == DVDNAV_STATUS_OK) |
19777
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
646 break; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
647 } |
25824 | 648 if((status=dvdnav_menu_call(nav, DVD_MENU_Title)) == DVDNAV_STATUS_OK) |
649 break; | |
650 status=dvdnav_menu_call(nav, DVD_MENU_Root); | |
19777
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
651 } |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
652 break; |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
653 case MP_CMD_DVDNAV_SELECT: |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
654 status = dvdnav_button_activate(nav, pci); |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
655 break; |
19912
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
656 case MP_CMD_DVDNAV_MOUSECLICK: |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
657 /* |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
658 this is a workaround: in theory the simple dvdnav_lower_button_select()+dvdnav_button_activate() |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
659 should be enough (and generally it is), but there are cases when the calls to dvdnav_lower_button_select() |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
660 and friends fail! Hence we have to call dvdnav_mouse_activate(priv->mousex, priv->mousey) with |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
661 the coodinates saved by mp_dvdnav_update_mouse_pos(). |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
662 This last call always works well |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
663 */ |
20809 | 664 status = dvdnav_mouse_activate(nav, pci, priv->mousex, priv->mousey); |
19912
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
665 break; |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
666 default: |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
667 mp_msg(MSGT_CPLAYER, MSGL_V, "Unknown DVDNAV cmd %d\n", cmd); |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
668 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
669 } |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
670 |
19840
ba3b77867047
in mp_dvdnav_handle_input() update current button only if the status of the previous operation succeeded; patch by Jonas Jermann
nicodvb
parents:
19839
diff
changeset
|
671 if(status == DVDNAV_STATUS_OK) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
672 dvdnav_get_current_highlight(nav, button); |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
673 } |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
674 |
19851
adfd08588514
report mouse coordinates after movement to dvdnav; this permits to enable button selection using the mouse; patch by Jonas Jermann and me
nicodvb
parents:
19842
diff
changeset
|
675 void mp_dvdnav_update_mouse_pos(stream_t *stream, int32_t x, int32_t y, int* button) { |
25829 | 676 dvdnav_priv_t * priv = stream->priv; |
20809 | 677 dvdnav_t *nav = priv->dvdnav; |
19851
adfd08588514
report mouse coordinates after movement to dvdnav; this permits to enable button selection using the mouse; patch by Jonas Jermann and me
nicodvb
parents:
19842
diff
changeset
|
678 dvdnav_status_t status; |
adfd08588514
report mouse coordinates after movement to dvdnav; this permits to enable button selection using the mouse; patch by Jonas Jermann and me
nicodvb
parents:
19842
diff
changeset
|
679 pci_t *pci = dvdnav_get_current_nav_pci(nav); |
adfd08588514
report mouse coordinates after movement to dvdnav; this permits to enable button selection using the mouse; patch by Jonas Jermann and me
nicodvb
parents:
19842
diff
changeset
|
680 |
adfd08588514
report mouse coordinates after movement to dvdnav; this permits to enable button selection using the mouse; patch by Jonas Jermann and me
nicodvb
parents:
19842
diff
changeset
|
681 if(!pci) return; |
adfd08588514
report mouse coordinates after movement to dvdnav; this permits to enable button selection using the mouse; patch by Jonas Jermann and me
nicodvb
parents:
19842
diff
changeset
|
682 |
adfd08588514
report mouse coordinates after movement to dvdnav; this permits to enable button selection using the mouse; patch by Jonas Jermann and me
nicodvb
parents:
19842
diff
changeset
|
683 status = dvdnav_mouse_select(nav, pci, x, y); |
adfd08588514
report mouse coordinates after movement to dvdnav; this permits to enable button selection using the mouse; patch by Jonas Jermann and me
nicodvb
parents:
19842
diff
changeset
|
684 if(status == DVDNAV_STATUS_OK) dvdnav_get_current_highlight(nav, button); |
adfd08588514
report mouse coordinates after movement to dvdnav; this permits to enable button selection using the mouse; patch by Jonas Jermann and me
nicodvb
parents:
19842
diff
changeset
|
685 else *button = -1; |
20809 | 686 priv->mousex = x; |
687 priv->mousey = y; | |
19851
adfd08588514
report mouse coordinates after movement to dvdnav; this permits to enable button selection using the mouse; patch by Jonas Jermann and me
nicodvb
parents:
19842
diff
changeset
|
688 } |
adfd08588514
report mouse coordinates after movement to dvdnav; this permits to enable button selection using the mouse; patch by Jonas Jermann and me
nicodvb
parents:
19842
diff
changeset
|
689 |
26990 | 690 static int mp_dvdnav_get_aid_from_format (stream_t *stream, int index, uint8_t lg) { |
691 dvdnav_priv_t * priv = stream->priv; | |
692 uint8_t format; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29130
diff
changeset
|
693 |
26990 | 694 format = dvdnav_audio_stream_format(priv->dvdnav, lg); |
695 switch(format) { | |
696 case DVDNAV_FORMAT_AC3: | |
29717
afc8b80eb027
cosmetics: Remove some pointless parentheses from return calls.
diego
parents:
29263
diff
changeset
|
697 return index + 128; |
26990 | 698 case DVDNAV_FORMAT_DTS: |
29717
afc8b80eb027
cosmetics: Remove some pointless parentheses from return calls.
diego
parents:
29263
diff
changeset
|
699 return index + 136; |
26990 | 700 case DVDNAV_FORMAT_LPCM: |
29717
afc8b80eb027
cosmetics: Remove some pointless parentheses from return calls.
diego
parents:
29263
diff
changeset
|
701 return index + 160; |
26990 | 702 case DVDNAV_FORMAT_MPEGAUDIO: |
703 return index; | |
704 default: | |
705 return -1; | |
706 } | |
707 | |
708 return -1; | |
709 } | |
710 | |
21424
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
711 /** |
26989
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
712 * \brief mp_dvdnav_aid_from_audio_num() returns the audio id corresponding to the logical number |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
713 * \param stream: - stream pointer |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
714 * \param audio_num: - logical number |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
715 * \return -1 on error, current subtitle id if successful |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
716 */ |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
717 int mp_dvdnav_aid_from_audio_num(stream_t *stream, int audio_num) { |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
718 dvdnav_priv_t * priv = stream->priv; |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
719 int k; |
26990 | 720 uint8_t lg; |
26989
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
721 |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
722 for(k=0; k<32; k++) { |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
723 lg = dvdnav_get_audio_logical_stream(priv->dvdnav, k); |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
724 if (lg == 0xff) continue; |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
725 if (lg != audio_num) continue; |
26990 | 726 |
727 return mp_dvdnav_get_aid_from_format (stream, k, lg); | |
26989
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
728 } |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
729 return -1; |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
730 } |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
731 |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
732 /** |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
733 * \brief mp_dvdnav_aid_from_lang() returns the audio id corresponding to the language code 'lang' |
21600 | 734 * \param stream: - stream pointer |
735 * \param lang: 2-characters language code[s], eventually separated by spaces of commas | |
736 * \return -1 on error, current subtitle id if successful | |
737 */ | |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
738 int mp_dvdnav_aid_from_lang(stream_t *stream, unsigned char *language) { |
25829 | 739 dvdnav_priv_t * priv = stream->priv; |
21600 | 740 int k; |
26990 | 741 uint8_t lg; |
28576 | 742 uint16_t lang, lcode; |
21600 | 743 |
744 while(language && strlen(language)>=2) { | |
745 lcode = (language[0] << 8) | (language[1]); | |
746 for(k=0; k<32; k++) { | |
747 lg = dvdnav_get_audio_logical_stream(priv->dvdnav, k); | |
748 if(lg == 0xff) continue; | |
749 lang = dvdnav_audio_stream_to_lang(priv->dvdnav, lg); | |
26990 | 750 if(lang != 0xFFFF && lang == lcode) |
751 return mp_dvdnav_get_aid_from_format (stream, k, lg); | |
21600 | 752 } |
753 language += 2; | |
754 while(language[0]==',' || language[0]==' ') ++language; | |
755 } | |
756 return -1; | |
757 } | |
758 | |
21603
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
759 /** |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
760 * \brief mp_dvdnav_lang_from_aid() assigns to buf the language corresponding to audio id 'aid' |
21603
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
761 * \param stream: - stream pointer |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
762 * \param sid: physical subtitle id |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
763 * \param buf: buffer to contain the 2-chars language string |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
764 * \return 0 on error, 1 if successful |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
765 */ |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
766 int mp_dvdnav_lang_from_aid(stream_t *stream, int aid, unsigned char *buf) { |
21603
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
767 uint8_t lg; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
768 uint16_t lang; |
25829 | 769 dvdnav_priv_t * priv = stream->priv; |
21603
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
770 |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
771 if(aid < 0) |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
772 return 0; |
21613
8547ae79e74b
simplified aid management in dvdnav_lang_from_aid(); patch by Joakim Patte
nicodvb
parents:
21603
diff
changeset
|
773 lg = dvdnav_get_audio_logical_stream(priv->dvdnav, aid & 0x7); |
21603
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
774 if(lg == 0xff) return 0; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
775 lang = dvdnav_audio_stream_to_lang(priv->dvdnav, lg); |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
776 if(lang == 0xffff) return 0; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
777 buf[0] = lang >> 8; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
778 buf[1] = lang & 0xFF; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
779 buf[2] = 0; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
780 return 1; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
781 } |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
782 |
21600 | 783 |
784 /** | |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
785 * \brief mp_dvdnav_sid_from_lang() returns the subtitle id corresponding to the language code 'lang' |
21424
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
786 * \param stream: - stream pointer |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
787 * \param lang: 2-characters language code[s], eventually separated by spaces of commas |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
788 * \return -1 on error, current subtitle id if successful |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
789 */ |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
790 int mp_dvdnav_sid_from_lang(stream_t *stream, unsigned char *language) { |
25829 | 791 dvdnav_priv_t * priv = stream->priv; |
23990 | 792 uint8_t lg, k; |
21204
1ddb1a86e419
support for comma-separated language codes in -slang
nicodvb
parents:
21200
diff
changeset
|
793 uint16_t lang, lcode; |
21197
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
794 |
21204
1ddb1a86e419
support for comma-separated language codes in -slang
nicodvb
parents:
21200
diff
changeset
|
795 while(language && strlen(language)>=2) { |
21333 | 796 lcode = (language[0] << 8) | (language[1]); |
797 for(k=0; k<32; k++) { | |
798 lg = dvdnav_get_spu_logical_stream(priv->dvdnav, k); | |
799 if(lg == 0xff) continue; | |
800 lang = dvdnav_spu_stream_to_lang(priv->dvdnav, lg); | |
801 if(lang != 0xFFFF && lang == lcode) { | |
802 return k; | |
803 } | |
21197
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
804 } |
21333 | 805 language += 2; |
806 while(language[0]==',' || language[0]==' ') ++language; | |
21204
1ddb1a86e419
support for comma-separated language codes in -slang
nicodvb
parents:
21200
diff
changeset
|
807 } |
21197
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
808 return -1; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
809 } |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
810 |
21424
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
811 /** |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
812 * \brief mp_dvdnav_lang_from_sid() assigns to buf the language corresponding to subtitle id 'sid' |
21560
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
813 * \param stream: - stream pointer |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
814 * \param sid: physical subtitle id |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
815 * \param buf: buffer to contain the 2-chars language string |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
816 * \return 0 on error, 1 if successful |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
817 */ |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
818 int mp_dvdnav_lang_from_sid(stream_t *stream, int sid, unsigned char *buf) { |
23990 | 819 uint8_t lg; |
21560
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
820 uint16_t lang; |
25829 | 821 dvdnav_priv_t *priv = stream->priv; |
21560
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
822 if(sid < 0) return 0; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
823 lg = dvdnav_get_spu_logical_stream(priv->dvdnav, sid); |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
824 lang = dvdnav_spu_stream_to_lang(priv->dvdnav, lg); |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
825 if(lang == 0xffff) return 0; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
826 buf[0] = lang >> 8; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
827 buf[1] = lang & 0xFF; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
828 buf[2] = 0; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
829 return 1; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
830 } |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
831 |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
832 /** |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
833 * \brief mp_dvdnav_number_of_subs() returns the count of available subtitles |
21424
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
834 * \param stream: - stream pointer |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
835 * \return 0 on error, something meaningful otherwise |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
836 */ |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
837 int mp_dvdnav_number_of_subs(stream_t *stream) { |
25829 | 838 dvdnav_priv_t * priv = stream->priv; |
21197
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
839 uint8_t lg, k, n=0; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
840 |
25824 | 841 if (priv->state & NAV_FLAG_VTS_DOMAIN) return 0; |
21197
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
842 for(k=0; k<32; k++) { |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
843 lg = dvdnav_get_spu_logical_stream(priv->dvdnav, k); |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
844 if(lg == 0xff) continue; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
845 n++; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
846 } |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
847 return n; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
848 } |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
849 |
23902 | 850 /** |
851 * \brief mp_dvdnav_get_spu_clut() returns the spu clut | |
852 * \param stream: - stream pointer | |
853 * \return spu clut pointer | |
854 */ | |
21538
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
855 unsigned int *mp_dvdnav_get_spu_clut(stream_t *stream) { |
25829 | 856 dvdnav_priv_t *priv = stream->priv; |
25828 | 857 return (priv->state & NAV_FLAG_SPU_SET) ? priv->spu_clut : NULL; |
21538
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
858 } |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
859 |
23902 | 860 /** |
861 * \brief mp_dvdnav_get_highlight() get dvdnav highlight struct | |
862 * \param stream: - stream pointer | |
863 * \param hl : - highlight struct pointer | |
864 */ | |
21219 | 865 void mp_dvdnav_get_highlight (stream_t *stream, nav_highlight_t *hl) { |
25829 | 866 dvdnav_priv_t *priv = stream->priv; |
21219 | 867 dvdnav_highlight_event_t hlev = priv->hlev; |
868 | |
869 hl->sx = hlev.sx; | |
870 hl->sy = hlev.sy; | |
871 hl->ex = hlev.ex; | |
872 hl->ey = hlev.ey; | |
26973 | 873 hl->palette = hlev.palette; |
21200 | 874 } |
19851
adfd08588514
report mouse coordinates after movement to dvdnav; this permits to enable button selection using the mouse; patch by Jonas Jermann and me
nicodvb
parents:
19842
diff
changeset
|
875 |
25817 | 876 void mp_dvdnav_switch_title (stream_t *stream, int title) { |
25829 | 877 dvdnav_priv_t *priv = stream->priv; |
25817 | 878 uint32_t titles; |
879 | |
880 dvdnav_get_number_of_titles (priv->dvdnav, &titles); | |
881 if (title > 0 && title <= titles) | |
882 dvdnav_title_play (priv->dvdnav, title); | |
883 } | |
884 | |
25824 | 885 /** |
886 * \brief Check if end of stream has been reached | |
887 * \param stream: - stream pointer | |
888 * \return 1 on really eof | |
889 */ | |
890 int mp_dvdnav_is_eof (stream_t *stream) { | |
891 return ((dvdnav_priv_t *) stream->priv)->state & NAV_FLAG_EOF; | |
892 } | |
893 | |
894 /** | |
895 * \brief Skip still frame | |
896 * \param stream: - stream pointer | |
897 * \return 0 on success | |
898 */ | |
899 int mp_dvdnav_skip_still (stream_t *stream) { | |
900 dvdnav_priv_t *priv = stream->priv; | |
901 if (priv->still_length == 0xff) | |
902 return 1; | |
903 dvdnav_still_skip(priv->dvdnav); | |
904 return 0; | |
905 } | |
906 | |
907 /** | |
908 * \brief Skip wait event | |
909 * \param stream: - stream pointer | |
910 * \return 0 on success | |
911 */ | |
912 int mp_dvdnav_skip_wait (stream_t *stream) { | |
913 dvdnav_priv_t *priv = stream->priv; | |
914 if (!(priv->state & NAV_FLAG_WAIT)) | |
915 return 1; | |
916 priv->state &= ~NAV_FLAG_WAIT; | |
917 dvdnav_wait_skip(priv->dvdnav); | |
918 return 0; | |
919 } | |
920 | |
921 /** | |
922 * \brief Set wait mode | |
923 * \param stream : - stream pointer | |
924 * \param mode : - if true, then suspend block read | |
925 * \param automode: - if true, then VTS or cell change set wait mode | |
926 */ | |
927 void mp_dvdnav_read_wait (stream_t *stream, int mode, int automode) { | |
928 dvdnav_priv_t *priv = stream->priv; | |
929 if (mode == 0) | |
930 priv->state &= ~NAV_FLAG_WAIT_READ; | |
931 if (mode > 0) | |
932 priv->state |= NAV_FLAG_WAIT_READ; | |
933 if (automode == 0) | |
934 priv->state &= ~NAV_FLAG_WAIT_READ_AUTO; | |
935 if (automode > 0) | |
936 priv->state |= NAV_FLAG_WAIT_READ_AUTO; | |
937 } | |
938 | |
939 /** | |
940 * \brief Check if cell has changed | |
941 * \param stream: - stream pointer | |
942 * \param clear : - if true, then clear cell change flag | |
943 * \return 1 if cell has changed | |
944 */ | |
945 int mp_dvdnav_cell_has_changed (stream_t *stream, int clear) { | |
946 dvdnav_priv_t *priv = stream->priv; | |
26985 | 947 if (!(priv->state & NAV_FLAG_CELL_CHANGE)) |
25824 | 948 return 0; |
25832 | 949 if (clear) { |
26985 | 950 priv->state &= ~NAV_FLAG_CELL_CHANGE; |
25832 | 951 priv->state |= NAV_FLAG_STREAM_CHANGE; |
952 } | |
25824 | 953 return 1; |
954 } | |
955 | |
26983
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
956 /** |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
957 * \brief Check if audio has changed |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
958 * \param stream: - stream pointer |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
959 * \param clear : - if true, then clear audio change flag |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
960 * \return 1 if audio has changed |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
961 */ |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
962 int mp_dvdnav_audio_has_changed (stream_t *stream, int clear) { |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
963 dvdnav_priv_t *priv = stream->priv; |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
964 |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
965 if (!(priv->state & NAV_FLAG_AUDIO_CHANGE)) |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
966 return 0; |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
967 |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
968 if (clear) |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
969 priv->state &= ~NAV_FLAG_AUDIO_CHANGE; |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
970 |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
971 return 1; |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
972 } |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
973 |
26984
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
974 /** |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
975 * \brief Check if SPU has changed |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
976 * \param stream: - stream pointer |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
977 * \param clear : - if true, then clear spu change flag |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
978 * \return 1 if spu has changed |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
979 */ |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
980 int mp_dvdnav_spu_has_changed (stream_t *stream, int clear) { |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
981 dvdnav_priv_t *priv = stream->priv; |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
982 |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
983 if (!(priv->state & NAV_FLAG_SPU_CHANGE)) |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
984 return 0; |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
985 |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
986 if (clear) |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
987 priv->state &= ~NAV_FLAG_SPU_CHANGE; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29130
diff
changeset
|
988 |
26984
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
989 return 1; |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
990 } |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
991 |
25830 | 992 /* Notify if something has changed in stream |
993 * Can be related to title, chapter, audio or SPU | |
994 */ | |
995 int mp_dvdnav_stream_has_changed (stream_t *stream) { | |
996 dvdnav_priv_t *priv = stream->priv; | |
997 | |
998 if (!(priv->state & NAV_FLAG_STREAM_CHANGE)) | |
999 return 0; | |
1000 | |
1001 priv->state &= ~NAV_FLAG_STREAM_CHANGE; | |
1002 return 1; | |
1003 } | |
25824 | 1004 |
25211 | 1005 const stream_info_t stream_info_dvdnav = { |
19302 | 1006 "DVDNAV stream", |
1007 "null", | |
1008 "", | |
1009 "", | |
1010 open_s, | |
1011 { "dvdnav", NULL }, | |
1012 &stream_opts, | |
1013 1 // Urls are an option string | |
1014 }; |