Mercurial > mplayer.hg
annotate libmpdemux/dvdnav_stream.c @ 18898:a1eb5320279e
respect dvdnav's requests of WAIT to prevent while(1)
author | nicodvb |
---|---|
date | Tue, 04 Jul 2006 21:12:12 +0000 |
parents | 5c8acc972551 |
children | d2d9d011203f |
rev | line source |
---|---|
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
1 #include "config.h" |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
2 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
3 #ifdef USE_DVDNAV |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
4 #include <stdlib.h> |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
5 #include <stdio.h> |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
6 #include <unistd.h> |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
7 #include <string.h> |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
8 #include "mp_msg.h" |
17012 | 9 #include "osdep/timer.h" |
10 #include "input/input.h" | |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
11 #include "stream.h" |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
12 #include "demuxer.h" |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
13 #include "dvdnav_stream.h" |
17012 | 14 #include "libvo/video_out.h" |
15 #include "spudec.h" | |
16 #include "m_option.h" | |
17 #include "m_struct.h" | |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
18 #include "help_mp.h" |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
19 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
20 extern char *dvd_device; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
21 extern char *audio_lang, *dvdsub_lang; |
15518 | 22 |
23 static struct stream_priv_s { | |
24 int track; | |
25 char* device; | |
26 } stream_priv_dflts = { | |
27 1, | |
28 NULL | |
29 }; | |
30 | |
31 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f) | |
32 /// URL definition | |
33 static m_option_t stream_opts_fields[] = { | |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
34 {"filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
35 {"hostname", ST_OFF(track), CONF_TYPE_INT, 0, 0, 0, NULL}, |
15518 | 36 { NULL, NULL, 0, 0, 0, 0, NULL } |
37 }; | |
38 static struct m_struct_st stream_opts = { | |
39 "dvd", | |
40 sizeof(struct stream_priv_s), | |
41 &stream_priv_dflts, | |
42 stream_opts_fields | |
43 }; | |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
44 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
45 int dvd_nav_skip_opening=0; /* skip opening stalls? */ |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
46 int osd_show_dvd_nav_delay=0; /* count down for dvd nav text on OSD */ |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
47 char dvd_nav_text[50]; /* for reporting stuff to OSD */ |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
48 int osd_show_dvd_nav_highlight; /* show highlight area */ |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
49 int osd_show_dvd_nav_sx; /* start x .... */ |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
50 int osd_show_dvd_nav_ex; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
51 int osd_show_dvd_nav_sy; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
52 int osd_show_dvd_nav_ey; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
53 int dvd_nav_still=0; /* are we on a still picture? */ |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
54 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
55 dvdnav_priv_t * new_dvdnav_stream(char * filename) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
56 char * title_str; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
57 dvdnav_priv_t *dvdnav_priv; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
58 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
59 if (!filename) |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
60 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
61 |
18885 | 62 if (!(dvdnav_priv=calloc(1,sizeof(*dvdnav_priv)))) |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
63 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
64 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
65 if (!(dvdnav_priv->filename=strdup(filename))) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
66 free(dvdnav_priv); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
67 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
68 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
69 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
70 if(dvdnav_open(&(dvdnav_priv->dvdnav),dvdnav_priv->filename)!=DVDNAV_STATUS_OK) |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
71 { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
72 free(dvdnav_priv->filename); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
73 free(dvdnav_priv); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
74 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
75 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
76 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
77 if (!dvdnav_priv->dvdnav) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
78 free(dvdnav_priv); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
79 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
80 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
81 |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
82 if(1) //from vlc: if not used dvdnav from cvs will fail |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
83 { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
84 int len, event; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
85 char buf[2048]; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
86 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
87 dvdnav_get_next_block(dvdnav_priv->dvdnav,buf,&event,&len); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
88 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
89 |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
90 /* turn on dvdnav caching */ |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
91 dvdnav_set_readahead_flag(dvdnav_priv->dvdnav, 0); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
92 if(dvdnav_set_PGC_positioning_flag(dvdnav_priv->dvdnav, 1) != DVDNAV_STATUS_OK) |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
93 mp_msg(MSGT_OPEN,MSGL_ERR,"stream_dvdnav, failed to set PGC positioning\n"); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
94 #if 1 |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
95 /* report the title?! */ |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
96 if (dvdnav_get_title_string(dvdnav_priv->dvdnav,&title_str)==DVDNAV_STATUS_OK) { |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
97 mp_msg(MSGT_IDENTIFY, MSGL_INFO,"Title: '%s'\n",title_str); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
98 } |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
99 #endif |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
100 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
101 //dvdnav_event_clear(dvdnav_priv); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
102 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
103 return dvdnav_priv; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
104 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
105 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
106 int dvdnav_stream_reset(dvdnav_priv_t * dvdnav_priv) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
107 if (!dvdnav_priv) return 0; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
108 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
109 // if (dvdnav_reset(dvdnav_priv->dvdnav)!=DVDNAV_STATUS_OK) |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
110 return 0; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
111 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
112 dvdnav_priv->started=0; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
113 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
114 return 1; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
115 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
116 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
117 int dvdnav_stream_sleeping(dvdnav_priv_t * dvdnav_priv) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
118 unsigned int now; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
119 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
120 if (!dvdnav_priv) return 0; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
121 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
122 if(dvdnav_priv->sleeping) |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
123 { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
124 now=GetTimer(); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
125 while(dvdnav_priv->sleeping>1 || now<dvdnav_priv->sleep_until) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
126 // printf("%s %u<%u\n",__FUNCTION__,now,dvdnav_priv->sleep_until); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
127 // usec_sleep(1000); /* 1ms granularity */ |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
128 return 1; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
129 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
130 dvdnav_still_skip(dvdnav_priv->dvdnav); // continue past... |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
131 dvdnav_priv->sleeping=0; |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
132 mp_msg(MSGT_OPEN,MSGL_V, "%s: woke up!\n",__FUNCTION__); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
133 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
134 dvd_nav_still=0; |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
135 mp_msg(MSGT_OPEN,MSGL_V, "%s: active\n",__FUNCTION__); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
136 return 0; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
137 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
138 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
139 void dvdnav_stream_sleep(dvdnav_priv_t * dvdnav_priv, int seconds) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
140 if (!dvdnav_priv) return; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
141 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
142 if (!dvdnav_priv->started) return; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
143 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
144 dvdnav_priv->sleeping=0; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
145 switch (seconds) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
146 case 0: |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
147 return; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
148 case 0xff: |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
149 mp_msg(MSGT_OPEN,MSGL_V, "Sleeping indefinately\n" ); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
150 dvdnav_priv->sleeping=2; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
151 break; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
152 default: |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
153 mp_msg(MSGT_OPEN,MSGL_V, "Sleeping %d sec(s)\n", seconds ); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
154 dvdnav_priv->sleep_until = GetTimer();// + seconds*1000000; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
155 dvdnav_priv->sleeping=1; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
156 break; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
157 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
158 //if (dvdnav_priv->started) dvd_nav_still=1; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
159 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
160 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
161 void dvdnav_stream_add_event(dvdnav_priv_t* dvdnav_priv, int event, unsigned char *buf, int len) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
162 //printf("%s: %d\n",__FUNCTION__,event); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
163 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
164 dvdnav_event_t * dvdnav_event; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
165 mp_cmd_t * cmd; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
166 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
167 if (!dvdnav_priv->started) return; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
168 |
18885 | 169 if (!(dvdnav_event=calloc(1,sizeof(*dvdnav_event)))) { |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
170 mp_msg(MSGT_OPEN,MSGL_V, "%s: dvdnav_event: out of memory!\n",__FUNCTION__); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
171 return; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
172 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
173 dvdnav_event->event=event; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
174 dvdnav_event->details=calloc(1,len); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
175 memcpy(dvdnav_event->details,buf,len); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
176 dvdnav_event->len=len; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
177 |
18885 | 178 if (!(cmd = calloc(1,sizeof(*cmd)))) { |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
179 mp_msg(MSGT_OPEN,MSGL_V, "%s: mp_cmd_t: out of memory!\n",__FUNCTION__); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
180 free(dvdnav_event->details); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
181 free(dvdnav_event); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
182 return; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
183 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
184 cmd->id=MP_CMD_DVDNAV_EVENT; // S+event; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
185 cmd->name=strdup("dvdnav_event"); // FIXME: do I really need a 'name'? |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
186 cmd->nargs=1; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
187 cmd->args[0].v.v=dvdnav_event; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
188 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
189 |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
190 int dvdnav_stream_read(dvdnav_priv_t * dvdnav_priv, unsigned char *buf, int *len) { |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
191 int event = DVDNAV_NOP; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
192 |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
193 if (!len) return -1; |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
194 *len=-1; |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
195 if (!dvdnav_priv) return -1; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
196 if (!buf) return -1; |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
197 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
198 if (dvd_nav_still) { |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
199 mp_msg(MSGT_OPEN,MSGL_V, "%s: got a stream_read while I should be asleep!\n",__FUNCTION__); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
200 *len=0; |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
201 return -1; |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
202 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
203 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
204 if (dvdnav_get_next_block(dvdnav_priv->dvdnav,buf,&event,len)!=DVDNAV_STATUS_OK) { |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
205 mp_msg(MSGT_OPEN,MSGL_V, "Error getting next block from DVD %d (%s)\n",event, dvdnav_err_to_string(dvdnav_priv->dvdnav) ); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
206 *len=-1; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
207 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
208 else if (event!=DVDNAV_BLOCK_OK) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
209 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
210 // need to handle certain events internally (like skipping stills) |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
211 switch (event) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
212 case DVDNAV_STILL_FRAME: { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
213 dvdnav_still_event_t *still_event = (dvdnav_still_event_t*)(buf); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
214 //if (dvdnav_priv->started) dvd_nav_still=1; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
215 //else |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
216 dvdnav_still_skip(dvdnav_priv->dvdnav); // don't let dvdnav stall on this image |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
217 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
218 break; |
18898
a1eb5320279e
respect dvdnav's requests of WAIT to prevent while(1)
nicodvb
parents:
18885
diff
changeset
|
219 case DVDNAV_WAIT: |
a1eb5320279e
respect dvdnav's requests of WAIT to prevent while(1)
nicodvb
parents:
18885
diff
changeset
|
220 dvdnav_wait_skip(dvdnav_priv->dvdnav); |
a1eb5320279e
respect dvdnav's requests of WAIT to prevent while(1)
nicodvb
parents:
18885
diff
changeset
|
221 break; |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
222 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
223 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
224 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
225 // got an event, repeat the read |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
226 dvdnav_stream_add_event(dvdnav_priv,event,buf,*len); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
227 *len=0; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
228 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
229 // printf("%s: got %d\n",__FUNCTION__,*len); |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
230 return event; |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
231 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
232 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
233 void dvdnav_stream_fullstart(dvdnav_priv_t * dvdnav_priv) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
234 if (dvdnav_priv && !dvdnav_priv->started) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
235 dvdnav_stream_reset(dvdnav_priv); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
236 dvdnav_priv->started=1; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
237 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
238 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
239 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
240 unsigned int * dvdnav_stream_get_palette(dvdnav_priv_t * dvdnav_priv) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
241 if (!dvdnav_priv) { |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
242 mp_msg(MSGT_OPEN,MSGL_V, "%s: NULL dvdnav_priv\n",__FUNCTION__); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
243 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
244 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
245 if (!dvdnav_priv->dvdnav) { |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
246 mp_msg(MSGT_OPEN,MSGL_V, "%s: NULL dvdnav_priv->dvdnav\n",__FUNCTION__); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
247 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
248 } |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
249 #if 0 |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
250 if (!dvdnav_priv->dvdnav->vm) { |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
251 mp_msg(MSGT_OPEN,MSGL_V, "%s: NULL dvdnav_priv->dvdnav->vm\n",__FUNCTION__); |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
252 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
253 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
254 if (!dvdnav_priv->dvdnav->vm->state.pgc) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
255 printf("%s: NULL dvdnav_priv->dvdnav->vm->state.pgc\n",__FUNCTION__); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
256 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
257 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
258 return dvdnav_priv->dvdnav->vm->state.pgc->palette; |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
259 #endif |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
260 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
261 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
262 static void update_title_len(stream_t *stream) { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
263 dvdnav_priv_t *priv = stream->priv; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
264 dvdnav_status_t status; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
265 uint32_t pos = 0, len = 0; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
266 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
267 status = dvdnav_get_position(priv->dvdnav, &pos, &len); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
268 if(status == DVDNAV_STATUS_OK && len) |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
269 stream->end_pos = (off_t) len * 2048; |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
270 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
271 |
15518 | 272 |
273 static int seek(stream_t *s, off_t newpos) { | |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
274 uint32_t pos = 0, len = 0, sector = 0; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
275 dvdnav_priv_t *priv = s->priv; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
276 |
15518 | 277 if(newpos==0) { |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
278 if(dvdnav_stream_reset(priv->dvdnav)) |
15518 | 279 s->pos=0; |
280 } | |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
281 else { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
282 if(s->end_pos && newpos > s->end_pos) |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
283 newpos = s->end_pos; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
284 sector = newpos / 2048ULL; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
285 if(dvdnav_sector_search(priv->dvdnav, (uint64_t) sector, SEEK_SET) != DVDNAV_STATUS_OK) |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
286 goto fail; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
287 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
288 s->pos = newpos; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
289 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
290 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
291 return 1; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
292 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
293 fail: |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
294 mp_msg(MSGT_STREAM,MSGL_INFO,"dvdnav_stream, seeking to %"PRIu64" failed: %s\n", newpos, dvdnav_err_to_string(priv->dvdnav)); |
15518 | 295 |
296 return 1; | |
297 } | |
298 | |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
299 static void stream_dvdnav_close(stream_t *s) { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
300 dvdnav_priv_t *priv = s->priv; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
301 dvdnav_close(priv->dvdnav); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
302 priv->dvdnav = NULL; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
303 free(priv); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
304 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
305 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
306 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
307 static int fill_buffer(stream_t *s, char *but, int len) |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
308 { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
309 int event; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
310 dvdnav_priv_t* dvdnav_priv=s->priv; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
311 len=0; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
312 if(!s->end_pos) |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
313 update_title_len(s); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
314 while(!len) /* grab all event until DVDNAV_BLOCK_OK (len=2048), DVDNAV_STOP or DVDNAV_STILL_FRAME */ |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
315 { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
316 if(-1==(event=dvdnav_stream_read(dvdnav_priv, s->buffer, &len)) || len==-1) |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
317 { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
318 mp_msg(MSGT_CPLAYER,MSGL_ERR, "DVDNAV stream read error!\n"); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
319 return 0; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
320 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
321 switch (event) { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
322 case DVDNAV_STOP: return len; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
323 case DVDNAV_BLOCK_OK: return len; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
324 #if 0 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
325 case DVDNAV_STILL_FRAME: { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
326 if(!dvdnav_priv->stillok) dvdnav_priv->stillcounter++; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
327 dvdnav_priv->lockstillcounter++; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
328 return len; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
329 break; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
330 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
331 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
332 case DVDNAV_WAIT: { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
333 if(dvdnav_priv->waitcounter>=DVDNAV_MAX_WAIT_FRAME) return len; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
334 break; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
335 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
336 #endif |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
337 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
338 #if 0 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
339 if(dvdnav_priv->event.cell_really_change && |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
340 dvdnav_priv->started && |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
341 !dvdnav_priv->vts_domain) |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
342 return len; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
343 #endif |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
344 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
345 mp_msg(MSGT_STREAM,MSGL_DBG2,"DVDNAV fill_buffer len: %d\n",len); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
346 return len; |
15518 | 347 } |
348 | |
349 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { | |
350 struct stream_priv_s* p = (struct stream_priv_s*)opts; | |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
351 char *filename; |
15518 | 352 int event,len,tmplen=0; |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
353 uint32_t pos, l2; |
15518 | 354 dvdnav_priv_t *dvdnav_priv; |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
355 dvdnav_status_t status; |
15518 | 356 |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
357 //mp_msg(MSGT_OPEN,MSGL_INFO,"URL: %s\n", filename); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
358 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
359 if(p->device) filename = p->device; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
360 else if(dvd_device) filename= dvd_device; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
361 else filename = DEFAULT_DVD_DEVICE; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
362 if(!(dvdnav_priv=new_dvdnav_stream(filename))) { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
363 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
364 return STREAM_UNSUPORTED; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
365 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
366 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
367 if(dvdnav_title_play(dvdnav_priv->dvdnav, p->track) != DVDNAV_STATUS_OK) { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
368 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)); |
15518 | 369 return STREAM_UNSUPORTED; |
370 } | |
371 | |
372 stream->sector_size = 2048; | |
373 stream->flags = STREAM_READ | STREAM_SEEK; | |
374 stream->fill_buffer = fill_buffer; | |
375 stream->seek = seek; | |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
376 stream->close = stream_dvdnav_close; |
15518 | 377 stream->type = STREAMTYPE_DVDNAV; |
378 stream->priv=(void*)dvdnav_priv; | |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
379 *file_format = DEMUXER_TYPE_MPEG_PS; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
380 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
381 update_title_len(stream); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
382 if(!stream->pos) |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
383 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)); |
15518 | 384 |
385 return STREAM_OK; | |
386 } | |
387 | |
388 stream_info_t stream_info_dvdnav = { | |
389 "DVDNAV stream", | |
390 "null", | |
391 "", | |
392 "", | |
393 open_s, | |
394 { "dvdnav", NULL }, | |
395 &stream_opts, | |
396 1 // Urls are an option string | |
397 }; | |
398 | |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
399 #endif /* USE_DVDNAV */ |