Mercurial > mplayer.hg
annotate stream/stream_dvdnav.c @ 19892:2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
(len > 0), or dvdnav may crash or complain.
author | nicodvb |
---|---|
date | Mon, 18 Sep 2006 21:12:22 +0000 |
parents | adfd08588514 |
children | 9440915a76f1 |
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> | |
7 #include "mp_msg.h" | |
8 #include "osdep/timer.h" | |
9 #include "input/input.h" | |
10 #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
|
11 #include "libmpdemux/demuxer.h" |
19302 | 12 #include "stream_dvdnav.h" |
13 #include "libvo/video_out.h" | |
14 #include "spudec.h" | |
15 #include "m_option.h" | |
16 #include "m_struct.h" | |
17 #include "help_mp.h" | |
18 | |
19 extern char *dvd_device; | |
20 extern char *audio_lang, *dvdsub_lang; | |
21 | |
22 static struct stream_priv_s { | |
23 int track; | |
24 char* device; | |
25 } 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
|
26 0, |
19302 | 27 NULL |
28 }; | |
29 | |
30 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f) | |
31 /// URL definition | |
32 static m_option_t stream_opts_fields[] = { | |
33 {"filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
34 {"hostname", ST_OFF(track), CONF_TYPE_INT, 0, 0, 0, NULL}, | |
35 { NULL, NULL, 0, 0, 0, 0, NULL } | |
36 }; | |
37 static struct m_struct_st stream_opts = { | |
38 "dvd", | |
39 sizeof(struct stream_priv_s), | |
40 &stream_priv_dflts, | |
41 stream_opts_fields | |
42 }; | |
43 | |
44 int dvd_nav_skip_opening=0; /* skip opening stalls? */ | |
45 int osd_show_dvd_nav_delay=0; /* count down for dvd nav text on OSD */ | |
46 char dvd_nav_text[50]; /* for reporting stuff to OSD */ | |
47 int osd_show_dvd_nav_highlight; /* show highlight area */ | |
48 int osd_show_dvd_nav_sx; /* start x .... */ | |
49 int osd_show_dvd_nav_ex; | |
50 int osd_show_dvd_nav_sy; | |
51 int osd_show_dvd_nav_ey; | |
52 int dvd_nav_still=0; /* are we on a still picture? */ | |
53 | |
19892
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
54 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
|
55 |
19302 | 56 dvdnav_priv_t * new_dvdnav_stream(char * filename) { |
57 char * title_str; | |
58 dvdnav_priv_t *dvdnav_priv; | |
59 | |
60 if (!filename) | |
61 return NULL; | |
62 | |
63 if (!(dvdnav_priv=calloc(1,sizeof(*dvdnav_priv)))) | |
64 return NULL; | |
65 | |
66 if (!(dvdnav_priv->filename=strdup(filename))) { | |
67 free(dvdnav_priv); | |
68 return NULL; | |
69 } | |
70 | |
71 if(dvdnav_open(&(dvdnav_priv->dvdnav),dvdnav_priv->filename)!=DVDNAV_STATUS_OK) | |
72 { | |
73 free(dvdnav_priv->filename); | |
74 free(dvdnav_priv); | |
75 return NULL; | |
76 } | |
77 | |
78 if (!dvdnav_priv->dvdnav) { | |
79 free(dvdnav_priv); | |
80 return NULL; | |
81 } | |
82 | |
83 if(1) //from vlc: if not used dvdnav from cvs will fail | |
84 { | |
85 int len, event; | |
86 char buf[2048]; | |
87 | |
88 dvdnav_get_next_block(dvdnav_priv->dvdnav,buf,&event,&len); | |
19781
61cc28c4236a
at start, reset dvdnav at the beginning of the stream after the first read (that is done to workaround a bug in dvdnav from cvs)
nicodvb
parents:
19780
diff
changeset
|
89 dvdnav_sector_search(dvdnav_priv->dvdnav, 0, SEEK_SET); |
19302 | 90 } |
91 | |
19454 | 92 /* turn off dvdnav caching */ |
19302 | 93 dvdnav_set_readahead_flag(dvdnav_priv->dvdnav, 0); |
94 if(dvdnav_set_PGC_positioning_flag(dvdnav_priv->dvdnav, 1) != DVDNAV_STATUS_OK) | |
95 mp_msg(MSGT_OPEN,MSGL_ERR,"stream_dvdnav, failed to set PGC positioning\n"); | |
96 #if 1 | |
97 /* report the title?! */ | |
98 if (dvdnav_get_title_string(dvdnav_priv->dvdnav,&title_str)==DVDNAV_STATUS_OK) { | |
99 mp_msg(MSGT_IDENTIFY, MSGL_INFO,"Title: '%s'\n",title_str); | |
100 } | |
101 #endif | |
102 | |
103 //dvdnav_event_clear(dvdnav_priv); | |
104 | |
105 return dvdnav_priv; | |
106 } | |
107 | |
108 int dvdnav_stream_reset(dvdnav_priv_t * dvdnav_priv) { | |
109 if (!dvdnav_priv) return 0; | |
110 | |
111 // if (dvdnav_reset(dvdnav_priv->dvdnav)!=DVDNAV_STATUS_OK) | |
112 return 0; | |
113 | |
114 dvdnav_priv->started=0; | |
115 | |
116 return 1; | |
117 } | |
118 | |
119 int dvdnav_stream_sleeping(dvdnav_priv_t * dvdnav_priv) { | |
120 unsigned int now; | |
121 | |
122 if (!dvdnav_priv) return 0; | |
123 | |
124 if(dvdnav_priv->sleeping) | |
125 { | |
126 now=GetTimer(); | |
127 while(dvdnav_priv->sleeping>1 || now<dvdnav_priv->sleep_until) { | |
128 // printf("%s %u<%u\n",__FUNCTION__,now,dvdnav_priv->sleep_until); | |
129 // usec_sleep(1000); /* 1ms granularity */ | |
130 return 1; | |
131 } | |
132 dvdnav_still_skip(dvdnav_priv->dvdnav); // continue past... | |
133 dvdnav_priv->sleeping=0; | |
134 mp_msg(MSGT_OPEN,MSGL_V, "%s: woke up!\n",__FUNCTION__); | |
135 } | |
136 dvd_nav_still=0; | |
137 mp_msg(MSGT_OPEN,MSGL_V, "%s: active\n",__FUNCTION__); | |
138 return 0; | |
139 } | |
140 | |
141 void dvdnav_stream_sleep(dvdnav_priv_t * dvdnav_priv, int seconds) { | |
142 if (!dvdnav_priv) return; | |
143 | |
144 if (!dvdnav_priv->started) return; | |
145 | |
146 dvdnav_priv->sleeping=0; | |
147 switch (seconds) { | |
148 case 0: | |
149 return; | |
150 case 0xff: | |
151 mp_msg(MSGT_OPEN,MSGL_V, "Sleeping indefinately\n" ); | |
152 dvdnav_priv->sleeping=2; | |
153 break; | |
154 default: | |
155 mp_msg(MSGT_OPEN,MSGL_V, "Sleeping %d sec(s)\n", seconds ); | |
156 dvdnav_priv->sleep_until = GetTimer();// + seconds*1000000; | |
157 dvdnav_priv->sleeping=1; | |
158 break; | |
159 } | |
160 //if (dvdnav_priv->started) dvd_nav_still=1; | |
161 } | |
162 | |
163 void dvdnav_stream_add_event(dvdnav_priv_t* dvdnav_priv, int event, unsigned char *buf, int len) { | |
164 //printf("%s: %d\n",__FUNCTION__,event); | |
165 | |
166 dvdnav_event_t * dvdnav_event; | |
167 | |
168 if (!dvdnav_priv->started) return; | |
169 | |
170 if (!(dvdnav_event=calloc(1,sizeof(*dvdnav_event)))) { | |
171 mp_msg(MSGT_OPEN,MSGL_V, "%s: dvdnav_event: out of memory!\n",__FUNCTION__); | |
172 return; | |
173 } | |
174 dvdnav_event->event=event; | |
175 dvdnav_event->details=calloc(1,len); | |
176 memcpy(dvdnav_event->details,buf,len); | |
177 dvdnav_event->len=len; | |
178 } | |
179 | |
180 int dvdnav_stream_read(dvdnav_priv_t * dvdnav_priv, unsigned char *buf, int *len) { | |
181 int event = DVDNAV_NOP; | |
182 | |
183 if (!len) return -1; | |
184 *len=-1; | |
185 if (!dvdnav_priv) return -1; | |
186 if (!buf) return -1; | |
187 | |
188 if (dvd_nav_still) { | |
189 mp_msg(MSGT_OPEN,MSGL_V, "%s: got a stream_read while I should be asleep!\n",__FUNCTION__); | |
190 *len=0; | |
191 return -1; | |
192 } | |
193 | |
194 if (dvdnav_get_next_block(dvdnav_priv->dvdnav,buf,&event,len)!=DVDNAV_STATUS_OK) { | |
195 mp_msg(MSGT_OPEN,MSGL_V, "Error getting next block from DVD %d (%s)\n",event, dvdnav_err_to_string(dvdnav_priv->dvdnav) ); | |
196 *len=-1; | |
197 } | |
198 else if (event!=DVDNAV_BLOCK_OK) { | |
199 | |
200 // need to handle certain events internally (like skipping stills) | |
201 switch (event) { | |
202 case DVDNAV_STILL_FRAME: { | |
203 dvdnav_still_event_t *still_event = (dvdnav_still_event_t*)(buf); | |
204 //if (dvdnav_priv->started) dvd_nav_still=1; | |
205 //else | |
206 dvdnav_still_skip(dvdnav_priv->dvdnav); // don't let dvdnav stall on this image | |
207 | |
208 break; | |
19451 | 209 } |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
210 case DVDNAV_CELL_CHANGE: { |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
211 dvdnav_cell_change_event_t *ev = (dvdnav_cell_change_event_t*)buf; |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
212 if(ev->pgc_length) |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
213 dvdnav_priv->duration = ev->pgc_length/90; |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
214 break; |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
215 } |
19302 | 216 case DVDNAV_WAIT: |
217 dvdnav_wait_skip(dvdnav_priv->dvdnav); | |
218 break; | |
219 } | |
220 | |
221 // got an event, repeat the read | |
222 dvdnav_stream_add_event(dvdnav_priv,event,buf,*len); | |
223 *len=0; | |
224 } | |
225 // printf("%s: got %d\n",__FUNCTION__,*len); | |
226 return event; | |
227 } | |
228 | |
229 void dvdnav_stream_fullstart(dvdnav_priv_t * dvdnav_priv) { | |
230 if (dvdnav_priv && !dvdnav_priv->started) { | |
19839
5b78f1c14256
dvdnav_stream_reset() should be called on dvdnav_priv->dvdnav not on dvdnav_priv; patch by Jonas Jermann
nicodvb
parents:
19838
diff
changeset
|
231 dvdnav_stream_reset(dvdnav_priv->dvdnav); |
19302 | 232 dvdnav_priv->started=1; |
233 } | |
234 } | |
235 | |
236 unsigned int * dvdnav_stream_get_palette(dvdnav_priv_t * dvdnav_priv) { | |
237 if (!dvdnav_priv) { | |
238 mp_msg(MSGT_OPEN,MSGL_V, "%s: NULL dvdnav_priv\n",__FUNCTION__); | |
239 return NULL; | |
240 } | |
241 if (!dvdnav_priv->dvdnav) { | |
242 mp_msg(MSGT_OPEN,MSGL_V, "%s: NULL dvdnav_priv->dvdnav\n",__FUNCTION__); | |
243 return NULL; | |
244 } | |
245 } | |
246 | |
247 static void update_title_len(stream_t *stream) { | |
248 dvdnav_priv_t *priv = stream->priv; | |
249 dvdnav_status_t status; | |
250 uint32_t pos = 0, len = 0; | |
251 | |
252 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
|
253 if(status == DVDNAV_STATUS_OK && len) { |
19302 | 254 stream->end_pos = (off_t) len * 2048; |
19892
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
255 stream->seek = seek; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
256 } else { |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
257 stream->seek = NULL; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
258 stream->end_pos = 0; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
259 } |
19302 | 260 } |
261 | |
262 | |
263 static int seek(stream_t *s, off_t newpos) { | |
264 uint32_t pos = 0, len = 0, sector = 0; | |
265 dvdnav_priv_t *priv = s->priv; | |
266 | |
267 if(newpos==0) { | |
268 if(dvdnav_stream_reset(priv->dvdnav)) | |
269 s->pos=0; | |
270 } | |
271 else { | |
272 if(s->end_pos && newpos > s->end_pos) | |
273 newpos = s->end_pos; | |
274 sector = newpos / 2048ULL; | |
275 if(dvdnav_sector_search(priv->dvdnav, (uint64_t) sector, SEEK_SET) != DVDNAV_STATUS_OK) | |
276 goto fail; | |
277 | |
278 s->pos = newpos; | |
279 } | |
280 | |
281 return 1; | |
282 | |
283 fail: | |
284 mp_msg(MSGT_STREAM,MSGL_INFO,"dvdnav_stream, seeking to %"PRIu64" failed: %s\n", newpos, dvdnav_err_to_string(priv->dvdnav)); | |
285 | |
286 return 1; | |
287 } | |
288 | |
289 static void stream_dvdnav_close(stream_t *s) { | |
290 dvdnav_priv_t *priv = s->priv; | |
291 dvdnav_close(priv->dvdnav); | |
292 priv->dvdnav = NULL; | |
293 free(priv); | |
294 } | |
295 | |
296 | |
297 static int fill_buffer(stream_t *s, char *but, int len) | |
298 { | |
299 int event; | |
300 dvdnav_priv_t* dvdnav_priv=s->priv; | |
301 len=0; | |
302 if(!s->end_pos) | |
303 update_title_len(s); | |
304 while(!len) /* grab all event until DVDNAV_BLOCK_OK (len=2048), DVDNAV_STOP or DVDNAV_STILL_FRAME */ | |
305 { | |
306 if(-1==(event=dvdnav_stream_read(dvdnav_priv, s->buffer, &len)) || len==-1) | |
307 { | |
308 mp_msg(MSGT_CPLAYER,MSGL_ERR, "DVDNAV stream read error!\n"); | |
309 return 0; | |
310 } | |
311 switch (event) { | |
312 case DVDNAV_STOP: return len; | |
313 case DVDNAV_BLOCK_OK: return len; | |
314 #if 0 | |
315 case DVDNAV_STILL_FRAME: { | |
316 if(!dvdnav_priv->stillok) dvdnav_priv->stillcounter++; | |
317 dvdnav_priv->lockstillcounter++; | |
318 return len; | |
319 break; | |
320 } | |
321 | |
322 case DVDNAV_WAIT: { | |
323 if(dvdnav_priv->waitcounter>=DVDNAV_MAX_WAIT_FRAME) return len; | |
324 break; | |
325 } | |
326 #endif | |
327 } | |
328 #if 0 | |
329 if(dvdnav_priv->event.cell_really_change && | |
330 dvdnav_priv->started && | |
331 !dvdnav_priv->vts_domain) | |
332 return len; | |
333 #endif | |
334 } | |
335 mp_msg(MSGT_STREAM,MSGL_DBG2,"DVDNAV fill_buffer len: %d\n",len); | |
336 return len; | |
337 } | |
338 | |
19443 | 339 static int control(stream_t *stream, int cmd, void* arg) { |
340 dvdnav_priv_t* dvdnav_priv=stream->priv; | |
341 int tit, part; | |
342 | |
343 switch(cmd) | |
344 { | |
345 case STREAM_CTRL_SEEK_TO_CHAPTER: | |
346 { | |
347 int chap = *((unsigned int *)arg)+1; | |
348 | |
349 if(chap < 1 || dvdnav_current_title_info(dvdnav_priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) | |
350 break; | |
351 if(dvdnav_part_play(dvdnav_priv->dvdnav, tit, chap) != DVDNAV_STATUS_OK) | |
352 break; | |
353 return 1; | |
354 } | |
19477 | 355 case STREAM_CTRL_GET_NUM_CHAPTERS: |
356 { | |
357 if(dvdnav_current_title_info(dvdnav_priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) | |
358 break; | |
359 if(dvdnav_get_number_of_parts(dvdnav_priv->dvdnav, tit, &part) != DVDNAV_STATUS_OK) | |
360 break; | |
361 if(!part) | |
362 break; | |
363 *((unsigned int *)arg) = part; | |
364 return 1; | |
365 } | |
19443 | 366 case STREAM_CTRL_GET_CURRENT_CHAPTER: |
367 { | |
368 if(dvdnav_current_title_info(dvdnav_priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) | |
369 break; | |
370 *((unsigned int *)arg) = part - 1; | |
371 return 1; | |
372 } | |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
373 case STREAM_CTRL_GET_TIME_LENGTH: |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
374 { |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
375 if(dvdnav_priv->duration) |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
376 { |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
377 *((unsigned int *)arg) = dvdnav_priv->duration; |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
378 return 1; |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
379 } |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
380 } |
19443 | 381 } |
382 | |
383 return STREAM_UNSUPORTED; | |
384 } | |
385 | |
19302 | 386 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { |
387 struct stream_priv_s* p = (struct stream_priv_s*)opts; | |
388 char *filename; | |
389 int event,len,tmplen=0; | |
390 uint32_t pos, l2; | |
391 dvdnav_priv_t *dvdnav_priv; | |
392 dvdnav_status_t status; | |
393 | |
394 //mp_msg(MSGT_OPEN,MSGL_INFO,"URL: %s\n", filename); | |
395 | |
396 if(p->device) filename = p->device; | |
397 else if(dvd_device) filename= dvd_device; | |
398 else filename = DEFAULT_DVD_DEVICE; | |
399 if(!(dvdnav_priv=new_dvdnav_stream(filename))) { | |
400 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename); | |
401 return STREAM_UNSUPORTED; | |
402 } | |
403 | |
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
|
404 if(p->track > 0) { |
19302 | 405 if(dvdnav_title_play(dvdnav_priv->dvdnav, p->track) != DVDNAV_STATUS_OK) { |
406 mp_msg(MSGT_OPEN,MSGL_FATAL,"dvdnav_stream, couldn't select title %d, error '%s'\n", p->track, dvdnav_err_to_string(dvdnav_priv->dvdnav)); | |
407 return STREAM_UNSUPORTED; | |
408 } | |
19780
49d6e27228bc
try to start from the root menu skipping all intros when playing dvdnav://-1; it's not guaranteed to work
nicodvb
parents:
19777
diff
changeset
|
409 } else if(p->track == -1) |
49d6e27228bc
try to start from the root menu skipping all intros when playing dvdnav://-1; it's not guaranteed to work
nicodvb
parents:
19777
diff
changeset
|
410 dvdnav_menu_call(dvdnav_priv->dvdnav, DVD_MENU_Root); |
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
|
411 else { |
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
|
412 mp_msg(MSGT_OPEN,MSGL_INFO,"dvdnav_stream, you didn't specify a track number (as in dvdnav://1), playing whole disc\n"); |
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
|
413 dvdnav_menu_call(dvdnav_priv->dvdnav, DVD_MENU_Title); |
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
|
414 } |
19302 | 415 |
416 stream->sector_size = 2048; | |
417 stream->flags = STREAM_READ | STREAM_SEEK; | |
418 stream->fill_buffer = fill_buffer; | |
419 stream->seek = seek; | |
19443 | 420 stream->control = control; |
19302 | 421 stream->close = stream_dvdnav_close; |
422 stream->type = STREAMTYPE_DVDNAV; | |
423 stream->priv=(void*)dvdnav_priv; | |
424 *file_format = DEMUXER_TYPE_MPEG_PS; | |
425 | |
426 update_title_len(stream); | |
427 if(!stream->pos) | |
428 mp_msg(MSGT_OPEN,MSGL_ERR, "INIT ERROR: %d, couldn't get init pos %s\r\n", status, dvdnav_err_to_string(dvdnav_priv->dvdnav)); | |
429 | |
430 return STREAM_OK; | |
431 } | |
432 | |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
433 |
19774
109e241c0cca
in mp_dvdnav_handle_input() assign the currently selected button, shown in the OSD by main()
nicodvb
parents:
19768
diff
changeset
|
434 int mp_dvdnav_handle_input(stream_t *stream, int cmd, int *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
|
435 dvdnav_priv_t * dvdnav_priv=(dvdnav_priv_t*)stream->priv; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
436 dvdnav_t *nav = dvdnav_priv->dvdnav; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
437 dvdnav_status_t status; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
438 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
|
439 int reset = 0; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
440 |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
441 if(cmd != MP_CMD_DVDNAV_SELECT && !pci) |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
442 return 0; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
443 |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
444 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
|
445 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
|
446 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
|
447 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
448 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
|
449 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
|
450 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
451 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
|
452 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
|
453 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
454 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
|
455 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
|
456 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
457 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
|
458 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
|
459 reset = 1; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
460 break; |
19777
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
461 case MP_CMD_DVDNAV_PREVMENU: { |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
462 int title=0, part=0; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
463 |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
464 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
|
465 if(title) { |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
466 if(dvdnav_menu_call(nav, DVD_MENU_Part) == DVDNAV_STATUS_OK |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
467 || dvdnav_menu_call(nav, DVD_MENU_Title) == DVDNAV_STATUS_OK) { |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
468 reset = 1; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
469 break; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
470 } |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
471 } |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
472 if(dvdnav_menu_call(nav, DVD_MENU_Root) == DVDNAV_STATUS_OK) |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
473 reset = 1; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
474 } |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
475 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
|
476 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
|
477 status = dvdnav_button_activate(nav, pci); |
19836
9470f7630ee4
when cmd == MP_CMD_DVDNAV_SELECT set reset=1 only if dvdnav_button_activate() succeeds, to avoid unneeded resets in main()
nicodvb
parents:
19781
diff
changeset
|
478 if(status == DVDNAV_STATUS_OK) reset = 1; |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
479 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
480 default: |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
481 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
|
482 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
483 } |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
484 |
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
|
485 if(status == DVDNAV_STATUS_OK) |
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
|
486 dvdnav_get_current_highlight(nav, button); |
19774
109e241c0cca
in mp_dvdnav_handle_input() assign the currently selected button, shown in the OSD by main()
nicodvb
parents:
19768
diff
changeset
|
487 |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
488 return reset; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
489 } |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
490 |
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
|
491 void mp_dvdnav_update_mouse_pos(stream_t *stream, int32_t x, int32_t y, int* 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
|
492 dvdnav_priv_t * dvdnav_priv=(dvdnav_priv_t*)stream->priv; |
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
|
493 dvdnav_t *nav = dvdnav_priv->dvdnav; |
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
|
494 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
|
495 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
|
496 |
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
|
497 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
|
498 |
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
|
499 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
|
500 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
|
501 else *button = -1; |
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
|
502 } |
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
|
503 |
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
|
504 |
19302 | 505 stream_info_t stream_info_dvdnav = { |
506 "DVDNAV stream", | |
507 "null", | |
508 "", | |
509 "", | |
510 open_s, | |
511 { "dvdnav", NULL }, | |
512 &stream_opts, | |
513 1 // Urls are an option string | |
514 }; |