Mercurial > mplayer.hg
annotate libmpdemux/open.c @ 9864:b65bcfaedbe5
Sync with 0_90. All stuff different from 0_90 is missing.
author | rtognimp |
---|---|
date | Sun, 06 Apr 2003 22:01:54 +0000 |
parents | 2f02809d32a8 |
children | 95727467a091 |
rev | line source |
---|---|
1467 | 1 |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
2 #include <ctype.h> |
1467 | 3 #include <stdio.h> |
4 #include <stdlib.h> | |
5 #include <string.h> | |
6 #include <unistd.h> | |
7 #include <fcntl.h> | |
9746 | 8 #include <string.h> |
1467 | 9 |
10 #include "config.h" | |
1567 | 11 #include "mp_msg.h" |
1584 | 12 #include "help_mp.h" |
1467 | 13 |
1468 | 14 #ifdef __FreeBSD__ |
15 #include <sys/cdrio.h> | |
16 #endif | |
17 | |
9712 | 18 #include "../m_config.h" |
1467 | 19 #include "stream.h" |
1482 | 20 #include "demuxer.h" |
4551 | 21 #include "mf.h" |
1467 | 22 |
23 #ifdef STREAMING | |
24 #include "url.h" | |
25 #include "network.h" | |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7854
diff
changeset
|
26 extern int streaming_start( stream_t *stream, int *demuxer_type, URL_t *url); |
6910
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
27 #ifdef STREAMING_LIVE_DOT_COM |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
28 #include "demux_rtp.h" |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
29 #endif |
1467 | 30 static URL_t* url; |
31 #endif | |
32 | |
9610 | 33 int dvbin_param_on=0; |
34 | |
9746 | 35 /// We keep these 2 for the gui atm, but they will be removed. |
1596 | 36 int dvd_title=0; |
9746 | 37 int vcd_track=0; |
38 | |
1596 | 39 int dvd_chapter=1; |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
40 int dvd_last_chapter=0; |
1596 | 41 int dvd_angle=1; |
4222
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
42 char* dvd_device=NULL; |
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
43 char* cdrom_device=NULL; |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
44 |
5381 | 45 #ifdef USE_DVDNAV |
5472 | 46 #include "dvdnav_stream.h" |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
47 #endif |
1596 | 48 |
49 #ifdef USE_DVDREAD | |
50 | |
1875 | 51 #define DVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro)) |
52 | |
53 /* | |
54 * Try to autodetect the libdvd-0.9.0 library | |
55 * (0.9.0 removed the <dvdread/dvd_udf.h> header, and moved the two defines | |
56 * DVD_VIDEO_LB_LEN and MAX_UDF_FILE_NAME_LEN from it to | |
57 * <dvdread/dvd_reader.h>) | |
58 */ | |
59 #if defined(DVD_VIDEO_LB_LEN) && defined(MAX_UDF_FILE_NAME_LEN) | |
60 #define LIBDVDREAD_VERSION DVDREAD_VERSION(0,9,0) | |
61 #else | |
62 #define LIBDVDREAD_VERSION DVDREAD_VERSION(0,8,0) | |
63 #endif | |
64 | |
2935 | 65 char * dvd_audio_stream_types[8] = |
66 { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" }; | |
1596 | 67 |
6651 | 68 char * dvd_audio_stream_channels[6] = |
69 { "unknown", "stereo", "unknown", "unknown", "unknown", "5.1" }; | |
1596 | 70 #endif |
71 | |
1467 | 72 extern int vcd_get_track_end(int fd,int track); |
8812 | 73 |
74 #include "cue_read.h" | |
1467 | 75 |
2790 | 76 #ifdef USE_TV |
77 #include "tv.h" | |
9795 | 78 extern char* tv_param_channel; |
2790 | 79 #endif |
80 | |
9610 | 81 #ifdef HAS_DVBIN_SUPPORT |
82 #include "dvbin.h" | |
83 #endif | |
84 | |
85 | |
86 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
87 #ifdef HAVE_CDDA |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
88 stream_t* open_cdda(char* dev,char* track); |
7432
8705ce9a9fe9
Enable CDDB support only if the network layer is enabled.
bertrand
parents:
7408
diff
changeset
|
89 #ifdef STREAMING |
6474 | 90 stream_t* cddb_open(char* dev,char* track); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
91 #endif |
7432
8705ce9a9fe9
Enable CDDB support only if the network layer is enabled.
bertrand
parents:
7408
diff
changeset
|
92 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
93 |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
94 // Define function about auth the libsmbclient library |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
95 // FIXME: I really do not not is this function is properly working |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
96 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
97 #ifdef LIBSMBCLIENT |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
98 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
99 #include "libsmbclient.h" |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
100 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
101 static char smb_password[15]; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
102 static char smb_username[15]; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
103 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
104 static void smb_auth_fn(const char *server, const char *share, |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
105 char *workgroup, int wgmaxlen, char *username, int unmaxlen, |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
106 char *password, int pwmaxlen) |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
107 { |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
108 char temp[128]; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
109 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
110 strcpy(temp, "LAN"); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
111 if (temp[strlen(temp) - 1] == 0x0a) |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
112 temp[strlen(temp) - 1] = 0x00; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
113 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
114 if (temp[0]) strncpy(workgroup, temp, wgmaxlen - 1); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
115 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
116 strcpy(temp, smb_username); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
117 if (temp[strlen(temp) - 1] == 0x0a) |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
118 temp[strlen(temp) - 1] = 0x00; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
119 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
120 if (temp[0]) strncpy(username, temp, unmaxlen - 1); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
121 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
122 strcpy(temp, smb_password); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
123 if (temp[strlen(temp) - 1] == 0x0a) |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
124 temp[strlen(temp) - 1] = 0x00; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
125 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
126 if (temp[0]) strncpy(password, temp, pwmaxlen - 1); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
127 } |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
128 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
129 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
130 #endif |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
131 |
1467 | 132 // Open a new stream (stdin/file/vcd/url) |
133 | |
9795 | 134 stream_t* open_stream(char* filename,char** options, int* file_format){ |
1467 | 135 stream_t* stream=NULL; |
136 int f=-1; | |
137 off_t len; | |
138 #ifdef __FreeBSD__ | |
139 int bsize = VCD_SECTOR_SIZE; | |
140 #endif | |
9746 | 141 *file_format = DEMUXER_TYPE_UNKNOWN; |
142 if(!filename) { | |
143 mp_msg(MSGT_OPEN,MSGL_ERR,"NULL filename, report this bug\n"); | |
144 return NULL; | |
145 } | |
1467 | 146 |
147 //============ Open VideoCD track ============== | |
3261 | 148 #ifdef HAVE_VCD |
9746 | 149 if(strncmp("vcd://",filename,6) == 0){ |
1467 | 150 int ret,ret2; |
8649
0c258b964b08
fixes (ok, just workarounds) sig11 in playtree/cfgparser's free()
arpi
parents:
8528
diff
changeset
|
151 if(!cdrom_device) cdrom_device=strdup(DEFAULT_CDROM_DEVICE); |
4222
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
152 f=open(cdrom_device,O_RDONLY); |
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
153 if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,cdrom_device);return NULL; } |
9746 | 154 vcd_track = filename[6] == '\0' ? 1 : strtol(filename+6,NULL,0); |
155 if(vcd_track < 1){ | |
156 mp_msg(MSGT_OPEN,MSGL_ERR,"Invalid vcd track %s\n",filename+6); | |
157 return NULL; | |
158 } | |
1467 | 159 vcd_read_toc(f); |
160 ret2=vcd_get_track_end(f,vcd_track); | |
1584 | 161 if(ret2<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n");return NULL;} |
1467 | 162 ret=vcd_seek_to_track(f,vcd_track); |
1584 | 163 if(ret<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");return NULL;} |
1567 | 164 mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2); |
1467 | 165 #ifdef __FreeBSD__ |
166 if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) { | |
167 perror ( "Error in CDRIOCSETBLOCKSIZE"); | |
168 } | |
169 #endif | |
170 stream=new_stream(f,STREAMTYPE_VCD); | |
171 stream->start_pos=ret; | |
172 stream->end_pos=ret2; | |
173 return stream; | |
174 } | |
3261 | 175 #endif |
1467 | 176 |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
177 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
178 // for opening of vcds in bincue files |
9746 | 179 if(strncmp("cue://",filename,6) == 0){ |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
180 int ret,ret2; |
9746 | 181 char* p = filename + 6; |
182 vcd_track = 1; | |
183 p = strchr(p,':'); | |
184 if(p && p[1] != '\0') { | |
185 vcd_track = strtol(p+1,NULL,0); | |
186 if(vcd_track < 1){ | |
187 mp_msg(MSGT_OPEN,MSGL_ERR,"Invalid cue track %s\n",p+1); | |
188 return NULL; | |
189 } | |
190 p[0] = '\0'; | |
191 } | |
192 f = cue_read_cue (filename + 6); | |
193 if(p && p[1] != '\0') p[0] = ':'; | |
194 if (f == -1) return NULL; | |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
195 cue_vcd_read_toc(); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
196 ret2=cue_vcd_get_track_end(vcd_track); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
197 ret=cue_vcd_seek_to_track(vcd_track); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
198 if(ret<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");return NULL;} |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
199 mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
200 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
201 stream=new_stream(f,STREAMTYPE_VCDBINCUE); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
202 stream->start_pos=ret; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
203 stream->end_pos=ret2; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
204 printf ("start:%d end:%d\n", ret, ret2); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
205 return stream; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
206 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
207 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
208 |
1596 | 209 //============ Open DVD title ============== |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
210 #ifdef USE_DVDNAV |
9746 | 211 if(strncmp("dvdnav://",filename,9) == 0){ |
5472 | 212 dvdnav_priv_t *dvdnav_priv; |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
213 int event,len,tmplen=0; |
9746 | 214 char* name = (filename[9] == '\0') ? NULL : filename + 9; |
215 | |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
216 stream=new_stream(-1,STREAMTYPE_DVDNAV); |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
217 if (!stream) { |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
218 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_Exit_error); |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
219 return NULL; |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
220 } |
5472 | 221 |
9746 | 222 if(!name) name=DEFAULT_DVD_DEVICE; |
223 if (!(dvdnav_priv=new_dvdnav_stream(name))) { | |
224 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,name); | |
5472 | 225 return NULL; |
226 } | |
227 | |
228 stream->priv=(void*)dvdnav_priv; | |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
229 return stream; |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
230 } |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
231 #endif |
1596 | 232 #ifdef USE_DVDREAD |
9746 | 233 if(strncmp("dvd://",filename,6) == 0){ |
2050 | 234 // int ret,ret2; |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
235 dvd_priv_t *d; |
1596 | 236 int ttn,pgc_id,pgn; |
237 dvd_reader_t *dvd; | |
238 dvd_file_t *title; | |
239 ifo_handle_t *vmg_file; | |
240 tt_srpt_t *tt_srpt; | |
241 ifo_handle_t *vts_file; | |
9746 | 242 dvd_title = filename[6] == '\0' ? 1 : strtol(filename + 6,NULL,0); |
1596 | 243 /** |
244 * Open the disc. | |
245 */ | |
8649
0c258b964b08
fixes (ok, just workarounds) sig11 in playtree/cfgparser's free()
arpi
parents:
8528
diff
changeset
|
246 if(!dvd_device) dvd_device=strdup(DEFAULT_DVD_DEVICE); |
9535
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
247 #ifdef SYS_DARWIN |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
248 /* Dynamic DVD drive selection on Darwin */ |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
249 if (!strcmp(dvd_device, "/dev/rdiskN")) { |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
250 int i; |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
251 char *temp_device = malloc((strlen(dvd_device)+1)*sizeof(char)); |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
252 |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
253 for (i = 1; i < 10; i++) { |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
254 sprintf(temp_device, "/dev/rdisk%d", i); |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
255 dvd = DVDOpen(temp_device); |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
256 if (!dvd) { |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
257 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,temp_device); |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
258 } else { |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
259 free(temp_device); |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
260 break; |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
261 } |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
262 } |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
263 |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
264 if (!dvd) |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
265 return NULL; |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
266 } else |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
267 #endif /* SYS_DARWIN */ |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
268 { |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
269 dvd = DVDOpen(dvd_device); |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
270 if( !dvd ) { |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
271 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,dvd_device); |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
272 return NULL; |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
273 } |
1596 | 274 } |
275 | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
276 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDwait); |
1596 | 277 |
278 /** | |
279 * Load the video manager to find out the information about the titles on | |
280 * this disc. | |
281 */ | |
282 vmg_file = ifoOpen( dvd, 0 ); | |
283 if( !vmg_file ) { | |
284 mp_msg(MSGT_OPEN,MSGL_ERR, "Can't open VMG info!\n"); | |
285 DVDClose( dvd ); | |
286 return NULL; | |
287 } | |
288 tt_srpt = vmg_file->tt_srpt; | |
289 /** | |
290 * Make sure our title number is valid. | |
291 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
292 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumTitles, |
1596 | 293 tt_srpt->nr_of_srpts ); |
294 if( dvd_title < 1 || dvd_title > tt_srpt->nr_of_srpts ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
295 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidTitle, dvd_title); |
1596 | 296 ifoClose( vmg_file ); |
297 DVDClose( dvd ); | |
298 return NULL; | |
299 } | |
300 --dvd_title; // remap 1.. -> 0.. | |
301 /** | |
302 * Make sure the chapter number is valid for this title. | |
303 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
304 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumChapters, |
1596 | 305 tt_srpt->title[dvd_title].nr_of_ptts ); |
306 if( dvd_chapter<1 || dvd_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
307 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidChapter, dvd_chapter); |
1596 | 308 ifoClose( vmg_file ); |
309 DVDClose( dvd ); | |
310 return NULL; | |
311 } | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
312 if( dvd_last_chapter>0 ) { |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
313 if ( dvd_last_chapter<dvd_chapter || dvd_last_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) { |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
314 mp_msg(MSGT_OPEN,MSGL_ERR, "Invalid DVD last chapter number: %d\n", dvd_last_chapter); |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
315 ifoClose( vmg_file ); |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
316 DVDClose( dvd ); |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
317 return NULL; |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
318 } |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
319 } |
1596 | 320 --dvd_chapter; // remap 1.. -> 0.. |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
321 /* XXX No need to remap dvd_last_chapter */ |
1596 | 322 /** |
323 * Make sure the angle number is valid for this title. | |
324 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
325 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumAngles, |
1596 | 326 tt_srpt->title[dvd_title].nr_of_angles ); |
327 if( dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles ) { | |
1977 | 328 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidAngle, dvd_angle); |
1596 | 329 ifoClose( vmg_file ); |
330 DVDClose( dvd ); | |
331 return NULL; | |
332 } | |
1617 | 333 --dvd_angle; // remap 1.. -> 0.. |
1596 | 334 /** |
335 * Load the VTS information for the title set our title is in. | |
336 */ | |
337 vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr ); | |
338 if( !vts_file ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
339 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoIFO, |
1596 | 340 tt_srpt->title[dvd_title].title_set_nr ); |
341 ifoClose( vmg_file ); | |
342 DVDClose( dvd ); | |
343 return NULL; | |
344 } | |
345 /** | |
346 * We've got enough info, time to open the title set data. | |
347 */ | |
348 title = DVDOpenFile( dvd, tt_srpt->title[dvd_title].title_set_nr, | |
349 DVD_READ_TITLE_VOBS ); | |
350 if( !title ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
351 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoVOBs, |
1596 | 352 tt_srpt->title[dvd_title].title_set_nr ); |
353 ifoClose( vts_file ); | |
354 ifoClose( vmg_file ); | |
355 DVDClose( dvd ); | |
356 return NULL; | |
357 } | |
358 | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
359 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDopenOk); |
1596 | 360 // store data |
361 d=malloc(sizeof(dvd_priv_t)); memset(d,0,sizeof(dvd_priv_t)); | |
362 d->dvd=dvd; | |
363 d->title=title; | |
364 d->vmg_file=vmg_file; | |
365 d->tt_srpt=tt_srpt; | |
366 d->vts_file=vts_file; | |
367 | |
368 /** | |
2935 | 369 * Check number of audio channels and types |
370 */ | |
371 { | |
372 int ac3aid = 128; | |
373 int mpegaid = 0; | |
374 int pcmaid = 160; | |
375 | |
376 d->nr_of_channels=0; | |
377 | |
378 if ( vts_file->vts_pgcit ) | |
379 { | |
380 int i; | |
381 for ( i=0;i<8;i++ ) | |
382 if ( vts_file->vts_pgcit->pgci_srp[0].pgc->audio_control[i] & 0x8000 ) | |
383 { | |
384 audio_attr_t * audio = &vts_file->vtsi_mat->vts_audio_attr[i]; | |
385 int language = 0; | |
386 char tmp[] = "unknown"; | |
387 | |
388 if ( audio->lang_type == 1 ) | |
389 { | |
390 language=audio->lang_code; | |
391 tmp[0]=language>>8; | |
392 tmp[1]=language&0xff; | |
393 tmp[2]=0; | |
394 } | |
395 | |
396 d->audio_streams[d->nr_of_channels].language=language; | |
397 d->audio_streams[d->nr_of_channels].id=0; | |
398 switch ( audio->audio_format ) | |
399 { | |
400 case 0: // ac3 | |
401 case 6: // dts | |
402 d->audio_streams[d->nr_of_channels].id=ac3aid; | |
403 ac3aid++; | |
404 break; | |
405 case 2: // mpeg layer 1/2/3 | |
406 case 3: // mpeg2 ext | |
407 d->audio_streams[d->nr_of_channels].id=mpegaid; | |
408 mpegaid++; | |
409 break; | |
410 case 4: // lpcm | |
411 d->audio_streams[d->nr_of_channels].id=pcmaid; | |
412 pcmaid++; | |
413 break; | |
414 } | |
415 | |
6651 | 416 d->audio_streams[d->nr_of_channels].type=audio->audio_format; |
417 // Pontscho: to my mind, tha channels: | |
418 // 1 - stereo | |
419 // 5 - 5.1 | |
420 d->audio_streams[d->nr_of_channels].channels=audio->channels; | |
421 mp_msg(MSGT_OPEN,MSGL_V,"[open] audio stream: %d audio format: %s (%s) language: %s aid: %d\n", | |
2935 | 422 d->nr_of_channels, |
423 dvd_audio_stream_types[ audio->audio_format ], | |
6651 | 424 dvd_audio_stream_channels[ audio->channels ], |
2935 | 425 tmp, |
426 d->audio_streams[d->nr_of_channels].id | |
427 ); | |
3753 | 428 |
2935 | 429 d->nr_of_channels++; |
430 } | |
431 } | |
3048 | 432 mp_msg(MSGT_OPEN,MSGL_V,"[open] number of audio channels on disk: %d.\n",d->nr_of_channels ); |
433 } | |
434 | |
435 /** | |
436 * Check number of subtitles and language | |
437 */ | |
438 { | |
439 int i; | |
440 | |
441 d->nr_of_subtitles=0; | |
442 for ( i=0;i<32;i++ ) | |
443 if ( vts_file->vts_pgcit->pgci_srp[0].pgc->subp_control[i] & 0x80000000 ) | |
444 { | |
445 subp_attr_t * subtitle = &vts_file->vtsi_mat->vts_subp_attr[i]; | |
446 int language = 0; | |
447 char tmp[] = "unknown"; | |
448 | |
449 if ( subtitle->type == 1 ) | |
450 { | |
451 language=subtitle->lang_code; | |
452 tmp[0]=language>>8; | |
453 tmp[1]=language&0xff; | |
454 tmp[2]=0; | |
455 } | |
456 | |
457 d->subtitles[ d->nr_of_subtitles ].language=language; | |
458 d->subtitles[ d->nr_of_subtitles ].id=d->nr_of_subtitles; | |
459 | |
460 mp_msg(MSGT_OPEN,MSGL_V,"[open] subtitle ( sid ): %d language: %s\n", | |
461 d->nr_of_subtitles, | |
462 tmp | |
463 ); | |
464 d->nr_of_subtitles++; | |
465 } | |
466 mp_msg(MSGT_OPEN,MSGL_V,"[open] number of subtitles on disk: %d\n",d->nr_of_subtitles ); | |
2935 | 467 } |
468 | |
469 /** | |
1596 | 470 * Determine which program chain we want to watch. This is based on the |
471 * chapter number. | |
472 */ | |
473 ttn = tt_srpt->title[ dvd_title ].vts_ttn; // local | |
474 pgc_id = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgcn; // local | |
475 pgn = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgn; // local | |
476 d->cur_pgc = vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; | |
477 d->cur_cell = d->cur_pgc->program_map[pgn-1] - 1; // start playback here | |
478 d->packs_left=-1; // for Navi stuff | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
479 d->angle_seek=0; |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
480 /* XXX dvd_last_chapter is in the range 1..nr_of_ptts */ |
6853
c52dc92ebf4b
There appears to be a trivial namespace error in determining the valid
arpi
parents:
6774
diff
changeset
|
481 if ( dvd_last_chapter > 0 && dvd_last_chapter < tt_srpt->title[dvd_title].nr_of_ptts ) { |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
482 pgn=vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_last_chapter].pgn; |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
483 d->last_cell=d->cur_pgc->program_map[pgn-1] - 1; |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
484 } |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
485 else |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
486 d->last_cell=d->cur_pgc->nr_of_cells; |
1596 | 487 |
6651 | 488 if( d->cur_pgc->cell_playback[d->cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; |
1596 | 489 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; |
490 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
491 mp_msg(MSGT_DVD,MSGL_V, "DVD start cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack); | |
492 | |
493 // ... (unimplemented) | |
494 // return NULL; | |
495 stream=new_stream(-1,STREAMTYPE_DVD); | |
496 stream->start_pos=(off_t)d->cur_pack*2048; | |
4390 | 497 stream->end_pos=(off_t)(d->cur_pgc->cell_playback[d->last_cell-1].last_sector)*2048; |
5932
1ebeebca86f3
printf to mp_msg + warning msg from MSGL_INFO to MSGT_WARN
albeu
parents:
5819
diff
changeset
|
498 mp_msg(MSGT_DVD,MSGL_V,"DVD start=%d end=%d \n",d->cur_pack,d->cur_pgc->cell_playback[d->last_cell-1].last_sector); |
1596 | 499 stream->priv=(void*)d; |
500 return stream; | |
501 } | |
502 #endif | |
503 | |
9610 | 504 #ifdef HAS_DVBIN_SUPPORT |
9746 | 505 if(strncmp("dvbin://",filename,8) == 0) |
9610 | 506 { |
507 stream = new_stream(-1, STREAMTYPE_DVB); | |
508 if (!stream) | |
509 return(NULL); | |
510 if (!dvb_streaming_start(stream)) | |
511 return NULL; | |
512 | |
513 return stream; | |
514 } | |
515 #endif | |
516 | |
517 | |
518 | |
519 | |
7408 | 520 //============ Check for TV-input or multi-file input ==== |
9746 | 521 if( (strncmp("mf://",filename,5) == 0) |
2790 | 522 #ifdef USE_TV |
9746 | 523 || (strncmp("tv://",filename,5) == 0) |
2790 | 524 #endif |
7408 | 525 ){ |
4551 | 526 /* create stream */ |
7407 | 527 stream = new_stream(-1, STREAMTYPE_DUMMY); |
528 if (!stream) return(NULL); | |
9746 | 529 if(strncmp("mf://",filename,5) == 0) { |
530 *file_format = DEMUXER_TYPE_MF; | |
9773 | 531 #ifdef USE_TV |
9746 | 532 } else { |
533 *file_format = DEMUXER_TYPE_TV; | |
534 if(filename[5] != '\0') | |
535 tv_param_channel = strdup(filename + 5); | |
9773 | 536 #endif |
9746 | 537 } |
538 stream->url= filename[5] != '\0' ? strdup(filename + 5) : NULL; | |
4551 | 539 return(stream); |
540 } | |
1467 | 541 |
542 #ifdef STREAMING | |
543 url = url_new(filename); | |
544 if(url) { | |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
545 if (strcmp(url->protocol, "smb")==0){ |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
546 #ifdef LIBSMBCLIENT |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
547 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
548 // we need init of libsmbclient |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
549 int err; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
550 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
551 // FIXME: HACK: make the username/password global varaibles |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
552 // so the auth_fn function should grab it ... |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
553 // i cannot thing other way... |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
554 err = smbc_init(smb_auth_fn, 10); /* Initialize things */ |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
555 // libsmbclient using |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
556 if (err < 0) { |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
557 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBInitError,err); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
558 return NULL; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
559 } |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
560 f=smbc_open(filename, O_RDONLY, 0666); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
561 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
562 // cannot open the file, outputs that |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
563 // MSGTR_FileNotFound -> MSGTR_SMBFileNotFound |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
564 if(f<0){ |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
565 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBFileNotFound,filename); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
566 return NULL; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
567 } |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
568 len=smbc_lseek(f,0,SEEK_END); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
569 smbc_lseek(f,0,SEEK_SET); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
570 // FIXME: I really wonder is such situation -> but who cares ;) |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
571 // if (len == -1) |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
572 // return new_stream(f,STREAMTYPE_STREAM); // open as stream |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
573 url_free(url); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
574 stream=new_stream(f,STREAMTYPE_SMB); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
575 stream->end_pos=len; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
576 return stream; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
577 #else |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
578 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBNotCompiled,filename); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
579 return NULL; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
580 #endif |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
581 } |
4251
05affdf4bdcd
Moved network related code from open.c to network.c
bertrand
parents:
4222
diff
changeset
|
582 stream=new_stream(f,STREAMTYPE_STREAM); |
4729
f51bd827ed1c
fixed MP3 ICY detection, return detected file format for open_stream
alex
parents:
4551
diff
changeset
|
583 if( streaming_start( stream, file_format, url )<0){ |
4251
05affdf4bdcd
Moved network related code from open.c to network.c
bertrand
parents:
4222
diff
changeset
|
584 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename); |
9795 | 585 //url_free(url); |
586 //return NULL; | |
587 } else { | |
1584 | 588 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ConnToServer, url->hostname ); |
3045
6c14fd789ba5
Changed the order of processing the network opening.
bertrand
parents:
2935
diff
changeset
|
589 url_free(url); |
2315 | 590 return stream; |
1467 | 591 } |
9795 | 592 } |
1467 | 593 |
6320
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
594 //============ Open STDIN or plain FILE ============ |
9795 | 595 #ifdef STREAMING_LIVE_DOT_COM |
596 // a SDP file: I hope the sdp protocol isn't really in use | |
597 if(strncmp("sdp://",filename,6) == 0) { | |
598 filename += 6; | |
9762 | 599 #if defined(__CYGWIN__) || defined(__MINGW32__) |
600 f=open(filename,O_RDONLY|O_BINARY); | |
601 #else | |
1467 | 602 f=open(filename,O_RDONLY); |
8712 | 603 #endif |
1584 | 604 if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);return NULL; } |
6320
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
605 |
1467 | 606 len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); |
607 if (len == -1) | |
9795 | 608 return NULL; |
6320
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
609 |
1467 | 610 #ifdef _LARGEFILE_SOURCE |
1567 | 611 mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len); |
1467 | 612 #else |
1567 | 613 mp_msg(MSGT_OPEN,MSGL_V,"File size is %u bytes\n", (unsigned int)len); |
1467 | 614 #endif |
9795 | 615 return stream_open_sdp(f, len, file_format); |
616 } | |
617 #endif | |
6910
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
618 #endif |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
619 |
9795 | 620 return open_stream_full(filename,STREAM_READ,options,file_format); |
1467 | 621 } |
1596 | 622 |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
623 int dvd_parse_chapter_range(struct config *conf, const char *range){ |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7432
diff
changeset
|
624 const char *s; |
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7432
diff
changeset
|
625 char *t; |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7854
diff
changeset
|
626 /* conf; prevent warning from GCC */ |
4344 | 627 s = range; |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
628 dvd_chapter = 1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
629 dvd_last_chapter = 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
630 if (*range && isdigit(*range)) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
631 dvd_chapter = strtol(range, &s, 10); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
632 if (range == s) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
633 mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
634 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
635 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
636 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
637 if (*s == 0) |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
638 return 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
639 else if (*s != '-') { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
640 mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
641 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
642 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
643 ++s; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
644 if (*s == 0) |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
645 return 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
646 if (! isdigit(*s)) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
647 mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
648 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
649 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
650 dvd_last_chapter = strtol(s, &t, 10); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
651 if (s == t || *t) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
652 mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
653 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
654 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
655 return 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
656 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
657 |
3753 | 658 #ifdef USE_DVDREAD |
7854 | 659 int dvd_chapter_from_cell(dvd_priv_t* dvd,int title,int cell) |
660 { | |
661 pgc_t * cur_pgc; | |
662 ptt_info_t* ptt; | |
663 int chapter = cell; | |
664 int pgc_id,pgn; | |
665 if(title < 0 || cell < 0){ | |
666 return 0; | |
667 } | |
668 /* for most DVD's chapter == cell */ | |
669 /* but there are more complecated cases... */ | |
670 if(chapter >= dvd->vmg_file->tt_srpt->title[title].nr_of_ptts){ | |
671 chapter = dvd->vmg_file->tt_srpt->title[title].nr_of_ptts-1; | |
672 } | |
673 title = dvd->tt_srpt->title[title].vts_ttn-1; | |
674 ptt = dvd->vts_file->vts_ptt_srpt->title[title].ptt; | |
675 while(chapter >= 0){ | |
676 pgc_id = ptt[chapter].pgcn; | |
677 pgn = ptt[chapter].pgn; | |
678 cur_pgc = dvd->vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; | |
679 if(cell >= cur_pgc->program_map[pgn-1]-1){ | |
680 return chapter; | |
681 } | |
682 --chapter; | |
683 } | |
684 /* didn't find a chapter ??? */ | |
685 return chapter; | |
686 } | |
1596 | 687 |
3753 | 688 int dvd_aid_from_lang(stream_t *stream, unsigned char* lang){ |
689 dvd_priv_t *d=stream->priv; | |
690 int code,i; | |
691 while(lang && strlen(lang)>=2){ | |
692 code=lang[1]|(lang[0]<<8); | |
693 for(i=0;i<d->nr_of_channels;i++){ | |
694 if(d->audio_streams[i].language==code){ | |
695 mp_msg(MSGT_OPEN,MSGL_INFO,"Selected DVD audio channel: %d language: %c%c\n", | |
696 d->audio_streams[i].id, lang[0],lang[1]); | |
697 return d->audio_streams[i].id; | |
698 } | |
699 // printf("%X != %X (%c%c)\n",code,d->audio_streams[i].language,lang[0],lang[1]); | |
700 } | |
701 lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; | |
702 } | |
5932
1ebeebca86f3
printf to mp_msg + warning msg from MSGL_INFO to MSGT_WARN
albeu
parents:
5819
diff
changeset
|
703 mp_msg(MSGT_OPEN,MSGL_WARN,"No matching DVD audio language found!\n"); |
3753 | 704 return -1; |
705 } | |
706 | |
707 int dvd_sid_from_lang(stream_t *stream, unsigned char* lang){ | |
708 dvd_priv_t *d=stream->priv; | |
709 int code,i; | |
710 while(lang && strlen(lang)>=2){ | |
711 code=lang[1]|(lang[0]<<8); | |
712 for(i=0;i<d->nr_of_subtitles;i++){ | |
713 if(d->subtitles[i].language==code){ | |
714 mp_msg(MSGT_OPEN,MSGL_INFO,"Selected DVD subtitle channel: %d language: %c%c\n", | |
715 d->subtitles[i].id, lang[0],lang[1]); | |
716 return d->subtitles[i].id; | |
717 } | |
718 } | |
719 lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; | |
720 } | |
5932
1ebeebca86f3
printf to mp_msg + warning msg from MSGL_INFO to MSGT_WARN
albeu
parents:
5819
diff
changeset
|
721 mp_msg(MSGT_OPEN,MSGL_WARN,"No matching DVD subtitle language found!\n"); |
3753 | 722 return -1; |
723 } | |
1596 | 724 |
725 static int dvd_next_cell(dvd_priv_t *d){ | |
726 int next_cell=d->cur_cell; | |
1616 | 727 |
728 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next1=0x%X \n",next_cell); | |
1596 | 729 |
730 if( d->cur_pgc->cell_playback[ next_cell ].block_type | |
731 == BLOCK_TYPE_ANGLE_BLOCK ) { | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
732 while(next_cell<d->last_cell){ |
1596 | 733 if( d->cur_pgc->cell_playback[next_cell].block_mode |
734 == BLOCK_MODE_LAST_CELL ) break; | |
735 ++next_cell; | |
736 } | |
737 } | |
1616 | 738 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next2=0x%X \n",next_cell); |
1596 | 739 |
740 ++next_cell; | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
741 if(next_cell>=d->last_cell) return -1; // EOF |
1596 | 742 if( d->cur_pgc->cell_playback[next_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ){ |
743 next_cell+=dvd_angle; | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
744 if(next_cell>=d->last_cell) return -1; // EOF |
1596 | 745 } |
1616 | 746 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next3=0x%X \n",next_cell); |
1596 | 747 return next_cell; |
748 } | |
749 | |
750 int dvd_read_sector(dvd_priv_t *d,unsigned char* data){ | |
751 int len; | |
752 | |
753 if(d->packs_left==0){ | |
754 /** | |
755 * If we're not at the end of this cell, we can determine the next | |
756 * VOBU to display using the VOBU_SRI information section of the | |
757 * DSI. Using this value correctly follows the current angle, | |
758 * avoiding the doubled scenes in The Matrix, and makes our life | |
759 * really happy. | |
760 * | |
761 * Otherwise, we set our next address past the end of this cell to | |
762 * force the code above to go to the next cell in the program. | |
763 */ | |
764 if( d->dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL ) { | |
765 d->cur_pack= d->dsi_pack.dsi_gi.nv_pck_lbn + | |
766 ( d->dsi_pack.vobu_sri.next_vobu & 0x7fffffff ); | |
767 mp_msg(MSGT_DVD,MSGL_DBG2, "Navi new pos=0x%X \n",d->cur_pack); | |
768 } else { | |
769 // end of cell! find next cell! | |
770 mp_msg(MSGT_DVD,MSGL_V, "--- END OF CELL !!! ---\n"); | |
771 d->cur_pack=d->cell_last_pack+1; | |
772 } | |
773 } | |
774 | |
775 read_next: | |
776 | |
777 if(d->cur_pack>d->cell_last_pack){ | |
778 // end of cell! | |
779 int next=dvd_next_cell(d); | |
780 if(next>=0){ | |
781 d->cur_cell=next; | |
782 | |
1615 | 783 // if( d->cur_pgc->cell_playback[d->cur_cell].block_type |
784 // == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; | |
1596 | 785 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; |
786 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
787 mp_msg(MSGT_DVD,MSGL_V, "DVD next cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack); | |
788 | |
789 } else return -1; // EOF | |
790 } | |
791 | |
792 len = DVDReadBlocks( d->title, d->cur_pack, 1, data ); | |
793 if(!len) return -1; //error | |
794 | |
795 if(data[38]==0 && data[39]==0 && data[40]==1 && data[41]==0xBF && | |
796 data[1024]==0 && data[1025]==0 && data[1026]==1 && data[1027]==0xBF){ | |
797 // found a Navi packet!!! | |
1875 | 798 #if LIBDVDREAD_VERSION >= DVDREAD_VERSION(0,9,0) |
799 navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]) ); | |
800 #else | |
1596 | 801 navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]), sizeof(dsi_t) ); |
1875 | 802 #endif |
1596 | 803 if(d->cur_pack != d->dsi_pack.dsi_gi.nv_pck_lbn ){ |
804 mp_msg(MSGT_DVD,MSGL_V, "Invalid NAVI packet! lba=0x%X navi=0x%X \n", | |
805 d->cur_pack,d->dsi_pack.dsi_gi.nv_pck_lbn); | |
806 } else { | |
807 // process! | |
808 d->packs_left = d->dsi_pack.dsi_gi.vobu_ea; | |
809 mp_msg(MSGT_DVD,MSGL_DBG2, "Found NAVI packet! lba=0x%X len=%d \n",d->cur_pack,d->packs_left); | |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
810 //navPrint_DSI(&d->dsi_pack); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
811 mp_msg(MSGT_DVD,MSGL_DBG3,"\r### CELL %d: Navi: %d/%d IFO: %d/%d \n",d->cur_cell, |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
812 d->dsi_pack.dsi_gi.vobu_c_idn,d->dsi_pack.dsi_gi.vobu_vob_idn, |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
813 d->cur_pgc->cell_position[d->cur_cell].cell_nr, |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
814 d->cur_pgc->cell_position[d->cur_cell].vob_id_nr); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
815 |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
816 if(d->angle_seek){ |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
817 int i,skip=0; |
7296
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
818 #if defined(__GNUC__) && defined(__sparc__) |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
819 // workaround for a bug in the sparc version of gcc 2.95.X ... 3.2, |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
820 // it generates incorrect code for unaligned access to a packed |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
821 // structure member, resulting in an mplayer crash with a SIGBUS |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
822 // signal. |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
823 // |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
824 // See also gcc problem report PR c/7847: |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
825 // http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gcc&cmd=view+audit-trail&pr=7847 |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
826 for(i=0;i<9;i++){ // check if all values zero: |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
827 typeof(d->dsi_pack.sml_agli.data[i].address) tmp_addr; |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
828 memcpy(&tmp_addr,&d->dsi_pack.sml_agli.data[i].address,sizeof(tmp_addr)); |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
829 if((skip=tmp_addr)!=0) break; |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
830 } |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
831 #else |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
832 for(i=0;i<9;i++) // check if all values zero: |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
833 if((skip=d->dsi_pack.sml_agli.data[i].address)!=0) break; |
7296
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
834 #endif |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
835 if(skip){ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
836 // sml_agli table has valid data (at least one non-zero): |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
837 d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
838 d->dsi_pack.sml_agli.data[dvd_angle].address; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
839 d->angle_seek=0; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
840 mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced using sml_agli map! new_lba=0x%X \n",d->cur_pack); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
841 } else { |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
842 // check if we're in the right cell, jump otherwise: |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
843 if( (d->dsi_pack.dsi_gi.vobu_c_idn==d->cur_pgc->cell_position[d->cur_cell].cell_nr) && |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
844 (d->dsi_pack.dsi_gi.vobu_vob_idn==d->cur_pgc->cell_position[d->cur_cell].vob_id_nr) ){ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
845 d->angle_seek=0; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
846 mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced by cell/vob IDN search! \n"); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
847 } else { |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
848 // wrong angle, skip this vobu: |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
849 d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
850 d->dsi_pack.dsi_gi.vobu_ea; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
851 d->angle_seek=2; // DEBUG |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
852 } |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
853 } |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
854 } |
1596 | 855 } |
856 ++d->cur_pack; | |
857 goto read_next; | |
858 } | |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
859 |
1596 | 860 ++d->cur_pack; |
861 if(d->packs_left>=0) --d->packs_left; | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
862 |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
863 if(d->angle_seek){ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
864 if(d->angle_seek==2) mp_msg(MSGT_DVD,MSGL_V, "!!! warning! reading packet while angle_seek !!!\n"); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
865 goto read_next; // searching for Navi packet |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
866 } |
1596 | 867 |
868 return d->cur_pack-1; | |
869 } | |
870 | |
871 void dvd_seek(dvd_priv_t *d,int pos){ | |
872 d->packs_left=-1; | |
873 d->cur_pack=pos; | |
874 | |
875 // check if we stay in current cell (speedup things, and avoid angle skip) | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
876 if(d->cur_pack>d->cell_last_pack || |
1596 | 877 d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){ |
878 | |
879 // ok, cell change, find the right cell! | |
880 d->cur_cell=0; | |
881 if( d->cur_pgc->cell_playback[d->cur_cell].block_type | |
882 == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; | |
883 | |
884 while(1){ | |
885 int next; | |
886 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
887 if(d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){ | |
888 d->cur_pack=d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; | |
889 break; | |
890 } | |
891 if(d->cur_pack<=d->cell_last_pack) break; // ok, we find it! :) | |
892 next=dvd_next_cell(d); | |
893 if(next<0){ | |
894 // d->cur_pack=d->cell_last_pack+1; | |
895 break; // we're after the last cell | |
896 } | |
897 d->cur_cell=next; | |
898 } | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
899 |
1596 | 900 } |
901 | |
902 mp_msg(MSGT_DVD,MSGL_V, "DVD Seek! lba=0x%X cell=%d packs: 0x%X-0x%X \n", | |
903 d->cur_pack,d->cur_cell,d->cur_pgc->cell_playback[ d->cur_cell ].first_sector,d->cell_last_pack); | |
904 | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
905 // if we're in interleaved multi-angle cell, find the right angle chain! |
1596 | 906 // (read Navi block, and use the seamless angle jump table) |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
907 d->angle_seek=1; |
1596 | 908 |
909 } | |
910 | |
6479 | 911 void dvd_close(dvd_priv_t *d) { |
912 ifoClose(d->vts_file); | |
913 ifoClose(d->vmg_file); | |
914 DVDCloseFile(d->title); | |
915 DVDClose(d->dvd); | |
9712 | 916 dvd_chapter = 1; |
917 dvd_last_chapter = 0; | |
6479 | 918 } |
919 | |
1596 | 920 #endif |