annotate stream/stream_dvdnav.c @ 36704:a37f9abea303

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