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