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