annotate libmpdemux/dvdnav_stream.c @ 18977:408714bc075c

_x11_paths should just be a list of paths without -L.
author diego
date Sun, 09 Jul 2006 16:37:18 +0000
parents d2d9d011203f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 #include <stdlib.h>
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
4 #include <stdio.h>
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
5 #include <unistd.h>
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
6 #include <string.h>
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
7 #include "mp_msg.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15518
diff changeset
8 #include "osdep/timer.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15518
diff changeset
9 #include "input/input.h"
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
10 #include "stream.h"
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
11 #include "demuxer.h"
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
12 #include "dvdnav_stream.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15518
diff changeset
13 #include "libvo/video_out.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15518
diff changeset
14 #include "spudec.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15518
diff changeset
15 #include "m_option.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15518
diff changeset
16 #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
17 #include "help_mp.h"
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
18
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
19 extern char *dvd_device;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
20 extern char *audio_lang, *dvdsub_lang;
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
21
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
22 static struct stream_priv_s {
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
23 int track;
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
24 char* device;
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
25 } stream_priv_dflts = {
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
26 1,
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
27 NULL
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
28 };
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
29
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
30 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f)
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
31 /// URL definition
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
32 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
33 {"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
34 {"hostname", ST_OFF(track), CONF_TYPE_INT, 0, 0, 0, NULL},
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
35 { NULL, NULL, 0, 0, 0, 0, NULL }
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
36 };
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
37 static struct m_struct_st stream_opts = {
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
38 "dvd",
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
39 sizeof(struct stream_priv_s),
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
40 &stream_priv_dflts,
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
41 stream_opts_fields
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
42 };
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
43
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
44 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
45 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
46 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
47 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
48 int osd_show_dvd_nav_sx; /* start x .... */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
49 int osd_show_dvd_nav_ex;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
50 int osd_show_dvd_nav_sy;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
51 int osd_show_dvd_nav_ey;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
52 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
53
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
54 dvdnav_priv_t * new_dvdnav_stream(char * filename) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
55 char * title_str;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
56 dvdnav_priv_t *dvdnav_priv;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
57
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
58 if (!filename)
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
59 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
60
18885
5c8acc972551 rm unnecesary casts from void* - part 4
reynaldo
parents: 18712
diff changeset
61 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
62 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
63
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
64 if (!(dvdnav_priv->filename=strdup(filename))) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
65 free(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
66 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
67 }
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 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
70 {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
71 free(dvdnav_priv->filename);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
72 free(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
73 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
74 }
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 if (!dvdnav_priv->dvdnav) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
77 free(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
78 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
79 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
80
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
81 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
82 {
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
83 int len, event;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
84 char buf[2048];
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
85
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
86 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
87 }
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
88
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
89 /* 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
90 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
91 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
92 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
93 #if 1
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
94 /* report the title?! */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
95 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
96 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
97 }
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
98 #endif
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
99
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
100 //dvdnav_event_clear(dvdnav_priv);
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
101
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
102 return dvdnav_priv;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
103 }
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 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
106 if (!dvdnav_priv) return 0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
107
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
108 // 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
109 return 0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
110
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
111 dvdnav_priv->started=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
112
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
113 return 1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
114 }
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 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
117 unsigned int now;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
118
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
119 if (!dvdnav_priv) return 0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
120
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
121 if(dvdnav_priv->sleeping)
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
122 {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
123 now=GetTimer();
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
124 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
125 // 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
126 // usec_sleep(1000); /* 1ms granularity */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
127 return 1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
128 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
129 dvdnav_still_skip(dvdnav_priv->dvdnav); // continue past...
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
130 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
131 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
132 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
133 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
134 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
135 return 0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
136 }
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 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
139 if (!dvdnav_priv) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
140
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
141 if (!dvdnav_priv->started) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
142
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
143 dvdnav_priv->sleeping=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
144 switch (seconds) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
145 case 0:
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
146 return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
147 case 0xff:
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
148 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
149 dvdnav_priv->sleeping=2;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
150 break;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
151 default:
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
152 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
153 dvdnav_priv->sleep_until = GetTimer();// + seconds*1000000;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
154 dvdnav_priv->sleeping=1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
155 break;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
156 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
157 //if (dvdnav_priv->started) dvd_nav_still=1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
158 }
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 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
161 //printf("%s: %d\n",__FUNCTION__,event);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
162
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
163 dvdnav_event_t * dvdnav_event;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
164 mp_cmd_t * cmd;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
165
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
166 if (!dvdnav_priv->started) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
167
18885
5c8acc972551 rm unnecesary casts from void* - part 4
reynaldo
parents: 18712
diff changeset
168 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
169 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
170 return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
171 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
172 dvdnav_event->event=event;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
173 dvdnav_event->details=calloc(1,len);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
174 memcpy(dvdnav_event->details,buf,len);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
175 dvdnav_event->len=len;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
176
18885
5c8acc972551 rm unnecesary casts from void* - part 4
reynaldo
parents: 18712
diff changeset
177 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
178 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
179 free(dvdnav_event->details);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
180 free(dvdnav_event);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
181 return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
182 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
183 cmd->id=MP_CMD_DVDNAV_EVENT; // S+event;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
184 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
185 cmd->nargs=1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
186 cmd->args[0].v.v=dvdnav_event;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
187 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
188
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
189 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
190 int event = DVDNAV_NOP;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
191
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
192 if (!len) return -1;
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
193 *len=-1;
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
194 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
195 if (!buf) return -1;
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
196
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
197 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
198 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
199 *len=0;
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
200 return -1;
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
201 }
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 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
204 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
205 *len=-1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
206 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
207 else if (event!=DVDNAV_BLOCK_OK) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
208
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
209 // 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
210 switch (event) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
211 case DVDNAV_STILL_FRAME: {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
212 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
213 //if (dvdnav_priv->started) dvd_nav_still=1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
214 //else
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
215 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
216
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
217 break;
18898
a1eb5320279e respect dvdnav's requests of WAIT to prevent while(1)
nicodvb
parents: 18885
diff changeset
218 case DVDNAV_WAIT:
a1eb5320279e respect dvdnav's requests of WAIT to prevent while(1)
nicodvb
parents: 18885
diff changeset
219 dvdnav_wait_skip(dvdnav_priv->dvdnav);
a1eb5320279e respect dvdnav's requests of WAIT to prevent while(1)
nicodvb
parents: 18885
diff changeset
220 break;
5471
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 }
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 // got an event, repeat the read
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
225 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
226 *len=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
227 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
228 // 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
229 return event;
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
230 }
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 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
233 if (dvdnav_priv && !dvdnav_priv->started) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
234 dvdnav_stream_reset(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
235 dvdnav_priv->started=1;
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 }
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 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
240 if (!dvdnav_priv) {
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
241 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
242 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
243 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
244 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
245 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
246 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
247 }
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
248 #if 0
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
249 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
250 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
251 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
252 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
253 if (!dvdnav_priv->dvdnav->vm->state.pgc) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
254 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
255 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
256 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
257 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
258 #endif
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
259 }
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 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
262 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
263 dvdnav_status_t status;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
264 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
265
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
266 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
267 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
268 stream->end_pos = (off_t) len * 2048;
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
269 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
270
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
271
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
272 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
273 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
274 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
275
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
276 if(newpos==0) {
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
277 if(dvdnav_stream_reset(priv->dvdnav))
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
278 s->pos=0;
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
279 }
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
280 else {
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
281 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
282 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 sector = newpos / 2048ULL;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
284 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
285 goto fail;
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 s->pos = newpos;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
288 }
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 return 1;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
291
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
292 fail:
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
293 mp_msg(MSGT_STREAM,MSGL_INFO,"dvdnav_stream, seeking to %"PRIu64" failed: %s\n", newpos, dvdnav_err_to_string(priv->dvdnav));
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
294
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
295 return 1;
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
296 }
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
297
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
298 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
299 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
300 dvdnav_close(priv->dvdnav);
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
301 priv->dvdnav = NULL;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
302 free(priv);
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
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 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
307 {
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
308 int event;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
309 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
310 len=0;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
311 if(!s->end_pos)
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
312 update_title_len(s);
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
313 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
314 {
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
315 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
316 {
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
317 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
318 return 0;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
319 }
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
320 switch (event) {
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
321 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
322 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
323 #if 0
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
324 case DVDNAV_STILL_FRAME: {
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
325 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
326 dvdnav_priv->lockstillcounter++;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
327 return len;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
328 break;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
329 }
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 case DVDNAV_WAIT: {
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
332 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
333 break;
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 #endif
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
336 }
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
337 #if 0
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
338 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
339 dvdnav_priv->started &&
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
340 !dvdnav_priv->vts_domain)
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
341 return len;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
342 #endif
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
343 }
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
344 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
345 return len;
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
346 }
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
347
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
348 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
349 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
350 char *filename;
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
351 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
352 uint32_t pos, l2;
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
353 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
354 dvdnav_status_t status;
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
355
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
356 //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
357
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
358 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
359 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
360 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
361 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
362 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
363 return STREAM_UNSUPORTED;
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
364 }
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 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
367 mp_msg(MSGT_OPEN,MSGL_FATAL,"dvdnav_stream, couldn't select title %d, error '%s'\n", p->track, dvdnav_err_to_string(dvdnav_priv->dvdnav));
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
368 return STREAM_UNSUPORTED;
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
369 }
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
370
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
371 stream->sector_size = 2048;
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
372 stream->flags = STREAM_READ | STREAM_SEEK;
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
373 stream->fill_buffer = fill_buffer;
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
374 stream->seek = seek;
18712
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
375 stream->close = stream_dvdnav_close;
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
376 stream->type = STREAMTYPE_DVDNAV;
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
377 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
378 *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
379
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
380 update_title_len(stream);
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
381 if(!stream->pos)
cb7da1894b00 restored support for dvdnav only in the stream layer; all other functionalities are disabled
nicodvb
parents: 17012
diff changeset
382 mp_msg(MSGT_OPEN,MSGL_ERR, "INIT ERROR: %d, couldn't get init pos %s\r\n", status, dvdnav_err_to_string(dvdnav_priv->dvdnav));
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
383
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
384 return STREAM_OK;
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
385 }
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
386
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
387 stream_info_t stream_info_dvdnav = {
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
388 "DVDNAV stream",
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
389 "null",
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
390 "",
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
391 "",
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
392 open_s,
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
393 { "dvdnav", NULL },
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
394 &stream_opts,
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
395 1 // Urls are an option string
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 9380
diff changeset
396 };