Mercurial > mplayer.hg
annotate libmpdemux/open.c @ 9988:a32fb6812221
bigendian fix by (Samuel Kleiner <kleiner at cd dot chalmers dot se>)
author | michael |
---|---|
date | Fri, 25 Apr 2003 17:22:11 +0000 |
parents | 233802490b0e |
children | f9eac474eb74 |
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 | |
8812 | 72 #include "cue_read.h" |
1467 | 73 |
9610 | 74 #ifdef HAS_DVBIN_SUPPORT |
75 #include "dvbin.h" | |
76 #endif | |
77 | |
78 | |
79 | |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
80 // Define function about auth the libsmbclient library |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
81 // 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
|
82 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
83 #ifdef LIBSMBCLIENT |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
84 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
85 #include "libsmbclient.h" |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
86 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
87 static char smb_password[15]; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
88 static char smb_username[15]; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
89 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
90 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
|
91 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
|
92 char *password, int pwmaxlen) |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
93 { |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
94 char temp[128]; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
95 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
96 strcpy(temp, "LAN"); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
97 if (temp[strlen(temp) - 1] == 0x0a) |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
98 temp[strlen(temp) - 1] = 0x00; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
99 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
100 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
|
101 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
102 strcpy(temp, smb_username); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
103 if (temp[strlen(temp) - 1] == 0x0a) |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
104 temp[strlen(temp) - 1] = 0x00; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
105 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
106 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
|
107 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
108 strcpy(temp, smb_password); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
109 if (temp[strlen(temp) - 1] == 0x0a) |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
110 temp[strlen(temp) - 1] = 0x00; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
111 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
112 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
|
113 } |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
114 |
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 #endif |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
117 |
1467 | 118 // Open a new stream (stdin/file/vcd/url) |
119 | |
9795 | 120 stream_t* open_stream(char* filename,char** options, int* file_format){ |
1467 | 121 stream_t* stream=NULL; |
122 int f=-1; | |
123 off_t len; | |
9746 | 124 *file_format = DEMUXER_TYPE_UNKNOWN; |
125 if(!filename) { | |
126 mp_msg(MSGT_OPEN,MSGL_ERR,"NULL filename, report this bug\n"); | |
127 return NULL; | |
128 } | |
1467 | 129 |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
130 // for opening of vcds in bincue files |
9746 | 131 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
|
132 int ret,ret2; |
9746 | 133 char* p = filename + 6; |
134 vcd_track = 1; | |
135 p = strchr(p,':'); | |
136 if(p && p[1] != '\0') { | |
137 vcd_track = strtol(p+1,NULL,0); | |
138 if(vcd_track < 1){ | |
139 mp_msg(MSGT_OPEN,MSGL_ERR,"Invalid cue track %s\n",p+1); | |
140 return NULL; | |
141 } | |
142 p[0] = '\0'; | |
143 } | |
144 f = cue_read_cue (filename + 6); | |
145 if(p && p[1] != '\0') p[0] = ':'; | |
146 if (f == -1) return NULL; | |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
147 cue_vcd_read_toc(); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
148 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
|
149 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
|
150 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
|
151 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
|
152 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
153 stream=new_stream(f,STREAMTYPE_VCDBINCUE); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
154 stream->start_pos=ret; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
155 stream->end_pos=ret2; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
156 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
|
157 return stream; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
158 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
159 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8712
diff
changeset
|
160 |
1596 | 161 //============ Open DVD title ============== |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
162 #ifdef USE_DVDNAV |
9746 | 163 if(strncmp("dvdnav://",filename,9) == 0){ |
5472 | 164 dvdnav_priv_t *dvdnav_priv; |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
165 int event,len,tmplen=0; |
9746 | 166 char* name = (filename[9] == '\0') ? NULL : filename + 9; |
167 | |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
168 stream=new_stream(-1,STREAMTYPE_DVDNAV); |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
169 if (!stream) { |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
170 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
|
171 return NULL; |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
172 } |
5472 | 173 |
9746 | 174 if(!name) name=DEFAULT_DVD_DEVICE; |
175 if (!(dvdnav_priv=new_dvdnav_stream(name))) { | |
176 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,name); | |
5472 | 177 return NULL; |
178 } | |
179 | |
180 stream->priv=(void*)dvdnav_priv; | |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
181 return stream; |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
182 } |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
183 #endif |
1596 | 184 #ifdef USE_DVDREAD |
9746 | 185 if(strncmp("dvd://",filename,6) == 0){ |
2050 | 186 // int ret,ret2; |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
187 dvd_priv_t *d; |
1596 | 188 int ttn,pgc_id,pgn; |
189 dvd_reader_t *dvd; | |
190 dvd_file_t *title; | |
191 ifo_handle_t *vmg_file; | |
192 tt_srpt_t *tt_srpt; | |
193 ifo_handle_t *vts_file; | |
9746 | 194 dvd_title = filename[6] == '\0' ? 1 : strtol(filename + 6,NULL,0); |
1596 | 195 /** |
196 * Open the disc. | |
197 */ | |
8649
0c258b964b08
fixes (ok, just workarounds) sig11 in playtree/cfgparser's free()
arpi
parents:
8528
diff
changeset
|
198 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
|
199 #ifdef SYS_DARWIN |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
200 /* 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
|
201 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
|
202 int i; |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
203 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
|
204 |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
205 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
|
206 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
|
207 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
|
208 if (!dvd) { |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
209 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
|
210 } else { |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
211 free(temp_device); |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
212 break; |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
213 } |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
214 } |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
215 |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
216 if (!dvd) |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
217 return NULL; |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
218 } else |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
219 #endif /* SYS_DARWIN */ |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
220 { |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
221 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
|
222 if( !dvd ) { |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
223 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
|
224 return NULL; |
aa0dd1f998d9
Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
michael
parents:
8812
diff
changeset
|
225 } |
1596 | 226 } |
227 | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
228 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDwait); |
1596 | 229 |
230 /** | |
231 * Load the video manager to find out the information about the titles on | |
232 * this disc. | |
233 */ | |
234 vmg_file = ifoOpen( dvd, 0 ); | |
235 if( !vmg_file ) { | |
236 mp_msg(MSGT_OPEN,MSGL_ERR, "Can't open VMG info!\n"); | |
237 DVDClose( dvd ); | |
238 return NULL; | |
239 } | |
240 tt_srpt = vmg_file->tt_srpt; | |
241 /** | |
242 * Make sure our title number is valid. | |
243 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
244 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumTitles, |
1596 | 245 tt_srpt->nr_of_srpts ); |
246 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
|
247 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidTitle, dvd_title); |
1596 | 248 ifoClose( vmg_file ); |
249 DVDClose( dvd ); | |
250 return NULL; | |
251 } | |
252 --dvd_title; // remap 1.. -> 0.. | |
253 /** | |
254 * Make sure the chapter number is valid for this title. | |
255 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
256 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumChapters, |
1596 | 257 tt_srpt->title[dvd_title].nr_of_ptts ); |
258 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
|
259 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidChapter, dvd_chapter); |
1596 | 260 ifoClose( vmg_file ); |
261 DVDClose( dvd ); | |
262 return NULL; | |
263 } | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
264 if( dvd_last_chapter>0 ) { |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
265 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
|
266 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
|
267 ifoClose( vmg_file ); |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
268 DVDClose( dvd ); |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
269 return NULL; |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
270 } |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
271 } |
1596 | 272 --dvd_chapter; // remap 1.. -> 0.. |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
273 /* XXX No need to remap dvd_last_chapter */ |
1596 | 274 /** |
275 * Make sure the angle number is valid for this title. | |
276 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
277 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumAngles, |
1596 | 278 tt_srpt->title[dvd_title].nr_of_angles ); |
279 if( dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles ) { | |
1977 | 280 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidAngle, dvd_angle); |
1596 | 281 ifoClose( vmg_file ); |
282 DVDClose( dvd ); | |
283 return NULL; | |
284 } | |
1617 | 285 --dvd_angle; // remap 1.. -> 0.. |
1596 | 286 /** |
287 * Load the VTS information for the title set our title is in. | |
288 */ | |
289 vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr ); | |
290 if( !vts_file ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
291 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoIFO, |
1596 | 292 tt_srpt->title[dvd_title].title_set_nr ); |
293 ifoClose( vmg_file ); | |
294 DVDClose( dvd ); | |
295 return NULL; | |
296 } | |
297 /** | |
298 * We've got enough info, time to open the title set data. | |
299 */ | |
300 title = DVDOpenFile( dvd, tt_srpt->title[dvd_title].title_set_nr, | |
301 DVD_READ_TITLE_VOBS ); | |
302 if( !title ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
303 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoVOBs, |
1596 | 304 tt_srpt->title[dvd_title].title_set_nr ); |
305 ifoClose( vts_file ); | |
306 ifoClose( vmg_file ); | |
307 DVDClose( dvd ); | |
308 return NULL; | |
309 } | |
310 | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
311 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDopenOk); |
1596 | 312 // store data |
313 d=malloc(sizeof(dvd_priv_t)); memset(d,0,sizeof(dvd_priv_t)); | |
314 d->dvd=dvd; | |
315 d->title=title; | |
316 d->vmg_file=vmg_file; | |
317 d->tt_srpt=tt_srpt; | |
318 d->vts_file=vts_file; | |
319 | |
320 /** | |
2935 | 321 * Check number of audio channels and types |
322 */ | |
323 { | |
324 int ac3aid = 128; | |
325 int mpegaid = 0; | |
326 int pcmaid = 160; | |
327 | |
328 d->nr_of_channels=0; | |
329 | |
330 if ( vts_file->vts_pgcit ) | |
331 { | |
332 int i; | |
333 for ( i=0;i<8;i++ ) | |
334 if ( vts_file->vts_pgcit->pgci_srp[0].pgc->audio_control[i] & 0x8000 ) | |
335 { | |
336 audio_attr_t * audio = &vts_file->vtsi_mat->vts_audio_attr[i]; | |
337 int language = 0; | |
338 char tmp[] = "unknown"; | |
339 | |
340 if ( audio->lang_type == 1 ) | |
341 { | |
342 language=audio->lang_code; | |
343 tmp[0]=language>>8; | |
344 tmp[1]=language&0xff; | |
345 tmp[2]=0; | |
346 } | |
347 | |
348 d->audio_streams[d->nr_of_channels].language=language; | |
349 d->audio_streams[d->nr_of_channels].id=0; | |
350 switch ( audio->audio_format ) | |
351 { | |
352 case 0: // ac3 | |
353 case 6: // dts | |
354 d->audio_streams[d->nr_of_channels].id=ac3aid; | |
355 ac3aid++; | |
356 break; | |
357 case 2: // mpeg layer 1/2/3 | |
358 case 3: // mpeg2 ext | |
359 d->audio_streams[d->nr_of_channels].id=mpegaid; | |
360 mpegaid++; | |
361 break; | |
362 case 4: // lpcm | |
363 d->audio_streams[d->nr_of_channels].id=pcmaid; | |
364 pcmaid++; | |
365 break; | |
366 } | |
367 | |
6651 | 368 d->audio_streams[d->nr_of_channels].type=audio->audio_format; |
369 // Pontscho: to my mind, tha channels: | |
370 // 1 - stereo | |
371 // 5 - 5.1 | |
372 d->audio_streams[d->nr_of_channels].channels=audio->channels; | |
373 mp_msg(MSGT_OPEN,MSGL_V,"[open] audio stream: %d audio format: %s (%s) language: %s aid: %d\n", | |
2935 | 374 d->nr_of_channels, |
375 dvd_audio_stream_types[ audio->audio_format ], | |
6651 | 376 dvd_audio_stream_channels[ audio->channels ], |
2935 | 377 tmp, |
378 d->audio_streams[d->nr_of_channels].id | |
379 ); | |
3753 | 380 |
2935 | 381 d->nr_of_channels++; |
382 } | |
383 } | |
3048 | 384 mp_msg(MSGT_OPEN,MSGL_V,"[open] number of audio channels on disk: %d.\n",d->nr_of_channels ); |
385 } | |
386 | |
387 /** | |
388 * Check number of subtitles and language | |
389 */ | |
390 { | |
391 int i; | |
392 | |
393 d->nr_of_subtitles=0; | |
394 for ( i=0;i<32;i++ ) | |
395 if ( vts_file->vts_pgcit->pgci_srp[0].pgc->subp_control[i] & 0x80000000 ) | |
396 { | |
397 subp_attr_t * subtitle = &vts_file->vtsi_mat->vts_subp_attr[i]; | |
398 int language = 0; | |
399 char tmp[] = "unknown"; | |
400 | |
401 if ( subtitle->type == 1 ) | |
402 { | |
403 language=subtitle->lang_code; | |
404 tmp[0]=language>>8; | |
405 tmp[1]=language&0xff; | |
406 tmp[2]=0; | |
407 } | |
408 | |
409 d->subtitles[ d->nr_of_subtitles ].language=language; | |
410 d->subtitles[ d->nr_of_subtitles ].id=d->nr_of_subtitles; | |
411 | |
412 mp_msg(MSGT_OPEN,MSGL_V,"[open] subtitle ( sid ): %d language: %s\n", | |
413 d->nr_of_subtitles, | |
414 tmp | |
415 ); | |
416 d->nr_of_subtitles++; | |
417 } | |
418 mp_msg(MSGT_OPEN,MSGL_V,"[open] number of subtitles on disk: %d\n",d->nr_of_subtitles ); | |
2935 | 419 } |
420 | |
421 /** | |
1596 | 422 * Determine which program chain we want to watch. This is based on the |
423 * chapter number. | |
424 */ | |
425 ttn = tt_srpt->title[ dvd_title ].vts_ttn; // local | |
426 pgc_id = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgcn; // local | |
427 pgn = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgn; // local | |
428 d->cur_pgc = vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; | |
429 d->cur_cell = d->cur_pgc->program_map[pgn-1] - 1; // start playback here | |
430 d->packs_left=-1; // for Navi stuff | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
431 d->angle_seek=0; |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
432 /* 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
|
433 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
|
434 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
|
435 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
|
436 } |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
437 else |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
438 d->last_cell=d->cur_pgc->nr_of_cells; |
1596 | 439 |
6651 | 440 if( d->cur_pgc->cell_playback[d->cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; |
1596 | 441 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; |
442 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
443 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); | |
444 | |
445 // ... (unimplemented) | |
446 // return NULL; | |
447 stream=new_stream(-1,STREAMTYPE_DVD); | |
448 stream->start_pos=(off_t)d->cur_pack*2048; | |
4390 | 449 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
|
450 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 | 451 stream->priv=(void*)d; |
452 return stream; | |
453 } | |
454 #endif | |
455 | |
9610 | 456 #ifdef HAS_DVBIN_SUPPORT |
9746 | 457 if(strncmp("dvbin://",filename,8) == 0) |
9610 | 458 { |
459 stream = new_stream(-1, STREAMTYPE_DVB); | |
460 if (!stream) | |
461 return(NULL); | |
462 if (!dvb_streaming_start(stream)) | |
463 return NULL; | |
464 | |
465 return stream; | |
466 } | |
467 #endif | |
468 | |
1467 | 469 #ifdef STREAMING |
9878
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
470 #ifdef STREAMING_LIVE_DOT_COM |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
471 // Check for a SDP file: |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
472 if (strncmp("sdp://",filename,6) == 0) { |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
473 filename += 6; |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
474 #if defined(__CYGWIN__) || defined(__MINGW32__) |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
475 f=open(filename,O_RDONLY|O_BINARY); |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
476 #else |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
477 f=open(filename,O_RDONLY); |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
478 #endif |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
479 if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);return NULL; } |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
480 |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
481 len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
482 if (len == -1) |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
483 return NULL; |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
484 |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
485 #ifdef _LARGEFILE_SOURCE |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
486 mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len); |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
487 #else |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
488 mp_msg(MSGT_OPEN,MSGL_V,"File size is %u bytes\n", (unsigned int)len); |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
489 #endif |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
490 return stream_open_sdp(f, len, file_format); |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
491 } |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
492 #endif |
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
493 |
1467 | 494 url = url_new(filename); |
495 if(url) { | |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
496 if (strcmp(url->protocol, "smb")==0){ |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
497 #ifdef LIBSMBCLIENT |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
498 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
499 // we need init of libsmbclient |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
500 int err; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
501 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
502 // 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
|
503 // 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
|
504 // i cannot thing other way... |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
505 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
|
506 // libsmbclient using |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
507 if (err < 0) { |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
508 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
|
509 return NULL; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
510 } |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
511 f=smbc_open(filename, O_RDONLY, 0666); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
512 |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
513 // cannot open the file, outputs that |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
514 // MSGTR_FileNotFound -> MSGTR_SMBFileNotFound |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
515 if(f<0){ |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
516 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
|
517 return NULL; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
518 } |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
519 len=smbc_lseek(f,0,SEEK_END); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
520 smbc_lseek(f,0,SEEK_SET); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
521 // 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
|
522 // if (len == -1) |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
523 // 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
|
524 url_free(url); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
525 stream=new_stream(f,STREAMTYPE_SMB); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
526 stream->end_pos=len; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
527 return stream; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
528 #else |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
529 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
|
530 return NULL; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
531 #endif |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7559
diff
changeset
|
532 } |
4251
05affdf4bdcd
Moved network related code from open.c to network.c
bertrand
parents:
4222
diff
changeset
|
533 stream=new_stream(f,STREAMTYPE_STREAM); |
4729
f51bd827ed1c
fixed MP3 ICY detection, return detected file format for open_stream
alex
parents:
4551
diff
changeset
|
534 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
|
535 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename); |
9795 | 536 //url_free(url); |
537 //return NULL; | |
538 } else { | |
1584 | 539 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
|
540 url_free(url); |
2315 | 541 return stream; |
1467 | 542 } |
9795 | 543 } |
9878
95727467a091
Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents:
9801
diff
changeset
|
544 #endif |
1467 | 545 |
6320
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
546 //============ Open STDIN or plain FILE ============ |
6910
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
547 |
9795 | 548 return open_stream_full(filename,STREAM_READ,options,file_format); |
1467 | 549 } |
1596 | 550 |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
551 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
|
552 const char *s; |
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7432
diff
changeset
|
553 char *t; |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7854
diff
changeset
|
554 /* conf; prevent warning from GCC */ |
4344 | 555 s = range; |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
556 dvd_chapter = 1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
557 dvd_last_chapter = 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
558 if (*range && isdigit(*range)) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
559 dvd_chapter = strtol(range, &s, 10); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
560 if (range == s) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
561 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
|
562 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
563 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
564 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
565 if (*s == 0) |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
566 return 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
567 else if (*s != '-') { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
568 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
|
569 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
570 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
571 ++s; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
572 if (*s == 0) |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
573 return 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
574 if (! isdigit(*s)) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
575 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
|
576 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
577 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
578 dvd_last_chapter = strtol(s, &t, 10); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
579 if (s == t || *t) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
580 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
|
581 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
582 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
583 return 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
584 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
585 |
3753 | 586 #ifdef USE_DVDREAD |
7854 | 587 int dvd_chapter_from_cell(dvd_priv_t* dvd,int title,int cell) |
588 { | |
589 pgc_t * cur_pgc; | |
590 ptt_info_t* ptt; | |
591 int chapter = cell; | |
592 int pgc_id,pgn; | |
593 if(title < 0 || cell < 0){ | |
594 return 0; | |
595 } | |
596 /* for most DVD's chapter == cell */ | |
597 /* but there are more complecated cases... */ | |
598 if(chapter >= dvd->vmg_file->tt_srpt->title[title].nr_of_ptts){ | |
599 chapter = dvd->vmg_file->tt_srpt->title[title].nr_of_ptts-1; | |
600 } | |
601 title = dvd->tt_srpt->title[title].vts_ttn-1; | |
602 ptt = dvd->vts_file->vts_ptt_srpt->title[title].ptt; | |
603 while(chapter >= 0){ | |
604 pgc_id = ptt[chapter].pgcn; | |
605 pgn = ptt[chapter].pgn; | |
606 cur_pgc = dvd->vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; | |
607 if(cell >= cur_pgc->program_map[pgn-1]-1){ | |
608 return chapter; | |
609 } | |
610 --chapter; | |
611 } | |
612 /* didn't find a chapter ??? */ | |
613 return chapter; | |
614 } | |
1596 | 615 |
3753 | 616 int dvd_aid_from_lang(stream_t *stream, unsigned char* lang){ |
617 dvd_priv_t *d=stream->priv; | |
618 int code,i; | |
619 while(lang && strlen(lang)>=2){ | |
620 code=lang[1]|(lang[0]<<8); | |
621 for(i=0;i<d->nr_of_channels;i++){ | |
622 if(d->audio_streams[i].language==code){ | |
623 mp_msg(MSGT_OPEN,MSGL_INFO,"Selected DVD audio channel: %d language: %c%c\n", | |
624 d->audio_streams[i].id, lang[0],lang[1]); | |
625 return d->audio_streams[i].id; | |
626 } | |
627 // printf("%X != %X (%c%c)\n",code,d->audio_streams[i].language,lang[0],lang[1]); | |
628 } | |
629 lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; | |
630 } | |
5932
1ebeebca86f3
printf to mp_msg + warning msg from MSGL_INFO to MSGT_WARN
albeu
parents:
5819
diff
changeset
|
631 mp_msg(MSGT_OPEN,MSGL_WARN,"No matching DVD audio language found!\n"); |
3753 | 632 return -1; |
633 } | |
634 | |
635 int dvd_sid_from_lang(stream_t *stream, unsigned char* lang){ | |
636 dvd_priv_t *d=stream->priv; | |
637 int code,i; | |
638 while(lang && strlen(lang)>=2){ | |
639 code=lang[1]|(lang[0]<<8); | |
640 for(i=0;i<d->nr_of_subtitles;i++){ | |
641 if(d->subtitles[i].language==code){ | |
642 mp_msg(MSGT_OPEN,MSGL_INFO,"Selected DVD subtitle channel: %d language: %c%c\n", | |
643 d->subtitles[i].id, lang[0],lang[1]); | |
644 return d->subtitles[i].id; | |
645 } | |
646 } | |
647 lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; | |
648 } | |
5932
1ebeebca86f3
printf to mp_msg + warning msg from MSGL_INFO to MSGT_WARN
albeu
parents:
5819
diff
changeset
|
649 mp_msg(MSGT_OPEN,MSGL_WARN,"No matching DVD subtitle language found!\n"); |
3753 | 650 return -1; |
651 } | |
1596 | 652 |
653 static int dvd_next_cell(dvd_priv_t *d){ | |
654 int next_cell=d->cur_cell; | |
1616 | 655 |
656 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next1=0x%X \n",next_cell); | |
1596 | 657 |
658 if( d->cur_pgc->cell_playback[ next_cell ].block_type | |
659 == BLOCK_TYPE_ANGLE_BLOCK ) { | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
660 while(next_cell<d->last_cell){ |
1596 | 661 if( d->cur_pgc->cell_playback[next_cell].block_mode |
662 == BLOCK_MODE_LAST_CELL ) break; | |
663 ++next_cell; | |
664 } | |
665 } | |
1616 | 666 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next2=0x%X \n",next_cell); |
1596 | 667 |
668 ++next_cell; | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
669 if(next_cell>=d->last_cell) return -1; // EOF |
1596 | 670 if( d->cur_pgc->cell_playback[next_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ){ |
671 next_cell+=dvd_angle; | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
672 if(next_cell>=d->last_cell) return -1; // EOF |
1596 | 673 } |
1616 | 674 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next3=0x%X \n",next_cell); |
1596 | 675 return next_cell; |
676 } | |
677 | |
678 int dvd_read_sector(dvd_priv_t *d,unsigned char* data){ | |
679 int len; | |
680 | |
681 if(d->packs_left==0){ | |
682 /** | |
683 * If we're not at the end of this cell, we can determine the next | |
684 * VOBU to display using the VOBU_SRI information section of the | |
685 * DSI. Using this value correctly follows the current angle, | |
686 * avoiding the doubled scenes in The Matrix, and makes our life | |
687 * really happy. | |
688 * | |
689 * Otherwise, we set our next address past the end of this cell to | |
690 * force the code above to go to the next cell in the program. | |
691 */ | |
692 if( d->dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL ) { | |
693 d->cur_pack= d->dsi_pack.dsi_gi.nv_pck_lbn + | |
694 ( d->dsi_pack.vobu_sri.next_vobu & 0x7fffffff ); | |
695 mp_msg(MSGT_DVD,MSGL_DBG2, "Navi new pos=0x%X \n",d->cur_pack); | |
696 } else { | |
697 // end of cell! find next cell! | |
698 mp_msg(MSGT_DVD,MSGL_V, "--- END OF CELL !!! ---\n"); | |
699 d->cur_pack=d->cell_last_pack+1; | |
700 } | |
701 } | |
702 | |
703 read_next: | |
704 | |
705 if(d->cur_pack>d->cell_last_pack){ | |
706 // end of cell! | |
707 int next=dvd_next_cell(d); | |
708 if(next>=0){ | |
709 d->cur_cell=next; | |
710 | |
1615 | 711 // if( d->cur_pgc->cell_playback[d->cur_cell].block_type |
712 // == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; | |
1596 | 713 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; |
714 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
715 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); | |
716 | |
717 } else return -1; // EOF | |
718 } | |
719 | |
720 len = DVDReadBlocks( d->title, d->cur_pack, 1, data ); | |
721 if(!len) return -1; //error | |
722 | |
723 if(data[38]==0 && data[39]==0 && data[40]==1 && data[41]==0xBF && | |
724 data[1024]==0 && data[1025]==0 && data[1026]==1 && data[1027]==0xBF){ | |
725 // found a Navi packet!!! | |
1875 | 726 #if LIBDVDREAD_VERSION >= DVDREAD_VERSION(0,9,0) |
727 navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]) ); | |
728 #else | |
1596 | 729 navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]), sizeof(dsi_t) ); |
1875 | 730 #endif |
1596 | 731 if(d->cur_pack != d->dsi_pack.dsi_gi.nv_pck_lbn ){ |
732 mp_msg(MSGT_DVD,MSGL_V, "Invalid NAVI packet! lba=0x%X navi=0x%X \n", | |
733 d->cur_pack,d->dsi_pack.dsi_gi.nv_pck_lbn); | |
734 } else { | |
735 // process! | |
736 d->packs_left = d->dsi_pack.dsi_gi.vobu_ea; | |
737 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
|
738 //navPrint_DSI(&d->dsi_pack); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
739 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
|
740 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
|
741 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
|
742 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
|
743 |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
744 if(d->angle_seek){ |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
745 int i,skip=0; |
7296
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
746 #if defined(__GNUC__) && defined(__sparc__) |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
747 // 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
|
748 // 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
|
749 // 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
|
750 // signal. |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
751 // |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
752 // 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
|
753 // 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
|
754 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
|
755 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
|
756 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
|
757 if((skip=tmp_addr)!=0) break; |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
758 } |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
759 #else |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
760 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
|
761 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
|
762 #endif |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
763 if(skip){ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
764 // 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
|
765 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
|
766 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
|
767 d->angle_seek=0; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
768 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
|
769 } else { |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
770 // 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
|
771 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
|
772 (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
|
773 d->angle_seek=0; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
774 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
|
775 } else { |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
776 // wrong angle, skip this vobu: |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
777 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
|
778 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
|
779 d->angle_seek=2; // DEBUG |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
780 } |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
781 } |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
782 } |
1596 | 783 } |
784 ++d->cur_pack; | |
785 goto read_next; | |
786 } | |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
787 |
1596 | 788 ++d->cur_pack; |
789 if(d->packs_left>=0) --d->packs_left; | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
790 |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
791 if(d->angle_seek){ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
792 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
|
793 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
|
794 } |
1596 | 795 |
796 return d->cur_pack-1; | |
797 } | |
798 | |
799 void dvd_seek(dvd_priv_t *d,int pos){ | |
800 d->packs_left=-1; | |
801 d->cur_pack=pos; | |
802 | |
803 // 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
|
804 if(d->cur_pack>d->cell_last_pack || |
1596 | 805 d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){ |
806 | |
807 // ok, cell change, find the right cell! | |
808 d->cur_cell=0; | |
809 if( d->cur_pgc->cell_playback[d->cur_cell].block_type | |
810 == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; | |
811 | |
812 while(1){ | |
813 int next; | |
814 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
815 if(d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){ | |
816 d->cur_pack=d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; | |
817 break; | |
818 } | |
819 if(d->cur_pack<=d->cell_last_pack) break; // ok, we find it! :) | |
820 next=dvd_next_cell(d); | |
821 if(next<0){ | |
822 // d->cur_pack=d->cell_last_pack+1; | |
823 break; // we're after the last cell | |
824 } | |
825 d->cur_cell=next; | |
826 } | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
827 |
1596 | 828 } |
829 | |
830 mp_msg(MSGT_DVD,MSGL_V, "DVD Seek! lba=0x%X cell=%d packs: 0x%X-0x%X \n", | |
831 d->cur_pack,d->cur_cell,d->cur_pgc->cell_playback[ d->cur_cell ].first_sector,d->cell_last_pack); | |
832 | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
833 // if we're in interleaved multi-angle cell, find the right angle chain! |
1596 | 834 // (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
|
835 d->angle_seek=1; |
1596 | 836 |
837 } | |
838 | |
6479 | 839 void dvd_close(dvd_priv_t *d) { |
840 ifoClose(d->vts_file); | |
841 ifoClose(d->vmg_file); | |
842 DVDCloseFile(d->title); | |
843 DVDClose(d->dvd); | |
9712 | 844 dvd_chapter = 1; |
845 dvd_last_chapter = 0; | |
6479 | 846 } |
847 | |
1596 | 848 #endif |