Mercurial > mplayer.hg
annotate stream/stream_dvdnav.c @ 20959:85092872c65f
some updates
author | diego |
---|---|
date | Fri, 17 Nov 2006 07:27:20 +0000 |
parents | 6602a90a06ec |
children | a067e7e18b50 |
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; | |
20409
8cd1b72aa488
support for -chapter option (same semanthics as for dvd://)
nicodvb
parents:
20407
diff
changeset
|
20 extern int dvd_chapter; |
8cd1b72aa488
support for -chapter option (same semanthics as for dvd://)
nicodvb
parents:
20407
diff
changeset
|
21 extern int dvd_last_chapter; |
20754 | 22 extern int dvd_angle; |
19302 | 23 extern char *audio_lang, *dvdsub_lang; |
24 | |
25 static struct stream_priv_s { | |
26 int track; | |
27 char* device; | |
28 } 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
|
29 0, |
19302 | 30 NULL |
31 }; | |
32 | |
33 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f) | |
34 /// URL definition | |
35 static m_option_t stream_opts_fields[] = { | |
36 {"filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
37 {"hostname", ST_OFF(track), CONF_TYPE_INT, 0, 0, 0, NULL}, | |
38 { NULL, NULL, 0, 0, 0, 0, NULL } | |
39 }; | |
40 static struct m_struct_st stream_opts = { | |
41 "dvd", | |
42 sizeof(struct stream_priv_s), | |
43 &stream_priv_dflts, | |
44 stream_opts_fields | |
45 }; | |
46 | |
47 int dvd_nav_skip_opening=0; /* skip opening stalls? */ | |
48 int osd_show_dvd_nav_delay=0; /* count down for dvd nav text on OSD */ | |
49 char dvd_nav_text[50]; /* for reporting stuff to OSD */ | |
50 int osd_show_dvd_nav_highlight; /* show highlight area */ | |
51 int osd_show_dvd_nav_sx; /* start x .... */ | |
52 int osd_show_dvd_nav_ex; | |
53 int osd_show_dvd_nav_sy; | |
54 int osd_show_dvd_nav_ey; | |
55 int dvd_nav_still=0; /* are we on a still picture? */ | |
56 | |
19892
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
57 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
|
58 |
19914
dfd1bb3fc7c0
made file-static new_dvdnav_stream() and dvdnav_stream_read()
nicodvb
parents:
19912
diff
changeset
|
59 static dvdnav_priv_t * new_dvdnav_stream(char * filename) { |
19302 | 60 char * title_str; |
20809 | 61 dvdnav_priv_t *priv; |
19302 | 62 |
63 if (!filename) | |
64 return NULL; | |
65 | |
20809 | 66 if (!(priv=calloc(1,sizeof(dvdnav_priv_t)))) |
19302 | 67 return NULL; |
68 | |
20809 | 69 if (!(priv->filename=strdup(filename))) { |
70 free(priv); | |
19302 | 71 return NULL; |
72 } | |
73 | |
20809 | 74 if(dvdnav_open(&(priv->dvdnav),priv->filename)!=DVDNAV_STATUS_OK) |
19302 | 75 { |
20809 | 76 free(priv->filename); |
77 free(priv); | |
19302 | 78 return NULL; |
79 } | |
80 | |
20809 | 81 if (!priv->dvdnav) { |
82 free(priv); | |
19302 | 83 return NULL; |
84 } | |
85 | |
86 if(1) //from vlc: if not used dvdnav from cvs will fail | |
87 { | |
88 int len, event; | |
89 char buf[2048]; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
90 |
20809 | 91 dvdnav_get_next_block(priv->dvdnav,buf,&event,&len); |
92 dvdnav_sector_search(priv->dvdnav, 0, SEEK_SET); | |
19302 | 93 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
94 |
19454 | 95 /* turn off dvdnav caching */ |
20809 | 96 dvdnav_set_readahead_flag(priv->dvdnav, 0); |
97 if(dvdnav_set_PGC_positioning_flag(priv->dvdnav, 1) != DVDNAV_STATUS_OK) | |
19302 | 98 mp_msg(MSGT_OPEN,MSGL_ERR,"stream_dvdnav, failed to set PGC positioning\n"); |
99 #if 1 | |
100 /* report the title?! */ | |
20809 | 101 if (dvdnav_get_title_string(priv->dvdnav,&title_str)==DVDNAV_STATUS_OK) { |
19302 | 102 mp_msg(MSGT_IDENTIFY, MSGL_INFO,"Title: '%s'\n",title_str); |
103 } | |
104 #endif | |
105 | |
20809 | 106 //dvdnav_event_clear(priv); |
19302 | 107 |
20809 | 108 return priv; |
19302 | 109 } |
110 | |
20809 | 111 static int dvdnav_stream_read(dvdnav_priv_t * priv, unsigned char *buf, int *len) { |
19302 | 112 int event = DVDNAV_NOP; |
113 | |
114 if (!len) return -1; | |
115 *len=-1; | |
20809 | 116 if (!priv) return -1; |
19302 | 117 if (!buf) return -1; |
118 | |
119 if (dvd_nav_still) { | |
120 mp_msg(MSGT_OPEN,MSGL_V, "%s: got a stream_read while I should be asleep!\n",__FUNCTION__); | |
121 *len=0; | |
122 return -1; | |
123 } | |
124 | |
20809 | 125 if (dvdnav_get_next_block(priv->dvdnav,buf,&event,len)!=DVDNAV_STATUS_OK) { |
126 mp_msg(MSGT_OPEN,MSGL_V, "Error getting next block from DVD %d (%s)\n",event, dvdnav_err_to_string(priv->dvdnav) ); | |
19302 | 127 *len=-1; |
128 } | |
129 else if (event!=DVDNAV_BLOCK_OK) { | |
130 // need to handle certain events internally (like skipping stills) | |
131 switch (event) { | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
132 case DVDNAV_STILL_FRAME: { |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
133 dvdnav_still_event_t *still_event = (dvdnav_still_event_t*)(buf); |
20809 | 134 //if (priv->started) dvd_nav_still=1; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
135 //else |
20809 | 136 dvdnav_still_skip(priv->dvdnav); // don't let dvdnav stall on this image |
19302 | 137 |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
138 break; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
139 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
140 case DVDNAV_CELL_CHANGE: { |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
141 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
|
142 if(ev->pgc_length) |
20809 | 143 priv->duration = ev->pgc_length/90; |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
144 break; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
145 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
146 case DVDNAV_WAIT: |
20809 | 147 dvdnav_wait_skip(priv->dvdnav); |
19302 | 148 break; |
149 } | |
150 | |
151 *len=0; | |
152 } | |
153 return event; | |
154 } | |
155 | |
156 static void update_title_len(stream_t *stream) { | |
157 dvdnav_priv_t *priv = stream->priv; | |
158 dvdnav_status_t status; | |
159 uint32_t pos = 0, len = 0; | |
160 | |
161 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
|
162 if(status == DVDNAV_STATUS_OK && len) { |
19302 | 163 stream->end_pos = (off_t) len * 2048; |
19892
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
164 stream->seek = seek; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
165 } else { |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
166 stream->seek = NULL; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
167 stream->end_pos = 0; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
168 } |
19302 | 169 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
170 |
19302 | 171 |
172 static int seek(stream_t *s, off_t newpos) { | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
173 uint32_t pos = 0, len = 0, sector = 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
174 dvdnav_priv_t *priv = s->priv; |
19302 | 175 |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
176 if(s->end_pos && newpos > s->end_pos) |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
177 newpos = s->end_pos; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
178 sector = newpos / 2048ULL; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
179 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
|
180 goto fail; |
19302 | 181 |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
182 s->pos = newpos; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
183 |
19302 | 184 return 1; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
185 |
19302 | 186 fail: |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
187 mp_msg(MSGT_STREAM,MSGL_INFO,"dvdnav_stream, seeking to %"PRIu64" failed: %s\n", newpos, dvdnav_err_to_string(priv->dvdnav)); |
19302 | 188 |
189 return 1; | |
190 } | |
191 | |
192 static void stream_dvdnav_close(stream_t *s) { | |
193 dvdnav_priv_t *priv = s->priv; | |
194 dvdnav_close(priv->dvdnav); | |
195 priv->dvdnav = NULL; | |
196 free(priv); | |
197 } | |
198 | |
199 | |
200 static int fill_buffer(stream_t *s, char *but, int len) | |
201 { | |
202 int event; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
203 |
20809 | 204 dvdnav_priv_t* priv=s->priv; |
19302 | 205 len=0; |
206 if(!s->end_pos) | |
207 update_title_len(s); | |
208 while(!len) /* grab all event until DVDNAV_BLOCK_OK (len=2048), DVDNAV_STOP or DVDNAV_STILL_FRAME */ | |
209 { | |
20810 | 210 event=dvdnav_stream_read(priv, s->buffer, &len); |
211 if(event==-1 || len==-1) | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
212 { |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
213 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
|
214 return 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
215 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
216 switch (event) { |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
217 case DVDNAV_STOP: return len; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
218 case DVDNAV_BLOCK_OK: return len; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
219 case DVDNAV_VTS_CHANGE: { |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
220 int tit = 0, part = 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
221 s->end_pos = 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
222 update_title_len(s); |
20809 | 223 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
|
224 mp_msg(MSGT_CPLAYER,MSGL_V, "\r\nDVDNAV, NEW TITLE %d\r\n", tit); |
20809 | 225 if(priv->title > 0 && tit != priv->title) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
226 return 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
227 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
228 break; |
19302 | 229 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
230 case DVDNAV_CELL_CHANGE: { |
20809 | 231 if(priv->title > 0 && dvd_last_chapter > 0) { |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
232 int tit=0, part=0; |
20809 | 233 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
|
234 return 0; |
19893
9440915a76f1
at titleset change call update_title_len() to reset stream->end_pos
nicodvb
parents:
19892
diff
changeset
|
235 } |
19302 | 236 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
237 break; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
238 } |
19302 | 239 } |
240 mp_msg(MSGT_STREAM,MSGL_DBG2,"DVDNAV fill_buffer len: %d\n",len); | |
241 return len; | |
242 } | |
243 | |
19443 | 244 static int control(stream_t *stream, int cmd, void* arg) { |
20809 | 245 dvdnav_priv_t* priv=stream->priv; |
19443 | 246 int tit, part; |
247 | |
248 switch(cmd) | |
249 { | |
250 case STREAM_CTRL_SEEK_TO_CHAPTER: | |
251 { | |
252 int chap = *((unsigned int *)arg)+1; | |
253 | |
20809 | 254 if(chap < 1 || dvdnav_current_title_info(priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) |
19443 | 255 break; |
20809 | 256 if(dvdnav_part_play(priv->dvdnav, tit, chap) != DVDNAV_STATUS_OK) |
19443 | 257 break; |
258 return 1; | |
259 } | |
19477 | 260 case STREAM_CTRL_GET_NUM_CHAPTERS: |
261 { | |
20809 | 262 if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) |
19477 | 263 break; |
20809 | 264 if(dvdnav_get_number_of_parts(priv->dvdnav, tit, &part) != DVDNAV_STATUS_OK) |
19477 | 265 break; |
266 if(!part) | |
267 break; | |
268 *((unsigned int *)arg) = part; | |
269 return 1; | |
270 } | |
19443 | 271 case STREAM_CTRL_GET_CURRENT_CHAPTER: |
272 { | |
20809 | 273 if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) |
19443 | 274 break; |
275 *((unsigned int *)arg) = part - 1; | |
276 return 1; | |
277 } | |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
278 case STREAM_CTRL_GET_TIME_LENGTH: |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
279 { |
20809 | 280 if(priv->duration) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
281 { |
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
|
282 *((double *)arg) = (double)priv->duration / 1000.0; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
283 return 1; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
284 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
285 break; |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
286 } |
19443 | 287 } |
288 | |
289 return STREAM_UNSUPORTED; | |
290 } | |
291 | |
19302 | 292 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { |
293 struct stream_priv_s* p = (struct stream_priv_s*)opts; | |
294 char *filename; | |
295 int event,len,tmplen=0; | |
296 uint32_t pos, l2; | |
20809 | 297 dvdnav_priv_t *priv; |
19302 | 298 dvdnav_status_t status; |
299 | |
300 if(p->device) filename = p->device; | |
301 else if(dvd_device) filename= dvd_device; | |
302 else filename = DEFAULT_DVD_DEVICE; | |
20809 | 303 if(!(priv=new_dvdnav_stream(filename))) { |
19302 | 304 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename); |
305 return STREAM_UNSUPORTED; | |
306 } | |
307 | |
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
|
308 if(p->track > 0) { |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
309 if(dvd_chapter > 0 && dvd_last_chapter > 0 && dvd_chapter > dvd_last_chapter) { |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
310 mp_msg(MSGT_OPEN,MSGL_FATAL,"dvdnav_stream, invalid chapter range: %d > %d\n", dvd_chapter, dvd_last_chapter); |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
311 return STREAM_UNSUPORTED; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
312 } |
20809 | 313 priv->title = p->track; |
314 if(dvdnav_title_play(priv->dvdnav, p->track) != DVDNAV_STATUS_OK) { | |
315 mp_msg(MSGT_OPEN,MSGL_FATAL,"dvdnav_stream, couldn't select title %d, error '%s'\n", p->track, dvdnav_err_to_string(priv->dvdnav)); | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
316 return STREAM_UNSUPORTED; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
317 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
318 if(dvd_chapter > 0) |
20809 | 319 dvdnav_part_play(priv->dvdnav, p->track, dvd_chapter); |
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
|
320 } else if(p->track == -1) |
20809 | 321 dvdnav_menu_call(priv->dvdnav, DVD_MENU_Root); |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
322 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
|
323 mp_msg(MSGT_OPEN,MSGL_INFO,"dvdnav_stream, you didn't specify a track number (as in dvdnav://1), playing whole disc\n"); |
20809 | 324 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
|
325 } |
20754 | 326 if(dvd_angle > 1) |
20809 | 327 dvdnav_angle_change(priv->dvdnav, dvd_angle); |
19302 | 328 |
329 stream->sector_size = 2048; | |
330 stream->flags = STREAM_READ | STREAM_SEEK; | |
331 stream->fill_buffer = fill_buffer; | |
332 stream->seek = seek; | |
19443 | 333 stream->control = control; |
19302 | 334 stream->close = stream_dvdnav_close; |
335 stream->type = STREAMTYPE_DVDNAV; | |
20809 | 336 stream->priv=(void*)priv; |
19302 | 337 *file_format = DEMUXER_TYPE_MPEG_PS; |
338 | |
339 update_title_len(stream); | |
340 if(!stream->pos) | |
20809 | 341 mp_msg(MSGT_OPEN,MSGL_ERR, "INIT ERROR: %d, couldn't get init pos %s\r\n", status, dvdnav_err_to_string(priv->dvdnav)); |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
342 |
20406 | 343 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 | 344 |
345 return STREAM_OK; | |
346 } | |
347 | |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
348 |
19774
109e241c0cca
in mp_dvdnav_handle_input() assign the currently selected button, shown in the OSD by main()
nicodvb
parents:
19768
diff
changeset
|
349 int mp_dvdnav_handle_input(stream_t *stream, int cmd, int *button) { |
20809 | 350 dvdnav_priv_t * priv=(dvdnav_priv_t*)stream->priv; |
351 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
|
352 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
|
353 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
|
354 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
|
355 |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
356 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
|
357 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
|
358 |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
359 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
|
360 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
|
361 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
|
362 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
363 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
|
364 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
|
365 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
366 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
|
367 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
|
368 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
369 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
|
370 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
|
371 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
372 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
|
373 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
|
374 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
|
375 break; |
19777
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
376 case MP_CMD_DVDNAV_PREVMENU: { |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
377 int title=0, part=0; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
378 |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
379 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
|
380 if(title) { |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
381 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
|
382 || 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
|
383 reset = 1; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
384 break; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
385 } |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
386 } |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
387 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
|
388 reset = 1; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
389 } |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
390 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
|
391 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
|
392 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
|
393 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
|
394 break; |
19912
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
395 case MP_CMD_DVDNAV_MOUSECLICK: |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
396 /* |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
397 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
|
398 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
|
399 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
|
400 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
|
401 This last call always works well |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
402 */ |
20809 | 403 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
|
404 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
|
405 default: |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
406 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
|
407 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
408 } |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
409 |
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
|
410 if(status == DVDNAV_STATUS_OK) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
411 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
|
412 |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
413 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
|
414 } |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
415 |
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
|
416 void mp_dvdnav_update_mouse_pos(stream_t *stream, int32_t x, int32_t y, int* button) { |
20809 | 417 dvdnav_priv_t * priv=(dvdnav_priv_t*)stream->priv; |
418 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
|
419 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
|
420 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
|
421 |
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
|
422 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
|
423 |
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
|
424 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
|
425 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
|
426 else *button = -1; |
20809 | 427 priv->mousex = x; |
428 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
|
429 } |
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
|
430 |
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
|
431 |
19302 | 432 stream_info_t stream_info_dvdnav = { |
433 "DVDNAV stream", | |
434 "null", | |
435 "", | |
436 "", | |
437 open_s, | |
438 { "dvdnav", NULL }, | |
439 &stream_opts, | |
440 1 // Urls are an option string | |
441 }; |