annotate stream/stream_dvdnav.c @ 19382:7c6c205b88b6

trying to fix the reverting paragraph if you dissagree, dont hesitate to revert this commit or flame, but at least we should not claim that svn cannot revert commits except by recommiting the old version
author michael
date Sun, 13 Aug 2006 22:14:32 +0000
parents ab8d6b6deb63
children 6e618d1fbb23
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 = {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
26 1,
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
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
54 dvdnav_priv_t * new_dvdnav_stream(char * filename) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
55 char * title_str;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
56 dvdnav_priv_t *dvdnav_priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
57
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
58 if (!filename)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
59 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
60
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
61 if (!(dvdnav_priv=calloc(1,sizeof(*dvdnav_priv))))
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
62 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
63
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
64 if (!(dvdnav_priv->filename=strdup(filename))) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
65 free(dvdnav_priv);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
66 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
67 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
68
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
69 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
70 {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
71 free(dvdnav_priv->filename);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
72 free(dvdnav_priv);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
73 return 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 if (!dvdnav_priv->dvdnav) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
77 free(dvdnav_priv);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
78 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
79 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
80
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
81 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
82 {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
83 int len, event;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
84 char buf[2048];
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
85
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
86 dvdnav_get_next_block(dvdnav_priv->dvdnav,buf,&event,&len);
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
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
89 /* turn on dvdnav caching */
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
90 dvdnav_set_readahead_flag(dvdnav_priv->dvdnav, 0);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
91 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
92 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
93 #if 1
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
94 /* report the title?! */
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
95 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
96 mp_msg(MSGT_IDENTIFY, MSGL_INFO,"Title: '%s'\n",title_str);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
97 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
98 #endif
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
99
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
100 //dvdnav_event_clear(dvdnav_priv);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
101
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
102 return dvdnav_priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
103 }
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 int dvdnav_stream_reset(dvdnav_priv_t * dvdnav_priv) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
106 if (!dvdnav_priv) return 0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
107
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
108 // if (dvdnav_reset(dvdnav_priv->dvdnav)!=DVDNAV_STATUS_OK)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
109 return 0;
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 dvdnav_priv->started=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
112
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
113 return 1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
114 }
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 int dvdnav_stream_sleeping(dvdnav_priv_t * dvdnav_priv) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
117 unsigned int now;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
118
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
119 if (!dvdnav_priv) return 0;
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 if(dvdnav_priv->sleeping)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
122 {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
123 now=GetTimer();
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
124 while(dvdnav_priv->sleeping>1 || now<dvdnav_priv->sleep_until) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
125 // printf("%s %u<%u\n",__FUNCTION__,now,dvdnav_priv->sleep_until);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
126 // usec_sleep(1000); /* 1ms granularity */
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
127 return 1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
128 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
129 dvdnav_still_skip(dvdnav_priv->dvdnav); // continue past...
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
130 dvdnav_priv->sleeping=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
131 mp_msg(MSGT_OPEN,MSGL_V, "%s: woke up!\n",__FUNCTION__);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
132 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
133 dvd_nav_still=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
134 mp_msg(MSGT_OPEN,MSGL_V, "%s: active\n",__FUNCTION__);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
135 return 0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
136 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
137
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
138 void dvdnav_stream_sleep(dvdnav_priv_t * dvdnav_priv, int seconds) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
139 if (!dvdnav_priv) return;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
140
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
141 if (!dvdnav_priv->started) return;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
142
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
143 dvdnav_priv->sleeping=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
144 switch (seconds) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
145 case 0:
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
146 return;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
147 case 0xff:
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
148 mp_msg(MSGT_OPEN,MSGL_V, "Sleeping indefinately\n" );
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
149 dvdnav_priv->sleeping=2;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
150 break;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
151 default:
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
152 mp_msg(MSGT_OPEN,MSGL_V, "Sleeping %d sec(s)\n", seconds );
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
153 dvdnav_priv->sleep_until = GetTimer();// + seconds*1000000;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
154 dvdnav_priv->sleeping=1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
155 break;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
156 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
157 //if (dvdnav_priv->started) dvd_nav_still=1;
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
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
160 void dvdnav_stream_add_event(dvdnav_priv_t* dvdnav_priv, int event, unsigned char *buf, int len) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
161 //printf("%s: %d\n",__FUNCTION__,event);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
162
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
163 dvdnav_event_t * dvdnav_event;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
164 mp_cmd_t * cmd;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
165
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
166 if (!dvdnav_priv->started) return;
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 if (!(dvdnav_event=calloc(1,sizeof(*dvdnav_event)))) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
169 mp_msg(MSGT_OPEN,MSGL_V, "%s: dvdnav_event: out of memory!\n",__FUNCTION__);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
170 return;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
171 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
172 dvdnav_event->event=event;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
173 dvdnav_event->details=calloc(1,len);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
174 memcpy(dvdnav_event->details,buf,len);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
175 dvdnav_event->len=len;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
176
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
177 if (!(cmd = calloc(1,sizeof(*cmd)))) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
178 mp_msg(MSGT_OPEN,MSGL_V, "%s: mp_cmd_t: out of memory!\n",__FUNCTION__);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
179 free(dvdnav_event->details);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
180 free(dvdnav_event);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
181 return;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
182 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
183 cmd->id=MP_CMD_DVDNAV_EVENT; // S+event;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
184 cmd->name=strdup("dvdnav_event"); // FIXME: do I really need a 'name'?
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
185 cmd->nargs=1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
186 cmd->args[0].v.v=dvdnav_event;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
187 }
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 int dvdnav_stream_read(dvdnav_priv_t * dvdnav_priv, unsigned char *buf, int *len) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
190 int event = DVDNAV_NOP;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
191
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
192 if (!len) return -1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
193 *len=-1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
194 if (!dvdnav_priv) return -1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
195 if (!buf) return -1;
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 if (dvd_nav_still) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
198 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
199 *len=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
200 return -1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
201 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
202
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
203 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
204 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
205 *len=-1;
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 else if (event!=DVDNAV_BLOCK_OK) {
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 // need to handle certain events internally (like skipping stills)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
210 switch (event) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
211 case DVDNAV_STILL_FRAME: {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
212 dvdnav_still_event_t *still_event = (dvdnav_still_event_t*)(buf);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
213 //if (dvdnav_priv->started) dvd_nav_still=1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
214 //else
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
215 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
216
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
217 break;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
218 case DVDNAV_WAIT:
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
219 dvdnav_wait_skip(dvdnav_priv->dvdnav);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
220 break;
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 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
223
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
224 // got an event, repeat the read
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
225 dvdnav_stream_add_event(dvdnav_priv,event,buf,*len);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
226 *len=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
227 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
228 // printf("%s: got %d\n",__FUNCTION__,*len);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
229 return event;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
230 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
231
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
232 void dvdnav_stream_fullstart(dvdnav_priv_t * dvdnav_priv) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
233 if (dvdnav_priv && !dvdnav_priv->started) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
234 dvdnav_stream_reset(dvdnav_priv);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
235 dvdnav_priv->started=1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
236 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
237 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
238
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
239 unsigned int * dvdnav_stream_get_palette(dvdnav_priv_t * dvdnav_priv) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
240 if (!dvdnav_priv) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
241 mp_msg(MSGT_OPEN,MSGL_V, "%s: NULL dvdnav_priv\n",__FUNCTION__);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
242 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
243 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
244 if (!dvdnav_priv->dvdnav) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
245 mp_msg(MSGT_OPEN,MSGL_V, "%s: NULL dvdnav_priv->dvdnav\n",__FUNCTION__);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
246 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
247 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
248 #if 0
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
249 if (!dvdnav_priv->dvdnav->vm) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
250 mp_msg(MSGT_OPEN,MSGL_V, "%s: NULL dvdnav_priv->dvdnav->vm\n",__FUNCTION__);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
251 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
252 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
253 if (!dvdnav_priv->dvdnav->vm->state.pgc) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
254 printf("%s: NULL dvdnav_priv->dvdnav->vm->state.pgc\n",__FUNCTION__);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
255 return NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
256 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
257 return dvdnav_priv->dvdnav->vm->state.pgc->palette;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
258 #endif
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
259 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
260
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
261 static void update_title_len(stream_t *stream) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
262 dvdnav_priv_t *priv = stream->priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
263 dvdnav_status_t status;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
264 uint32_t pos = 0, len = 0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
265
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
266 status = dvdnav_get_position(priv->dvdnav, &pos, &len);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
267 if(status == DVDNAV_STATUS_OK && len)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
268 stream->end_pos = (off_t) len * 2048;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
269 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
270
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
271
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
272 static int seek(stream_t *s, off_t newpos) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
273 uint32_t pos = 0, len = 0, sector = 0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
274 dvdnav_priv_t *priv = s->priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
275
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
276 if(newpos==0) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
277 if(dvdnav_stream_reset(priv->dvdnav))
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
278 s->pos=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
279 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
280 else {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
281 if(s->end_pos && newpos > s->end_pos)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
282 newpos = s->end_pos;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
283 sector = newpos / 2048ULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
284 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
285 goto fail;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
286
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
287 s->pos = newpos;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
288 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
289
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
290 return 1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
291
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
292 fail:
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
293 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
294
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
295 return 1;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
296 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
297
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
298 static void stream_dvdnav_close(stream_t *s) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
299 dvdnav_priv_t *priv = s->priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
300 dvdnav_close(priv->dvdnav);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
301 priv->dvdnav = NULL;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
302 free(priv);
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
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
305
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
306 static int fill_buffer(stream_t *s, char *but, int len)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
307 {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
308 int event;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
309 dvdnav_priv_t* dvdnav_priv=s->priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
310 len=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
311 if(!s->end_pos)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
312 update_title_len(s);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
313 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
314 {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
315 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
316 {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
317 mp_msg(MSGT_CPLAYER,MSGL_ERR, "DVDNAV stream read error!\n");
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
318 return 0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
319 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
320 switch (event) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
321 case DVDNAV_STOP: return len;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
322 case DVDNAV_BLOCK_OK: return len;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
323 #if 0
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
324 case DVDNAV_STILL_FRAME: {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
325 if(!dvdnav_priv->stillok) dvdnav_priv->stillcounter++;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
326 dvdnav_priv->lockstillcounter++;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
327 return len;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
328 break;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
329 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
330
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
331 case DVDNAV_WAIT: {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
332 if(dvdnav_priv->waitcounter>=DVDNAV_MAX_WAIT_FRAME) return len;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
333 break;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
334 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
335 #endif
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
336 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
337 #if 0
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
338 if(dvdnav_priv->event.cell_really_change &&
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
339 dvdnav_priv->started &&
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
340 !dvdnav_priv->vts_domain)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
341 return len;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
342 #endif
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
343 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
344 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
345 return len;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
346 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
347
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
348 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
349 struct stream_priv_s* p = (struct stream_priv_s*)opts;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
350 char *filename;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
351 int event,len,tmplen=0;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
352 uint32_t pos, l2;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
353 dvdnav_priv_t *dvdnav_priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
354 dvdnav_status_t status;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
355
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
356 //mp_msg(MSGT_OPEN,MSGL_INFO,"URL: %s\n", filename);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
357
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
358 if(p->device) filename = p->device;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
359 else if(dvd_device) filename= dvd_device;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
360 else filename = DEFAULT_DVD_DEVICE;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
361 if(!(dvdnav_priv=new_dvdnav_stream(filename))) {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
362 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
363 return STREAM_UNSUPORTED;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
364 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
365
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
366 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
367 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
368 return STREAM_UNSUPORTED;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
369 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
370
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
371 stream->sector_size = 2048;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
372 stream->flags = STREAM_READ | STREAM_SEEK;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
373 stream->fill_buffer = fill_buffer;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
374 stream->seek = seek;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
375 stream->close = stream_dvdnav_close;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
376 stream->type = STREAMTYPE_DVDNAV;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
377 stream->priv=(void*)dvdnav_priv;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
378 *file_format = DEMUXER_TYPE_MPEG_PS;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
379
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
380 update_title_len(stream);
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
381 if(!stream->pos)
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
382 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));
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
383
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
384 return STREAM_OK;
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
385 }
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
386
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
387 stream_info_t stream_info_dvdnav = {
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
388 "DVDNAV stream",
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
389 "null",
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
390 "",
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
391 "",
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
392 open_s,
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
393 { "dvdnav", NULL },
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
394 &stream_opts,
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
395 1 // Urls are an option string
cc4774869fbc renamed dvdnav_stream to stream_dvdnav for consistency
ben
parents:
diff changeset
396 };