Mercurial > mplayer.hg
annotate stream/stream_dvdnav.c @ 27629:d04568721d39
Make output messages of frequency selection code more useful by
providing additional information like requested frequency
and found nearest fequency/channel.
patch from Laurent laurent dot aml at gmail dot com
author | voroshil |
---|---|
date | Wed, 24 Sep 2008 20:42:15 +0000 |
parents | ea35e46aa7af |
children | a6b506faeb34 |
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); |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
77 |
19914
dfd1bb3fc7c0
made file-static new_dvdnav_stream() and dvdnav_stream_read()
nicodvb
parents:
19912
diff
changeset
|
78 static dvdnav_priv_t * new_dvdnav_stream(char * filename) { |
25819 | 79 const char * title_str; |
20809 | 80 dvdnav_priv_t *priv; |
19302 | 81 |
82 if (!filename) | |
83 return NULL; | |
84 | |
20809 | 85 if (!(priv=calloc(1,sizeof(dvdnav_priv_t)))) |
19302 | 86 return NULL; |
87 | |
20809 | 88 if (!(priv->filename=strdup(filename))) { |
89 free(priv); | |
19302 | 90 return NULL; |
91 } | |
92 | |
20809 | 93 if(dvdnav_open(&(priv->dvdnav),priv->filename)!=DVDNAV_STATUS_OK) |
19302 | 94 { |
20809 | 95 free(priv->filename); |
96 free(priv); | |
19302 | 97 return NULL; |
98 } | |
99 | |
20809 | 100 if (!priv->dvdnav) { |
101 free(priv); | |
19302 | 102 return NULL; |
103 } | |
104 | |
105 if(1) //from vlc: if not used dvdnav from cvs will fail | |
106 { | |
107 int len, event; | |
108 char buf[2048]; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
109 |
20809 | 110 dvdnav_get_next_block(priv->dvdnav,buf,&event,&len); |
111 dvdnav_sector_search(priv->dvdnav, 0, SEEK_SET); | |
19302 | 112 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
113 |
19454 | 114 /* turn off dvdnav caching */ |
20809 | 115 dvdnav_set_readahead_flag(priv->dvdnav, 0); |
116 if(dvdnav_set_PGC_positioning_flag(priv->dvdnav, 1) != DVDNAV_STATUS_OK) | |
19302 | 117 mp_msg(MSGT_OPEN,MSGL_ERR,"stream_dvdnav, failed to set PGC positioning\n"); |
118 #if 1 | |
119 /* report the title?! */ | |
20809 | 120 if (dvdnav_get_title_string(priv->dvdnav,&title_str)==DVDNAV_STATUS_OK) { |
19302 | 121 mp_msg(MSGT_IDENTIFY, MSGL_INFO,"Title: '%s'\n",title_str); |
122 } | |
123 #endif | |
124 | |
20809 | 125 //dvdnav_event_clear(priv); |
19302 | 126 |
20809 | 127 return priv; |
19302 | 128 } |
129 | |
21219 | 130 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
|
131 pci_t *pnavpci = NULL; |
21219 | 132 dvdnav_highlight_event_t *hlev = &(priv->hlev); |
133 int btnum; | |
21198
fbe50a67612a
COSMETICS: consistently reformatted after ben's mess
nicodvb
parents:
21197
diff
changeset
|
134 |
21219 | 135 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
|
136 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
|
137 |
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 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
|
139 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
|
140 return; |
21198
fbe50a67612a
COSMETICS: consistently reformatted after ben's mess
nicodvb
parents:
21197
diff
changeset
|
141 |
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
|
142 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
|
143 hlev->display = display_mode; /* show */ |
21198
fbe50a67612a
COSMETICS: consistently reformatted after ben's mess
nicodvb
parents:
21197
diff
changeset
|
144 |
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
|
145 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
|
146 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
|
147 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
|
148 |
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 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
|
150 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
|
151 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
|
152 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
|
153 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
|
154 |
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 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
|
156 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
|
157 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
|
158 } |
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 } 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
|
161 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
|
162 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
|
163 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
|
164 } |
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 |
25824 | 167 static inline int dvdnav_get_duration (int length) { |
168 return (length == 255) ? 0 : length * 1000; | |
169 } | |
170 | |
20809 | 171 static int dvdnav_stream_read(dvdnav_priv_t * priv, unsigned char *buf, int *len) { |
19302 | 172 int event = DVDNAV_NOP; |
173 | |
174 *len=-1; | |
20809 | 175 if (dvdnav_get_next_block(priv->dvdnav,buf,&event,len)!=DVDNAV_STATUS_OK) { |
176 mp_msg(MSGT_OPEN,MSGL_V, "Error getting next block from DVD %d (%s)\n",event, dvdnav_err_to_string(priv->dvdnav) ); | |
19302 | 177 *len=-1; |
178 } | |
179 else if (event!=DVDNAV_BLOCK_OK) { | |
180 // need to handle certain events internally (like skipping stills) | |
181 switch (event) { | |
21332 | 182 case DVDNAV_NAV_PACKET: |
183 return event; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
184 case DVDNAV_STILL_FRAME: { |
25824 | 185 dvdnav_still_event_t *still_event = (dvdnav_still_event_t *) buf; |
186 priv->still_length = still_event->length; | |
187 /* set still frame duration */ | |
188 priv->duration = dvdnav_get_duration (priv->still_length); | |
189 if (priv->still_length <= 1) { | |
190 pci_t *pnavpci = dvdnav_get_current_nav_pci (priv->dvdnav); | |
191 priv->duration = mp_dvdtimetomsec (&pnavpci->pci_gi.e_eltm); | |
192 } | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
193 break; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
194 } |
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
|
195 case DVDNAV_HIGHLIGHT: { |
21219 | 196 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
|
197 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
|
198 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
199 case DVDNAV_CELL_CHANGE: { |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
200 dvdnav_cell_change_event_t *ev = (dvdnav_cell_change_event_t*)buf; |
25824 | 201 uint32_t nextstill; |
202 | |
203 priv->state &= ~NAV_FLAG_WAIT_SKIP; | |
25830 | 204 priv->state |= NAV_FLAG_STREAM_CHANGE; |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
205 if(ev->pgc_length) |
20809 | 206 priv->duration = ev->pgc_length/90; |
25824 | 207 |
208 if (dvdnav_is_domain_vts(priv->dvdnav)) | |
209 priv->state &= ~NAV_FLAG_VTS_DOMAIN; | |
210 else | |
211 priv->state |= NAV_FLAG_VTS_DOMAIN; | |
212 | |
213 nextstill = dvdnav_get_next_still_flag (priv->dvdnav); | |
214 if (nextstill) { | |
215 priv->duration = dvdnav_get_duration (nextstill); | |
216 priv->still_length = nextstill; | |
217 if (priv->still_length <= 1) { | |
218 pci_t *pnavpci = dvdnav_get_current_nav_pci (priv->dvdnav); | |
219 priv->duration = mp_dvdtimetomsec (&pnavpci->pci_gi.e_eltm); | |
220 } | |
221 } | |
222 | |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
223 break; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
224 } |
21538
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
225 case DVDNAV_SPU_CLUT_CHANGE: { |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
226 memcpy(priv->spu_clut, buf, 16*sizeof(unsigned int)); |
25827 | 227 priv->state |= NAV_FLAG_SPU_SET; |
21538
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
228 break; |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
229 } |
25824 | 230 case DVDNAV_WAIT: { |
231 if ((priv->state & NAV_FLAG_WAIT_SKIP) && | |
232 !(priv->state & NAV_FLAG_WAIT)) | |
233 dvdnav_wait_skip (priv->dvdnav); | |
234 else | |
235 priv->state |= NAV_FLAG_WAIT; | |
19302 | 236 break; |
25824 | 237 } |
238 case DVDNAV_VTS_CHANGE: { | |
239 priv->state &= ~NAV_FLAG_WAIT_SKIP; | |
25830 | 240 priv->state |= NAV_FLAG_STREAM_CHANGE; |
241 break; | |
242 } | |
243 case DVDNAV_SPU_STREAM_CHANGE: { | |
244 priv->state |= NAV_FLAG_STREAM_CHANGE; | |
25824 | 245 break; |
246 } | |
19302 | 247 } |
248 | |
249 *len=0; | |
250 } | |
251 return event; | |
252 } | |
253 | |
254 static void update_title_len(stream_t *stream) { | |
255 dvdnav_priv_t *priv = stream->priv; | |
256 dvdnav_status_t status; | |
257 uint32_t pos = 0, len = 0; | |
258 | |
259 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
|
260 if(status == DVDNAV_STATUS_OK && len) { |
19302 | 261 stream->end_pos = (off_t) len * 2048; |
19892
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
262 stream->seek = seek; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
263 } else { |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
264 stream->seek = NULL; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
265 stream->end_pos = 0; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
266 } |
19302 | 267 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
268 |
19302 | 269 |
270 static int seek(stream_t *s, off_t newpos) { | |
23990 | 271 uint32_t sector = 0; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
272 dvdnav_priv_t *priv = s->priv; |
19302 | 273 |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
274 if(s->end_pos && newpos > s->end_pos) |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
275 newpos = s->end_pos; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
276 sector = newpos / 2048ULL; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
277 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
|
278 goto fail; |
19302 | 279 |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
280 s->pos = newpos; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
281 |
19302 | 282 return 1; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
283 |
19302 | 284 fail: |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
285 mp_msg(MSGT_STREAM,MSGL_INFO,"dvdnav_stream, seeking to %"PRIu64" failed: %s\n", newpos, dvdnav_err_to_string(priv->dvdnav)); |
19302 | 286 |
287 return 1; | |
288 } | |
289 | |
290 static void stream_dvdnav_close(stream_t *s) { | |
291 dvdnav_priv_t *priv = s->priv; | |
292 dvdnav_close(priv->dvdnav); | |
293 priv->dvdnav = NULL; | |
294 free(priv); | |
295 } | |
296 | |
297 | |
298 static int fill_buffer(stream_t *s, char *but, int len) | |
299 { | |
300 int event; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
301 |
20809 | 302 dvdnav_priv_t* priv=s->priv; |
25824 | 303 if (priv->state & NAV_FLAG_WAIT_READ) /* read is suspended */ |
304 return -1; | |
19302 | 305 len=0; |
306 if(!s->end_pos) | |
307 update_title_len(s); | |
308 while(!len) /* grab all event until DVDNAV_BLOCK_OK (len=2048), DVDNAV_STOP or DVDNAV_STILL_FRAME */ | |
309 { | |
20810 | 310 event=dvdnav_stream_read(priv, s->buffer, &len); |
311 if(event==-1 || len==-1) | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
312 { |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
313 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
|
314 return 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
315 } |
25825
4c17a62383a4
automatically set spu button highlight when nav cell has changed
ben
parents:
25824
diff
changeset
|
316 if (event != DVDNAV_BLOCK_OK) |
4c17a62383a4
automatically set spu button highlight when nav cell has changed
ben
parents:
25824
diff
changeset
|
317 dvdnav_get_highlight (priv, 1); |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
318 switch (event) { |
25824 | 319 case DVDNAV_STOP: { |
320 priv->state |= NAV_FLAG_EOF; | |
321 return len; | |
322 } | |
21333 | 323 case DVDNAV_BLOCK_OK: |
324 case DVDNAV_NAV_PACKET: | |
25824 | 325 case DVDNAV_STILL_FRAME: |
21333 | 326 return len; |
25824 | 327 case DVDNAV_WAIT: { |
328 if (priv->state & NAV_FLAG_WAIT) | |
329 return len; | |
330 break; | |
331 } | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
332 case DVDNAV_VTS_CHANGE: { |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
333 int tit = 0, part = 0; |
23043
4038852b041e
after a DVDNAV_VTS_CHANGE event report the title being played
nicodvb
parents:
22936
diff
changeset
|
334 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
|
335 mp_msg(MSGT_CPLAYER,MSGL_INFO, "DVDNAV, switched to title: %d\r\n", vts_event->new_vtsN); |
26985 | 336 priv->state |= NAV_FLAG_CELL_CHANGE; |
26983
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
337 priv->state |= NAV_FLAG_AUDIO_CHANGE; |
26984
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
338 priv->state |= NAV_FLAG_SPU_CHANGE; |
25824 | 339 priv->state &= ~NAV_FLAG_WAIT_SKIP; |
340 priv->state &= ~NAV_FLAG_WAIT; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
341 s->end_pos = 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
342 update_title_len(s); |
25824 | 343 if (priv->state & NAV_FLAG_WAIT_READ_AUTO) |
344 priv->state |= NAV_FLAG_WAIT_READ; | |
20809 | 345 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
|
346 mp_msg(MSGT_CPLAYER,MSGL_V, "\r\nDVDNAV, NEW TITLE %d\r\n", tit); |
21219 | 347 dvdnav_get_highlight (priv, 0); |
20809 | 348 if(priv->title > 0 && tit != priv->title) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
349 return 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
350 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
351 break; |
19302 | 352 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
353 case DVDNAV_CELL_CHANGE: { |
26985 | 354 priv->state |= NAV_FLAG_CELL_CHANGE; |
26983
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
355 priv->state |= NAV_FLAG_AUDIO_CHANGE; |
26984
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
356 priv->state |= NAV_FLAG_SPU_CHANGE; |
25824 | 357 priv->state &= ~NAV_FLAG_WAIT_SKIP; |
358 priv->state &= ~NAV_FLAG_WAIT; | |
359 if (priv->state & NAV_FLAG_WAIT_READ_AUTO) | |
360 priv->state |= NAV_FLAG_WAIT_READ; | |
20809 | 361 if(priv->title > 0 && dvd_last_chapter > 0) { |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
362 int tit=0, part=0; |
20809 | 363 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
|
364 return 0; |
25826 | 365 } |
25825
4c17a62383a4
automatically set spu button highlight when nav cell has changed
ben
parents:
25824
diff
changeset
|
366 dvdnav_get_highlight (priv, 1); |
19302 | 367 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
368 break; |
26983
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
369 case DVDNAV_AUDIO_STREAM_CHANGE: |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
370 priv->state |= NAV_FLAG_AUDIO_CHANGE; |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
371 break; |
26984
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
372 case DVDNAV_SPU_STREAM_CHANGE: |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
373 priv->state |= NAV_FLAG_SPU_CHANGE; |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
374 break; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
375 } |
19302 | 376 } |
377 mp_msg(MSGT_STREAM,MSGL_DBG2,"DVDNAV fill_buffer len: %d\n",len); | |
378 return len; | |
379 } | |
380 | |
19443 | 381 static int control(stream_t *stream, int cmd, void* arg) { |
20809 | 382 dvdnav_priv_t* priv=stream->priv; |
19443 | 383 int tit, part; |
384 | |
385 switch(cmd) | |
386 { | |
387 case STREAM_CTRL_SEEK_TO_CHAPTER: | |
388 { | |
389 int chap = *((unsigned int *)arg)+1; | |
390 | |
20809 | 391 if(chap < 1 || dvdnav_current_title_info(priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) |
19443 | 392 break; |
20809 | 393 if(dvdnav_part_play(priv->dvdnav, tit, chap) != DVDNAV_STATUS_OK) |
19443 | 394 break; |
395 return 1; | |
396 } | |
19477 | 397 case STREAM_CTRL_GET_NUM_CHAPTERS: |
398 { | |
20809 | 399 if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) |
19477 | 400 break; |
20809 | 401 if(dvdnav_get_number_of_parts(priv->dvdnav, tit, &part) != DVDNAV_STATUS_OK) |
19477 | 402 break; |
403 if(!part) | |
404 break; | |
405 *((unsigned int *)arg) = part; | |
406 return 1; | |
407 } | |
19443 | 408 case STREAM_CTRL_GET_CURRENT_CHAPTER: |
409 { | |
20809 | 410 if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) |
19443 | 411 break; |
412 *((unsigned int *)arg) = part - 1; | |
413 return 1; | |
414 } | |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
415 case STREAM_CTRL_GET_TIME_LENGTH: |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
416 { |
25824 | 417 if(priv->duration || priv->still_length) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
418 { |
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
|
419 *((double *)arg) = (double)priv->duration / 1000.0; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
420 return 1; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
421 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
422 break; |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
423 } |
24303 | 424 case STREAM_CTRL_GET_ASPECT_RATIO: |
425 { | |
426 uint8_t ar = dvdnav_get_video_aspect(priv->dvdnav); | |
427 *((double *)arg) = !ar ? 4.0/3.0 : 16.0/9.0; | |
428 return 1; | |
429 } | |
22936
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
430 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
|
431 { |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
432 double tm; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
433 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
|
434 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
|
435 { |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
436 *((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
|
437 return 1; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
438 } |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
439 break; |
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 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
|
442 { |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
443 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
|
444 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
|
445 return 1; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
446 break; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
447 } |
25574
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
448 case STREAM_CTRL_GET_NUM_ANGLES: |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
449 { |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
450 uint32_t curr, angles; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
451 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
|
452 break; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
453 *((int *)arg) = angles; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
454 return 1; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
455 } |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
456 case STREAM_CTRL_GET_ANGLE: |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
457 { |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
458 uint32_t curr, angles; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
459 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
|
460 break; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
461 *((int *)arg) = curr; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
462 return 1; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
463 } |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
464 case STREAM_CTRL_SET_ANGLE: |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
465 { |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
466 uint32_t curr, angles; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
467 int new_angle = *((int *)arg); |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
468 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
|
469 break; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
470 if(new_angle>angles || new_angle<1) |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
471 break; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
472 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
|
473 return 1; |
bef7f820d179
implemented _ANGLE STREAM_CTRLs, patch by oattila chello hu
nicodvb
parents:
25539
diff
changeset
|
474 } |
19443 | 475 } |
476 | |
24257 | 477 return STREAM_UNSUPPORTED; |
19443 | 478 } |
479 | |
25165 | 480 static void identify_chapters(dvdnav_t *nav, uint32_t title) |
481 { | |
25177
a43d99a80f4a
-identify also shows the duration(s) of the title(s)
nicodvb
parents:
25176
diff
changeset
|
482 uint64_t *parts=NULL, duration=0; |
25165 | 483 uint32_t n, i, t; |
25177
a43d99a80f4a
-identify also shows the duration(s) of the title(s)
nicodvb
parents:
25176
diff
changeset
|
484 n = dvdnav_describe_title_chapters(nav, title, &parts, &duration); |
25165 | 485 if(parts) { |
25177
a43d99a80f4a
-identify also shows the duration(s) of the title(s)
nicodvb
parents:
25176
diff
changeset
|
486 t = duration / 90; |
a43d99a80f4a
-identify also shows the duration(s) of the title(s)
nicodvb
parents:
25176
diff
changeset
|
487 mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_DVD_TITLE_%d_LENGTH=%d.%03d\n", title, t / 1000, t % 1000); |
25167 | 488 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "TITLE %u, CHAPTERS: ", title); |
25165 | 489 for(i=0; i<n; i++) { |
490 t = parts[i] / 90000; | |
491 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "%02d:%02d:%02d,", t/3600, (t/60)%60, t%60); | |
492 } | |
493 free(parts); | |
494 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "\n"); | |
495 } | |
496 } | |
497 | |
25176
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
498 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
|
499 { |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
500 uint32_t titles=0, i; |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
501 if(p->track <= 0) { |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
502 dvdnav_get_number_of_titles(priv->dvdnav, &titles); |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
503 for(i=0; i<titles; i++) |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
504 identify_chapters(priv->dvdnav, i); |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
505 } |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
506 else |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
507 identify_chapters(priv->dvdnav, p->track); |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
508 } |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
509 |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
510 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
|
511 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
512 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
|
513 uint16_t i, lang, format, id, channels; |
25820
b43eaaa94dd3
array was defined for 6 elements while 7 were declared
ben
parents:
25819
diff
changeset
|
514 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
|
515 char tmp[3]; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
516 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
|
517 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
518 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
|
519 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
|
520 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
|
521 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
|
522 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
|
523 else |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
524 channels--; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
525 lang = dvdnav_audio_stream_to_lang(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(lang == 0xFFFF) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
527 tmp[0] = tmp[1] = '?'; |
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 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
530 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
|
531 tmp[1] = lang & 0xFF; |
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[2] = 0; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
534 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
|
535 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
|
536 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
|
537 id = i + base[format]; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
538 mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDaudioStreamInfo, i, |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
539 dvd_audio_stream_types[format], dvd_audio_stream_channels[channels], tmp, id); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
540 } |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
541 |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
542 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
|
543 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
544 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
|
545 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
|
546 lang = dvdnav_spu_stream_to_lang(nav, lg); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
547 if(lang == 0xFFFF) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
548 tmp[0] = tmp[1] = '?'; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
549 else |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
550 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
551 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
|
552 tmp[1] = lang & 0xFF; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
553 } |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
554 tmp[2] = 0; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
555 mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDsubtitleLanguage, i+0x20, tmp); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
556 } |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
557 } |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
558 |
19302 | 559 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { |
560 struct stream_priv_s* p = (struct stream_priv_s*)opts; | |
561 char *filename; | |
20809 | 562 dvdnav_priv_t *priv; |
19302 | 563 |
564 if(p->device) filename = p->device; | |
565 else if(dvd_device) filename= dvd_device; | |
566 else filename = DEFAULT_DVD_DEVICE; | |
20809 | 567 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
|
568 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename, strerror(errno)); |
24257 | 569 return STREAM_UNSUPPORTED; |
19302 | 570 } |
571 | |
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
|
572 if(p->track > 0) { |
20809 | 573 priv->title = p->track; |
574 if(dvdnav_title_play(priv->dvdnav, p->track) != DVDNAV_STATUS_OK) { | |
575 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 | 576 return STREAM_UNSUPPORTED; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
577 } |
25824 | 578 } else if (p->track == 0) { |
579 if(dvdnav_menu_call(priv->dvdnav, DVD_MENU_Root) != DVDNAV_STATUS_OK) | |
580 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
|
581 } |
25176
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
582 if(mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
583 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
|
584 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
|
585 show_audio_subs_languages(priv->dvdnav); |
20754 | 586 if(dvd_angle > 1) |
20809 | 587 dvdnav_angle_change(priv->dvdnav, dvd_angle); |
19302 | 588 |
589 stream->sector_size = 2048; | |
590 stream->flags = STREAM_READ | STREAM_SEEK; | |
591 stream->fill_buffer = fill_buffer; | |
592 stream->seek = seek; | |
19443 | 593 stream->control = control; |
19302 | 594 stream->close = stream_dvdnav_close; |
595 stream->type = STREAMTYPE_DVDNAV; | |
20809 | 596 stream->priv=(void*)priv; |
19302 | 597 *file_format = DEMUXER_TYPE_MPEG_PS; |
598 | |
599 update_title_len(stream); | |
25824 | 600 if(!stream->pos && p->track > 0) |
24109 | 601 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
|
602 |
20406 | 603 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 | 604 |
605 return STREAM_OK; | |
606 } | |
607 | |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
608 |
25824 | 609 void mp_dvdnav_handle_input(stream_t *stream, int cmd, int *button) { |
25829 | 610 dvdnav_priv_t * priv = stream->priv; |
20809 | 611 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
|
612 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
|
613 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
|
614 |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
615 if(cmd != MP_CMD_DVDNAV_SELECT && !pci) |
25824 | 616 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
|
617 |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
618 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
|
619 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
|
620 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
|
621 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
622 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
|
623 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
|
624 break; |
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_LEFT: |
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_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
|
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_RIGHT: |
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_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
|
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_MENU: |
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_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
|
633 break; |
19777
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
634 case MP_CMD_DVDNAV_PREVMENU: { |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
635 int title=0, part=0; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
636 |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
637 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
|
638 if(title) { |
25824 | 639 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
|
640 break; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
641 } |
25824 | 642 if((status=dvdnav_menu_call(nav, DVD_MENU_Title)) == DVDNAV_STATUS_OK) |
643 break; | |
644 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
|
645 } |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
646 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
|
647 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
|
648 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
|
649 break; |
19912
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
650 case MP_CMD_DVDNAV_MOUSECLICK: |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
651 /* |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
652 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
|
653 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
|
654 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
|
655 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
|
656 This last call always works well |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
657 */ |
20809 | 658 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
|
659 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
|
660 default: |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
661 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
|
662 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
663 } |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
664 |
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
|
665 if(status == DVDNAV_STATUS_OK) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
666 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
|
667 } |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
668 |
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
|
669 void mp_dvdnav_update_mouse_pos(stream_t *stream, int32_t x, int32_t y, int* button) { |
25829 | 670 dvdnav_priv_t * priv = stream->priv; |
20809 | 671 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
|
672 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
|
673 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
|
674 |
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 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
|
676 |
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
|
677 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
|
678 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
|
679 else *button = -1; |
20809 | 680 priv->mousex = x; |
681 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
|
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 |
26990 | 684 static int mp_dvdnav_get_aid_from_format (stream_t *stream, int index, uint8_t lg) { |
685 dvdnav_priv_t * priv = stream->priv; | |
686 uint8_t format; | |
687 | |
688 format = dvdnav_audio_stream_format(priv->dvdnav, lg); | |
689 switch(format) { | |
690 case DVDNAV_FORMAT_AC3: | |
691 return (index + 128); | |
692 case DVDNAV_FORMAT_DTS: | |
693 return (index + 136); | |
694 case DVDNAV_FORMAT_LPCM: | |
695 return (index + 160); | |
696 case DVDNAV_FORMAT_MPEGAUDIO: | |
697 return index; | |
698 default: | |
699 return -1; | |
700 } | |
701 | |
702 return -1; | |
703 } | |
704 | |
21424
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
705 /** |
26989
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
706 * \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
|
707 * \param stream: - stream pointer |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
708 * \param audio_num: - logical number |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
709 * \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
|
710 */ |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
711 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
|
712 dvdnav_priv_t * priv = stream->priv; |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
713 int k; |
26990 | 714 uint8_t lg; |
26989
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
715 |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
716 for(k=0; k<32; k++) { |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
717 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
|
718 if (lg == 0xff) continue; |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
719 if (lg != audio_num) continue; |
26990 | 720 |
721 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
|
722 } |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
723 return -1; |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
724 } |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
725 |
1c6b9d0c63aa
Add routine that provides audio ID corresponding to logical number
ben
parents:
26986
diff
changeset
|
726 /** |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
727 * \brief mp_dvdnav_aid_from_lang() returns the audio id corresponding to the language code 'lang' |
21600 | 728 * \param stream: - stream pointer |
729 * \param lang: 2-characters language code[s], eventually separated by spaces of commas | |
730 * \return -1 on error, current subtitle id if successful | |
731 */ | |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
732 int mp_dvdnav_aid_from_lang(stream_t *stream, unsigned char *language) { |
25829 | 733 dvdnav_priv_t * priv = stream->priv; |
21600 | 734 int k; |
26990 | 735 uint8_t lg; |
21600 | 736 uint16_t lang, lcode;; |
737 | |
738 while(language && strlen(language)>=2) { | |
739 lcode = (language[0] << 8) | (language[1]); | |
740 for(k=0; k<32; k++) { | |
741 lg = dvdnav_get_audio_logical_stream(priv->dvdnav, k); | |
742 if(lg == 0xff) continue; | |
743 lang = dvdnav_audio_stream_to_lang(priv->dvdnav, lg); | |
26990 | 744 if(lang != 0xFFFF && lang == lcode) |
745 return mp_dvdnav_get_aid_from_format (stream, k, lg); | |
21600 | 746 } |
747 language += 2; | |
748 while(language[0]==',' || language[0]==' ') ++language; | |
749 } | |
750 return -1; | |
751 } | |
752 | |
21603
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
753 /** |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
754 * \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
|
755 * \param stream: - stream pointer |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
756 * \param sid: physical subtitle id |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
757 * \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
|
758 * \return 0 on error, 1 if successful |
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 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
|
761 uint8_t lg; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
762 uint16_t lang; |
25829 | 763 dvdnav_priv_t * priv = stream->priv; |
21603
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
764 |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
765 if(aid < 0) |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
766 return 0; |
21613
8547ae79e74b
simplified aid management in dvdnav_lang_from_aid(); patch by Joakim Patte
nicodvb
parents:
21603
diff
changeset
|
767 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
|
768 if(lg == 0xff) return 0; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
769 lang = dvdnav_audio_stream_to_lang(priv->dvdnav, lg); |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
770 if(lang == 0xffff) return 0; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
771 buf[0] = lang >> 8; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
772 buf[1] = lang & 0xFF; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
773 buf[2] = 0; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
774 return 1; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
775 } |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
776 |
21600 | 777 |
778 /** | |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
779 * \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
|
780 * \param stream: - stream pointer |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
781 * \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
|
782 * \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
|
783 */ |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
784 int mp_dvdnav_sid_from_lang(stream_t *stream, unsigned char *language) { |
25829 | 785 dvdnav_priv_t * priv = stream->priv; |
23990 | 786 uint8_t lg, k; |
21204
1ddb1a86e419
support for comma-separated language codes in -slang
nicodvb
parents:
21200
diff
changeset
|
787 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
|
788 |
21204
1ddb1a86e419
support for comma-separated language codes in -slang
nicodvb
parents:
21200
diff
changeset
|
789 while(language && strlen(language)>=2) { |
21333 | 790 lcode = (language[0] << 8) | (language[1]); |
791 for(k=0; k<32; k++) { | |
792 lg = dvdnav_get_spu_logical_stream(priv->dvdnav, k); | |
793 if(lg == 0xff) continue; | |
794 lang = dvdnav_spu_stream_to_lang(priv->dvdnav, lg); | |
795 if(lang != 0xFFFF && lang == lcode) { | |
796 return k; | |
797 } | |
21197
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
798 } |
21333 | 799 language += 2; |
800 while(language[0]==',' || language[0]==' ') ++language; | |
21204
1ddb1a86e419
support for comma-separated language codes in -slang
nicodvb
parents:
21200
diff
changeset
|
801 } |
21197
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
802 return -1; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
803 } |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
804 |
21424
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
805 /** |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
806 * \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
|
807 * \param stream: - stream pointer |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
808 * \param sid: physical subtitle id |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
809 * \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
|
810 * \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
|
811 */ |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
812 int mp_dvdnav_lang_from_sid(stream_t *stream, int sid, unsigned char *buf) { |
23990 | 813 uint8_t lg; |
21560
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
814 uint16_t lang; |
25829 | 815 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
|
816 if(sid < 0) return 0; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
817 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
|
818 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
|
819 if(lang == 0xffff) return 0; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
820 buf[0] = lang >> 8; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
821 buf[1] = lang & 0xFF; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
822 buf[2] = 0; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
823 return 1; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
824 } |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
825 |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
826 /** |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
827 * \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
|
828 * \param stream: - stream pointer |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
829 * \return 0 on error, something meaningful otherwise |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
830 */ |
26986
4bee4b9ec054
Rename some functions as they are mplayer related and not
ben
parents:
26985
diff
changeset
|
831 int mp_dvdnav_number_of_subs(stream_t *stream) { |
25829 | 832 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
|
833 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
|
834 |
25824 | 835 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
|
836 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
|
837 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
|
838 if(lg == 0xff) continue; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
839 n++; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
840 } |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
841 return n; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
842 } |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
843 |
23902 | 844 /** |
845 * \brief mp_dvdnav_get_spu_clut() returns the spu clut | |
846 * \param stream: - stream pointer | |
847 * \return spu clut pointer | |
848 */ | |
21538
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
849 unsigned int *mp_dvdnav_get_spu_clut(stream_t *stream) { |
25829 | 850 dvdnav_priv_t *priv = stream->priv; |
25828 | 851 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
|
852 } |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
853 |
23902 | 854 /** |
855 * \brief mp_dvdnav_get_highlight() get dvdnav highlight struct | |
856 * \param stream: - stream pointer | |
857 * \param hl : - highlight struct pointer | |
858 */ | |
21219 | 859 void mp_dvdnav_get_highlight (stream_t *stream, nav_highlight_t *hl) { |
25829 | 860 dvdnav_priv_t *priv = stream->priv; |
21219 | 861 dvdnav_highlight_event_t hlev = priv->hlev; |
862 | |
863 hl->sx = hlev.sx; | |
864 hl->sy = hlev.sy; | |
865 hl->ex = hlev.ex; | |
866 hl->ey = hlev.ey; | |
26973 | 867 hl->palette = hlev.palette; |
21200 | 868 } |
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
|
869 |
25817 | 870 void mp_dvdnav_switch_title (stream_t *stream, int title) { |
25829 | 871 dvdnav_priv_t *priv = stream->priv; |
25817 | 872 uint32_t titles; |
873 | |
874 dvdnav_get_number_of_titles (priv->dvdnav, &titles); | |
875 if (title > 0 && title <= titles) | |
876 dvdnav_title_play (priv->dvdnav, title); | |
877 } | |
878 | |
25824 | 879 /** |
880 * \brief Check if end of stream has been reached | |
881 * \param stream: - stream pointer | |
882 * \return 1 on really eof | |
883 */ | |
884 int mp_dvdnav_is_eof (stream_t *stream) { | |
885 return ((dvdnav_priv_t *) stream->priv)->state & NAV_FLAG_EOF; | |
886 } | |
887 | |
888 /** | |
889 * \brief Skip still frame | |
890 * \param stream: - stream pointer | |
891 * \return 0 on success | |
892 */ | |
893 int mp_dvdnav_skip_still (stream_t *stream) { | |
894 dvdnav_priv_t *priv = stream->priv; | |
895 if (priv->still_length == 0xff) | |
896 return 1; | |
897 dvdnav_still_skip(priv->dvdnav); | |
898 return 0; | |
899 } | |
900 | |
901 /** | |
902 * \brief Skip wait event | |
903 * \param stream: - stream pointer | |
904 * \return 0 on success | |
905 */ | |
906 int mp_dvdnav_skip_wait (stream_t *stream) { | |
907 dvdnav_priv_t *priv = stream->priv; | |
908 if (!(priv->state & NAV_FLAG_WAIT)) | |
909 return 1; | |
910 priv->state &= ~NAV_FLAG_WAIT; | |
911 dvdnav_wait_skip(priv->dvdnav); | |
912 return 0; | |
913 } | |
914 | |
915 /** | |
916 * \brief Set wait mode | |
917 * \param stream : - stream pointer | |
918 * \param mode : - if true, then suspend block read | |
919 * \param automode: - if true, then VTS or cell change set wait mode | |
920 */ | |
921 void mp_dvdnav_read_wait (stream_t *stream, int mode, int automode) { | |
922 dvdnav_priv_t *priv = stream->priv; | |
923 if (mode == 0) | |
924 priv->state &= ~NAV_FLAG_WAIT_READ; | |
925 if (mode > 0) | |
926 priv->state |= NAV_FLAG_WAIT_READ; | |
927 if (automode == 0) | |
928 priv->state &= ~NAV_FLAG_WAIT_READ_AUTO; | |
929 if (automode > 0) | |
930 priv->state |= NAV_FLAG_WAIT_READ_AUTO; | |
931 } | |
932 | |
933 /** | |
934 * \brief Check if cell has changed | |
935 * \param stream: - stream pointer | |
936 * \param clear : - if true, then clear cell change flag | |
937 * \return 1 if cell has changed | |
938 */ | |
939 int mp_dvdnav_cell_has_changed (stream_t *stream, int clear) { | |
940 dvdnav_priv_t *priv = stream->priv; | |
26985 | 941 if (!(priv->state & NAV_FLAG_CELL_CHANGE)) |
25824 | 942 return 0; |
25832 | 943 if (clear) { |
26985 | 944 priv->state &= ~NAV_FLAG_CELL_CHANGE; |
25832 | 945 priv->state |= NAV_FLAG_STREAM_CHANGE; |
946 } | |
25824 | 947 return 1; |
948 } | |
949 | |
26983
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
950 /** |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
951 * \brief Check if audio has changed |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
952 * \param stream: - stream pointer |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
953 * \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
|
954 * \return 1 if audio has changed |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
955 */ |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
956 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
|
957 dvdnav_priv_t *priv = stream->priv; |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
958 |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
959 if (!(priv->state & NAV_FLAG_AUDIO_CHANGE)) |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
960 return 0; |
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 if (clear) |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
963 priv->state &= ~NAV_FLAG_AUDIO_CHANGE; |
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 return 1; |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
966 } |
a9626d7ae755
Add routine to determine if audio has changed in dvdnav stream.
ben
parents:
26973
diff
changeset
|
967 |
26984
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
968 /** |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
969 * \brief Check if SPU has changed |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
970 * \param stream: - stream pointer |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
971 * \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
|
972 * \return 1 if spu has changed |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
973 */ |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
974 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
|
975 dvdnav_priv_t *priv = stream->priv; |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
976 |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
977 if (!(priv->state & NAV_FLAG_SPU_CHANGE)) |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
978 return 0; |
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 if (clear) |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
981 priv->state &= ~NAV_FLAG_SPU_CHANGE; |
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 return 1; |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
984 } |
540400f89398
Add routine to determine if SPU has changed in dvdnav stream.
ben
parents:
26983
diff
changeset
|
985 |
25830 | 986 /* Notify if something has changed in stream |
987 * Can be related to title, chapter, audio or SPU | |
988 */ | |
989 int mp_dvdnav_stream_has_changed (stream_t *stream) { | |
990 dvdnav_priv_t *priv = stream->priv; | |
991 | |
992 if (!(priv->state & NAV_FLAG_STREAM_CHANGE)) | |
993 return 0; | |
994 | |
995 priv->state &= ~NAV_FLAG_STREAM_CHANGE; | |
996 return 1; | |
997 } | |
25824 | 998 |
25211 | 999 const stream_info_t stream_info_dvdnav = { |
19302 | 1000 "DVDNAV stream", |
1001 "null", | |
1002 "", | |
1003 "", | |
1004 open_s, | |
1005 { "dvdnav", NULL }, | |
1006 &stream_opts, | |
1007 1 // Urls are an option string | |
1008 }; |