annotate stream/stream_vcd.c @ 35756:3919b6360e54

Cosmetic: Adjust indent.
author ib
date Thu, 24 Jan 2013 15:59:24 +0000
parents 206264c532f5
children b5abdfe9bc61
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30426
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29263
diff changeset
1 /*
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29263
diff changeset
3 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29263
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: 29263
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: 29263
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: 29263
diff changeset
7 * (at your option) any later version.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29263
diff changeset
8 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29263
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: 29263
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: 29263
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: 29263
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: 29263
diff changeset
13 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29263
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: 29263
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: 29263
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: 29263
diff changeset
17 */
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
18
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
19 #include "config.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
20
27727
48c1ae64255b Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
diego
parents: 25691
diff changeset
21 #if defined(__MINGW32__) || defined(__CYGWIN__)
22506
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
22 #include <windows.h>
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
23 #endif
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
24
30777
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
25 #include "osdep/osdep.h"
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
26
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
27 #include "mp_msg.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
28 #include "stream.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
29 #include "help_mp.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15912
diff changeset
30 #include "m_option.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15912
diff changeset
31 #include "m_struct.h"
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
32
10121
d42177a0da2a Changed the STREAMING defines to MPLAYER_NETWORK to avoid name definition clash.
bertrand
parents: 9886
diff changeset
33 #include <fcntl.h>
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
34 #include <stdlib.h>
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
35 #include <unistd.h>
27727
48c1ae64255b Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
diego
parents: 25691
diff changeset
36 #if !defined(__MINGW32__) && !defined(__CYGWIN__)
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
37 #include <sys/ioctl.h>
22506
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
38 #endif
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
39 #include <errno.h>
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
40
23857
d5223bab4b92 Somewhat unified *BSD vcd reading
reimar
parents: 22775
diff changeset
41 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27727
diff changeset
42 #include "vcd_read_fbsd.h"
25342
23f02d6ac901 Replace SYS_DARWIN by __APPLE__ and __DARWIN__ where appropriate.
diego
parents: 25242
diff changeset
43 #elif defined(__APPLE__)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27727
diff changeset
44 #include "vcd_read_darwin.h"
27727
48c1ae64255b Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
diego
parents: 25691
diff changeset
45 #elif defined(__MINGW32__) || defined(__CYGWIN__)
22506
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
46 #include "vcd_read_win32.h"
30777
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
47 #elif defined(__OS2__)
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
48 #include "vcd_read_os2.h"
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
49 #else
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
50 #include "vcd_read.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
51 #endif
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
52
21926
a8cd73869242 at open() assign *file_format=DEMUXER_TYPE_MPEG_PS to avoid useless demuxer probing
nicodvb
parents: 21848
diff changeset
53 #include "libmpdemux/demuxer.h"
a8cd73869242 at open() assign *file_format=DEMUXER_TYPE_MPEG_PS to avoid useless demuxer probing
nicodvb
parents: 21848
diff changeset
54
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
55 static struct stream_priv_s {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
56 int track;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
57 char* device;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
58 } stream_priv_dflts = {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
59 1,
10591
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
60 NULL
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
61 };
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
62
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
63 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f)
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
64 /// URL definition
25242
371a40dcc1cc stream_opts arrays should be const
reimar
parents: 25211
diff changeset
65 static const m_option_t stream_opts_fields[] = {
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
66 { "track", ST_OFF(track), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL },
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
67 { "device", ST_OFF(device), CONF_TYPE_STRING, 0, 0 ,0, NULL},
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
68 /// For url parsing
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
69 { "hostname", ST_OFF(track), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL },
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
70 { "filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0 ,0, NULL},
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
71 { NULL, NULL, 0, 0, 0, 0, NULL }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
72 };
25691
68015115f63a stream_opts should be const
reimar
parents: 25342
diff changeset
73 static const struct m_struct_st stream_opts = {
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
74 "vcd",
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
75 sizeof(struct stream_priv_s),
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
76 &stream_priv_dflts,
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
77 stream_opts_fields
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
78 };
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
79
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
80 static int fill_buffer(stream_t *s, char* buffer, int max_len){
15912
25feca1387e7 don't read past the end of the selected track
nicodvb
parents: 15566
diff changeset
81 if(s->pos > s->end_pos) /// don't past end of current track
25feca1387e7 don't read past the end of the selected track
nicodvb
parents: 15566
diff changeset
82 return 0;
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
83 return vcd_read(s->priv,buffer);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
84 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
85
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
86 static int seek(stream_t *s,off_t newpos) {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
87 s->pos = newpos;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
88 vcd_set_msf(s->priv,s->pos/VCD_SECTOR_DATA);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
89 return 1;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
90 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
91
30977
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
92 static int control(stream_t *stream, int cmd, void *arg) {
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
93 struct stream_priv_s *p = stream->priv;
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
94 switch(cmd) {
34386
206264c532f5 Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents: 31433
diff changeset
95 case STREAM_CTRL_GET_NUM_TITLES:
30977
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
96 case STREAM_CTRL_GET_NUM_CHAPTERS:
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
97 {
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
98 mp_vcd_priv_t *vcd = vcd_read_toc(stream->fd);
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
99 if (!vcd)
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
100 break;
30981
9bab99cfdff2 Try to fix VCD compilation on non-Linux systems.
reimar
parents: 30977
diff changeset
101 *(unsigned int *)arg = vcd_end_track(vcd);
30977
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
102 return STREAM_OK;
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
103 }
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
104 case STREAM_CTRL_SEEK_TO_CHAPTER:
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
105 {
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
106 int r;
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
107 unsigned int track = *(unsigned int *)arg + 1;
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
108 mp_vcd_priv_t *vcd = vcd_read_toc(stream->fd);
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
109 if (!vcd)
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
110 break;
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
111 r = vcd_seek_to_track(vcd, track);
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
112 if (r >= 0) {
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
113 p->track = track;
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
114 return STREAM_OK;
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
115 }
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
116 break;
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
117 }
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
118 case STREAM_CTRL_GET_CURRENT_CHAPTER:
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
119 {
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
120 *(unsigned int *)arg = p->track - 1;
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
121 return STREAM_OK;
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
122 }
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
123 }
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
124 return STREAM_UNSUPPORTED;
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
125 }
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
126
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
127 static void close_s(stream_t *stream) {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
128 free(stream->priv);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
129 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
130
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
131 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
30752
abec4bb780e5 Remove useless cast.
reimar
parents: 30426
diff changeset
132 struct stream_priv_s* p = opts;
22775
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
133 int ret,ret2,f,sect,tmp;
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
134 mp_vcd_priv_t* vcd;
21848
3ff1eade91f9 GNU/kFreeBSD support, closes Bugzilla #704.
diego
parents: 19271
diff changeset
135 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
136 int bsize = VCD_SECTOR_SIZE;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
137 #endif
27727
48c1ae64255b Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
diego
parents: 25691
diff changeset
138 #if defined(__MINGW32__) || defined(__CYGWIN__)
22506
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
139 HANDLE hd;
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
140 char device[] = "\\\\.\\?:";
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
141 #endif
30777
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
142 #if defined(__OS2__)
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
143 char device[] = "X:";
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
144 HFILE hcd;
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
145 ULONG ulAction;
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
146 ULONG rc;
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
147 #endif
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
148
22506
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
149 if(mode != STREAM_READ
27727
48c1ae64255b Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
diego
parents: 25691
diff changeset
150 #if defined(__MINGW32__) || defined(__CYGWIN__)
22506
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
151 || GetVersion() > 0x80000000 // Win9x
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
152 #endif
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
153 ) {
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
154 m_struct_free(&stream_opts,opts);
24257
d261f5109660 cosmetics: typo fix UNSUPORTED --> UNSUPPORTED
diego
parents: 23857
diff changeset
155 return STREAM_UNSUPPORTED;
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
156 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
157
10591
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
158 if (!p->device) {
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
159 if(cdrom_device)
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
160 p->device = strdup(cdrom_device);
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
161 else
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
162 p->device = strdup(DEFAULT_CDROM_DEVICE);
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
163 }
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
164
27727
48c1ae64255b Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
diego
parents: 25691
diff changeset
165 #if defined(__MINGW32__) || defined(__CYGWIN__)
22506
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
166 device[4] = p->device[0];
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
167 /* open() can't be used for devices so do it the complicated way */
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
168 hd = CreateFile(device, GENERIC_READ, FILE_SHARE_READ, NULL,
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
169 OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
170 f = _open_osfhandle((long)hd, _O_RDONLY);
30777
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
171 #elif defined(__OS2__)
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
172 device[0] = p->device[0];
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
173 rc = DosOpen(device, &hcd, &ulAction, 0, FILE_NORMAL,
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
174 OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW,
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
175 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_DASD,
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
176 NULL);
079be31079d3 Add a VCD support for OS/2
komh
parents: 30752
diff changeset
177 f = rc ? -1 : hcd;
22506
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
178 #else
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
179 f=open(p->device,O_RDONLY);
22506
72fbf66a9429 add vcd:// for win32, patch by zuxy meng
compn
parents: 21926
diff changeset
180 #endif
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27727
diff changeset
181 if(f<0){
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
182 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,p->device);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
183 m_struct_free(&stream_opts,opts);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
184 return STREAM_ERROR;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
185 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
186
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
187 vcd = vcd_read_toc(f);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
188 if(!vcd) {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
189 mp_msg(MSGT_OPEN,MSGL_ERR,"Failed to get cd toc\n");
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
190 close(f);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
191 m_struct_free(&stream_opts,opts);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
192 return STREAM_ERROR;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
193 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
194 ret2=vcd_get_track_end(vcd,p->track);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
195 if(ret2<0){
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
196 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n");
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
197 close(f);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
198 free(vcd);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
199 m_struct_free(&stream_opts,opts);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
200 return STREAM_ERROR;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
201 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
202 ret=vcd_seek_to_track(vcd,p->track);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
203 if(ret<0){
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
204 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
205 close(f);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
206 free(vcd);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
207 m_struct_free(&stream_opts,opts);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
208 return STREAM_ERROR;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
209 }
22775
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
210 /* search forward up to at most 3 seconds to skip leading margin */
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
211 sect = ret / VCD_SECTOR_DATA;
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
212 for (tmp = sect; tmp < sect + 3 * 75; tmp++) {
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
213 char mem[VCD_SECTOR_DATA];
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
214 //since MPEG packs are block-aligned we stop discarding sectors if they are non-null
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
215 if (vcd_read(vcd, mem) != VCD_SECTOR_DATA || mem[2] || mem[3])
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
216 break;
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
217 }
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
218 mp_msg(MSGT_OPEN, MSGL_DBG2, "%d leading sectors skipped\n", tmp - sect);
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
219 vcd_set_msf(vcd, tmp);
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
220 ret = tmp * VCD_SECTOR_DATA;
f6dc5fd2b347 at open() discard front margin/empty sectors (fixes demuxing by libavformat); patch by Zuxy meng
nicodvb
parents: 22506
diff changeset
221
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
222 mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
223
21848
3ff1eade91f9 GNU/kFreeBSD support, closes Bugzilla #704.
diego
parents: 19271
diff changeset
224 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
225 if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
226 mp_msg(MSGT_OPEN,MSGL_WARN,"Error in CDRIOCSETBLOCKSIZE");
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
227 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
228 #endif
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
229
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
230 stream->fd = f;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
231 stream->type = STREAMTYPE_VCD;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
232 stream->sector_size = VCD_SECTOR_DATA;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
233 stream->start_pos=ret;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
234 stream->end_pos=ret2;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
235 stream->priv = vcd;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
236
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
237 stream->fill_buffer = fill_buffer;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
238 stream->seek = seek;
30977
0b45d6af9ffe Export VCD tracks as chapters, just like for cue:// URLs.
reimar
parents: 30777
diff changeset
239 stream->control = control;
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
240 stream->close = close_s;
21926
a8cd73869242 at open() assign *file_format=DEMUXER_TYPE_MPEG_PS to avoid useless demuxer probing
nicodvb
parents: 21848
diff changeset
241 *file_format = DEMUXER_TYPE_MPEG_PS;
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
242
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
243 m_struct_free(&stream_opts,opts);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
244 return STREAM_OK;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
245 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
246
25211
c1d17bd6683c Mark all stream_info_t as const
reimar
parents: 24257
diff changeset
247 const stream_info_t stream_info_vcd = {
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
248 "Video CD",
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
249 "vcd",
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
250 "Albeu",
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
251 "based on the code from ???",
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
252 open_s,
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
253 { "vcd", NULL },
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
254 &stream_opts,
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
255 1 // Urls are an option string
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
256 };