Mercurial > mplayer.hg
annotate libmpdemux/dvdnav_stream.c @ 18771:a1807995e2ab
Move #ifdefs around complete files into the build system.
author | diego |
---|---|
date | Wed, 21 Jun 2006 14:49:09 +0000 |
parents | cb7da1894b00 |
children | 5c8acc972551 |
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 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
62 if (!(dvdnav_priv=(dvdnav_priv_t*)calloc(1,sizeof(*dvdnav_priv)))) |
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 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
169 if (!(dvdnav_event=(dvdnav_event_t*)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 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
178 if (!(cmd = (mp_cmd_t*)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; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
219 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
220 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
221 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
222 // got an event, repeat the read |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
223 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
|
224 *len=0; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
225 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
226 // 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
|
227 return event; |
5471
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 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
230 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
|
231 if (dvdnav_priv && !dvdnav_priv->started) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
232 dvdnav_stream_reset(dvdnav_priv); |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
233 dvdnav_priv->started=1; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
234 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
235 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
236 |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
237 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
|
238 if (!dvdnav_priv) { |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
239 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
|
240 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
241 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
242 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
|
243 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
|
244 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
245 } |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
246 #if 0 |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
247 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
|
248 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
|
249 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
250 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
251 if (!dvdnav_priv->dvdnav->vm->state.pgc) { |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
252 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
|
253 return NULL; |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
254 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
255 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
|
256 #endif |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
257 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
258 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
259 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
|
260 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
|
261 dvdnav_status_t status; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
262 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
|
263 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
264 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
|
265 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
|
266 stream->end_pos = (off_t) len * 2048; |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
267 } |
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
268 |
15518 | 269 |
270 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
|
271 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
|
272 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
|
273 |
15518 | 274 if(newpos==0) { |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
275 if(dvdnav_stream_reset(priv->dvdnav)) |
15518 | 276 s->pos=0; |
277 } | |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
278 else { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
279 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
|
280 newpos = s->end_pos; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
281 sector = newpos / 2048ULL; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
282 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
|
283 goto fail; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
284 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
285 s->pos = newpos; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
286 } |
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 return 1; |
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 fail: |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
291 mp_msg(MSGT_STREAM,MSGL_INFO,"dvdnav_stream, seeking to %"PRIu64" failed: %s\n", newpos, dvdnav_err_to_string(priv->dvdnav)); |
15518 | 292 |
293 return 1; | |
294 } | |
295 | |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
296 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
|
297 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
|
298 dvdnav_close(priv->dvdnav); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
299 priv->dvdnav = NULL; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
300 free(priv); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
301 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
302 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
303 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
304 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
|
305 { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
306 int event; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
307 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
|
308 len=0; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
309 if(!s->end_pos) |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
310 update_title_len(s); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
311 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
|
312 { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
313 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
|
314 { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
315 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
|
316 return 0; |
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 switch (event) { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
319 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
|
320 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
|
321 #if 0 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
322 case DVDNAV_STILL_FRAME: { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
323 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
|
324 dvdnav_priv->lockstillcounter++; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
325 return len; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
326 break; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
327 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
328 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
329 case DVDNAV_WAIT: { |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
330 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
|
331 break; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
332 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
333 #endif |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
334 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
335 #if 0 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
336 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
|
337 dvdnav_priv->started && |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
338 !dvdnav_priv->vts_domain) |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
339 return len; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
340 #endif |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
341 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
342 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
|
343 return len; |
15518 | 344 } |
345 | |
346 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { | |
347 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
|
348 char *filename; |
15518 | 349 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
|
350 uint32_t pos, l2; |
15518 | 351 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
|
352 dvdnav_status_t status; |
15518 | 353 |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
354 //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
|
355 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
356 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 return STREAM_UNSUPORTED; |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
362 } |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
363 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
364 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
|
365 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 | 366 return STREAM_UNSUPORTED; |
367 } | |
368 | |
369 stream->sector_size = 2048; | |
370 stream->flags = STREAM_READ | STREAM_SEEK; | |
371 stream->fill_buffer = fill_buffer; | |
372 stream->seek = seek; | |
18712
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
373 stream->close = stream_dvdnav_close; |
15518 | 374 stream->type = STREAMTYPE_DVDNAV; |
375 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
|
376 *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
|
377 |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
378 update_title_len(stream); |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
379 if(!stream->pos) |
cb7da1894b00
restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents:
17012
diff
changeset
|
380 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 | 381 |
382 return STREAM_OK; | |
383 } | |
384 | |
385 stream_info_t stream_info_dvdnav = { | |
386 "DVDNAV stream", | |
387 "null", | |
388 "", | |
389 "", | |
390 open_s, | |
391 { "dvdnav", NULL }, | |
392 &stream_opts, | |
393 1 // Urls are an option string | |
394 }; | |
395 | |
5471
348c7d83e710
dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff
changeset
|
396 #endif /* USE_DVDNAV */ |