annotate stream/stream_dvdnav.c @ 20304:c9c6db3c2645

Remove stray line.
author diego
date Thu, 19 Oct 2006 21:00:35 +0000
parents b0a938df89ed
children a11a208925b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
1 #include "config.h"
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
2
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
3 #include <stdlib.h>
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
4 #include <stdio.h>
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
5 #include <unistd.h>
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
6 #include <string.h>
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
7 #include "mp_msg.h"
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
8 #include "osdep/timer.h"
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
9 #include "input/input.h"
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
10 #include "stream.h"
19312
ab8d6b6deb63 proper inclusion of demuxer.h (including libmpdemux in Makefile only was to make previous split easier)
ben
parents: 19302
diff changeset
11 #include "libmpdemux/demuxer.h"
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
12 #include "stream_dvdnav.h"
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
13 #include "libvo/video_out.h"
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
14 #include "spudec.h"
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
15 #include "m_option.h"
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
16 #include "m_struct.h"
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
17 #include "help_mp.h"
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
18
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
19 extern char *dvd_device;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
20 extern char *audio_lang, *dvdsub_lang;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
21
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
22 static struct stream_priv_s {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
23 int track;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
24 char* device;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
25 } 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
26 0,
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
27 NULL
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
28 };
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
29
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
30 #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
31 /// URL definition
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
32 static m_option_t stream_opts_fields[] = {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
33 {"filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL },
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
34 {"hostname", ST_OFF(track), CONF_TYPE_INT, 0, 0, 0, NULL},
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
35 { NULL, NULL, 0, 0, 0, 0, NULL }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
36 };
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
37 static struct m_struct_st stream_opts = {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
38 "dvd",
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
39 sizeof(struct stream_priv_s),
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
40 &stream_priv_dflts,
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
41 stream_opts_fields
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
42 };
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
43
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
44 int dvd_nav_skip_opening=0; /* skip opening stalls? */
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
45 int osd_show_dvd_nav_delay=0; /* count down for dvd nav text on OSD */
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
46 char dvd_nav_text[50]; /* for reporting stuff to OSD */
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
47 int osd_show_dvd_nav_highlight; /* show highlight area */
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
48 int osd_show_dvd_nav_sx; /* start x .... */
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
49 int osd_show_dvd_nav_ex;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
50 int osd_show_dvd_nav_sy;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
51 int osd_show_dvd_nav_ey;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
52 int dvd_nav_still=0; /* are we on a still picture? */
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
53
19892
2c361743ce69 don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents: 19851
diff changeset
54 static int seek(stream_t *s, off_t newpos);
2c361743ce69 don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents: 19851
diff changeset
55
19914
dfd1bb3fc7c0 made file-static new_dvdnav_stream() and dvdnav_stream_read()
nicodvb
parents: 19912
diff changeset
56 static dvdnav_priv_t * new_dvdnav_stream(char * filename) {
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
57 char * title_str;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
58 dvdnav_priv_t *dvdnav_priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
59
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
60 if (!filename)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
61 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
62
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
63 if (!(dvdnav_priv=calloc(1,sizeof(*dvdnav_priv))))
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
64 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
65
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
66 if (!(dvdnav_priv->filename=strdup(filename))) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
67 free(dvdnav_priv);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
68 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
69 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
70
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
71 if(dvdnav_open(&(dvdnav_priv->dvdnav),dvdnav_priv->filename)!=DVDNAV_STATUS_OK)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
72 {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
73 free(dvdnav_priv->filename);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
74 free(dvdnav_priv);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
75 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
76 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
77
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
78 if (!dvdnav_priv->dvdnav) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
79 free(dvdnav_priv);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
80 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
81 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
82
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
83 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
84 {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
85 int len, event;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
86 char buf[2048];
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
87
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
88 dvdnav_get_next_block(dvdnav_priv->dvdnav,buf,&event,&len);
19781
61cc28c4236a at start, reset dvdnav at the beginning of the stream after the first read (that is done to workaround a bug in dvdnav from cvs)
nicodvb
parents: 19780
diff changeset
89 dvdnav_sector_search(dvdnav_priv->dvdnav, 0, SEEK_SET);
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
90 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
91
19454
b9a62caeb61b corrected _very_ misleading comment
nicodvb
parents: 19453
diff changeset
92 /* turn off dvdnav caching */
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
93 dvdnav_set_readahead_flag(dvdnav_priv->dvdnav, 0);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
94 if(dvdnav_set_PGC_positioning_flag(dvdnav_priv->dvdnav, 1) != DVDNAV_STATUS_OK)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
95 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
96 #if 1
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
97 /* report the title?! */
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
98 if (dvdnav_get_title_string(dvdnav_priv->dvdnav,&title_str)==DVDNAV_STATUS_OK) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
99 mp_msg(MSGT_IDENTIFY, MSGL_INFO,"Title: '%s'\n",title_str);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
100 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
101 #endif
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
102
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
103 //dvdnav_event_clear(dvdnav_priv);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
104
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
105 return dvdnav_priv;
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
19914
dfd1bb3fc7c0 made file-static new_dvdnav_stream() and dvdnav_stream_read()
nicodvb
parents: 19912
diff changeset
108 static int dvdnav_stream_read(dvdnav_priv_t * dvdnav_priv, unsigned char *buf, int *len) {
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
109 int event = DVDNAV_NOP;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
110
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
111 if (!len) return -1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
112 *len=-1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
113 if (!dvdnav_priv) return -1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
114 if (!buf) return -1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
115
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
116 if (dvd_nav_still) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
117 mp_msg(MSGT_OPEN,MSGL_V, "%s: got a stream_read while I should be asleep!\n",__FUNCTION__);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
118 *len=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
119 return -1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
120 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
121
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
122 if (dvdnav_get_next_block(dvdnav_priv->dvdnav,buf,&event,len)!=DVDNAV_STATUS_OK) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
123 mp_msg(MSGT_OPEN,MSGL_V, "Error getting next block from DVD %d (%s)\n",event, dvdnav_err_to_string(dvdnav_priv->dvdnav) );
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
124 *len=-1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
125 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
126 else if (event!=DVDNAV_BLOCK_OK) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
127
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
128 // need to handle certain events internally (like skipping stills)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
129 switch (event) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
130 case DVDNAV_STILL_FRAME: {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
131 dvdnav_still_event_t *still_event = (dvdnav_still_event_t*)(buf);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
132 //if (dvdnav_priv->started) dvd_nav_still=1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
133 //else
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
134 dvdnav_still_skip(dvdnav_priv->dvdnav); // don't let dvdnav stall on this image
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
135
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
136 break;
19451
0ceeedf7f04d 10l: misplaced brace in a switch
nicodvb
parents: 19443
diff changeset
137 }
19453
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
138 case DVDNAV_CELL_CHANGE: {
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
139 dvdnav_cell_change_event_t *ev = (dvdnav_cell_change_event_t*)buf;
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
140 if(ev->pgc_length)
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
141 dvdnav_priv->duration = ev->pgc_length/90;
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
142 break;
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
143 }
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
144 case DVDNAV_WAIT:
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
145 dvdnav_wait_skip(dvdnav_priv->dvdnav);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
146 break;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
147 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
148
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
149 *len=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
150 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
151 return event;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
152 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
153
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
154 static void update_title_len(stream_t *stream) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
155 dvdnav_priv_t *priv = stream->priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
156 dvdnav_status_t status;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
157 uint32_t pos = 0, len = 0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
158
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
159 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
160 if(status == DVDNAV_STATUS_OK && len) {
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
161 stream->end_pos = (off_t) len * 2048;
19892
2c361743ce69 don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents: 19851
diff changeset
162 stream->seek = seek;
2c361743ce69 don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents: 19851
diff changeset
163 } else {
2c361743ce69 don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents: 19851
diff changeset
164 stream->seek = NULL;
2c361743ce69 don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents: 19851
diff changeset
165 stream->end_pos = 0;
2c361743ce69 don't seek until dvdnav_get_position() returns something meaningful
nicodvb
parents: 19851
diff changeset
166 }
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
167 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
168
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
169
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
170 static int seek(stream_t *s, off_t newpos) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
171 uint32_t pos = 0, len = 0, sector = 0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
172 dvdnav_priv_t *priv = s->priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
173
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
174 if(s->end_pos && newpos > s->end_pos)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
175 newpos = s->end_pos;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
176 sector = newpos / 2048ULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
177 if(dvdnav_sector_search(priv->dvdnav, (uint64_t) sector, SEEK_SET) != DVDNAV_STATUS_OK)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
178 goto fail;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
179
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
180 s->pos = newpos;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
181
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
182 return 1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
183
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
184 fail:
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
185 mp_msg(MSGT_STREAM,MSGL_INFO,"dvdnav_stream, seeking to %"PRIu64" failed: %s\n", newpos, dvdnav_err_to_string(priv->dvdnav));
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
186
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
187 return 1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
188 }
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 static void stream_dvdnav_close(stream_t *s) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
191 dvdnav_priv_t *priv = s->priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
192 dvdnav_close(priv->dvdnav);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
193 priv->dvdnav = NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
194 free(priv);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
195 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
196
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
197
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
198 static int fill_buffer(stream_t *s, char *but, int len)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
199 {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
200 int event;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
201 dvdnav_priv_t* dvdnav_priv=s->priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
202 len=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
203 if(!s->end_pos)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
204 update_title_len(s);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
205 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
206 {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
207 if(-1==(event=dvdnav_stream_read(dvdnav_priv, s->buffer, &len)) || len==-1)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
208 {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
209 mp_msg(MSGT_CPLAYER,MSGL_ERR, "DVDNAV stream read error!\n");
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
210 return 0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
211 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
212 switch (event) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
213 case DVDNAV_STOP: return len;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
214 case DVDNAV_BLOCK_OK: return len;
19893
9440915a76f1 at titleset change call update_title_len() to reset stream->end_pos
nicodvb
parents: 19892
diff changeset
215 case DVDNAV_VTS_CHANGE: {
19894
bec5c0d5fb17 in the previous commit I forgot to set s->end_pos=0
nicodvb
parents: 19893
diff changeset
216 s->end_pos = 0;
19893
9440915a76f1 at titleset change call update_title_len() to reset stream->end_pos
nicodvb
parents: 19892
diff changeset
217 update_title_len(s);
9440915a76f1 at titleset change call update_title_len() to reset stream->end_pos
nicodvb
parents: 19892
diff changeset
218 break;
9440915a76f1 at titleset change call update_title_len() to reset stream->end_pos
nicodvb
parents: 19892
diff changeset
219 }
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
220 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
221 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
222 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
223 return len;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
224 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
225
19443
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
226 static int control(stream_t *stream, int cmd, void* arg) {
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
227 dvdnav_priv_t* dvdnav_priv=stream->priv;
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
228 int tit, part;
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
229
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
230 switch(cmd)
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
231 {
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
232 case STREAM_CTRL_SEEK_TO_CHAPTER:
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
233 {
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
234 int chap = *((unsigned int *)arg)+1;
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
235
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
236 if(chap < 1 || dvdnav_current_title_info(dvdnav_priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK)
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
237 break;
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
238 if(dvdnav_part_play(dvdnav_priv->dvdnav, tit, chap) != DVDNAV_STATUS_OK)
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
239 break;
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
240 return 1;
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
241 }
19477
2a6520a36e96 implemented STREAM_CTRL_GET_NUM_CHAPTERS
nicodvb
parents: 19454
diff changeset
242 case STREAM_CTRL_GET_NUM_CHAPTERS:
2a6520a36e96 implemented STREAM_CTRL_GET_NUM_CHAPTERS
nicodvb
parents: 19454
diff changeset
243 {
2a6520a36e96 implemented STREAM_CTRL_GET_NUM_CHAPTERS
nicodvb
parents: 19454
diff changeset
244 if(dvdnav_current_title_info(dvdnav_priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK)
2a6520a36e96 implemented STREAM_CTRL_GET_NUM_CHAPTERS
nicodvb
parents: 19454
diff changeset
245 break;
2a6520a36e96 implemented STREAM_CTRL_GET_NUM_CHAPTERS
nicodvb
parents: 19454
diff changeset
246 if(dvdnav_get_number_of_parts(dvdnav_priv->dvdnav, tit, &part) != DVDNAV_STATUS_OK)
2a6520a36e96 implemented STREAM_CTRL_GET_NUM_CHAPTERS
nicodvb
parents: 19454
diff changeset
247 break;
2a6520a36e96 implemented STREAM_CTRL_GET_NUM_CHAPTERS
nicodvb
parents: 19454
diff changeset
248 if(!part)
2a6520a36e96 implemented STREAM_CTRL_GET_NUM_CHAPTERS
nicodvb
parents: 19454
diff changeset
249 break;
2a6520a36e96 implemented STREAM_CTRL_GET_NUM_CHAPTERS
nicodvb
parents: 19454
diff changeset
250 *((unsigned int *)arg) = part;
2a6520a36e96 implemented STREAM_CTRL_GET_NUM_CHAPTERS
nicodvb
parents: 19454
diff changeset
251 return 1;
2a6520a36e96 implemented STREAM_CTRL_GET_NUM_CHAPTERS
nicodvb
parents: 19454
diff changeset
252 }
19443
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
253 case STREAM_CTRL_GET_CURRENT_CHAPTER:
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
254 {
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
255 if(dvdnav_current_title_info(dvdnav_priv->dvdnav, &tit, &part) != DVDNAV_STATUS_OK)
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
256 break;
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
257 *((unsigned int *)arg) = part - 1;
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
258 return 1;
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
259 }
19453
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
260 case STREAM_CTRL_GET_TIME_LENGTH:
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
261 {
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
262 if(dvdnav_priv->duration)
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
263 {
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
264 *((unsigned int *)arg) = dvdnav_priv->duration;
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
265 return 1;
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
266 }
087d4a916ea3 implemented STREAM_CTRL_GET_TIME_LENGTH (duration of the pgc playing)
nicodvb
parents: 19452
diff changeset
267 }
19443
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
268 }
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
269
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
270 return STREAM_UNSUPORTED;
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
271 }
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
272
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
273 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
274 struct stream_priv_s* p = (struct stream_priv_s*)opts;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
275 char *filename;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
276 int event,len,tmplen=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
277 uint32_t pos, l2;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
278 dvdnav_priv_t *dvdnav_priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
279 dvdnav_status_t status;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
280
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
281 if(p->device) filename = p->device;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
282 else if(dvd_device) filename= dvd_device;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
283 else filename = DEFAULT_DVD_DEVICE;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
284 if(!(dvdnav_priv=new_dvdnav_stream(filename))) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
285 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
286 return STREAM_UNSUPORTED;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
287 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
288
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
289 if(p->track > 0) {
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
290 if(dvdnav_title_play(dvdnav_priv->dvdnav, p->track) != DVDNAV_STATUS_OK) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
291 mp_msg(MSGT_OPEN,MSGL_FATAL,"dvdnav_stream, couldn't select title %d, error '%s'\n", p->track, dvdnav_err_to_string(dvdnav_priv->dvdnav));
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
292 return STREAM_UNSUPORTED;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
293 }
19780
49d6e27228bc try to start from the root menu skipping all intros when playing dvdnav://-1; it's not guaranteed to work
nicodvb
parents: 19777
diff changeset
294 } else if(p->track == -1)
49d6e27228bc try to start from the root menu skipping all intros when playing dvdnav://-1; it's not guaranteed to work
nicodvb
parents: 19777
diff changeset
295 dvdnav_menu_call(dvdnav_priv->dvdnav, DVD_MENU_Root);
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
296 else {
19764
499e5525d706 if no track number specified play the whole disc, or the menus can't be shown at start
nicodvb
parents: 19477
diff changeset
297 mp_msg(MSGT_OPEN,MSGL_INFO,"dvdnav_stream, you didn't specify a track number (as in dvdnav://1), playing whole disc\n");
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
298 dvdnav_menu_call(dvdnav_priv->dvdnav, DVD_MENU_Title);
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
299 }
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 stream->sector_size = 2048;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
302 stream->flags = STREAM_READ | STREAM_SEEK;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
303 stream->fill_buffer = fill_buffer;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
304 stream->seek = seek;
19443
6e618d1fbb23 implemented seeking to chapter
nicodvb
parents: 19312
diff changeset
305 stream->control = control;
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
306 stream->close = stream_dvdnav_close;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
307 stream->type = STREAMTYPE_DVDNAV;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
308 stream->priv=(void*)dvdnav_priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
309 *file_format = DEMUXER_TYPE_MPEG_PS;
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 update_title_len(stream);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
312 if(!stream->pos)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
313 mp_msg(MSGT_OPEN,MSGL_ERR, "INIT ERROR: %d, couldn't get init pos %s\r\n", status, dvdnav_err_to_string(dvdnav_priv->dvdnav));
20026
b0a938df89ed warn the user to disable the cache when playing dvdnav streams
nicodvb
parents: 19914
diff changeset
314
b0a938df89ed warn the user to disable the cache when playing dvdnav streams
nicodvb
parents: 19914
diff changeset
315 mp_msg(MSGT_OPEN,MSGL_INFO, "Remember to disable MPlayer's cache when playing dvdnav:// streams (adding -nocache to your command like)\r\n");
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
316
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
317 return STREAM_OK;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
318 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
319
19768
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
320
19774
109e241c0cca in mp_dvdnav_handle_input() assign the currently selected button, shown in the OSD by main()
nicodvb
parents: 19768
diff changeset
321 int mp_dvdnav_handle_input(stream_t *stream, int cmd, int *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
322 dvdnav_priv_t * dvdnav_priv=(dvdnav_priv_t*)stream->priv;
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
323 dvdnav_t *nav = dvdnav_priv->dvdnav;
19908
b6aa47caeb72 §Ænitial button value is -1. Only (button>0) is a correct button selection.
jonas
parents: 19895
diff changeset
324 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
325 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
326 int reset = 0;
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
327
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
328 if(cmd != MP_CMD_DVDNAV_SELECT && !pci)
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
329 return 0;
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
330
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
331 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
332 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
333 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
334 break;
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
335 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
336 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
337 break;
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
338 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
339 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
340 break;
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
341 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
342 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
343 break;
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
344 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
345 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
346 reset = 1;
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
347 break;
19777
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
348 case MP_CMD_DVDNAV_PREVMENU: {
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
349 int title=0, part=0;
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
350
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
351 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
352 if(title) {
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
353 if(dvdnav_menu_call(nav, DVD_MENU_Part) == DVDNAV_STATUS_OK
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
354 || dvdnav_menu_call(nav, DVD_MENU_Title) == DVDNAV_STATUS_OK) {
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
355 reset = 1;
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
356 break;
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
357 }
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
358 }
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
359 if(dvdnav_menu_call(nav, DVD_MENU_Root) == DVDNAV_STATUS_OK)
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
360 reset = 1;
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
361 }
bb1b570ac7c1 permit to select previous dvdnav menu, in the order chapter->title->root
nicodvb
parents: 19774
diff changeset
362 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
363 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
364 status = dvdnav_button_activate(nav, pci);
19836
9470f7630ee4 when cmd == MP_CMD_DVDNAV_SELECT set reset=1 only if dvdnav_button_activate() succeeds, to avoid unneeded resets in main()
nicodvb
parents: 19781
diff changeset
365 if(status == DVDNAV_STATUS_OK) reset = 1;
19768
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
366 break;
19912
3fdb44285fe7 introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents: 19909
diff changeset
367 case MP_CMD_DVDNAV_MOUSECLICK:
3fdb44285fe7 introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents: 19909
diff changeset
368 /*
3fdb44285fe7 introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents: 19909
diff changeset
369 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
370 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
371 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
372 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
373 This last call always works well
3fdb44285fe7 introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents: 19909
diff changeset
374 */
3fdb44285fe7 introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents: 19909
diff changeset
375 status = dvdnav_mouse_activate(nav, pci, dvdnav_priv->mousex, dvdnav_priv->mousey);
3fdb44285fe7 introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents: 19909
diff changeset
376 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
377 default:
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
378 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
379 break;
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
380 }
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
381
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
382 if(status == DVDNAV_STATUS_OK)
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
383 dvdnav_get_current_highlight(nav, button);
19774
109e241c0cca in mp_dvdnav_handle_input() assign the currently selected button, shown in the OSD by main()
nicodvb
parents: 19768
diff changeset
384
19768
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
385 return reset;
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
386 }
1069a634fc92 added mp_dvdnav_handle_input to handle user's input (revived from the repository with few changes)
nicodvb
parents: 19764
diff changeset
387
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
388 void mp_dvdnav_update_mouse_pos(stream_t *stream, int32_t x, int32_t y, int* 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
389 dvdnav_priv_t * dvdnav_priv=(dvdnav_priv_t*)stream->priv;
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
390 dvdnav_t *nav = dvdnav_priv->dvdnav;
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
391 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
392 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
393
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
394 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
395
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
396 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
397 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
398 else *button = -1;
19912
3fdb44285fe7 introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents: 19909
diff changeset
399 dvdnav_priv->mousex = x;
3fdb44285fe7 introduced new MP_CMD_DVDNAV_MOUSECLICK command (bound to mouse0);
nicodvb
parents: 19909
diff changeset
400 dvdnav_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
401 }
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
402
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
403
19302
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
404 stream_info_t stream_info_dvdnav = {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
405 "DVDNAV stream",
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
406 "null",
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
407 "",
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
408 "",
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
409 open_s,
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
410 { "dvdnav", NULL },
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
411 &stream_opts,
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
412 1 // Urls are an option string
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
413 };