Mercurial > mplayer.hg
annotate stream/stream_dvdnav.c @ 25371:657c63d001ae
implemented frame selection for savage driver
synchronized with vidix.sf.net r325
author | ben |
---|---|
date | Fri, 14 Dec 2007 18:38:08 +0000 |
parents | e91e3944c07d |
children | a7eec00ebb9c |
rev | line source |
---|---|
19302 | 1 #include "config.h" |
2 | |
3 #include <stdlib.h> | |
4 #include <stdio.h> | |
5 #include <unistd.h> | |
6 #include <string.h> | |
25031
5e1e61012a05
report why the dvd couldn't be opened. Patch by Jan Knutar jknutar+nic+fi
nicodvb
parents:
25025
diff
changeset
|
7 #include <errno.h> |
19302 | 8 #include "mp_msg.h" |
9 #include "osdep/timer.h" | |
10 #include "input/input.h" | |
11 #include "stream.h" | |
19312
ab8d6b6deb63
proper inclusion of demuxer.h (including libmpdemux in Makefile only was to make previous split easier)
ben
parents:
19302
diff
changeset
|
12 #include "libmpdemux/demuxer.h" |
19302 | 13 #include "stream_dvdnav.h" |
14 #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
|
15 #include "libavutil/common.h" |
19302 | 16 #include "spudec.h" |
17 #include "m_option.h" | |
18 #include "m_struct.h" | |
19 #include "help_mp.h" | |
20 | |
21 extern char *dvd_device; | |
20409
8cd1b72aa488
support for -chapter option (same semanthics as for dvd://)
nicodvb
parents:
20407
diff
changeset
|
22 extern int dvd_chapter; |
8cd1b72aa488
support for -chapter option (same semanthics as for dvd://)
nicodvb
parents:
20407
diff
changeset
|
23 extern int dvd_last_chapter; |
20754 | 24 extern int dvd_angle; |
19302 | 25 extern char *audio_lang, *dvdsub_lang; |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
26 extern char *dvd_audio_stream_channels[6], *dvd_audio_stream_types[8]; |
19302 | 27 |
28 static struct stream_priv_s { | |
29 int track; | |
30 char* device; | |
31 } 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
|
32 0, |
19302 | 33 NULL |
34 }; | |
35 | |
36 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f) | |
37 /// URL definition | |
25242 | 38 static const m_option_t stream_opts_fields[] = { |
19302 | 39 {"filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, |
40 {"hostname", ST_OFF(track), CONF_TYPE_INT, 0, 0, 0, NULL}, | |
41 { NULL, NULL, 0, 0, 0, 0, NULL } | |
42 }; | |
43 static struct m_struct_st stream_opts = { | |
44 "dvd", | |
45 sizeof(struct stream_priv_s), | |
46 &stream_priv_dflts, | |
47 stream_opts_fields | |
48 }; | |
49 | |
19892
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
50 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
|
51 |
19914
dfd1bb3fc7c0
made file-static new_dvdnav_stream() and dvdnav_stream_read()
nicodvb
parents:
19912
diff
changeset
|
52 static dvdnav_priv_t * new_dvdnav_stream(char * filename) { |
19302 | 53 char * title_str; |
20809 | 54 dvdnav_priv_t *priv; |
19302 | 55 |
56 if (!filename) | |
57 return NULL; | |
58 | |
20809 | 59 if (!(priv=calloc(1,sizeof(dvdnav_priv_t)))) |
19302 | 60 return NULL; |
61 | |
20809 | 62 if (!(priv->filename=strdup(filename))) { |
63 free(priv); | |
19302 | 64 return NULL; |
65 } | |
66 | |
20809 | 67 if(dvdnav_open(&(priv->dvdnav),priv->filename)!=DVDNAV_STATUS_OK) |
19302 | 68 { |
20809 | 69 free(priv->filename); |
70 free(priv); | |
19302 | 71 return NULL; |
72 } | |
73 | |
20809 | 74 if (!priv->dvdnav) { |
75 free(priv); | |
19302 | 76 return NULL; |
77 } | |
78 | |
79 if(1) //from vlc: if not used dvdnav from cvs will fail | |
80 { | |
81 int len, event; | |
82 char buf[2048]; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
83 |
20809 | 84 dvdnav_get_next_block(priv->dvdnav,buf,&event,&len); |
85 dvdnav_sector_search(priv->dvdnav, 0, SEEK_SET); | |
19302 | 86 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
87 |
19454 | 88 /* turn off dvdnav caching */ |
20809 | 89 dvdnav_set_readahead_flag(priv->dvdnav, 0); |
90 if(dvdnav_set_PGC_positioning_flag(priv->dvdnav, 1) != DVDNAV_STATUS_OK) | |
19302 | 91 mp_msg(MSGT_OPEN,MSGL_ERR,"stream_dvdnav, failed to set PGC positioning\n"); |
92 #if 1 | |
93 /* report the title?! */ | |
20809 | 94 if (dvdnav_get_title_string(priv->dvdnav,&title_str)==DVDNAV_STATUS_OK) { |
19302 | 95 mp_msg(MSGT_IDENTIFY, MSGL_INFO,"Title: '%s'\n",title_str); |
96 } | |
97 #endif | |
98 | |
20809 | 99 //dvdnav_event_clear(priv); |
19302 | 100 |
20809 | 101 return priv; |
19302 | 102 } |
103 | |
21219 | 104 static void dvdnav_get_highlight (dvdnav_priv_t *priv, int display_mode) { |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
105 pci_t *pnavpci = NULL; |
21219 | 106 dvdnav_highlight_event_t *hlev = &(priv->hlev); |
107 int btnum; | |
21198
fbe50a67612a
COSMETICS: consistently reformatted after ben's mess
nicodvb
parents:
21197
diff
changeset
|
108 |
21219 | 109 if (!priv || !priv->dvdnav) |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
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 *len=-1; | |
20809 | 145 if (dvdnav_get_next_block(priv->dvdnav,buf,&event,len)!=DVDNAV_STATUS_OK) { |
146 mp_msg(MSGT_OPEN,MSGL_V, "Error getting next block from DVD %d (%s)\n",event, dvdnav_err_to_string(priv->dvdnav) ); | |
19302 | 147 *len=-1; |
148 } | |
149 else if (event!=DVDNAV_BLOCK_OK) { | |
150 // need to handle certain events internally (like skipping stills) | |
151 switch (event) { | |
21332 | 152 case DVDNAV_NAV_PACKET: |
153 return event; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
154 case DVDNAV_STILL_FRAME: { |
23991
6b5d9e7e4b17
cosmetics: removed commented code and small reindentation
nicodvb
parents:
23990
diff
changeset
|
155 dvdnav_still_skip(priv->dvdnav); // don't let dvdnav stall on this image |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
156 break; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
157 } |
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
|
158 case DVDNAV_HIGHLIGHT: { |
21219 | 159 dvdnav_get_highlight (priv, 1); |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
20851
diff
changeset
|
160 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
|
161 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
162 case DVDNAV_CELL_CHANGE: { |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
163 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
|
164 if(ev->pgc_length) |
20809 | 165 priv->duration = ev->pgc_length/90; |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
166 break; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
167 } |
21538
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
168 case DVDNAV_SPU_CLUT_CHANGE: { |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
169 memcpy(priv->spu_clut, buf, 16*sizeof(unsigned int)); |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
170 priv->spu_set = 1; |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
171 break; |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
172 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
173 case DVDNAV_WAIT: |
20809 | 174 dvdnav_wait_skip(priv->dvdnav); |
19302 | 175 break; |
176 } | |
177 | |
178 *len=0; | |
179 } | |
180 return event; | |
181 } | |
182 | |
183 static void update_title_len(stream_t *stream) { | |
184 dvdnav_priv_t *priv = stream->priv; | |
185 dvdnav_status_t status; | |
186 uint32_t pos = 0, len = 0; | |
187 | |
188 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
|
189 if(status == DVDNAV_STATUS_OK && len) { |
19302 | 190 stream->end_pos = (off_t) len * 2048; |
19892
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
191 stream->seek = seek; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
192 } else { |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
193 stream->seek = NULL; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
194 stream->end_pos = 0; |
2c361743ce69
don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents:
19851
diff
changeset
|
195 } |
19302 | 196 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
197 |
19302 | 198 |
199 static int seek(stream_t *s, off_t newpos) { | |
23990 | 200 uint32_t sector = 0; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
201 dvdnav_priv_t *priv = s->priv; |
19302 | 202 |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
203 if(s->end_pos && newpos > s->end_pos) |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
204 newpos = s->end_pos; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
205 sector = newpos / 2048ULL; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
206 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
|
207 goto fail; |
19302 | 208 |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
209 s->pos = newpos; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
210 |
19302 | 211 return 1; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
212 |
19302 | 213 fail: |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
214 mp_msg(MSGT_STREAM,MSGL_INFO,"dvdnav_stream, seeking to %"PRIu64" failed: %s\n", newpos, dvdnav_err_to_string(priv->dvdnav)); |
19302 | 215 |
216 return 1; | |
217 } | |
218 | |
219 static void stream_dvdnav_close(stream_t *s) { | |
220 dvdnav_priv_t *priv = s->priv; | |
221 dvdnav_close(priv->dvdnav); | |
222 priv->dvdnav = NULL; | |
223 free(priv); | |
224 } | |
225 | |
226 | |
227 static int fill_buffer(stream_t *s, char *but, int len) | |
228 { | |
229 int event; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
230 |
20809 | 231 dvdnav_priv_t* priv=s->priv; |
19302 | 232 len=0; |
233 if(!s->end_pos) | |
234 update_title_len(s); | |
235 while(!len) /* grab all event until DVDNAV_BLOCK_OK (len=2048), DVDNAV_STOP or DVDNAV_STILL_FRAME */ | |
236 { | |
20810 | 237 event=dvdnav_stream_read(priv, s->buffer, &len); |
238 if(event==-1 || len==-1) | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
239 { |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
240 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
|
241 return 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
242 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
243 switch (event) { |
21333 | 244 case DVDNAV_STOP: |
245 case DVDNAV_BLOCK_OK: | |
246 case DVDNAV_NAV_PACKET: | |
247 return len; | |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
248 case DVDNAV_VTS_CHANGE: { |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
249 int tit = 0, part = 0; |
23043
4038852b041e
after a DVDNAV_VTS_CHANGE event report the title being played
nicodvb
parents:
22936
diff
changeset
|
250 dvdnav_vts_change_event_t *vts_event = (dvdnav_vts_change_event_t *)s->buffer; |
4038852b041e
after a DVDNAV_VTS_CHANGE event report the title being played
nicodvb
parents:
22936
diff
changeset
|
251 mp_msg(MSGT_CPLAYER,MSGL_INFO, "DVDNAV, switched to title: %d\r\n", vts_event->new_vtsN); |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
252 s->end_pos = 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
253 update_title_len(s); |
20809 | 254 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
|
255 mp_msg(MSGT_CPLAYER,MSGL_V, "\r\nDVDNAV, NEW TITLE %d\r\n", tit); |
21219 | 256 dvdnav_get_highlight (priv, 0); |
20809 | 257 if(priv->title > 0 && tit != priv->title) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
258 return 0; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
259 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
260 break; |
19302 | 261 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
262 case DVDNAV_CELL_CHANGE: { |
20809 | 263 if(priv->title > 0 && dvd_last_chapter > 0) { |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
264 int tit=0, part=0; |
20809 | 265 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
|
266 return 0; |
19893
9440915a76f1
at titleset change call update_title_len() to reset stream->end_pos
nicodvb
parents:
19892
diff
changeset
|
267 } |
19302 | 268 } |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
269 break; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
270 } |
19302 | 271 } |
272 mp_msg(MSGT_STREAM,MSGL_DBG2,"DVDNAV fill_buffer len: %d\n",len); | |
273 return len; | |
274 } | |
275 | |
19443 | 276 static int control(stream_t *stream, int cmd, void* arg) { |
20809 | 277 dvdnav_priv_t* priv=stream->priv; |
19443 | 278 int tit, part; |
279 | |
280 switch(cmd) | |
281 { | |
282 case STREAM_CTRL_SEEK_TO_CHAPTER: | |
283 { | |
284 int chap = *((unsigned int *)arg)+1; | |
285 | |
20809 | 286 if(chap < 1 || dvdnav_current_title_info(priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) |
19443 | 287 break; |
20809 | 288 if(dvdnav_part_play(priv->dvdnav, tit, chap) != DVDNAV_STATUS_OK) |
19443 | 289 break; |
290 return 1; | |
291 } | |
19477 | 292 case STREAM_CTRL_GET_NUM_CHAPTERS: |
293 { | |
20809 | 294 if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) |
19477 | 295 break; |
20809 | 296 if(dvdnav_get_number_of_parts(priv->dvdnav, tit, &part) != DVDNAV_STATUS_OK) |
19477 | 297 break; |
298 if(!part) | |
299 break; | |
300 *((unsigned int *)arg) = part; | |
301 return 1; | |
302 } | |
19443 | 303 case STREAM_CTRL_GET_CURRENT_CHAPTER: |
304 { | |
20809 | 305 if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK) |
19443 | 306 break; |
307 *((unsigned int *)arg) = part - 1; | |
308 return 1; | |
309 } | |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
310 case STREAM_CTRL_GET_TIME_LENGTH: |
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
311 { |
20809 | 312 if(priv->duration) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
313 { |
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
|
314 *((double *)arg) = (double)priv->duration / 1000.0; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
315 return 1; |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
316 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
317 break; |
19453
087d4a916ea3
implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents:
19452
diff
changeset
|
318 } |
24303 | 319 case STREAM_CTRL_GET_ASPECT_RATIO: |
320 { | |
321 uint8_t ar = dvdnav_get_video_aspect(priv->dvdnav); | |
322 *((double *)arg) = !ar ? 4.0/3.0 : 16.0/9.0; | |
323 return 1; | |
324 } | |
22936
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
325 case STREAM_CTRL_GET_CURRENT_TIME: |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
326 { |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
327 double tm; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
328 tm = dvdnav_get_current_time(priv->dvdnav)/90000.0f; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
329 if(tm != -1) |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
330 { |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
331 *((double *)arg) = tm; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
332 return 1; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
333 } |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
334 break; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
335 } |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
336 case STREAM_CTRL_SEEK_TO_TIME: |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
337 { |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
338 uint64_t tm = (uint64_t) (*((double*)arg) * 90000); |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
339 if(dvdnav_time_search(priv->dvdnav, tm) == DVDNAV_STATUS_OK) |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
340 return 1; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
341 break; |
a6486d2975d2
implemented STREAM_CTRL_GET_CURRENT_TIME and STREAM_CTRL_SEEK_TO_TIME - dvdnav from mphq required
nicodvb
parents:
21613
diff
changeset
|
342 } |
19443 | 343 } |
344 | |
24257 | 345 return STREAM_UNSUPPORTED; |
19443 | 346 } |
347 | |
25165 | 348 static void identify_chapters(dvdnav_t *nav, uint32_t title) |
349 { | |
25177
a43d99a80f4a
-identify also shows the duration(s) of the title(s)
nicodvb
parents:
25176
diff
changeset
|
350 uint64_t *parts=NULL, duration=0; |
25165 | 351 uint32_t n, i, t; |
25177
a43d99a80f4a
-identify also shows the duration(s) of the title(s)
nicodvb
parents:
25176
diff
changeset
|
352 n = dvdnav_describe_title_chapters(nav, title, &parts, &duration); |
25165 | 353 if(parts) { |
25177
a43d99a80f4a
-identify also shows the duration(s) of the title(s)
nicodvb
parents:
25176
diff
changeset
|
354 t = duration / 90; |
a43d99a80f4a
-identify also shows the duration(s) of the title(s)
nicodvb
parents:
25176
diff
changeset
|
355 mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_DVD_TITLE_%d_LENGTH=%d.%03d\n", title, t / 1000, t % 1000); |
25167 | 356 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "TITLE %u, CHAPTERS: ", title); |
25165 | 357 for(i=0; i<n; i++) { |
358 t = parts[i] / 90000; | |
359 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "%02d:%02d:%02d,", t/3600, (t/60)%60, t%60); | |
360 } | |
361 free(parts); | |
362 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "\n"); | |
363 } | |
364 } | |
365 | |
25176
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
366 static void identify(dvdnav_priv_t *priv, struct stream_priv_s *p) |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
367 { |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
368 uint32_t titles=0, i; |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
369 if(p->track <= 0) { |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
370 dvdnav_get_number_of_titles(priv->dvdnav, &titles); |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
371 for(i=0; i<titles; i++) |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
372 identify_chapters(priv->dvdnav, i); |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
373 } |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
374 else |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
375 identify_chapters(priv->dvdnav, p->track); |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
376 } |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
377 |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
378 static void show_audio_subs_languages(dvdnav_t *nav) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
379 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
380 uint8_t lg; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
381 uint16_t i, lang, format, id, channels; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
382 int base[6] = {128, 0, 0, 0, 160, 136, 0}; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
383 char tmp[3]; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
384 for(i=0; i<8; i++) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
385 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
386 lg = dvdnav_get_audio_logical_stream(nav, i); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
387 if(lg == 0xff) continue; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
388 channels = dvdnav_audio_stream_channels(nav, lg); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
389 if(channels == 0xFFFF) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
390 channels = 2; //unknown |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
391 else |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
392 channels--; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
393 lang = dvdnav_audio_stream_to_lang(nav, lg); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
394 if(lang == 0xFFFF) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
395 tmp[0] = tmp[1] = '?'; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
396 else |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
397 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
398 tmp[0] = lang >> 8; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
399 tmp[1] = lang & 0xFF; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
400 } |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
401 tmp[2] = 0; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
402 format = dvdnav_audio_stream_format(nav, lg); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
403 if(format == 0xFFFF || format > 6) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
404 format = 1; //unknown |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
405 id = i + base[format]; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
406 mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDaudioStreamInfo, i, |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
407 dvd_audio_stream_types[format], dvd_audio_stream_channels[channels], tmp, id); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
408 } |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
409 |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
410 for(i=0; i<32; i++) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
411 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
412 lg = dvdnav_get_spu_logical_stream(nav, i); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
413 if(lg == 0xff) continue; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
414 lang = dvdnav_spu_stream_to_lang(nav, lg); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
415 if(lang == 0xFFFF) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
416 tmp[0] = tmp[1] = '?'; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
417 else |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
418 { |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
419 tmp[0] = lang >> 8; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
420 tmp[1] = lang & 0xFF; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
421 } |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
422 tmp[2] = 0; |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
423 mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDsubtitleLanguage, i+0x20, tmp); |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
424 } |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
425 } |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
426 |
19302 | 427 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { |
428 struct stream_priv_s* p = (struct stream_priv_s*)opts; | |
429 char *filename; | |
20809 | 430 dvdnav_priv_t *priv; |
19302 | 431 |
432 if(p->device) filename = p->device; | |
433 else if(dvd_device) filename= dvd_device; | |
434 else filename = DEFAULT_DVD_DEVICE; | |
20809 | 435 if(!(priv=new_dvdnav_stream(filename))) { |
25031
5e1e61012a05
report why the dvd couldn't be opened. Patch by Jan Knutar jknutar+nic+fi
nicodvb
parents:
25025
diff
changeset
|
436 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename, strerror(errno)); |
24257 | 437 return STREAM_UNSUPPORTED; |
19302 | 438 } |
439 | |
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
|
440 if(p->track > 0) { |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
441 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
|
442 mp_msg(MSGT_OPEN,MSGL_FATAL,"dvdnav_stream, invalid chapter range: %d > %d\n", dvd_chapter, dvd_last_chapter); |
24257 | 443 return STREAM_UNSUPPORTED; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
444 } |
20809 | 445 priv->title = p->track; |
446 if(dvdnav_title_play(priv->dvdnav, p->track) != DVDNAV_STATUS_OK) { | |
447 mp_msg(MSGT_OPEN,MSGL_FATAL,"dvdnav_stream, couldn't select title %d, error '%s'\n", p->track, dvdnav_err_to_string(priv->dvdnav)); | |
24257 | 448 return STREAM_UNSUPPORTED; |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
449 } |
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
450 if(dvd_chapter > 0) |
20809 | 451 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
|
452 } else if(p->track == -1) |
20809 | 453 dvdnav_menu_call(priv->dvdnav, DVD_MENU_Root); |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
454 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
|
455 mp_msg(MSGT_OPEN,MSGL_INFO,"dvdnav_stream, you didn't specify a track number (as in dvdnav://1), playing whole disc\n"); |
20809 | 456 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
|
457 } |
25176
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
458 if(mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) |
6d9212e61af8
cosmetics: moved identification code to a separate function
nicodvb
parents:
25168
diff
changeset
|
459 identify(priv, p); |
25196
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
460 if(p->track > 0) |
5487d363a9ac
at startup show audio and subtitle streams available in the chosen title with all their properties
nicodvb
parents:
25177
diff
changeset
|
461 show_audio_subs_languages(priv->dvdnav); |
20754 | 462 if(dvd_angle > 1) |
20809 | 463 dvdnav_angle_change(priv->dvdnav, dvd_angle); |
19302 | 464 |
465 stream->sector_size = 2048; | |
466 stream->flags = STREAM_READ | STREAM_SEEK; | |
467 stream->fill_buffer = fill_buffer; | |
468 stream->seek = seek; | |
19443 | 469 stream->control = control; |
19302 | 470 stream->close = stream_dvdnav_close; |
471 stream->type = STREAMTYPE_DVDNAV; | |
20809 | 472 stream->priv=(void*)priv; |
19302 | 473 *file_format = DEMUXER_TYPE_MPEG_PS; |
474 | |
475 update_title_len(stream); | |
476 if(!stream->pos) | |
24109 | 477 mp_msg(MSGT_OPEN,MSGL_ERR, "INIT ERROR: couldn't get init pos %s\r\n", dvdnav_err_to_string(priv->dvdnav)); |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
478 |
20406 | 479 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 | 480 |
481 return STREAM_OK; | |
482 } | |
483 | |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
484 |
19774
109e241c0cca
in mp_dvdnav_handle_input() assign the currently selected button, shown in the OSD by main()
nicodvb
parents:
19768
diff
changeset
|
485 int mp_dvdnav_handle_input(stream_t *stream, int cmd, int *button) { |
20809 | 486 dvdnav_priv_t * priv=(dvdnav_priv_t*)stream->priv; |
487 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
|
488 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
|
489 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
|
490 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
|
491 |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
492 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
|
493 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
|
494 |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
495 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
|
496 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
|
497 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
|
498 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
499 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
|
500 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
|
501 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
502 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
|
503 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
|
504 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
505 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
|
506 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
|
507 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
508 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
|
509 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
|
510 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
|
511 break; |
19777
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
512 case MP_CMD_DVDNAV_PREVMENU: { |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
513 int title=0, part=0; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
514 |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
515 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
|
516 if(title) { |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
517 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
|
518 || 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
|
519 reset = 1; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
520 break; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
521 } |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
522 } |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
523 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
|
524 reset = 1; |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
525 } |
bb1b570ac7c1
permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents:
19774
diff
changeset
|
526 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
|
527 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
|
528 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
|
529 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
|
530 break; |
19912
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
531 case MP_CMD_DVDNAV_MOUSECLICK: |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
532 /* |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
533 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
|
534 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
|
535 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
|
536 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
|
537 This last call always works well |
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
538 */ |
20809 | 539 status = dvdnav_mouse_activate(nav, pci, priv->mousex, priv->mousey); |
24304
032c82a7a053
a mouse selection may require at least a video codec reinit
nicodvb
parents:
24303
diff
changeset
|
540 if(status == DVDNAV_STATUS_OK) reset = 1; |
19912
3fdb44285fe7
introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents:
19909
diff
changeset
|
541 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
|
542 default: |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
543 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
|
544 break; |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
545 } |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
546 |
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
|
547 if(status == DVDNAV_STATUS_OK) |
20786
50b5a9e01009
COSMETICS: reformatted this ugly mess in a consistent manner
nicodvb
parents:
20754
diff
changeset
|
548 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
|
549 |
19768
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
550 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
|
551 } |
1069a634fc92
added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents:
19764
diff
changeset
|
552 |
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
|
553 void mp_dvdnav_update_mouse_pos(stream_t *stream, int32_t x, int32_t y, int* button) { |
20809 | 554 dvdnav_priv_t * priv=(dvdnav_priv_t*)stream->priv; |
555 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
|
556 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
|
557 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
|
558 |
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
|
559 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
|
560 |
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
|
561 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
|
562 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
|
563 else *button = -1; |
20809 | 564 priv->mousex = x; |
565 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
|
566 } |
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
|
567 |
21424
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
568 /** |
21600 | 569 * \brief dvdnav_aid_from_lang() returns the audio id corresponding to the language code 'lang' |
570 * \param stream: - stream pointer | |
571 * \param lang: 2-characters language code[s], eventually separated by spaces of commas | |
572 * \return -1 on error, current subtitle id if successful | |
573 */ | |
574 int dvdnav_aid_from_lang(stream_t *stream, unsigned char *language) { | |
575 dvdnav_priv_t * priv=(dvdnav_priv_t*)stream->priv; | |
576 int k; | |
577 uint8_t format, lg; | |
578 uint16_t lang, lcode;; | |
579 | |
580 while(language && strlen(language)>=2) { | |
581 lcode = (language[0] << 8) | (language[1]); | |
582 for(k=0; k<32; k++) { | |
583 lg = dvdnav_get_audio_logical_stream(priv->dvdnav, k); | |
584 if(lg == 0xff) continue; | |
585 lang = dvdnav_audio_stream_to_lang(priv->dvdnav, lg); | |
586 if(lang != 0xFFFF && lang == lcode) { | |
587 format = dvdnav_audio_stream_format(priv->dvdnav, lg); | |
588 switch(format) { | |
589 case DVDNAV_FORMAT_AC3: | |
590 return k+128; | |
591 case DVDNAV_FORMAT_DTS: | |
592 return k+136; | |
593 case DVDNAV_FORMAT_LPCM: | |
594 return k+160; | |
595 case DVDNAV_FORMAT_MPEGAUDIO: | |
596 return k; | |
597 default: | |
598 return -1; | |
599 } | |
600 } | |
601 } | |
602 language += 2; | |
603 while(language[0]==',' || language[0]==' ') ++language; | |
604 } | |
605 return -1; | |
606 } | |
607 | |
21603
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
608 /** |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
609 * \brief dvdnav_lang_from_aid() assigns to buf the language corresponding to audio id 'aid' |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
610 * \param stream: - stream pointer |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
611 * \param sid: physical subtitle id |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
612 * \param buf: buffer to contain the 2-chars language string |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
613 * \return 0 on error, 1 if successful |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
614 */ |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
615 int dvdnav_lang_from_aid(stream_t *stream, int aid, unsigned char *buf) { |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
616 uint8_t lg; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
617 uint16_t lang; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
618 dvdnav_priv_t * priv=(dvdnav_priv_t*)stream->priv; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
619 |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
620 if(aid < 0) |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
621 return 0; |
21613
8547ae79e74b
simplified aid management in dvdnav_lang_from_aid(); patch by Joakim Patte
nicodvb
parents:
21603
diff
changeset
|
622 lg = dvdnav_get_audio_logical_stream(priv->dvdnav, aid & 0x7); |
21603
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
623 if(lg == 0xff) return 0; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
624 lang = dvdnav_audio_stream_to_lang(priv->dvdnav, lg); |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
625 if(lang == 0xffff) return 0; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
626 buf[0] = lang >> 8; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
627 buf[1] = lang & 0xFF; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
628 buf[2] = 0; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
629 return 1; |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
630 } |
4bfdaf8bcae5
implemented dvdnav_lang_from_aid() to retrieve audio language
nicodvb
parents:
21600
diff
changeset
|
631 |
21600 | 632 |
633 /** | |
21424
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
634 * \brief dvdnav_sid_from_lang() returns the subtitle id corresponding to the language code 'lang' |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
635 * \param stream: - stream pointer |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
636 * \param lang: 2-characters language code[s], eventually separated by spaces of commas |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
637 * \return -1 on error, current subtitle id if successful |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
638 */ |
21197
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
639 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
|
640 dvdnav_priv_t * priv=(dvdnav_priv_t*)stream->priv; |
23990 | 641 uint8_t lg, k; |
21204
1ddb1a86e419
support for comma-separated language codes in -slang
nicodvb
parents:
21200
diff
changeset
|
642 uint16_t lang, lcode; |
21197
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
643 |
21204
1ddb1a86e419
support for comma-separated language codes in -slang
nicodvb
parents:
21200
diff
changeset
|
644 while(language && strlen(language)>=2) { |
21333 | 645 lcode = (language[0] << 8) | (language[1]); |
646 for(k=0; k<32; k++) { | |
647 lg = dvdnav_get_spu_logical_stream(priv->dvdnav, k); | |
648 if(lg == 0xff) continue; | |
649 lang = dvdnav_spu_stream_to_lang(priv->dvdnav, lg); | |
650 if(lang != 0xFFFF && lang == lcode) { | |
651 return k; | |
652 } | |
21197
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
653 } |
21333 | 654 language += 2; |
655 while(language[0]==',' || language[0]==' ') ++language; | |
21204
1ddb1a86e419
support for comma-separated language codes in -slang
nicodvb
parents:
21200
diff
changeset
|
656 } |
21197
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
657 return -1; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
658 } |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
659 |
21424
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
660 /** |
21560
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
661 * \brief dvdnav_lang_from_sid() assigns to buf the language corresponding to subtitle id 'sid' |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
662 * \param stream: - stream pointer |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
663 * \param sid: physical subtitle id |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
664 * \param buf: buffer to contain the 2-chars language string |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
665 * \return 0 on error, 1 if successful |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
666 */ |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
667 int dvdnav_lang_from_sid(stream_t *stream, int sid, unsigned char *buf) { |
23990 | 668 uint8_t lg; |
21560
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
669 uint16_t lang; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
670 dvdnav_priv_t *priv=(dvdnav_priv_t*)stream->priv; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
671 if(sid < 0) return 0; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
672 lg = dvdnav_get_spu_logical_stream(priv->dvdnav, sid); |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
673 lang = dvdnav_spu_stream_to_lang(priv->dvdnav, lg); |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
674 if(lang == 0xffff) return 0; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
675 buf[0] = lang >> 8; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
676 buf[1] = lang & 0xFF; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
677 buf[2] = 0; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
678 return 1; |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
679 } |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
680 |
a16219e6d656
added function to return the language of the specified subtitle id. Patch by
nicodvb
parents:
21538
diff
changeset
|
681 /** |
21424
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
682 * \brief dvdnav_number_of_subs() returns the count of available subtitles |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
683 * \param stream: - stream pointer |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
684 * \return 0 on error, something meaningful otherwise |
3504737c4e96
doxygenized dvdnav_sid_from_lang() and dvdnav_number_of_subs()
nicodvb
parents:
21333
diff
changeset
|
685 */ |
21197
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
686 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
|
687 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
|
688 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
|
689 |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
690 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
|
691 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
|
692 if(lg == 0xff) continue; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
693 n++; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
694 } |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
695 return n; |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
696 } |
7ecd9de03435
added code to identify subs language and count; needed for forthcoming support for -slang
nicodvb
parents:
21193
diff
changeset
|
697 |
23902 | 698 /** |
699 * \brief mp_dvdnav_get_spu_clut() returns the spu clut | |
700 * \param stream: - stream pointer | |
701 * \return spu clut pointer | |
702 */ | |
21538
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
703 unsigned int *mp_dvdnav_get_spu_clut(stream_t *stream) { |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
704 dvdnav_priv_t *priv=(dvdnav_priv_t*)stream->priv; |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
705 if(!priv->spu_set) return NULL; |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
706 return priv->spu_clut; |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
707 } |
c9b6588932b5
export spu palette; part of a patch by Otvos Attila
nicodvb
parents:
21424
diff
changeset
|
708 |
23902 | 709 /** |
710 * \brief mp_dvdnav_get_highlight() get dvdnav highlight struct | |
711 * \param stream: - stream pointer | |
712 * \param hl : - highlight struct pointer | |
713 */ | |
21219 | 714 void mp_dvdnav_get_highlight (stream_t *stream, nav_highlight_t *hl) { |
715 dvdnav_priv_t *priv = (dvdnav_priv_t *) stream->priv; | |
716 dvdnav_highlight_event_t hlev = priv->hlev; | |
717 | |
718 hl->sx = hlev.sx; | |
719 hl->sy = hlev.sy; | |
720 hl->ex = hlev.ex; | |
721 hl->ey = hlev.ey; | |
21200 | 722 } |
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
|
723 |
25211 | 724 const stream_info_t stream_info_dvdnav = { |
19302 | 725 "DVDNAV stream", |
726 "null", | |
727 "", | |
728 "", | |
729 open_s, | |
730 { "dvdnav", NULL }, | |
731 &stream_opts, | |
732 1 // Urls are an option string | |
733 }; |