Mercurial > mplayer.hg
annotate stream/vcd_read_darwin.h @ 36965:5fb43d5efdca
configure: add CONFIG_CABAC
fix ffmpeg linking
author | michael |
---|---|
date | Tue, 25 Mar 2014 00:15:02 +0000 |
parents | 3a192d8ecc56 |
children |
rev | line source |
---|---|
30426
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
1 /* |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
2 * This file is part of MPlayer. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
3 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
7 * (at your option) any later version. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
8 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
12 * GNU General Public License for more details. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
13 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
17 */ |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
18 |
26029 | 19 #ifndef MPLAYER_VCD_READ_DARWIN_H |
20 #define MPLAYER_VCD_READ_DARWIN_H | |
26012 | 21 |
30165 | 22 #define _XOPEN_SOURCE 500 |
23 | |
26184
7ee4ae1648e6
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
24 #include <stdlib.h> |
7ee4ae1648e6
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
25 #include <string.h> |
7ee4ae1648e6
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
26 #include <errno.h> |
13842 | 27 #include <sys/types.h> |
26186
49df679a7c1a
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26184
diff
changeset
|
28 #include <sys/uio.h> |
49df679a7c1a
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26184
diff
changeset
|
29 #include <unistd.h> |
13842 | 30 #include <CoreFoundation/CFBase.h> |
31 #include <IOKit/IOKitLib.h> | |
32 #include <IOKit/storage/IOCDTypes.h> | |
33 #include <IOKit/storage/IOCDMedia.h> | |
13682 | 34 #include <IOKit/storage/IOCDMediaBSDClient.h> |
23896 | 35 #include "mpbswap.h" |
26184
7ee4ae1648e6
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
36 #include "mp_msg.h" |
26186
49df679a7c1a
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26184
diff
changeset
|
37 #include "stream.h" |
13682 | 38 |
39 //=================== VideoCD ========================== | |
40 #define CDROM_LEADOUT 0xAA | |
41 | |
42 typedef struct | |
43 { | |
44 uint8_t sync [12]; | |
45 uint8_t header [4]; | |
46 uint8_t subheader [8]; | |
47 uint8_t data [2324]; | |
48 uint8_t spare [4]; | |
49 } cdsector_t; | |
50 | |
51 typedef struct mp_vcd_priv_st | |
52 { | |
53 int fd; | |
25376
382aeacc771f
The buffer used for pread need be aligned, but currently it got an offset 23
ulion
parents:
25375
diff
changeset
|
54 cdsector_t buf; |
13682 | 55 dk_cd_read_track_info_t entry; |
25378
f0f03ec41cd3
Only read disc info once and save it for later using.
ulion
parents:
25376
diff
changeset
|
56 struct CDDiscInfo hdr; |
13682 | 57 CDMSF msf; |
36433 | 58 unsigned int track; |
13682 | 59 } mp_vcd_priv_t; |
60 | |
61 static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect) | |
62 { | |
23898
3a5f766397b5
Simplify and fix missing offset for Darwin vcd_get/set_msf functions
reimar
parents:
23896
diff
changeset
|
63 vcd->msf = CDConvertLBAToMSF(sect); |
13682 | 64 } |
65 | |
66 static inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd) | |
67 { | |
23898
3a5f766397b5
Simplify and fix missing offset for Darwin vcd_get/set_msf functions
reimar
parents:
23896
diff
changeset
|
68 return CDConvertMSFToLBA(vcd->msf); |
13682 | 69 } |
70 | |
33349
3ab3212fb624
Make vcd_seek_to_track static, the GUI no longer needs to
reimar
parents:
30981
diff
changeset
|
71 static int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track) |
13682 | 72 { |
73 struct CDTrackInfo entry; | |
74 | |
75 memset( &vcd->entry, 0, sizeof(vcd->entry)); | |
76 vcd->entry.addressType = kCDTrackInfoAddressTypeTrackNumber; | |
77 vcd->entry.address = track; | |
78 vcd->entry.bufferLength = sizeof(entry); | |
79 vcd->entry.buffer = &entry; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
80 |
13682 | 81 if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry)) |
82 { | |
83 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno)); | |
84 return -1; | |
85 } | |
23896 | 86 vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress)); |
13682 | 87 return VCD_SECTOR_DATA*vcd_get_msf(vcd); |
88 } | |
89 | |
30670
fbd6ba7e0e14
Mark vcd_get_track_end () and vcd_read_toc() as static.
diego
parents:
30426
diff
changeset
|
90 static int vcd_get_track_end(mp_vcd_priv_t* vcd, int track) |
13682 | 91 { |
92 struct CDTrackInfo entry; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
93 |
25378
f0f03ec41cd3
Only read disc info once and save it for later using.
ulion
parents:
25376
diff
changeset
|
94 if (track > vcd->hdr.lastTrackNumberInLastSessionLSB) { |
25375
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
95 mp_msg(MSGT_OPEN, MSGL_ERR, |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
96 "track number %d greater than last track number %d\n", |
25378
f0f03ec41cd3
Only read disc info once and save it for later using.
ulion
parents:
25376
diff
changeset
|
97 track, vcd->hdr.lastTrackNumberInLastSessionLSB); |
25375
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
98 return -1; |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
99 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
100 |
13682 | 101 //read track info |
102 memset( &vcd->entry, 0, sizeof(vcd->entry)); | |
103 vcd->entry.addressType = kCDTrackInfoAddressTypeTrackNumber; | |
25378
f0f03ec41cd3
Only read disc info once and save it for later using.
ulion
parents:
25376
diff
changeset
|
104 vcd->entry.address = track<vcd->hdr.lastTrackNumberInLastSessionLSB?track+1:vcd->hdr.lastTrackNumberInLastSessionLSB; |
13682 | 105 vcd->entry.bufferLength = sizeof(entry); |
106 vcd->entry.buffer = &entry; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
107 |
13682 | 108 if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry)) |
109 { | |
110 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno)); | |
111 return -1; | |
112 } | |
25378
f0f03ec41cd3
Only read disc info once and save it for later using.
ulion
parents:
25376
diff
changeset
|
113 if (track == vcd->hdr.lastTrackNumberInLastSessionLSB) |
25375
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
114 vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress) + |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
115 be2me_32(entry.trackSize)); |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
116 else |
23896 | 117 vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress)); |
13682 | 118 return VCD_SECTOR_DATA*vcd_get_msf(vcd); |
119 } | |
120 | |
30670
fbd6ba7e0e14
Mark vcd_get_track_end () and vcd_read_toc() as static.
diego
parents:
30426
diff
changeset
|
121 static mp_vcd_priv_t* vcd_read_toc(int fd) |
13682 | 122 { |
123 dk_cd_read_disc_info_t tochdr; | |
124 struct CDDiscInfo hdr; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
125 |
13682 | 126 dk_cd_read_track_info_t tocentry; |
127 struct CDTrackInfo entry; | |
128 CDMSF trackMSF; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
129 |
13682 | 130 mp_vcd_priv_t* vcd; |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
131 int i, min = 0, sec = 0, frame = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
132 |
13682 | 133 //read toc header |
134 memset(&tochdr, 0, sizeof(tochdr)); | |
135 tochdr.buffer = &hdr; | |
136 tochdr.bufferLength = sizeof(hdr); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
137 |
13682 | 138 if (ioctl(fd, DKIOCCDREADDISCINFO, &tochdr) < 0) |
139 { | |
140 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno)); | |
141 return NULL; | |
142 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
143 |
13682 | 144 //print all track info |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
145 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n", hdr.firstTrackNumberInLastSessionLSB); |
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
146 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n", hdr.lastTrackNumberInLastSessionLSB); |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
147 for (i=hdr.firstTrackNumberInLastSessionLSB ; i<=hdr.lastTrackNumberInLastSessionLSB + 1; i++) |
13682 | 148 { |
25375
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
149 if (i <= hdr.lastTrackNumberInLastSessionLSB) { |
13682 | 150 memset( &tocentry, 0, sizeof(tocentry)); |
151 tocentry.addressType = kCDTrackInfoAddressTypeTrackNumber; | |
25375
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
152 tocentry.address = i; |
13682 | 153 tocentry.bufferLength = sizeof(entry); |
154 tocentry.buffer = &entry; | |
155 | |
156 if (ioctl(fd,DKIOCCDREADTRACKINFO,&tocentry)==-1) | |
157 { | |
158 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno)); | |
159 return NULL; | |
160 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
161 |
23896 | 162 trackMSF = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress)); |
25375
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
163 } |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
164 else |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
165 trackMSF = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress) |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
166 + be2me_32(entry.trackSize)); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
167 |
13682 | 168 //mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n", |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
169 if (i<=hdr.lastTrackNumberInLastSessionLSB) |
13682 | 170 mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: format=%d %02d:%02d:%02d\n", |
171 (int)tocentry.address, | |
172 //(int)tocentry.entry.addr_type, | |
173 //(int)tocentry.entry.control, | |
174 (int)tocentry.addressType, | |
175 (int)trackMSF.minute, | |
176 (int)trackMSF.second, | |
177 (int)trackMSF.frame | |
178 ); | |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
179 |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
180 if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
181 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
182 if (i > hdr.firstTrackNumberInLastSessionLSB) |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
183 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
184 min = trackMSF.minute - min; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
185 sec = trackMSF.second - sec; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
186 frame = trackMSF.frame - frame; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
187 if ( frame < 0 ) |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
188 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
189 frame += 75; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
190 sec --; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
191 } |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
192 if ( sec < 0 ) |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
193 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
194 sec += 60; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
195 min --; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
196 } |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
197 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", i - 1, min, sec, frame); |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
198 } |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
199 min = trackMSF.minute; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
200 sec = trackMSF.second; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
201 frame = trackMSF.frame; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
202 } |
13682 | 203 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
204 |
13682 | 205 vcd = malloc(sizeof(mp_vcd_priv_t)); |
206 vcd->fd = fd; | |
25378
f0f03ec41cd3
Only read disc info once and save it for later using.
ulion
parents:
25376
diff
changeset
|
207 vcd->hdr = hdr; |
13682 | 208 vcd->msf = trackMSF; |
209 return vcd; | |
210 } | |
211 | |
30981 | 212 static int vcd_end_track(mp_vcd_priv_t* vcd) |
213 { | |
214 return vcd->hdr.lastTrackNumberInLastSessionLSB; | |
215 } | |
216 | |
13682 | 217 static int vcd_read(mp_vcd_priv_t* vcd,char *mem) |
218 { | |
219 if (pread(vcd->fd,&vcd->buf,VCD_SECTOR_SIZE,vcd_get_msf(vcd)*VCD_SECTOR_SIZE) != VCD_SECTOR_SIZE) | |
220 return 0; // EOF? | |
221 | |
222 vcd->msf.frame++; | |
223 if (vcd->msf.frame==75) | |
224 { | |
225 vcd->msf.frame=0; | |
226 vcd->msf.second++; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
227 |
13682 | 228 if (vcd->msf.second==60) |
229 { | |
230 vcd->msf.second=0; | |
231 vcd->msf.minute++; | |
232 } | |
233 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
234 |
13682 | 235 memcpy(mem,vcd->buf.data,VCD_SECTOR_DATA); |
236 return VCD_SECTOR_DATA; | |
237 } | |
238 | |
26029 | 239 #endif /* MPLAYER_VCD_READ_DARWIN_H */ |